feat: source PreferencesController from @metamask/wallet#32346
feat: source PreferencesController from @metamask/wallet#32346sirtimid wants to merge 4 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
wallet-init/instance-options/preferences-controller.ts builder (alongside the
other per-controller wallet wiring). Persisted state is spread last so a
returning user's saved preferences win — identical to the deleted init.
Add a CODEOWNERS entry for the new builder owned by @MetaMask/mobile-platform
and @MetaMask/core-platform, matching the other wallet-init instance-options.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
isMultiAccountBalancesEnabled, showTestNetworks, isIpfsGatewayEnabled,
securityAlertsEnabled and useTransactionSimulations are now real fields on
the upstream @metamask/preferences-controller PreferencesState, so the
`as PreferencesState & {...}` casts (and the stale comments referencing the
long-removed @MetaMask+preferences-controller+2.1.0.patch) are dead weight.
Access them directly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |
|



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