feat(multichain-account-service, snap-account-service): select v1/v2 keyring client from snap capabilities#9377
Open
hmalik88 wants to merge 11 commits into
Open
feat(multichain-account-service, snap-account-service): select v1/v2 keyring client from snap capabilities#9377hmalik88 wants to merge 11 commits into
hmalik88 wants to merge 11 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit feb0197. Configure here.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
… gate discovery on bip44.discover
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. |
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
Changes account creation and discovery routing for Snap keyrings (breaking config removal) in security-sensitive wallet infrastructure; wrong v1/v2 selection could mis-create or fail to discover accounts.
Overview
Snap wallet account providers no longer hardcode v1 vs v2 keyring behavior or a
createAccounts.batchedflag. They callSnapAccountService:getCapabilities(newgetCapabilities(snapId)action) after the Snap is ready, cache manifest-derivedKeyringCapabilities, and build a lazySnapKeyringClientadapter that wraps either the v1 or v2keyring-snap-client.v2 is inferred when capabilities declare
bip44(batchedcreateAccountson the bridge keyring; no singularcreateAccount). v1 keeps singularcreateAccountand clientdiscoverAccountsusing per-providerv1DiscoveryScopes. Discovery moves intoSnapAccountProvider: v2 usescreateAccounts({ bip44:discover })whenbip44.discoveris set; otherwise discovery is a no-op on v2. Bitcoin, Solana, Tron, and Stellar providers drop static capability objects and duplicatediscoverAccountsimplementations in favor of this base behavior.Breaking:
SnapAccountProviderConfig.createAccounts.batchedis removed—consumers must rely on Snap capabilities. Monorepo dependency bumps (keyring-api,keyring-snap-client,eth-snap-keyring, etc.) align with v2 RPC and manifest-populated capabilities.Reviewed by Cursor Bugbot for commit a1e525c. Bugbot is set up for automated code reviews on this repo. Configure here.