Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add experimental provider request RPC method #2773

Merged
merged 5 commits into from
Oct 1, 2024

Conversation

FrederikBolding
Copy link
Member

@FrederikBolding FrederikBolding commented Sep 30, 2024

Adds an experimental RPC method that lets Snaps make requests to networks that are not currently selected in the MetaMask UI. This is a large improvement for Snaps that want to leverage MetaMask RPC as previously the only access to RPC was given through endowment:ethereum-provider which strictly uses the currently selected network. This change would effectively let Snaps make requests to any networks added by the user and is a temporary stopgap solution until the MetaMask multichain API ships. This means that this API may break at any time, use accordingly.

Snaps with endowment:ethereum-provider would now be able to make requests like this:

const chainId = await snap.request({
  method: 'snap_experimentalProviderRequest',
  params: {
    chainId: 'eip155:59144',
    request: { method: 'eth_chainId' },
  },
});

The RPC method requires the endowment:ethereum-provider permission and enforces an allowlist to only allow access to certain RPC methods (mostly read methods).

Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.43%. Comparing base (24e7f90) to head (7ede87f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2773      +/-   ##
==========================================
+ Coverage   94.41%   94.43%   +0.01%     
==========================================
  Files         482      483       +1     
  Lines       10261    10297      +36     
  Branches     1563     1568       +5     
==========================================
+ Hits         9688     9724      +36     
  Misses        573      573              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@FrederikBolding FrederikBolding marked this pull request as ready for review October 1, 2024 14:46
@FrederikBolding FrederikBolding requested a review from a team as a code owner October 1, 2024 14:46
@FrederikBolding FrederikBolding merged commit 824fd4f into main Oct 1, 2024
165 checks passed
@FrederikBolding FrederikBolding deleted the fb/experimental-provider-request branch October 1, 2024 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants