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>
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>
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. |
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>
|
@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. |
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 construction sites (live
main):Jira: N/A
Checklist
🤖 Generated with Claude Code
Note
Medium Risk
Breaking messenger registration affects extension/mobile upgrade paths, though override-by-name is supported and behavior is covered by tests.
Overview
The default
Walletnow bootstrapsPreferencesControllerfrom@metamask/preferences-controller, exposingPreferencesController:*messenger actions (state and preference setters) on the wallet messenger andPreferencesControlleron wallet state.This is a breaking change for apps that already register their own
PreferencesControlleron a shared messenger—they must drop duplicate wiring or face action registration collisions. Clients with a superset controller can still replace the default viainitializationConfigurationswith the samename.The package also exports
InitializationConfiguration,InitFunctionArguments, andInstanceStateso consumers can type custom init overrides. Dependency graph, TS project references, CODEOWNERS, and tests cover the new default and override path.Reviewed by Cursor Bugbot for commit 55f1664. Bugbot is set up for automated code reviews on this repo. Configure here.