Skip to content

feat: source PreferencesController from @metamask/wallet (core#9232 integration)#32344

Closed
sirtimid wants to merge 2 commits into
mainfrom
adopt-wallet-preferences-controller
Closed

feat: source PreferencesController from @metamask/wallet (core#9232 integration)#32344
sirtimid wants to merge 2 commits into
mainfrom
adopt-wallet-preferences-controller

Conversation

@sirtimid

@sirtimid sirtimid commented Jun 24, 2026

Copy link
Copy Markdown
Member

Description

Sources PreferencesController from @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-controller unchanged, so there's no override — it resolves the wallet-owned instance and only seeds initial state. Mirrors the prior Keyring/Accounts/Connectivity/RFFC adoptions:

  • Delete the local preferences-controller-init.ts / -messenger.ts (+ tests).
  • Drop it from the init registry, MESSENGER_FACTORIES, and MessengerClientsToInitialize; keep it in MessengerClients, EngineState, the Actions/Events unions, and BACKGROUND_STATE_CHANGE_EVENT_NAMES.
  • Resolve via wallet.getInstance('PreferencesController').
  • Seed mobile's defaults via state.PreferencesController (new wallet-init/instance-options/preferences-controller.ts), since the package controller takes no instance options. Persisted state wins.

Also drops now-obsolete PreferencesState casts in the preferences selectors (those fields are upstream now).

The preview pin lives in a TEMP chore: commit — bump to the real @metamask/wallet release 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, and yarn lint all clean (only the pre-existing unrelated termsOfUse tsc noise). Install resolves @metamask/wallet to the preview, which wires PreferencesController by default.

On a simulator (not run here): boot the app, confirm no duplicate PreferencesController registration, 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)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

🤖 Generated with Claude Code

sirtimid and others added 2 commits June 24, 2026 18:13
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>
@github-actions github-actions Bot added the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jun 24, 2026
@mm-token-exchange-service mm-token-exchange-service Bot added the team-ocap-kernel Ocap Kernel team label Jun 24, 2026
@sirtimid sirtimid closed this Jun 24, 2026
@sirtimid sirtimid deleted the adopt-wallet-preferences-controller branch June 24, 2026 16:39
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 24, 2026
@sirtimid

Copy link
Copy Markdown
Member Author

Superseded by #32346 (recreated after the branch was renamed to sirtimid/adopt-wallet-preferences-controller; the rename closed this PR instead of retargeting it).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. size-M team-ocap-kernel Ocap Kernel team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant