Conversation
…ns' of github.com:MetaMask/metamask-mobile into chore/remove-tokensChainsCache-from-usePerpsPaymentTokens
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 f58dff2. Configure here.
enhanceTokenWithIcon and its supporting types/imports are no longer used by any production code after removing the last caller in usePerpsPaymentTokens. Made-with: Cursor
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Tag selection rationale:
The risk is low because: (1) the change is a simplification (static URL vs dynamic lookup), (2) USDC is the primary token used in Perps and its icon URL is now hardcoded from the controller package, (3) no shared infrastructure or cross-feature components are affected. Performance Test Selection: |
|
|
✅ E2E Fixture Validation — Schema is up to date |




Description
Removes the dependency on
selectTokenList(backed bytokensChainsCache) andselectIsIpfsGatewayEnabledfrom theusePerpsPaymentTokenshook, as part of the broader effort to eliminatetokensChainsCacheusage across the codebase.The
tokenListselector was used in two places inside the hook, both of which were effectively dead code:enhanceTokenWithIconwas 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, butUSDC_TOKEN_ICON_URL(already exported from@metamask/perps-controllerand used elsewhere in the codebase for this exact purpose) is the correct, always-available icon. Replaced with the hardcoded constant.enhanceTokenWithIconwas guarded bytokenList && !token.image. However,useTokensWithBalancealready populatestoken.imageviagetTokenIconUrl(constructing the MetaMask static CDN URL from the CAIP-19 asset ID) for every token it returns. The!token.imagecondition was therefore almost never true, making the entire enhancement block a no-op. Removed; tokens now pass through as-is fromuseTokensWithBalance.Changelog
CHANGELOG entry: remove tokensChainsCache usage from usePerpsPaymentTokens
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-3049
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
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_URLanduseTokensWithBalanceimages) and removes token-list/IPFS fallbacks, which could affect UI rendering if assumptions are wrong.Overview
Removes
tokensChainsCache-backed dependencies fromusePerpsPaymentTokensby droppingselectTokenList/selectIsIpfsGatewayEnabledand theenhanceTokenWithIconflow.Hyperliquid USDC now always uses
USDC_TOKEN_ICON_URLfor itsimage, and non-Hyperliquid tokens are passed through fromuseTokensWithBalancewith onlybalance/balanceFiatfallbacks. Associated tests are updated, andtokenIconUtils(and its unit tests) are deleted.Reviewed by Cursor Bugbot for commit f73a8f0. Bugbot is set up for automated code reviews on this repo. Configure here.