Commit 14d5551
authored
chore: remove TokenListController (#29872)
## **Description**
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
`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**
```gherkin
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**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
#### Performance checks (if applicable)
- [x] I've tested on Android
- Ideally on a mid-range device; emulator is acceptable
- [x] I've tested with a power user scenario
- Use these [power-user
SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93)
to import wallets with many accounts and tokens
- [x] I've instrumented key operations with Sentry traces for production
performance metrics
- See [`trace()`](/app/util/trace.ts) for usage and
[`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274)
for an example
## **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 the help of the pr-description AI skill -->
<!-- CURSOR_SUMMARY -->
---
> [!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.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
ceeb3ef. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent e88fd67 commit 14d5551
24 files changed
Lines changed: 4 additions & 752 deletions
File tree
- app
- components
- UI
- Earn/hooks
- TransactionElement
- Views/AddAsset
- hooks/AssetPolling
- core
- Engine
- controllers
- messengers
- selectors
- store/migrations
- util/test
- tests
- component-view
- framework/fixtures
- json
Lines changed: 0 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
37 | | - | |
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
| |||
52 | 50 | | |
53 | 51 | | |
54 | 52 | | |
55 | | - | |
56 | 53 | | |
57 | 54 | | |
58 | 55 | | |
| |||
140 | 137 | | |
141 | 138 | | |
142 | 139 | | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | 140 | | |
147 | 141 | | |
148 | 142 | | |
| |||
164 | 158 | | |
165 | 159 | | |
166 | 160 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | 161 | | |
171 | 162 | | |
172 | 163 | | |
| |||
367 | 358 | | |
368 | 359 | | |
369 | 360 | | |
370 | | - | |
371 | 361 | | |
372 | 362 | | |
373 | 363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
61 | 60 | | |
62 | 61 | | |
63 | 62 | | |
64 | | - | |
65 | 63 | | |
66 | 64 | | |
67 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
839 | 839 | | |
840 | 840 | | |
841 | 841 | | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
| 842 | + | |
851 | 843 | | |
852 | 844 | | |
853 | 845 | | |
| |||
876 | 868 | | |
877 | 869 | | |
878 | 870 | | |
879 | | - | |
| 871 | + | |
880 | 872 | | |
881 | 873 | | |
882 | 874 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | | - | |
16 | 14 | | |
17 | 15 | | |
18 | 16 | | |
| |||
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | 57 | | |
63 | 58 | | |
64 | 59 | | |
| |||
Lines changed: 0 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | | - | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
| |||
34 | 32 | | |
35 | 33 | | |
36 | 34 | | |
37 | | - | |
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
| |||
57 | 54 | | |
58 | 55 | | |
59 | 56 | | |
60 | | - | |
61 | 57 | | |
62 | 58 | | |
63 | 59 | | |
| |||
85 | 81 | | |
86 | 82 | | |
87 | 83 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | 84 | | |
93 | 85 | | |
94 | 86 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
32 | | - | |
33 | 31 | | |
34 | 32 | | |
35 | 33 | | |
| |||
0 commit comments