feat(accounts-controller): use KeyringV1Adapter for SnapKeyring (v2) accounts#8703
Merged
feat(accounts-controller): use KeyringV1Adapter for SnapKeyring (v2) accounts#8703
KeyringV1Adapter for SnapKeyring (v2) accounts#8703Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
KeyringV1Adapter for SnapKeyring (v2) accounts
gantunesr
approved these changes
May 5, 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
I introduced a new v1 adapter for
SnapKeyringV2since the v2 interface has an incompatiblegetAccountsmethod that cannot be used by theKeyringController.So the new
SnapKeyringV2will now be "wrapped" by their v1 adapter AND also be available as normal v2 keyring instances (using the same ref).This allows us to query them with
:getKeyringsByTypeand to make synchronous calls (something that we will have to change someday) AND to make them compatible with theKeyrignControllerkeyrings lifecycle!References
N/A
Checklist
Note
Medium Risk
Changes how Snap v2 accounts are discovered by unwrapping
KeyringV1Adapterinstances returned fromKeyringController:getKeyringsByType, which can affect account synchronization duringKeyringController:stateChange. Dependency bumps (including adding@metamask/keyring-sdk) may introduce subtle behavior changes in keyring interop.Overview
Snap v2 account lookup is now routed through
KeyringV1Adapter.AccountsController’s Snap v2 path (#getAccountFromSnapKeyringV2) now expectsKeyringController:getKeyringsByType(KeyringType.Snap)to return v1-adapted keyrings and usesKeyringV1Adapter.unwrap()to reach the underlyingSnapKeyringV2forlookupByAddressandsnapId.Tests were updated to wrap mocked
SnapKeyringV2instances inKeyringV1Adapter, and package deps/changelogs were updated (adds@metamask/keyring-sdk, bumps@metamask/keyring-utilsacross affected packages, and updatesyarn.lock).Reviewed by Cursor Bugbot for commit f2ae211. Bugbot is set up for automated code reviews on this repo. Configure here.