Skip to content

feat(snap-account-service): add migration logic + keyring v2 support#8732

Open
ccharly wants to merge 11 commits into
mainfrom
cc/feat/snap-account-service-keyring-v2-support
Open

feat(snap-account-service): add migration logic + keyring v2 support#8732
ccharly wants to merge 11 commits into
mainfrom
cc/feat/snap-account-service-keyring-v2-support

Conversation

@ccharly
Copy link
Copy Markdown
Contributor

@ccharly ccharly commented May 7, 2026

Explanation

Add migration logic to migrate from the legacy Snap keyring to the new architecture with 1 Snap keyring v2 per Snaps.

Also enhance :ensureReady so consumers can safely call :withKeyringV2 to get the associated Snap keyring v2 instance before using it.

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
High risk because it changes Snap keyring lifecycle/selection and introduces automatic migration + keyring creation in ensureReady, affecting account management, message routing, and selected-account forwarding.

Overview
Implements a legacy → per-Snap v2 keyring migration in SnapAccountService (migrate) and makes ensureReady run it, then auto-create a v2 Snap keyring for the requested Snap when missing.

Switches handleKeyringSnapMessage and selected-account forwarding to target v2 Snap keyrings (including a GetSelectedAccounts fast-path filtered by keyring ownership), adds new messenger dependencies (withKeyringV2/withKeyringV2Unsafe), and updates multichain Snap providers/tests to use KeyringController:withKeyringV2 and v2 Snap keyring APIs (createAccounts signature changes, removeAccountdeleteAccount, selector filtering by snapId).

Reviewed by Cursor Bugbot for commit f462720. Bugbot is set up for automated code reviews on this repo. Configure here.

Base automatically changed from cc/feat/snap-account-service-track-snaps to main May 7, 2026 15:23
@ccharly ccharly force-pushed the cc/feat/snap-account-service-keyring-v2-support branch from 96269d0 to 43c238b Compare May 12, 2026 10:50
@ccharly ccharly changed the base branch from main to cc/feat/snap-account-service-account-group-events May 12, 2026 10:50
@ccharly ccharly changed the title feat(snap-account-service): add keyring v2 support feat(snap-account-service): add migration logic + keyring v2 support May 12, 2026
@ccharly ccharly marked this pull request as ready for review May 12, 2026 10:57
@ccharly ccharly requested review from a team as code owners May 12, 2026 10:57
Comment thread packages/snap-account-service/src/SnapAccountService.ts
@ccharly ccharly force-pushed the cc/feat/snap-account-service-keyring-v2-support branch from 8452267 to ce71df1 Compare May 12, 2026 13:21
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/snap-account-service/src/SnapAccountService.ts
Copy link
Copy Markdown

@cursor cursor Bot left a 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.

Fix All in Cursor

❌ 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 2adb638. Configure here.

Comment thread packages/snap-account-service/src/SnapAccountService.ts
Base automatically changed from cc/feat/snap-account-service-account-group-events to main May 12, 2026 19:50
@ccharly ccharly force-pushed the cc/feat/snap-account-service-keyring-v2-support branch from a4b5e03 to 47199fa Compare May 12, 2026 22:09
@ccharly
Copy link
Copy Markdown
Contributor Author

ccharly commented May 13, 2026

@metamaskbot publish-preview

@github-actions
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.3.0-preview-f4627208e
@metamask-previews/accounts-controller@38.1.1-preview-f4627208e
@metamask-previews/address-book-controller@7.1.2-preview-f4627208e
@metamask-previews/ai-controllers@0.6.3-preview-f4627208e
@metamask-previews/analytics-controller@1.0.1-preview-f4627208e
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-f4627208e
@metamask-previews/announcement-controller@8.1.0-preview-f4627208e
@metamask-previews/app-metadata-controller@2.0.1-preview-f4627208e
@metamask-previews/approval-controller@9.0.1-preview-f4627208e
@metamask-previews/assets-controller@7.1.1-preview-f4627208e
@metamask-previews/assets-controllers@108.0.0-preview-f4627208e
@metamask-previews/authenticated-user-storage@1.0.1-preview-f4627208e
@metamask-previews/base-controller@9.1.0-preview-f4627208e
@metamask-previews/base-data-service@0.1.2-preview-f4627208e
@metamask-previews/bridge-controller@72.0.4-preview-f4627208e
@metamask-previews/bridge-status-controller@71.1.4-preview-f4627208e
@metamask-previews/build-utils@3.0.4-preview-f4627208e
@metamask-previews/chain-agnostic-permission@1.6.1-preview-f4627208e
@metamask-previews/chomp-api-service@3.1.0-preview-f4627208e
@metamask-previews/claims-controller@0.5.1-preview-f4627208e
@metamask-previews/client-controller@1.0.1-preview-f4627208e
@metamask-previews/compliance-controller@2.0.1-preview-f4627208e
@metamask-previews/composable-controller@12.0.1-preview-f4627208e
@metamask-previews/config-registry-controller@0.3.1-preview-f4627208e
@metamask-previews/connectivity-controller@0.2.0-preview-f4627208e
@metamask-previews/controller-utils@12.1.0-preview-f4627208e
@metamask-previews/core-backend@6.2.2-preview-f4627208e
@metamask-previews/delegation-controller@3.0.0-preview-f4627208e
@metamask-previews/earn-controller@12.1.2-preview-f4627208e
@metamask-previews/eip-5792-middleware@3.0.3-preview-f4627208e
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.1-preview-f4627208e
@metamask-previews/eip1193-permission-middleware@2.0.1-preview-f4627208e
@metamask-previews/ens-controller@19.1.3-preview-f4627208e
@metamask-previews/eth-block-tracker@15.0.1-preview-f4627208e
@metamask-previews/eth-json-rpc-middleware@23.1.3-preview-f4627208e
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-f4627208e
@metamask-previews/foundryup@1.0.1-preview-f4627208e
@metamask-previews/gas-fee-controller@26.2.1-preview-f4627208e
@metamask-previews/gator-permissions-controller@4.1.2-preview-f4627208e
@metamask-previews/geolocation-controller@0.1.3-preview-f4627208e
@metamask-previews/json-rpc-engine@10.5.0-preview-f4627208e
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-f4627208e
@metamask-previews/keyring-controller@25.5.0-preview-f4627208e
@metamask-previews/logging-controller@8.0.2-preview-f4627208e
@metamask-previews/message-manager@14.1.2-preview-f4627208e
@metamask-previews/messenger@1.2.0-preview-f4627208e
@metamask-previews/messenger-cli@0.2.0-preview-f4627208e
@metamask-previews/money-account-balance-service@1.0.2-preview-f4627208e
@metamask-previews/money-account-controller@0.3.0-preview-f4627208e
@metamask-previews/money-account-upgrade-controller@2.0.1-preview-f4627208e
@metamask-previews/multichain-account-service@9.0.0-preview-f4627208e
@metamask-previews/multichain-api-middleware@3.1.2-preview-f4627208e
@metamask-previews/multichain-network-controller@3.1.1-preview-f4627208e
@metamask-previews/multichain-transactions-controller@7.1.0-preview-f4627208e
@metamask-previews/name-controller@9.1.2-preview-f4627208e
@metamask-previews/network-controller@32.0.0-preview-f4627208e
@metamask-previews/network-enablement-controller@5.1.1-preview-f4627208e
@metamask-previews/notification-services-controller@23.1.1-preview-f4627208e
@metamask-previews/passkey-controller@2.0.1-preview-f4627208e
@metamask-previews/permission-controller@13.1.1-preview-f4627208e
@metamask-previews/permission-log-controller@5.1.0-preview-f4627208e
@metamask-previews/perps-controller@6.0.1-preview-f4627208e
@metamask-previews/phishing-controller@17.1.2-preview-f4627208e
@metamask-previews/polling-controller@16.0.5-preview-f4627208e
@metamask-previews/preferences-controller@23.1.0-preview-f4627208e
@metamask-previews/profile-metrics-controller@3.1.4-preview-f4627208e
@metamask-previews/profile-sync-controller@28.0.2-preview-f4627208e
@metamask-previews/ramps-controller@13.3.1-preview-f4627208e
@metamask-previews/rate-limit-controller@7.0.1-preview-f4627208e
@metamask-previews/react-data-query@0.2.0-preview-f4627208e
@metamask-previews/remote-feature-flag-controller@4.2.1-preview-f4627208e
@metamask-previews/sample-controllers@5.0.1-preview-f4627208e
@metamask-previews/seedless-onboarding-controller@9.1.0-preview-f4627208e
@metamask-previews/selected-network-controller@26.1.3-preview-f4627208e
@metamask-previews/shield-controller@5.1.2-preview-f4627208e
@metamask-previews/signature-controller@39.2.2-preview-f4627208e
@metamask-previews/snap-account-service@0.0.0-preview-f4627208e
@metamask-previews/social-controllers@2.2.1-preview-f4627208e
@metamask-previews/storage-service@1.0.1-preview-f4627208e
@metamask-previews/subscription-controller@6.1.3-preview-f4627208e
@metamask-previews/transaction-controller@65.3.0-preview-f4627208e
@metamask-previews/transaction-pay-controller@22.3.1-preview-f4627208e
@metamask-previews/user-operation-controller@41.2.2-preview-f4627208e

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.

1 participant