-
Notifications
You must be signed in to change notification settings - Fork 642
feat!: Add Multichain API support #3759
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
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
917fc58 to
491f06d
Compare
packages/snaps-simulation/src/middleware/internal-methods/chain-id.ts
Outdated
Show resolved
Hide resolved
packages/snaps-simulation/src/middleware/multichain/create-session.ts
Outdated
Show resolved
Hide resolved
packages/snaps-simulation/src/middleware/multichain/invoke-method.ts
Outdated
Show resolved
Hide resolved
packages/examples/packages/multichain-provider/src/modules/base.ts
Outdated
Show resolved
Hide resolved
ef6f3be to
559f0ff
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3759 +/- ##
========================================
Coverage 98.33% 98.34%
========================================
Files 422 430 +8
Lines 12082 12250 +168
Branches 1876 1904 +28
========================================
+ Hits 11881 12047 +166
- Misses 201 203 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
packages/examples/packages/multichain-provider/src/modules/base.ts
Outdated
Show resolved
Hide resolved
| export const DEFAULT_ACCOUNTS: SimulationAccount[] = [ | ||
| { | ||
| address: '0x1234567890abcdef1234567890abcdef12345678', | ||
| address: '0xc6d5a3c98ec9073b54fa0969957bd582e8d874bf', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this may be breaking, but it makes a lot more sense for this to return the address of the default account in the simulation IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this should be considered breaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added note to the description
afdf778 to
a35de5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
packages/examples/packages/multichain-provider/src/modules/evm.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Adds support for using the multichain API in Snaps. This is accomplished by setting up a separate provider and substream called
metamask-multichain-provider. Whensnap.requestis called with a multichain request, this provider and substream is used. The clients will need to route to the proper JSON-RPC pipeline based on the substream and verify that the Snap has the proper permission.Additionally this PR adds a example Snap for usage of this API, that can leverage Ethereum and Solana APIs at once. It also adds limited simulation support for the multichain API. The simulation framework implements a basic version of the multichain API where sessions are tracked and requests are routed to supported EVM providers. There are no underlying providers for non-EVM request, but they can be mocked.
Breaking: This PR changes the default accounts used in
snaps-jestto match the accounts derived from the default SRP.Note
Adds first-class Multichain API support across runtime, RPC, SDK, simulation, and examples.
snap.requestmultichain calls via newmetamask-multichain-providersubstream; addisMultichainRequestand stream wiring inBaseSnapExecutor.endowment:multichain-providerand register builder; expose in permissions listing/tests.wallet_createSession,wallet_getSession,wallet_invokeMethod,wallet_revokeSessionrequest/response types.wallet_invokeMethodrouting; provider now respects CAIP-2scope(EVM) and ignores non‑EVM; integrates CAIP‑25 caveat validation and simulated accounts; updates tests and defaults.@metamask/multichain-provider-example-snap(EVM + Solana) with E2E tests; added UI in test-snaps to create/revoke sessions, switch chains, and sign.Written by Cursor Bugbot for commit 17795ea. This will update automatically on new commits. Configure here.