feat(wallet): add AccountsController and ConnectivityController#8924
feat(wallet): add AccountsController and ConnectivityController#8924grypez wants to merge 29 commits into
Conversation
d35a344 to
83241f6
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ctivityController Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ller initialization Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ce86ff2 to
e85be4e
Compare
There was a problem hiding this comment.
Let's add a CODEOWNER rule for this that matches the controller (same applies to ConnectivityController).
Additionally, let's have the accounts team review the addition.
Use explicit type annotation instead of verbose generic type parameters, leveraging the exported AccountsControllerMessenger type. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… init Add connectivityAdapter to instanceOptions so mobile and extension can supply a platform-specific adapter. Fall back to AlwaysOnlineAdapter when none is provided. Call controller.init() from the factory so the initial connectivity status is always fetched on construction. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ired init Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…explicit dependencies Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…OWNERS Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…vityController factory Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ller options are provided Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tions field Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…angelog Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Given mandatory connectivity adaptor is a breaking change, will need to prepare integration PRs in mobile and extension |
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 488b4c6. Configure here.
| } | ||
| } | ||
|
|
||
| export const connectivityController: InitializationConfiguration< |
There was a problem hiding this comment.
Do we not need a way to call init?
Perhaps we can just have an async function on the Wallet class that iterates each instance and calls init if it exists
Pass the connectivity adapter through `instanceOptions.connectivityController` instead of a top-level `WalletOptions.connectivityAdapter` field, and make the `connectivityController` instance options required. This drops the constructor glue that re-wrapped the top-level option and keeps the wallet defaults compatible across mobile and extension, since each consumer supplies its own adapter. Supersedes the top-level field introduced in 878145e, per PR review feedback. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Drop @MetaMask/core-platform as co-owner of the wallet accounts-controller initialization file so it matches the ownership of the accounts-controller package itself (@MetaMask/accounts-engineers), per PR review feedback. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…tor state Document that the `AccountsController` constructor's `state` option is now optional, introduced in this PR alongside the wallet default-controller work. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…-controllers # Conflicts: # .github/CODEOWNERS # README.md # packages/wallet/CHANGELOG.md # packages/wallet/package.json # packages/wallet/src/initialization/instances/index.ts # packages/wallet/src/types.ts # packages/wallet/tsconfig.build.json # yarn.lock
…directory convention
Move the AccountsController and ConnectivityController initialization
configs into their own directories to match the per-controller layout
established by the ApprovalController instance, so the package isn't left
in two styles.
- accounts-controller/accounts-controller.ts
- connectivity-controller/{connectivity-controller,types,always-online-adapter}.ts
with colocated tests, pulling AlwaysOnlineAdapter into its own sibling
file (mirroring the keyring encryptor split) and extracting the
connectivity instance options into a ConnectivityControllerInstanceOptions
type.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Explanation
Adds
AccountsControllerandConnectivityControlleras default initialized controllers in thewalletpackage, following theInitializationConfigurationpattern established byKeyringController. The required messenger delegation forAccountsControlleris wired up (keyring actions, SnapKeyring events, andMultichainNetworkController:networkDidChange). A temporaryAlwaysOnlineAdapteris introduced forConnectivityControllerpending a real platform adapter, and acreateSecretRecoveryPhraseutility is added alongside the existingimportSecretRecoveryPhrase.AccountsControlleris deprecated in favour ofAccountTreeControllerandMultichainAccountService, but both of those still consumeAccountsControlleractions/events at the messenger level, so it must remain present as infrastructure. Migration is tracked via a TODO on the initialization file.References
N/A
Checklist
Note
Medium Risk
Breaking wallet API (required connectivity adapter) plus account/keyring messenger wiring; scope is bounded to wallet initialization and a small accounts-controller constructor tweak.
Overview
Breaking change for
@metamask/walletconsumers: default initialization now includesAccountsControllerandConnectivityController, andinstanceOptions.connectivityController.connectivityAdapteris required (tests use the newAlwaysOnlineAdapterstub until a real platform adapter is injected).AccountsController is registered via the existing
InitializationConfigurationpattern, with messenger delegation for keyring actions/events (includingKeyringController:stateChange, Snap keyring account updates, andMultichainNetworkController:networkDidChange). Wallet tests assert keyring-created addresses appear inAccountsControllerstate.ConnectivityController is wired the same way, taking the injected adapter at init.
@metamask/accounts-controllermakes constructorstateoptional (defaults when omitted). Package deps, TS project references, README dependency graph, and CODEOWNERS paths are updated accordingly.Reviewed by Cursor Bugbot for commit 02b1f32. Bugbot is set up for automated code reviews on this repo. Configure here.