Skip to content

Commit c901518

Browse files
authored
chore: remove allDetectedTokens Card references (#30236)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until this PR meets the canonical Definition of Ready For Review in `docs/readme/ready-for-review.md`. In short: the template must be materially complete (not just section titles present), all status checks must be currently passing, and the only expected follow-up commits must be reviewer-driven. --> ## **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? --> `allDetectedTokens` has been deprecated and empty for a long time. We are now removing all remaining references to that piece of state since we are in the process of deprecating many assets controllers. This should not have any effect in the app, as the content of that piece of state is always empty. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-3197 ## **Manual testing steps** ```gherkin 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** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** <!-- Every checklist item must be consciously assessed before marking this PR as "Ready for review". A checked box means you deliberately considered that responsibility, not that you literally performed every action listed. Unchecked boxes are ambiguous: they are not an implicit "N/A" and they are not a silent "skip". See `docs/readme/ready-for-review.md` for the full checklist semantics. --> - [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) - [ ] 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](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 - [ ] 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 For performance guidelines and tooling, see the [Performance Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers). ## **Pre-merge reviewer checklist** <!-- Reviewer checklist items follow the same semantics as the author checklist: an unchecked box is ambiguous, a checked box means the reviewer consciously assessed that responsibility. See `docs/readme/ready-for-review.md`. --> - [ ] 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.
1 parent 75d1e2b commit c901518

2 files changed

Lines changed: 1 addition & 38 deletions

File tree

app/components/UI/Card/hooks/useAssetBalances.test.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ describe('useAssetBalances', () => {
131131
backgroundState: {
132132
TokensController: {
133133
allTokens: {},
134-
allDetectedTokens: {},
135134
},
136135
NetworkController: {
137136
networkConfigurationsByChainId: {
@@ -218,7 +217,6 @@ describe('useAssetBalances', () => {
218217
backgroundState: {
219218
TokensController: {
220219
allTokens: {},
221-
allDetectedTokens: {},
222220
},
223221
NetworkController: {
224222
networkConfigurationsByChainId: {
@@ -449,7 +447,6 @@ describe('useAssetBalances', () => {
449447
'mock-account': [walletAsset],
450448
},
451449
},
452-
allDetectedTokens: {},
453450
},
454451
NetworkController: {
455452
networkConfigurationsByChainId: {
@@ -546,7 +543,6 @@ describe('useAssetBalances', () => {
546543
'mock-account': [walletAsset],
547544
},
548545
},
549-
allDetectedTokens: {},
550546
},
551547
NetworkController: {
552548
networkConfigurationsByChainId: {
@@ -694,7 +690,6 @@ describe('useAssetBalances', () => {
694690
'mock-account': [walletAsset],
695691
},
696692
},
697-
allDetectedTokens: {},
698693
},
699694
NetworkController: {
700695
networkConfigurationsByChainId: {
@@ -754,7 +749,6 @@ describe('useAssetBalances', () => {
754749
backgroundState: {
755750
TokensController: {
756751
allTokens: {},
757-
allDetectedTokens: {},
758752
},
759753
NetworkController: {
760754
networkConfigurationsByChainId: {
@@ -804,7 +798,6 @@ describe('useAssetBalances', () => {
804798
backgroundState: {
805799
TokensController: {
806800
allTokens: {},
807-
allDetectedTokens: {},
808801
},
809802
NetworkController: {
810803
networkConfigurationsByChainId: {
@@ -870,7 +863,6 @@ describe('useAssetBalances', () => {
870863
backgroundState: {
871864
TokensController: {
872865
allTokens: {},
873-
allDetectedTokens: {},
874866
},
875867
NetworkController: {
876868
networkConfigurationsByChainId: {},
@@ -1017,7 +1009,6 @@ describe('useAssetBalances', () => {
10171009
'mock-account': [walletAsset],
10181010
},
10191011
},
1020-
allDetectedTokens: {},
10211012
},
10221013
NetworkController: {
10231014
networkConfigurationsByChainId: {
@@ -1089,7 +1080,6 @@ describe('useAssetBalances', () => {
10891080
'mock-account': [walletAsset],
10901081
},
10911082
},
1092-
allDetectedTokens: {},
10931083
},
10941084
NetworkController: {
10951085
networkConfigurationsByChainId: {
@@ -1161,7 +1151,6 @@ describe('useAssetBalances', () => {
11611151
'mock-account': [walletAsset],
11621152
},
11631153
},
1164-
allDetectedTokens: {},
11651154
},
11661155
NetworkController: {
11671156
networkConfigurationsByChainId: {
@@ -1233,7 +1222,6 @@ describe('useAssetBalances', () => {
12331222
'mock-account': [walletAsset],
12341223
},
12351224
},
1236-
allDetectedTokens: {},
12371225
},
12381226
NetworkController: {
12391227
networkConfigurationsByChainId: {
@@ -1291,7 +1279,6 @@ describe('useAssetBalances', () => {
12911279
backgroundState: {
12921280
TokensController: {
12931281
allTokens: {},
1294-
allDetectedTokens: {},
12951282
},
12961283
NetworkController: {
12971284
networkConfigurationsByChainId: {
@@ -1356,7 +1343,6 @@ describe('useAssetBalances', () => {
13561343
backgroundState: {
13571344
TokensController: {
13581345
allTokens: {},
1359-
allDetectedTokens: {},
13601346
},
13611347
NetworkController: {
13621348
networkConfigurationsByChainId: {
@@ -1426,7 +1412,6 @@ describe('useAssetBalances', () => {
14261412
'mock-account': [walletAsset],
14271413
},
14281414
},
1429-
allDetectedTokens: {},
14301415
},
14311416
NetworkController: {
14321417
networkConfigurationsByChainId: {
@@ -1496,7 +1481,6 @@ describe('useAssetBalances', () => {
14961481
'mock-account': [walletAsset],
14971482
},
14981483
},
1499-
allDetectedTokens: {},
15001484
},
15011485
NetworkController: {
15021486
networkConfigurationsByChainId: {
@@ -1877,7 +1861,6 @@ describe('useAssetBalances', () => {
18771861
'mock-account': [walletAsset],
18781862
},
18791863
},
1880-
allDetectedTokens: {},
18811864
},
18821865
NetworkController: {
18831866
networkConfigurationsByChainId: {
@@ -1944,7 +1927,6 @@ describe('useAssetBalances', () => {
19441927
'mock-account': [walletAsset],
19451928
},
19461929
},
1947-
allDetectedTokens: {},
19481930
},
19491931
NetworkController: {
19501932
networkConfigurationsByChainId: {
@@ -2012,7 +1994,6 @@ describe('useAssetBalances', () => {
20121994
'mock-account': [walletAsset],
20131995
},
20141996
},
2015-
allDetectedTokens: {},
20161997
},
20171998
NetworkController: {
20181999
networkConfigurationsByChainId: {
@@ -2079,7 +2060,6 @@ describe('useAssetBalances', () => {
20792060
'mock-account': [walletAsset],
20802061
},
20812062
},
2082-
allDetectedTokens: {},
20832063
},
20842064
NetworkController: {
20852065
networkConfigurationsByChainId: {

app/components/UI/Card/hooks/useAssetBalances.tsx

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ export const useAssetBalances = (
9595

9696
// Get raw state needed for asset lookups - these are stable references from Redux
9797
const allAssets = useSelector(getTokensControllerAllTokens);
98-
const allDetectedTokens = useSelector(
99-
(state: RootState) =>
100-
state.engine.backgroundState.TokensController.allDetectedTokens,
101-
);
10298
const networkConfigs = useSelector(
10399
(state: RootState) =>
104100
state.engine.backgroundState.NetworkController
@@ -124,7 +120,6 @@ export const useAssetBalances = (
124120

125121
// Manually lookup asset from raw state (similar to selectAsset)
126122
const allTokensForChain = allAssets?.[chainId as Hex];
127-
const detectedTokensForChain = allDetectedTokens?.[chainId as Hex];
128123

129124
let asset: TokenI | undefined;
130125
if (allTokensForChain) {
@@ -139,18 +134,6 @@ export const useAssetBalances = (
139134
}
140135
}
141136
}
142-
if (!asset && detectedTokensForChain) {
143-
for (const accountTokens of Object.values(detectedTokensForChain)) {
144-
const found = (accountTokens as TokenI[])?.find(
145-
(t) =>
146-
t.address?.toLowerCase() === token.address?.toLowerCase(),
147-
);
148-
if (found) {
149-
asset = found;
150-
break;
151-
}
152-
}
153-
}
154137

155138
if (asset) {
156139
const key = `${token.address.toLowerCase()}-${token.caipChainId}`;
@@ -159,7 +142,7 @@ export const useAssetBalances = (
159142
}
160143
});
161144
return map;
162-
}, [tokens, allAssets, allDetectedTokens]);
145+
}, [tokens, allAssets]);
163146

164147
// Build the exchangeRatesMap in useMemo using raw state
165148
const exchangeRatesMap = useMemo(() => {

0 commit comments

Comments
 (0)