Conversation
|
@metamaskbot publish-previews |
|
@metamaskbot publish-previews |
|
Preview builds have been published. See these instructions (from the Expand for full list of packages and versions. |
| // Default capabilities — parent updates this when snap metadata is available. | ||
| // We cast here because KeyringCapabilities requires a non-empty scopes array, | ||
| // but we don't have the snap metadata at construction time (e.g. during deserialization). | ||
| this.capabilities = { scopes: [] } as unknown as KeyringCapabilities; |
There was a problem hiding this comment.
Will update when there's a new release of snaps-rpc-methods so I can use getKeyringCaveatCapabilities. Safe to leave as it is for now since we're not using capabilities at the moment.
|
@metamaskbot publish-previews |
|
Preview builds have been published. See these instructions (from the Expand for full list of packages and versions. |
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 d23a1b9. Configure here.

Summary
Introduces
SnapKeyringV2as a per-snap keyring wrapper that implements theKeyringV2interface, establishing a 1:1 relationship between account management snaps and their keyrings.Architecture Diagrams
What changed
SnapKeyringV2implementsKeyringV2withcreateAccount,createAccounts,deleteAccount,submitRequest,getAccount, andgetAccountsSnapKeyringSnapKeyringbecomes a thin router by delegatingcreateAccount,createAccounts, and#deleteAccountto the per-snap wrappernormalizeAccountAddressextracted to shared util (was duplicated)#accountIndexreverse map enables O(1) "which snap owns this account?" lookupsIntegration
Version bump in the clients. The public API of
SnapKeyringis unchanged.What's next
SnapKeyringV2instances directly toKeyringControllerNote
Medium Risk
Refactors core Snap account storage/routing and create/delete flows to go through new per-snap wrappers and a global account-id index, which could affect account ownership resolution and persistence if edge cases are missed. External serialized format is preserved, but deserialize/serialize logic is rewritten and should be validated against existing state.
Overview
Introduces
SnapKeyringV2, a per-snap wrapper implementingKeyringV2(account CRUD +submitRequest) backed by@metamask/keyring-sdk’s registry, and exports it publicly.Refactors
SnapKeyringto replace the flat#accountsmap with per-snap wrappers plus a reverse#accountIndexfor O(1) account-id → snap ownership routing;createAccount,createAccounts, and deletion now delegate to the wrapper, whileserialize/deserializere-group and rebuild wrappers but keep the external persisted format.Moves
normalizeAccountAddressintoutil, adds@metamask/keyring-sdkas a dependency/tsconfig reference, and updates tests (newSnapKeyringV2suite plus adjusted expectations and an unknown-snap case forgetAccountsBySnapId).Reviewed by Cursor Bugbot for commit 8691743. Bugbot is set up for automated code reviews on this repo. Configure here.