Skip to content

fix: resolve native token icons in QuickBuy Pay with list#31026

Merged
xavier-brochard merged 2 commits into
mainfrom
fix/quick-buy-native-token-icons
Jun 3, 2026
Merged

fix: resolve native token icons in QuickBuy Pay with list#31026
xavier-brochard merged 2 commits into
mainfrom
fix/quick-buy-native-token-icons

Conversation

@xavier-brochard

@xavier-brochard xavier-brochard commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Description

Native EVM tokens (ETH on Linea, Optimism, Arbitrum, and mainnet) were rendering without their token icon in the QuickBuy "Pay with" list, falling back to the network badge / symbol monogram only.

Reason for the change: Native tokens come from getNativeSourceToken with an empty image and the zero address. The icon helper getBridgeTokenImageSource then fell back to getAssetImageUrl(token.address, token.chainId), which builds an erc20:0x0000…0000 CAIP asset id for the zero address. The MetaMask icon CDN (static.cx.metamask.io) only serves a real image at that erc20:0x0 path on a handful of chains (e.g. Base, 9396 B); for Linea/Optimism/Arbitrum/mainnet it returns a ~675 B placeholder, so no icon shows. The canonical SLIP-44 path (slip44/60) serves the real 7930 B ETH icon on every chain.

Solution: In getBridgeTokenImageSource, when the token is native, resolve its asset id via the bridge-controller's getNativeAssetForChainId(chainId).assetId (e.g. eip155:59144/slip44:60) before building the CDN URL, with a try/catch fallback to the raw address for unsupported chains. ERC-20s and the token.image short-circuit are untouched, and isNativeAddress keeps Solana/non-EVM natives working. The fix is intentionally contained to this QuickBuy helper, leaving the shared getAssetImageUrl/toAssetId untouched to avoid app-wide regressions.

Changelog

CHANGELOG entry: Fixed missing native token icons (e.g. Linea ETH) in the QuickBuy "Pay with" list.

Related issues

Fixes:

Manual testing steps

Feature: QuickBuy Pay with native token icons

  Scenario: user opens the Pay with sheet with native balances on multiple chains
    Given a wallet holding native ETH on Linea (and other non-Base EVM chains)

    When the user opens QuickBuy and taps the "Pay with" selector
    Then each native token row shows its proper token icon (no blank/monogram placeholder)

Screenshots/Recordings

Before

IMG_0029

After

image

Pre-merge author checklist

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.

Made with Cursor


Note

Low Risk
Scoped UI helper change with try/catch fallback; no auth, payments, or shared bridge URL logic changes.

Overview
Fixes missing native token icons in the QuickBuy Pay with list (and related picker rows) when token.image is empty.

getBridgeTokenImageSource now uses @metamask/bridge-controller’s isNativeAddress and getNativeAssetForChainId so CDN fallback URLs use the canonical SLIP-44 asset id instead of the zero address—addressing placeholder icons on Linea, Optimism, Arbitrum, mainnet, etc. ERC-20 behavior and the token.image shortcut are unchanged; unsupported chains still fall back to the raw address inside a try/catch.

Tests cover native SLIP-44 resolution and error fallback; QuickBuyPayWithScreen mocks were extended for the new bridge-controller helpers.

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

Native EVM tokens (ETH on Linea, Optimism, Arbitrum, mainnet) rendered no
icon because their CDN URL was built from the zero-address erc20 path, which
only serves a real image on a few chains. Resolve native tokens through their
canonical SLIP-44 asset id (e.g. eip155:59144/slip44:60), which the icon CDN
serves on every chain.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@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 Jun 3, 2026
@mm-token-exchange-service mm-token-exchange-service Bot added the team-social-ai Social & AI team label Jun 3, 2026
@github-actions github-actions Bot added the size-S label Jun 3, 2026
@xavier-brochard xavier-brochard marked this pull request as ready for review June 3, 2026 16:05
@xavier-brochard xavier-brochard 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 Jun 3, 2026
@github-actions github-actions Bot added the risk:low AI analysis: low risk label Jun 3, 2026
zone-live
zone-live previously approved these changes Jun 3, 2026
@xavier-brochard xavier-brochard enabled auto-merge June 3, 2026 16:09
@xavier-brochard

Copy link
Copy Markdown
Contributor Author

@cursor fix unit test in quick but

@cursor

cursor Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

The PR already exists and the description doesn't need updating. The fix is pushed.

The QuickBuyPayWithScreen.test.tsx was failing because its @metamask/bridge-controller mock only included formatChainIdToHex and isNonEvmChainId, but the updated getBridgeTokenImageSource.ts now also imports isNativeAddress and getNativeAssetForChainId from that module. I added both missing mock functions (isNativeAddress: () => false and getNativeAssetForChainId: () => undefined) to the existing mock, and all 13 tests in the suite now pass.

Open in Web Open in Cursor 

The @metamask/bridge-controller mock was missing isNativeAddress and
getNativeAssetForChainId, which are now used by getBridgeTokenImageSource.
This caused all QuickBuyPayWithScreen tests to fail with
'isNativeAddress is not a function'.

Co-authored-by: Xavier Brochard <xavier-brochard@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 95%
click to see 🤖 AI reasoning details

E2E Test Selection:
The three changed files are all within the SocialLeaderboard/TraderPositionView/QuickBuy component area:

  1. getBridgeTokenImageSource.ts - A utility function that resolves token image sources. The change improves native token icon resolution by using SLIP-44 asset IDs (via getNativeAssetForChainId from @metamask/bridge-controller) instead of the zero-address path. This is a visual/display bug fix with no behavioral impact on transaction flows.

  2. getBridgeTokenImageSource.test.ts - Unit tests updated to cover the new native token SLIP-44 resolution logic and error fallback scenarios.

  3. QuickBuyPayWithScreen.test.tsx - Mock updated to include the two new bridge-controller functions used by the updated utility.

No E2E tests reference SocialLeaderboard, TraderPositionView, or QuickBuy components. The changed utility is only imported by QuickBuyActionFooter.tsx and QuickBuyPayWithRow.tsx (UI display components). No controllers, Engine, navigation, or critical infrastructure is modified. This is a purely isolated unit-level change affecting only token icon display in the QuickBuy flow, with no risk to any E2E test flows.

Performance Test Selection:
The change only affects token image URL resolution logic (a utility function for determining which CDN URL to use for token icons). This has no impact on rendering performance, data loading, state management, or any critical user flows measured by performance tests.

View GitHub Actions results

@zone-live zone-live added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Jun 3, 2026
@xavier-brochard xavier-brochard added this pull request to the merge queue Jun 3, 2026
Merged via the queue into main with commit 3a1691d Jun 3, 2026
174 of 178 checks passed
@xavier-brochard xavier-brochard deleted the fix/quick-buy-native-token-icons branch June 3, 2026 17:47
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

risk:low AI analysis: low risk size-S skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-social-ai Social & AI team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants