Skip to content

chore: remove TokenListController#29872

Merged
juanmigdr merged 17 commits into
mainfrom
chore/remove-tokensListController
May 12, 2026
Merged

chore: remove TokenListController#29872
juanmigdr merged 17 commits into
mainfrom
chore/remove-tokensListController

Conversation

@juanmigdr

@juanmigdr juanmigdr commented May 7, 2026

Copy link
Copy Markdown
Member

Description

TokenListController has been removed from @metamask/assets-controllers in favour of the token list being fetched directly by dependent controllers (e.g. TokenDetectionController, TokenRatesController). This PR removes all wiring of TokenListController from the mobile app.

Changes included:

  • Deleted token-list-controller-init.ts and its messenger (token-list-controller-messenger.ts) along with their tests
  • Deleted useTokenListPolling hook and its test
  • Removed TokenListController from Engine.ts (instantiation, wiring, and exported state)
  • Removed TokenListController from types.ts (MessengerClients, EngineState, MessengerClientsToInitialize, global action/event union types)
  • Removed TokenListController from messengers/index.ts (MESSENGER_FACTORIES)
  • Removed TokenListController:stateChange from constants.ts (BACKGROUND_STATE_CHANGE_EVENT_NAMES)
  • Removed TOKEN_LIST_STATE_CHANGE_EVENT constant from AppConstants.ts
  • Removed useTokenListPolling call from AssetPollingProvider and useEarnNetworkPolling
  • Removed runtime access to TokenListController.state.tokensChainsCache from TransactionElement/utils.js
  • Removed TokenListController.fetchTokenList call from AddAsset.tsx
  • Cleaned up initial-background-state.json, E2E fixture files (default-fixture.json, fixture-validation.ts), and mock state files (Bridge/initialState.ts, perpsStateMock.ts, other-controllers-mock.ts, component-view/mocks.ts)

Changelog

CHANGELOG entry: remove TokenListController

Related issues

https://consensyssoftware.atlassian.net/browse/ASSETS-3181

Manual testing steps

Feature: TokenListController removal

  Background:
    Given I am logged into MetaMask Mobile

  Scenario: NEW user imports SRP/PK with a lot of tokens (from app install)
    Tokens list and detection should work as expected
    There should be no issues loading tokens

  Scenario: EXISTING user imports SRP/PK with a lot of tokens
    Tokens list and detection should work as expected
    There should be no issues loading tokens

  Scenario: token detection still works after controller removal
    Given I am on the Wallet home screen
    And I have an account with no custom tokens

    When user navigates to Add Asset
    Then the token search screen should load without errors

    When user selects a different network
    Then no crash or error should occur

  Scenario: transaction list still displays correctly
    Given I am on the Wallet home screen
    And I have prior ERC-20 transactions

    When user navigates to the Activity tab
    Then all transactions should render without errors
    And token symbols should still appear where available

Screenshots/Recordings

Before

N/A

After

https://github.com/MetaMask/metamask-mobile/actions/runs/25657693707
https://github.com/MetaMask/metamask-mobile/actions/runs/25726986329

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

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.

Note

Medium Risk
Medium risk because it removes TokenListController from Engine wiring/state and strips related polling and fixtures, which can impact token discovery/display paths if any remaining callsites still expect the controller or its cached token metadata.

Overview
Removes TokenListController integration from the app, including Engine initialization/exported state, messenger wiring, background state change constants, and shared type definitions.

Eliminates token-list polling (useTokenListPolling) and stops calling it from AssetPollingProvider and useEarnNetworkPolling, along with deleting the hook and its tests.

Cleans up UI callsites that depended on the controller: AddAsset no longer triggers fetchTokenList on network change, and TransactionElement no longer prefixes approval action labels using token-list cache data. Updates/cleans fixtures and tests to reflect the removed controller state.

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

@juanmigdr juanmigdr requested review from a team as code owners May 7, 2026 15:35
@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 May 7, 2026
@github-actions github-actions Bot added the size-L label May 7, 2026
Comment thread app/components/UI/TransactionElement/utils.js
@juanmigdr juanmigdr removed 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 May 7, 2026
@juanmigdr juanmigdr requested a review from a team as a code owner May 7, 2026 15:44
Base automatically changed from chore/udate-assets-controllers-tokensList to main May 8, 2026 16:36
@juanmigdr juanmigdr changed the title chore: remove tokensListController chore: remove TokenListController May 8, 2026
@juanmigdr juanmigdr removed request for a team May 8, 2026 17:14
@juanmigdr juanmigdr added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label May 11, 2026
@juanmigdr juanmigdr enabled auto-merge May 11, 2026 07:26

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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 1 potential issue.

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 d85c0c7. Configure here.

Comment thread app/components/UI/TransactionElement/utils.js
@juanmigdr juanmigdr added the force-builds Forces e2e native builds to trigger label May 11, 2026

@bergarces bergarces left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed and tested locally. LGTM

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeWalletPlatform, SmokeConfirmations, SmokeSwap, SmokeStake, SmokeNetworkAbstractions
  • Selected Performance tags: @PerformanceAssetLoading
  • Risk Level: high
  • AI Confidence: 82%
click to see 🤖 AI reasoning details

E2E Test Selection:
This PR removes TokenListController from the Engine's initialization system entirely - a significant architectural change in the Token Management domain (Phase 4). Key impacts:

  1. Engine.ts / types.ts / constants.ts / messengers/index.ts: TokenListController completely removed from the Engine initialization pipeline, messenger factory, type definitions, and Redux state sync events. This is a breaking architectural change that removes a controller that was previously used across multiple features.

  2. TransactionElement/utils.js: Removed token symbol lookup from TokenListController.state.tokensChainsCache - this directly affects how transaction action keys are displayed in transaction history (previously showed 'SNX Approve', now just 'Approve'). This impacts SmokeWalletPlatform (transaction history display).

  3. AssetPollingProvider.tsx + useEarnNetworkPolling.ts: Removed useTokenListPolling hook calls - token list data is no longer polled via this mechanism. This affects token detection and asset loading flows, impacting SmokeWalletPlatform and SmokeStake.

  4. AddAsset.tsx: Removed TokenListController.fetchTokenList() call when switching networks in the Add Asset flow - affects SmokeNetworkAbstractions (token management).

  5. Test fixtures (default-fixture.json, initial-background-state.json, fixture-validation.ts): TokenListController state removed from E2E test fixtures - this directly affects the test infrastructure and could cause fixture validation failures if any test still expects this state.

  6. Migration test (029.test.ts): Added TokenListController to expected migration state for backward compatibility.

The removal of TokenListController from the Engine means token list data must now come from another source (likely the new useTokensData hook that calls the tokens API directly). This is a significant change that could affect:

  • Token display in confirmations (SmokeConfirmations)
  • Transaction history display (SmokeWalletPlatform)
  • Token detection and asset management (SmokeNetworkAbstractions)
  • Swap flows that rely on token metadata (SmokeSwap)
  • Staking/lending flows that used token list polling (SmokeStake)

The fixture changes are particularly important as they affect the E2E test infrastructure directly.

Performance Test Selection:
The removal of TokenListController polling (useTokenListPolling) from AssetPollingProvider changes how token list data is loaded. Previously, token list data was polled via the controller; now it appears to be fetched on-demand via the useTokensData hook (direct API calls). This architectural change in asset loading could impact performance - specifically token list rendering and balance display which are covered by @PerformanceAssetLoading. The change from controller-based polling to direct API fetching could affect load times for token lists.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@juanmigdr juanmigdr added this pull request to the merge queue May 12, 2026
@juanmigdr juanmigdr removed this pull request from the merge queue due to a manual request May 12, 2026
@juanmigdr juanmigdr added this pull request to the merge queue May 12, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 12, 2026
@juanmigdr juanmigdr added this pull request to the merge queue May 12, 2026
Merged via the queue into main with commit 14d5551 May 12, 2026
126 of 130 checks passed
@juanmigdr juanmigdr deleted the chore/remove-tokensListController branch May 12, 2026 11:14
@github-actions github-actions Bot locked and limited conversation to collaborators May 12, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.78.0 Issue or pull request that will be included in release 7.78.0 label May 12, 2026
@Prithpal-Sooriya Prithpal-Sooriya added the area-performance Issues relating to slowness of app, cpu usage, and/or blank screens. label May 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-performance Issues relating to slowness of app, cpu usage, and/or blank screens. force-builds Forces e2e native builds to trigger release-7.78.0 Issue or pull request that will be included in release 7.78.0 size-L skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants