Commit 2ff2004
authored
chore: remove tokensChainsCache usage from usePerpsPaymentTokens (#28639)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
Removes the dependency on `selectTokenList` (backed by
`tokensChainsCache`) and `selectIsIpfsGatewayEnabled` from the
`usePerpsPaymentTokens` hook, as part of the broader effort to eliminate
`tokensChainsCache` usage across the codebase.
The `tokenList` selector was used in two places inside the hook, both of
which were effectively dead code:
1. **Hyperliquid USDC entry** — `enhanceTokenWithIcon` was called with
the current EVM chain's token list to look up the USDC icon. This lookup
would virtually never succeed because Hyperliquid tokens don't appear in
EVM chain token lists. The symbol-based cross-chain fallback might
occasionally match, but `USDC_TOKEN_ICON_URL` (already exported from
`@metamask/perps-controller` and used elsewhere in the codebase for this
exact purpose) is the correct, always-available icon. Replaced with the
hardcoded constant.
2. **Other wallet tokens** — `enhanceTokenWithIcon` was guarded by
`tokenList && !token.image`. However, `useTokensWithBalance` already
populates `token.image` via `getTokenIconUrl` (constructing the MetaMask
static CDN URL from the CAIP-19 asset ID) for every token it returns.
The `!token.image` condition was therefore almost never true, making the
entire enhancement block a no-op. Removed; tokens now pass through as-is
from `useTokensWithBalance`.
<!--
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?
-->
## **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: remove tokensChainsCache usage from
usePerpsPaymentTokens
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-3049
## **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**
- [ ] 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).
- [ ] I've completed the PR template to the best of my ability
- [ ] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] 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.
## **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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Moderate risk because it changes how token icons are sourced in the
Perps payment token list (now relying on `USDC_TOKEN_ICON_URL` and
`useTokensWithBalance` images) and removes token-list/IPFS fallbacks,
which could affect UI rendering if assumptions are wrong.
>
> **Overview**
> Removes `tokensChainsCache`-backed dependencies from
`usePerpsPaymentTokens` by dropping
`selectTokenList`/`selectIsIpfsGatewayEnabled` and the
`enhanceTokenWithIcon` flow.
>
> Hyperliquid USDC now always uses `USDC_TOKEN_ICON_URL` for its
`image`, and non-Hyperliquid tokens are passed through from
`useTokensWithBalance` with only `balance`/`balanceFiat` fallbacks.
Associated tests are updated, and `tokenIconUtils` (and its unit tests)
are deleted.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
f73a8f0. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 51e1608 commit 2ff2004
File tree
4 files changed
+27
-586
lines changed- app/components/UI/Perps
- hooks
- utils
4 files changed
+27
-586
lines changedLines changed: 14 additions & 57 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
15 | | - | |
16 | | - | |
17 | 14 | | |
18 | 15 | | |
19 | 16 | | |
| |||
40 | 37 | | |
41 | 38 | | |
42 | 39 | | |
43 | | - | |
44 | 40 | | |
45 | 41 | | |
46 | 42 | | |
| |||
52 | 48 | | |
53 | 49 | | |
54 | 50 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | 51 | | |
68 | 52 | | |
69 | 53 | | |
| |||
109 | 93 | | |
110 | 94 | | |
111 | 95 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 96 | + | |
116 | 97 | | |
117 | 98 | | |
118 | 99 | | |
| |||
122 | 103 | | |
123 | 104 | | |
124 | 105 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | 106 | | |
132 | 107 | | |
133 | 108 | | |
| |||
176 | 151 | | |
177 | 152 | | |
178 | 153 | | |
179 | | - | |
180 | 154 | | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
| 155 | + | |
185 | 156 | | |
186 | 157 | | |
187 | 158 | | |
| |||
288 | 259 | | |
289 | 260 | | |
290 | 261 | | |
291 | | - | |
292 | | - | |
293 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
294 | 265 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
305 | 275 | | |
306 | 276 | | |
307 | 277 | | |
| |||
346 | 316 | | |
347 | 317 | | |
348 | 318 | | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | 319 | | |
363 | 320 | | |
364 | 321 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | 6 | | |
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
| 13 | + | |
15 | 14 | | |
16 | 15 | | |
17 | | - | |
18 | 16 | | |
19 | 17 | | |
20 | 18 | | |
| |||
32 | 30 | | |
33 | 31 | | |
34 | 32 | | |
35 | | - | |
36 | | - | |
37 | 33 | | |
38 | 34 | | |
39 | 35 | | |
| |||
71 | 67 | | |
72 | 68 | | |
73 | 69 | | |
74 | | - | |
| 70 | + | |
75 | 71 | | |
76 | 72 | | |
77 | 73 | | |
78 | 74 | | |
79 | 75 | | |
| 76 | + | |
80 | 77 | | |
81 | 78 | | |
82 | 79 | | |
83 | 80 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | 81 | | |
91 | 82 | | |
92 | 83 | | |
| |||
99 | 90 | | |
100 | 91 | | |
101 | 92 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
126 | 102 | | |
127 | 103 | | |
128 | 104 | | |
| |||
147 | 123 | | |
148 | 124 | | |
149 | 125 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 126 | + | |
157 | 127 | | |
158 | 128 | | |
159 | 129 | | |
| |||
0 commit comments