Skip to content

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

Open
ccharly wants to merge 9 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 9 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 introduces a one-time migration that moves Snap-managed accounts between keyring implementations and changes how keyring messages/selected-account forwarding are routed, which can impact account availability and state integrity.

Overview
Adds a concurrent-safe SnapAccountService.migrate() and updates ensureReady() to always migrate legacy Snap keyring accounts into per-Snap v2 keyrings and auto-create a missing v2 keyring for a Snap before proceeding.

Switches keyring message handling and selected-account forwarding to target v2 Snap keyrings (KeyringController:withKeyringV2/withKeyringV2Unsafe), including special-casing GetSelectedAccounts, and updates multichain-account-service Snap providers to use withKeyringV2 plus v2 Snap keyring APIs (createAccount(s) signature and deleteAccount instead of removeAccount).

Updates tests/changelogs accordingly and adds @metamask/keyring-api + @metamask/keyring-snap-sdk dependencies for the new v2/event-based integration.

Reviewed by Cursor Bugbot for commit 47199fa. 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
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