Skip to content

Conversation

@salimtb
Copy link
Contributor

@salimtb salimtb commented Dec 10, 2025

Description

Changelog

CHANGELOG entry:

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAssets, SmokeCore, SmokeWalletPlatform, SmokeSwaps, SmokeTrade, SmokeAccounts, SmokeNetworkAbstractions, SmokeMultiChainPermissions, SmokeStake
  • Risk Level: high
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

These changes are HIGH RISK because they modify critical Engine infrastructure and controller behavior:

  1. Engine.ts changes: Reordering controller initialization can affect timing dependencies between controllers. This is in the critical app/core/ path.

  2. TokenDetectionController initialization changes: Removing platform: 'mobile' and useAccountsAPI: true parameters changes how tokens are detected, which could affect token appearance in the wallet.

  3. Token-balances-controller-messenger changes: Adding many new messenger subscriptions including KeyringController lock/unlock events, TransactionController events, and TokenListController events significantly expands the TokenBalancesController's interaction scope.

  4. @metamask-assets-controllers patch: This is a massive patch that:

    • Disables SPOT_PRICES_SUPPORT_INFO for MANY major networks (Ethereum, Polygon, BSC, Arbitrum, Optimism, Base, Linea, Avalanche, etc.) by setting their values to null
    • Adds keyring lock/unlock awareness to TokenBalancesController
    • Changes balance update behavior to check isActive status before updates
    • Adds new methods for token importing and balance filtering

These changes affect:

  • Token balance display and updates across all chains
  • Token detection and import flows
  • Price fetching for tokens (disabled for many networks via null values)
  • Lock/unlock wallet interactions with balance updates
  • Transaction-triggered balance updates

The changes touch core wallet functionality (token balances, detection), multi-chain behavior (network-specific price support), account management (keyring events), and asset management. Testing should cover assets, wallet core, swaps/trade (which depend on balances), account functionality, network handling, and staking (which shows balances).

View GitHub Actions results

github-merge-queue bot pushed a commit to MetaMask/core that referenced this pull request Dec 11, 2025
## Explanation

Extension UI: MetaMask/metamask-extension#38708
Mobile UI: MetaMask/metamask-mobile#23864

Acceptance Criteria
• Replace all Account API v2 calls with Account API v4 for token
auto-detection.
• Continue using RPC-based detection for chains not supported by Account
API v4.
• If Account API v4 requests fail, fallback to RPC-based token
detection.
• If Account API v4 returns any unprocessed networks, fallback to RPC
detection for those networks as well.

<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:

* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->

## References

<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?

For example:

* Fixes #12345
* Related to #67890
-->

## 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](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Replaces token auto-detection via Accounts API v2 with v4, delegating
supported chains to TokenBalancesController, adding RPC fallbacks/new
actions, and improving polling, lock handling, and tests.
> 
> - **Breaking/Behavioral Changes**
> - Replace Accounts API v2 with v4 for token auto-detection; RPC-based
detection remains for unsupported chains.
> - `TokenDetectionController.detectTokens()` adds `forceRpc` and is
exposed via `TokenDetectionController:detectTokens`.
> - **TokenDetectionController**
> - Skips Accounts API–supported chains (handled by balances), performs
RPC detection otherwise.
> - Adds `addDetectedTokensViaPolling` and enhances
`addDetectedTokensViaWs`; respects prefs/external services; metrics
tracking.
> - Subscribes to tx confirmed events; refactors polling restart and
state helpers; minor type/utility cleanups.
> - **TokenBalancesController**
> - On Accounts API failure or unprocessed chains, calls
`TokenDetectionController:detectTokens` with `forceRpc: true`.
> - Imports untracked tokens via
`TokenDetectionController:addDetectedTokensViaPolling`.
> - Adds keyring lock/unlock gating (`isActive`), transaction events
handling, per-chain polling grouping/updates, token address filtering,
and robust state normalization.
> - **Accounts API Fetcher**
> - Supports v4 response shapes: handles CAIP `unprocessedNetworks`,
maps to hex; maintains timeout/batching; staked balances handling.
> - **Exports & Docs**
> - Update `index.ts` exports for new actions; changelog documents
breaking changes and new flows.
> - **Tests**
> - Extensive new/updated tests covering RPC fallback, polling behavior,
event handling, lock state, and edge cases.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
10463da. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants