refactor(multichain-account-service)!: replace withKeyring usage with withKeyringV2#8491
Merged
refactor(multichain-account-service)!: replace withKeyring usage with withKeyringV2#8491
withKeyring usage with withKeyringV2#8491Conversation
…t service types and base provider
withKeyring usage with withKeyringV2withKeyring usage with withKeyringV2
ccharly
reviewed
Apr 24, 2026
ccharly
reviewed
May 4, 2026
ccharly
reviewed
May 4, 2026
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 efd0921. Configure here.
ccharly
approved these changes
May 4, 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
Changes
Base provider & types
KeyringControllerWithKeyringV2Actionto the messenger's AllowedActionsBaseBip44AccountProvider.withKeyringinto two helpers:withKeyring; callsKeyringController:withKeyring(V1). Used bySnapAccountProvideruntil its V2 migration lands.withKeyringV2<SelectedKeyring extends KeyringV2>; callsKeyringController:withKeyringV2. Used by the EVM provider.EvmAccountProvider
withKeyringV2getAccounts()returnsKeyringAccount[],createAccounts({ type: 'bip44:derive-index', entropySource, groupIndex })replacesaddAccounts()bip44:derive-indexsinceHdKeyringV2does not supportbip44:derive-index-range#getAddressFromGroupIndexis now typed againstHdKeyringfrom@metamask/eth-hd-keyring/v2and peeks viakeyring.root.deriveChild(groupIndex)(the V2 wrapper forwards the legacy root getter)discoverAccountskeeps the V1-style peek-then-create pattern: peek the address → check on-chain activity outside the keyring mutex → create the account only if there is activity → look up theInternalAccountfromAccountsControllerafter thewithKeyringV2callback completesKeyringCapabilitiesandKeyringtypes now come from@metamask/keyring-api/v2References
N/a
Checklist
Note
Medium Risk
Moderate risk because it changes the EVM account-creation and discovery path to use the V2 keyring interface and different keyring methods; regressions could affect account derivation/indexing and discovery behavior.
Overview
BREAKING: Migrates the EVM account provider from
KeyringController:withKeyring(V1) toKeyringController:withKeyringV2(V2) and updates types/messenger wiring to allow the new action.EvmAccountProvidernow uses V2 keyring APIs (getAccountsreturningKeyringAccount[],createAccountsreplacingaddAccounts, and deriving IDs from returned accounts) and changes range creation to loop per index (sinceHdKeyringV2doesn’t support range creation). Discovery now “peeks” the derived address via the V2 HD keyringrootbefore creating the account, and adds explicit assertions/error handling when keyring creation returns no account.Tests were updated accordingly, including new V2 keyring mocks and deterministic derivation fixtures, and the changelog documents the breaking migration.
Reviewed by Cursor Bugbot for commit cdf3ac5. Bugbot is set up for automated code reviews on this repo. Configure here.