Skip to content

feat(assets-controllers): seed mUSD as default tracked asset#8620

Merged
salimtb merged 7 commits intomainfrom
feat/musd-default-all-tokens
Apr 30, 2026
Merged

feat(assets-controllers): seed mUSD as default tracked asset#8620
salimtb merged 7 commits intomainfrom
feat/musd-default-all-tokens

Conversation

@salimtb
Copy link
Copy Markdown
Contributor

@salimtb salimtb commented Apr 28, 2026

Adds mUSD (0xaca92e438df0b2401ff60da7e4337b687a2435da) as a default tracked token for all accounts on Ethereum mainnet (0x1), Linea (0xe708), Monad mainnet (0x8f), and Monad testnet (0x279f).

TokensController changes:

  • Directly seeds mUSD into allTokens state for all known accounts at construction time, from persisted state, and on these events:
    • KeyringController:unlock — covers post-unlock account availability
    • AccountsController:accountAdded — covers async account loading
    • AccountsController:selectedEvmAccountChange — covers account switching
    • NetworkController:networkAdded — covers newly added supported chains
    • NetworkController:stateChange patches (op: add) — detects chain additions

TokenDetectionController changes:

  • start() now calls #seedDefaultTokens() which uses the TokensController:addTokens action per supported chain, ensuring mUSD is seeded via the standard deduplication path on every detection run
  • Re-seeds when the selected EVM account changes or a supported chain is added
  • #defaultTokensSeeded flag prevents redundant seeding within a session

Tests:

  • Added 13 tests for mUSD seeding triggers in TokensController
  • Updated messenger event delegation and helpers for new event types

Explanation

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Touches token state seeding and network/account event handling, which can affect users’ persisted allTokens and default asset visibility across chains. Logic is largely additive and guarded/deduped, but incorrect triggers or chain lists could lead to unexpected token entries or missed seeding.

Overview
Adds automatic seeding of MetaMask USD (mUSD) into TokensController state so it appears as a default tracked token on supported chains, including seeding for existing/persisted accounts and re-seeding on account selection, account creation, unlock, and supported network additions (both networkAdded and stateChange add patches).

Updates TokenDetectionController.start() to seed mUSD via TokensController:addTokens per configured supported chain, guarded by a per-session flag and re-triggered on selected-account changes and supported NetworkController:networkAdded.

Expands TokensController/TokenDetectionController messenger allowed events accordingly, updates/extends TokensController tests heavily (mUSD seeding scenarios plus a few behavioral test additions like watchAsset passing pageMeta, updating existing tokens via addDetectedTokens, safer handling when network patches omit networkConfigurationsByChainId, and ERC721 detection when supportsInterface throws), and removes an eslint suppression for explicit return types in TokensController.test.ts.

Reviewed by Cursor Bugbot for commit 5ee1f4a. Bugbot is set up for automated code reviews on this repo. Configure here.

Adds mUSD (0xaca92e438df0b2401ff60da7e4337b687a2435da) as a default
tracked token for all accounts on Ethereum mainnet (0x1), Linea (0xe708),
Monad mainnet (0x8f), and Monad testnet (0x279f).

TokensController changes:
- Directly seeds mUSD into `allTokens` state for all known accounts
  at construction time, from persisted state, and on these events:
  - `KeyringController:unlock` — covers post-unlock account availability
  - `AccountsController:accountAdded` — covers async account loading
  - `AccountsController:selectedEvmAccountChange` — covers account switching
  - `NetworkController:networkAdded` — covers newly added supported chains
  - `NetworkController:stateChange` patches (op: add) — detects chain additions

TokenDetectionController changes:
- `start()` now calls `#seedDefaultTokens()` which uses the
  `TokensController:addTokens` action per supported chain, ensuring
  mUSD is seeded via the standard deduplication path on every detection run
- Re-seeds when the selected EVM account changes or a supported chain is added
- `#defaultTokensSeeded` flag prevents redundant seeding within a session

Tests:
- Added 13 tests for mUSD seeding triggers in TokensController
- Updated messenger event delegation and helpers for new event types
@salimtb salimtb force-pushed the feat/musd-default-all-tokens branch from 99c1fd1 to c8ac494 Compare April 28, 2026 14:48
@salimtb salimtb marked this pull request as ready for review April 28, 2026 16:12
@salimtb salimtb requested review from a team as code owners April 28, 2026 16:12
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ccc42bd. Configure here.

Comment thread packages/assets-controllers/src/TokensController.ts
Comment thread packages/assets-controllers/src/TokensController.ts
@salimtb salimtb added this pull request to the merge queue Apr 30, 2026
Merged via the queue into main with commit 8e93e0b Apr 30, 2026
366 checks passed
@salimtb salimtb deleted the feat/musd-default-all-tokens branch April 30, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants