Skip to content

Conversation

@FrederikBolding
Copy link
Member

@FrederikBolding FrederikBolding commented Dec 1, 2025

Adds support for using the multichain API in Snaps. This is accomplished by setting up a separate provider and substream called metamask-multichain-provider. When snap.request is 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.

@socket-security
Copy link

socket-security bot commented Dec 1, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​metamask/​chain-agnostic-permission@​1.4.01001007895100

View full report

@FrederikBolding FrederikBolding force-pushed the fb/multichain-api branch 2 times, most recently from 917fc58 to 491f06d Compare January 7, 2026 10:58
@FrederikBolding FrederikBolding changed the title wip: Add Multichain API support feat: Add Multichain API support Jan 12, 2026
@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

❌ Patch coverage is 98.97959% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.34%. Comparing base (6f79d0c) to head (c19b59e).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s/snaps-execution-environments/src/common/utils.ts 33.33% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #3759    +/-   ##
========================================
  Coverage   98.33%   98.34%            
========================================
  Files         422      430     +8     
  Lines       12082    12252   +170     
  Branches     1876     1904    +28     
========================================
+ Hits        11881    12049   +168     
- Misses        201      203     +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

const MOCK_SIGNATURE =
'0x01b37713300d99fecf0274bcb0dfb586a23d56c4bf2ed700c5ecf4ada7a2a14825e7b1212b1cc49c9440c375337561f2b7a6e639ba25be6a6f5a16f60e6931d31c';

it('returns a signature for Ethereum', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a test to make sure it throws "method not supported" for Solana.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trouble with testing the Solana behavior during signMessage and signTypedData is that snaps-jest doesn't populate the accounts for Solana in the multichain session. So we don't even get to the point where it would throw the proper error 🤔

Comment on lines +36 to +46
abstract signMessage(
account: CaipAccountId,
message: string,
): Promise<string>;

abstract signTypedData(
account: CaipAccountId,
message: string,
): Promise<string>;

abstract getGenesisHash(): Promise<string>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add JSDoc to these too?

return result.signature;
}

async signTypedData(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add JSDoc here too? Something like "This method is not supported by Solana" is fine.

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.

3 participants