Skip to content

feat(multichain-account-service, snap-account-service): select v1/v2 keyring client from snap capabilities#9377

Merged
hmalik88 merged 22 commits into
mainfrom
hm/fix-snap-client
Jul 8, 2026
Merged

feat(multichain-account-service, snap-account-service): select v1/v2 keyring client from snap capabilities#9377
hmalik88 merged 22 commits into
mainfrom
hm/fix-snap-client

Conversation

@hmalik88

@hmalik88 hmalik88 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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.

  • Adds SnapAccountService.getCapabilities(snapId), returning the capabilities the bridge keyring populates from the Snap manifest.
  • SnapAccountProvider resolves those capabilities lazily (after the Snap is ready) and builds a version-agnostic keyring client (new SnapKeyringClient adapter): v1 KeyringClient or v2 KeyringClient.
  • Batching and discovery routing are now driven by capabilities, not static config: a Snap declaring bip44 is treated as v2 (batched from bip44.deriveIndexRange), and v2 discovery flows through createAccounts({ bip44:discover }). v1 Snaps keep using discoverAccounts.

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-sdk and @metamask/eth-snap-keyring to the release containing the v2 SnapKeyringRpc + manifest-populated capabilities.

⚠️ Breaking

  • Removes batched from SnapAccountProviderConfig['createAccounts'], batching is now derived from Snap capabilities.

References

N/A

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

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.batched flag. They call SnapAccountService:getCapabilities on first use, cache the manifest-derived capabilities, and build a SnapKeyringClient adapter that wraps either the v1 or v2 RPC client.

v1 vs v2 routing: Snaps that declare bip44 capabilities are treated as v2—account creation always uses batched createAccounts, and discovery uses createAccounts({ bip44:discover }) when bip44.discover is set; otherwise discovery returns nothing. v1 Snaps keep singular createAccount and client discoverAccounts (with per-chain v1DiscoveryScopes on BTC/SOL/TRX/XLM until full v2).

Breaking: batched is removed from SnapAccountProviderConfig. multichain-account-service now depends on the new messenger action. Chain-specific discoverAccounts overrides are removed in favor of the shared base implementation.

snap-account-service exposes getCapabilities(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.

@hmalik88 hmalik88 requested review from a team as code owners July 2, 2026 14:57
@hmalik88 hmalik88 temporarily deployed to default-branch July 2, 2026 14:57 — with GitHub Actions Inactive
@hmalik88 hmalik88 changed the title feat(multichain-account-service): select v1/v2 keyring client from snap capabilities feat(multichain-account-service, snap-account-service): select v1/v2 keyring client from snap capabilities Jul 2, 2026
@hmalik88 hmalik88 requested review from a team as code owners July 2, 2026 15:43
@hmalik88

hmalik88 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-previews

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.5.3-preview-a1e525c77
@metamask-previews/accounts-controller@39.0.4-preview-a1e525c77
@metamask-previews/address-book-controller@7.1.2-preview-a1e525c77
@metamask-previews/ai-controllers@0.7.0-preview-a1e525c77
@metamask-previews/analytics-controller@1.2.1-preview-a1e525c77
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-a1e525c77
@metamask-previews/announcement-controller@8.1.0-preview-a1e525c77
@metamask-previews/app-metadata-controller@2.0.1-preview-a1e525c77
@metamask-previews/approval-controller@9.0.2-preview-a1e525c77
@metamask-previews/assets-controller@10.0.1-preview-a1e525c77
@metamask-previews/assets-controllers@109.3.0-preview-a1e525c77
@metamask-previews/authenticated-user-storage@3.0.0-preview-a1e525c77
@metamask-previews/base-controller@9.1.0-preview-a1e525c77
@metamask-previews/base-data-service@0.1.3-preview-a1e525c77
@metamask-previews/bitcoin-regtest-up@1.0.0-preview-a1e525c77
@metamask-previews/bridge-controller@77.3.2-preview-a1e525c77
@metamask-previews/bridge-status-controller@74.0.2-preview-a1e525c77
@metamask-previews/build-utils@3.0.4-preview-a1e525c77
@metamask-previews/chain-agnostic-permission@1.6.2-preview-a1e525c77
@metamask-previews/chomp-api-service@3.1.0-preview-a1e525c77
@metamask-previews/claims-controller@0.5.3-preview-a1e525c77
@metamask-previews/client-controller@1.0.1-preview-a1e525c77
@metamask-previews/client-utils@0.0.0-preview-a1e525c77
@metamask-previews/compliance-controller@2.1.0-preview-a1e525c77
@metamask-previews/composable-controller@12.0.1-preview-a1e525c77
@metamask-previews/config-registry-controller@0.4.1-preview-a1e525c77
@metamask-previews/connectivity-controller@0.2.0-preview-a1e525c77
@metamask-previews/controller-utils@12.3.0-preview-a1e525c77
@metamask-previews/core-backend@6.5.0-preview-a1e525c77
@metamask-previews/delegation-controller@3.0.2-preview-a1e525c77
@metamask-previews/earn-controller@12.2.2-preview-a1e525c77
@metamask-previews/eip-5792-middleware@3.0.4-preview-a1e525c77
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.1-preview-a1e525c77
@metamask-previews/eip1193-permission-middleware@2.0.1-preview-a1e525c77
@metamask-previews/ens-controller@19.1.5-preview-a1e525c77
@metamask-previews/eth-block-tracker@15.0.1-preview-a1e525c77
@metamask-previews/eth-json-rpc-middleware@23.1.3-preview-a1e525c77
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-a1e525c77
@metamask-previews/foundryup@1.0.1-preview-a1e525c77
@metamask-previews/gas-fee-controller@26.2.4-preview-a1e525c77
@metamask-previews/gator-permissions-controller@4.2.2-preview-a1e525c77
@metamask-previews/geolocation-controller@0.1.3-preview-a1e525c77
@metamask-previews/java-tron-up@1.0.0-preview-a1e525c77
@metamask-previews/json-rpc-engine@10.5.0-preview-a1e525c77
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-a1e525c77
@metamask-previews/keyring-controller@27.1.0-preview-a1e525c77
@metamask-previews/local-node-utils@1.0.0-preview-a1e525c77
@metamask-previews/logging-controller@8.0.2-preview-a1e525c77
@metamask-previews/message-manager@14.1.2-preview-a1e525c77
@metamask-previews/messenger@1.2.0-preview-a1e525c77
@metamask-previews/messenger-cli@0.2.0-preview-a1e525c77
@metamask-previews/money-account-balance-service@2.1.2-preview-a1e525c77
@metamask-previews/money-account-controller@0.3.3-preview-a1e525c77
@metamask-previews/money-account-upgrade-controller@2.2.1-preview-a1e525c77
@metamask-previews/multichain-account-service@11.1.0-preview-a1e525c77
@metamask-previews/multichain-api-middleware@4.0.0-preview-a1e525c77
@metamask-previews/multichain-network-controller@3.2.1-preview-a1e525c77
@metamask-previews/multichain-transactions-controller@7.1.1-preview-a1e525c77
@metamask-previews/name-controller@9.1.2-preview-a1e525c77
@metamask-previews/network-controller@34.0.0-preview-a1e525c77
@metamask-previews/network-enablement-controller@5.4.1-preview-a1e525c77
@metamask-previews/notification-services-controller@24.3.0-preview-a1e525c77
@metamask-previews/passkey-controller@2.0.1-preview-a1e525c77
@metamask-previews/permission-controller@13.1.1-preview-a1e525c77
@metamask-previews/permission-log-controller@5.1.0-preview-a1e525c77
@metamask-previews/perps-controller@9.1.0-preview-a1e525c77
@metamask-previews/phishing-controller@17.2.0-preview-a1e525c77
@metamask-previews/platform-api-docs@0.0.0-preview-a1e525c77
@metamask-previews/polling-controller@16.0.8-preview-a1e525c77
@metamask-previews/preferences-controller@23.1.0-preview-a1e525c77
@metamask-previews/profile-metrics-controller@4.0.1-preview-a1e525c77
@metamask-previews/profile-sync-controller@28.2.0-preview-a1e525c77
@metamask-previews/ramps-controller@15.0.0-preview-a1e525c77
@metamask-previews/rate-limit-controller@7.0.1-preview-a1e525c77
@metamask-previews/react-data-query@0.2.1-preview-a1e525c77
@metamask-previews/remote-feature-flag-controller@4.2.2-preview-a1e525c77
@metamask-previews/sample-controllers@5.0.3-preview-a1e525c77
@metamask-previews/seedless-onboarding-controller@10.0.3-preview-a1e525c77
@metamask-previews/selected-network-controller@26.1.5-preview-a1e525c77
@metamask-previews/shield-controller@5.1.2-preview-a1e525c77
@metamask-previews/signature-controller@39.2.7-preview-a1e525c77
@metamask-previews/smart-transactions-controller@24.2.4-preview-a1e525c77
@metamask-previews/snap-account-service@1.0.0-preview-a1e525c77
@metamask-previews/social-controllers@2.3.1-preview-a1e525c77
@metamask-previews/solana-test-validator-up@1.0.0-preview-a1e525c77
@metamask-previews/stellar-quickstart-up@0.0.0-preview-a1e525c77
@metamask-previews/storage-service@1.0.2-preview-a1e525c77
@metamask-previews/subscription-controller@6.2.0-preview-a1e525c77
@metamask-previews/transaction-controller@68.2.2-preview-a1e525c77
@metamask-previews/transaction-pay-controller@23.17.4-preview-a1e525c77
@metamask-previews/user-operation-controller@41.2.6-preview-a1e525c77
@metamask-previews/wallet@6.0.0-preview-a1e525c77
@metamask-previews/wallet-cli@0.0.0-preview-a1e525c77

Comment thread packages/multichain-account-service/src/providers/SnapAccountProvider.ts Outdated
Comment thread packages/multichain-account-service/src/providers/SnapAccountProvider.ts Outdated
Comment thread packages/multichain-account-service/CHANGELOG.md Outdated
Comment thread packages/multichain-account-service/CHANGELOG.md
Comment thread packages/multichain-account-service/src/providers/SnapAccountProvider.test.ts Outdated

@ccharly ccharly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 💪

@hmalik88 hmalik88 added this pull request to the merge queue Jul 8, 2026
Merged via the queue into main with commit d2a0dea Jul 8, 2026
417 checks passed
@hmalik88 hmalik88 deleted the hm/fix-snap-client branch July 8, 2026 15:48
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