feat(multichain-account-service, snap-account-service): select v1/v2 keyring client from snap capabilities#9377
Merged
Merged
Conversation
Contributor
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
ccharly
reviewed
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Account Snaps are migrating to the v2 Keyring API, but the clients still drives them over a single hardcoded v1 path. This makes the Snap account providers pick the v1 or v2 keyring path per Snap, based on the capabilities the Snap declares
in its manifest.
SnapAccountService.getCapabilities(snapId), returning the capabilities the bridge keyring populates from the Snap manifest.SnapAccountProviderresolves those capabilities lazily (after the Snap is ready) and builds a version-agnostic keyring client (newSnapKeyringClientadapter): v1KeyringClientor v2KeyringClient.bip44is treated as v2 (batchedfrombip44.deriveIndexRange), and v2 discovery flows throughcreateAccounts({ bip44:discover }). v1 Snaps keep usingdiscoverAccounts.The base-class change covers all four Snap providers (Solana, Bitcoin, Tron, Stellar). Only Solana declares manifest capabilities today, so only Solana switches to v2; the others stay on v1 unchanged and self-enroll once their Snaps ship capabilities.
Also bumps
@metamask/keyring-api,@metamask/keyring-snap-client,@metamask/keyring-snap-sdkand@metamask/eth-snap-keyringto the release containing the v2SnapKeyringRpc+ manifest-populated capabilities.batchedfromSnapAccountProviderConfig['createAccounts'], batching is now derived from Snap capabilities.References
N/A
Checklist
Note
High Risk
Breaking API and messenger contract changes affect all Snap wallet account creation, discovery, and resync paths; mis-routed v1/v2 behavior could fail account ops until Snaps declare correct capabilities.
Overview
Snap account providers no longer hardcode v1 keyring behavior or a static
createAccounts.batchedflag. They callSnapAccountService:getCapabilitieson first use, cache the manifest-derived capabilities, and build aSnapKeyringClientadapter that wraps either the v1 or v2 RPC client.v1 vs v2 routing: Snaps that declare
bip44capabilities are treated as v2—account creation always uses batchedcreateAccounts, and discovery usescreateAccounts({ bip44:discover })whenbip44.discoveris set; otherwise discovery returns nothing. v1 Snaps keep singularcreateAccountand clientdiscoverAccounts(with per-chainv1DiscoveryScopeson BTC/SOL/TRX/XLM until full v2).Breaking:
batchedis removed fromSnapAccountProviderConfig.multichain-account-servicenow depends on the new messenger action. Chain-specificdiscoverAccountsoverrides are removed in favor of the shared base implementation.snap-account-serviceexposesgetCapabilities(snapId)via the v2 bridge keyring (unsafe read). Tests and changelogs are updated across providers.Reviewed by Cursor Bugbot for commit d04c64e. Bugbot is set up for automated code reviews on this repo. Configure here.