feat(wallet): wire PreferencesController into default initialization#9232
feat(wallet): wire PreferencesController into default initialization#9232sirtimid wants to merge 4 commits into
PreferencesController into default initialization#9232Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
e951604 to
a8fd340
Compare
There was a problem hiding this comment.
Before we can do this, we will need metamask-extension and metamask-mobile to both be using PreferencesController from core.
Today they have diverged unfortunately.
EDIT: In theory, we may be able to wire in PreferencesController to wallet and override the initialization on extension to use the diverging version. But will depend on whether their state overlaps enough.
@FrederikBolding Mobile is already on vanilla core |
|
@metamaskbot publish-previews |
Yeah, I realized that and added my EDIT. Have you verified that the controller state on extension is a superset of the We should de-risk by creating integration PRs regardless! |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
|
@metamaskbot publish-previews |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Add an integration test asserting PreferencesController.setAccountLabel routes through the wallet-delegated AccountsController:getAccountByAddress / :setAccountName (real wallet + override). Trim the override comments to the essential rationale and tie both runtime casts to MetaMask/core#9232 for removal once it ships. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
55f1664 to
68c1526
Compare
Add `PreferencesController` to the default wallet initialization set. It has no cross-controller messenger dependencies and its only constructor inputs are `messenger` and `state`, so it wires with a plain namespaced child messenger and no `instanceOptions` slot — per-client values are supplied through the existing `state.PreferencesController` initial state. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Prove a consumer can keep a diverging superset PreferencesController by supplying its own initialization configuration under the same name, which overrides the package default — the adoption path for clients (e.g. the extension) that cannot converge to the package controller's state shape. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Re-export `InitializationConfiguration`, `InitFunctionArguments`, and `InstanceState` from the package root so consumers can annotate their own initialization configurations that override a default controller (e.g. the extension overriding the default `PreferencesController`). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
68c1526 to
a7c0a88
Compare
Explanation
Wires the
@metamask/preferences-controllerpackage into@metamask/wallet's default initialization. The defaultWalletnow constructs aPreferencesControllerand exposes itsPreferencesController:*messenger actions (getState/stateChangeplus the preference setters).References
Client adoption PRs (integrate this default into each client):
Client construction sites (live
main):Jira: N/A
Checklist
🤖 Generated with Claude Code
Note
Medium Risk
Breaking change for extension/mobile that already register
PreferencesController; duplicate messenger actions will fail at runtime. Preference state affects UX/privacy settings but follows the same pattern as prior default-controller wiring (e.g. RemoteFeatureFlagController).Overview
BREAKING: The default
Walletnow builds@metamask/preferences-controllerduring initialization and registersPreferencesController:*messenger actions on the root messenger, sowallet.state.PreferencesControllerand calls likePreferencesController:setIpfsGatewaywork out of the box. Extension/mobile clients that already register their ownPreferencesControlleron a shared messenger must drop that wiring before upgrading or messenger registration will collide.A new
preferences-controllerinitialization instance mirrors other default controllers (child messenger +PreferencesControllerconstructor). Consumers can still replace it by supplying aninitializationConfigurationsentry withname: 'PreferencesController'(e.g. a client-specific superset controller).The package also exports
InitializationConfiguration,InitFunctionArguments, andInstanceStatefor authoring overrides, adds@metamask/preferences-controlleras a dependency, and documents the breaking change in the wallet changelog.Reviewed by Cursor Bugbot for commit a7c0a88. Bugbot is set up for automated code reviews on this repo. Configure here.