feat: source PreferencesController from @metamask/wallet (core#9232 integration)#32344
Closed
sirtimid wants to merge 2 commits into
Closed
feat: source PreferencesController from @metamask/wallet (core#9232 integration)#32344sirtimid wants to merge 2 commits into
sirtimid wants to merge 2 commits into
Conversation
Temporarily alias @metamask/wallet to the published core preview @metamask-previews/wallet@4.0.0-preview-55f166437 (branch sirtimid/wire-preferences-controller, core#9232), which wires PreferencesController into the wallet's default controller set. This is an integration-prototype pin: bump it to the real @metamask/wallet release once core#9232 ships, and drop this commit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ntegration)
Adopt the wallet-owned PreferencesController now that core#9232 wires the
package @metamask/preferences-controller into @metamask/wallet's default
controller set. Mobile already ran the package controller unchanged (its
local init/messenger delegated nothing), so no override config is needed —
mobile resolves the wallet's default instance and only seeds its own initial
state.
Mirroring the prior Keyring/Accounts/Connectivity/RFFC adoptions:
- Delete the standalone preferences-controller-init.ts and
preferences-controller-messenger.ts (+ tests).
- Drop PreferencesController from the init registry (Engine.ts initFunctions),
the MESSENGER_FACTORIES map, and the MessengerClientsToInitialize union.
- Keep it in the MessengerClients type, EngineState, the Actions/Events
unions, and BACKGROUND_STATE_CHANGE_EVENT_NAMES so background/Redux state
and consuming selectors keep working.
- Resolve it via this.#wallet.getInstance('PreferencesController') (with the
existing messengerClientsByName fallback in getMessengerClientOrThrow).
The package controller exposes no instance-options slot, so mobile's defaults
(IPFS gateway, detection toggles, smart-transactions opt-in, token sort order)
are seeded through WalletOptions.state.PreferencesController via the new
getPreferencesControllerInitialState helper. Persisted state is spread last so
a returning user's saved preferences win — identical to the deleted init.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
Author
|
Superseded by #32346 (recreated after the branch was renamed to |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
Sources
PreferencesControllerfrom@metamask/wallet's default controller set instead of mobile's own wiring, validated against a core preview build of core#9232.Mobile already used the package
@metamask/preferences-controllerunchanged, so there's no override — it resolves the wallet-owned instance and only seeds initial state. Mirrors the prior Keyring/Accounts/Connectivity/RFFC adoptions:preferences-controller-init.ts/-messenger.ts(+ tests).MESSENGER_FACTORIES, andMessengerClientsToInitialize; keep it inMessengerClients,EngineState, the Actions/Events unions, andBACKGROUND_STATE_CHANGE_EVENT_NAMES.wallet.getInstance('PreferencesController').state.PreferencesController(newwallet-init/instance-options/preferences-controller.ts), since the package controller takes no instance options. Persisted state wins.Also drops now-obsolete
PreferencesStatecasts in the preferences selectors (those fields are upstream now).The preview pin lives in a TEMP
chore:commit — bump to the real@metamask/walletrelease once core#9232 ships, and drop that commit.Changelog
CHANGELOG entry: null
Related issues
Refs: MetaMask/core#9232
Manual testing steps
Verified locally:
yarn install --immutable,yarn dedupe --check,yarn lint:tsc, andyarn lintall clean (only the pre-existing unrelatedtermsOfUsetsc noise). Install resolves@metamask/walletto the preview, which wiresPreferencesControllerby default.On a simulator (not run here): boot the app, confirm no duplicate
PreferencesControllerregistration, and that a preferences-driven flow (NFT detection / IPFS gateway / privacy mode) applies defaults on a fresh install and persists across relaunch.Screenshots/Recordings
N/A — no user-facing UI change.
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
🤖 Generated with Claude Code