Skip to content

chore(runway): cherry-pick fix: account for POL non-zero native address cp-7.69.0#27119

Merged
joaoloureirop merged 1 commit into
release/7.69.0from
runway-cherry-pick-7.69.0-1772788738
Mar 9, 2026
Merged

chore(runway): cherry-pick fix: account for POL non-zero native address cp-7.69.0#27119
joaoloureirop merged 1 commit into
release/7.69.0from
runway-cherry-pick-7.69.0-1772788738

Conversation

@runway-github

@runway-github runway-github Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

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
0x0000000000000000000000000000000000001010 in wallet state (from
getNativeTokenAddress), but the bridge API expects AddressZero
(0x0000...0000) for all native assets. The bridge-controller's
isNativeAddress() does not recognize 0x...1010 as native, so:

  1. tokenToIncludeAsset sent the wrong asset ID (erc20:0x...1010
    instead of slip44:966) to the API, which couldn't deduplicate it with
    its own native POL entry.
  2. When the user selected POL with 0x...1010, quote matching in
    useBridgeQuoteData failed because the returned quote used
    AddressZero for destAsset.address.

Fix: Extracted the existing normalization logic from
useTokenAddress into a reusable pure function normalizeTokenAddress,
and applied it in useTokensWithBalance when building BridgeToken
objects from wallet state. This ensures POL enters the bridge flow with
AddressZero from 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

Feature: Bridge token selector - Polygon native token

  Scenario: user selects POL as destination token on Polygon
    Given user has a POL balance on Polygon
    And user opens the bridge token selector for destination

    When user filters by Polygon network
    Then POL appears only once in the token list with balance displayed

  Scenario: user gets a valid quote after selecting POL destination
    Given user has a source token with balance
    And user has selected POL on Polygon as the destination token

    When the quote loads
    Then the destination input shows a non-zero amount
    And the rate displays a valid exchange rate (not "--")

Screenshots/Recordings

Before

After

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.

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 useTokenAddress
into a reusable normalizeTokenAddress utility and applies it when
constructing tokens in useTokensWithBalance, 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.

[ec4fbf2](https://github.com/MetaMask/metamask-mobile/commit/ec4fbf279cc188b6b714b2dc803f95001532c8d0)

…ss cp-7.69.0 (#27052)

## **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
`0x0000000000000000000000000000000000001010` in wallet state (from
`getNativeTokenAddress`), but the bridge API expects `AddressZero`
(`0x0000...0000`) for all native assets. The bridge-controller's
`isNativeAddress()` does not recognize `0x...1010` as native, so:
1. `tokenToIncludeAsset` sent the wrong asset ID (`erc20:0x...1010`
instead of `slip44:966`) to the API, which couldn't deduplicate it with
its own native POL entry.
2. When the user selected POL with `0x...1010`, quote matching in
`useBridgeQuoteData` failed because the returned quote used
`AddressZero` for `destAsset.address`.

**Fix**: Extracted the existing normalization logic from
`useTokenAddress` into a reusable pure function `normalizeTokenAddress`,
and applied it in `useTokensWithBalance` when building `BridgeToken`
objects from wallet state. This ensures POL enters the bridge flow with
`AddressZero` from 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**

```gherkin
Feature: Bridge token selector - Polygon native token

  Scenario: user selects POL as destination token on Polygon
    Given user has a POL balance on Polygon
    And user opens the bridge token selector for destination

    When user filters by Polygon network
    Then POL appears only once in the token list with balance displayed

  Scenario: user gets a valid quote after selecting POL destination
    Given user has a source token with balance
    And user has selected POL on Polygon as the destination token

    When the quote loads
    Then the destination input shows a non-zero amount
    And the rate displays a valid exchange rate (not "--")
```

## **Screenshots/Recordings**

### **Before**


### **After**


## **Pre-merge author checklist**

- [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.

## **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**
> 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 `useTokenAddress`
into a reusable `normalizeTokenAddress` utility and applies it when
constructing tokens in `useTokensWithBalance`, preventing duplicate POL
entries and quote mismatches caused by inconsistent native-address
representations.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
b0deef0. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@runway-github runway-github Bot requested a review from a team as a code owner March 6, 2026 09:19
@github-actions

github-actions Bot commented Mar 6, 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.

@metamaskbot metamaskbot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Mar 6, 2026
@github-actions github-actions Bot added the size-S label Mar 6, 2026
@github-actions

github-actions Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - base branch is not main (base: release/7.69.0)

All E2E tests pre-selected.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented Mar 6, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

⚠️ E2E Fixture Validation — Structural changes detected

Category Count
New keys 68
Missing keys 11
Type mismatches 0
Value mismatches 6 (informational)

The committed fixture schema is out of date. To update, comment:

@metamaskbot update-mobile-fixture

View full details | Download diff report

@joaoloureirop joaoloureirop enabled auto-merge (squash) March 9, 2026 17:12
@joaoloureirop joaoloureirop merged commit 2853b06 into release/7.69.0 Mar 9, 2026
106 checks passed
@joaoloureirop joaoloureirop deleted the runway-cherry-pick-7.69.0-1772788738 branch March 9, 2026 17:13
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 9, 2026
@metamaskbot metamaskbot added the release-7.69.0 Issue or pull request that will be included in release 7.69.0 label Mar 10, 2026
@metamaskbot

Copy link
Copy Markdown
Collaborator

No release label on PR. Adding release label release-7.69.0 on PR, as PR was cherry-picked in branch 7.69.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.69.0 Issue or pull request that will be included in release 7.69.0 size-S team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants