Skip to content

feat: add missing methods#176

Merged
hmalik88 merged 3 commits into
mainfrom
hm/update-snap
May 5, 2026
Merged

feat: add missing methods#176
hmalik88 merged 3 commits into
mainfrom
hm/update-snap

Conversation

@hmalik88
Copy link
Copy Markdown
Contributor

@hmalik88 hmalik88 commented May 5, 2026

Summary

Adds support for the new keyring methods that @metamask/eth-snap-keyring@^22 invokes against installed snaps:

  • keyring_setSelectedAccounts — called when MetaMask switches the active account; the snap now persists the selected account IDs in its state.
  • keyring_resolveAccountAddress — called when MetaMask needs to determine which account a signing request belongs to; the snap inspects the EVM signing request params (personal_sign, eth_sign, eth_signTransaction, eth_signTypedData_v1/v3/v4), looks up the matching wallet by address, and returns a CAIP-10 account ID (or null if no match).

Without these, the previous version of this snap fails to load in builds running on eth-snap-keyring@22+ because permission checks reject the new outbound calls and the snap throws on the unimplemented methods, crashing the snap and breaking e2e flows in metamask-extension#42334.

Changes

  • Implement setSelectedAccounts and resolveAccountAddress on SimpleKeyring.
  • Add a selectedAccounts: string[] field to KeyringState (with default []).
  • Grant the metamask origin permission to call keyring_createAccount, keyring_resolveAccountAddress, and keyring_setSelectedAccounts.
  • Rebuild the snap bundle and update snap.manifest.json shasum.

Notes

  • keyring_createAccounts (the v2 batch variant) is intentionally not implemented here. It is only invoked through the extension's MultichainAccountService, which is wired up exclusively for Solana/Bitcoin/Tron account providers. SSK is EVM-only and goes through the singular keyring_createAccount path.
  • A follow-up release will be needed to bring this fix into the extension's preinstalled snap e2e fixtures.

Note

Medium Risk
Medium risk: adds new keyring RPC methods and expands metamask origin permissions, which affects how signing requests are mapped to accounts and persisted in snap state.

Overview
Adds support for MetaMask keyring method calls required by @metamask/eth-snap-keyring@^22: implements keyring_setSelectedAccounts (persist selected account IDs) and keyring_resolveAccountAddress (derive the signing account from EVM request params and return a CAIP-10 address).

Updates snap state to include selectedAccounts, expands metamask origin permissions to allow keyring_createAccount/keyring_resolveAccountAddress/keyring_setSelectedAccounts, and refreshes the built snap shasum plus changelog entry.

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

@hmalik88 hmalik88 marked this pull request as ready for review May 5, 2026 18:09
@hmalik88 hmalik88 merged commit 947d53f into main May 5, 2026
18 checks passed
@hmalik88 hmalik88 deleted the hm/update-snap branch May 5, 2026 19:04
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