fix: account for POL non-zero native address cp-7.69.0#27052
Conversation
|
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: The changes are purely refactoring with no functional changes - the same logic is preserved, just extracted into a reusable utility. The affected hooks are used in:
SmokeTrade is selected because it covers bridge functionality (tests/smoke/swap/bridge-action-smoke.spec.ts). SmokeConfirmations is selected as a dependent tag per the tag description guidance: "when selecting SmokeTrade for swap or bridge flows, also select SmokeConfirmations". Performance Test Selection: |
The committed fixture schema is out of date. To update, comment: |
|



Description
Fixes a bug in the bridge token selector where Polygon's native token (POL) appeared twice in the list — once with balance at the top and once without balance at the bottom. Selecting the balance entry as a destination token caused the quote to show 0 and the rate to display "--".
Root cause: Polygon's native token uses address
0x0000000000000000000000000000000000001010in wallet state (fromgetNativeTokenAddress), but the bridge API expectsAddressZero(0x0000...0000) for all native assets. The bridge-controller'sisNativeAddress()does not recognize0x...1010as native, so:tokenToIncludeAssetsent the wrong asset ID (erc20:0x...1010instead ofslip44:966) to the API, which couldn't deduplicate it with its own native POL entry.0x...1010, quote matching inuseBridgeQuoteDatafailed because the returned quote usedAddressZerofordestAsset.address.Fix: Extracted the existing normalization logic from
useTokenAddressinto a reusable pure functionnormalizeTokenAddress, and applied it inuseTokensWithBalancewhen buildingBridgeTokenobjects from wallet state. This ensures POL enters the bridge flow withAddressZerofrom the start, fixing both the duplicate listing and the quote/rate mismatch.Changelog
CHANGELOG entry: Fixed a bug where Polygon's native token (POL) appeared twice in the bridge token selector and selecting it showed incorrect quote data.
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Medium risk because it changes how token addresses are represented in the bridge token list and downstream API/quote matching, which could affect token identification on Polygon. Scope is small and isolated to bridge token normalization.
Overview
Fixes Polygon native token (POL) handling in the bridge UI by normalizing Polygon’s non-zero native token address to the zero address the bridge API expects.
Extracts the Polygon-specific normalization from
useTokenAddressinto a reusablenormalizeTokenAddressutility and applies it when constructing tokens inuseTokensWithBalance, preventing duplicate POL entries and quote mismatches caused by inconsistent native-address representations.Written by Cursor Bugbot for commit b0deef0. This will update automatically on new commits. Configure here.