Commit cdad5de
authored
fix: remove duplicate POL tokens from swap select token screen (#21924)
<!--
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**
POL token is defined with zero address in our backend services but its
actual address is `0x0000000000000000000000000000000000001010`. That
creates an issue where both tokes are rendered even if they are the
same. To mitigate this issue we keep the one with zero address as it's
more consistent with similar logic.
<!--
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: Fixes an issue where users will see two POL tokens on
swap select token screen
## **Related issues**
Fixes: #19334
## **Manual testing steps**
```gherkin
- Ensure that users see only one POL token on Select Token screen of swaps.
- Ensure that POL token rendered in Select Token screen of swaps have correct balance.
- Ensure that users can complete a swap or bridge transaction using POL token both as source and dest.
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
<img width="429" height="878" alt="Screenshot 2025-10-30 at 11 40 04 AM"
src="https://github.com/user-attachments/assets/13d41b1a-2f52-4070-9f47-ca8c38263629"
/>
### **After**
<img width="449" height="909" alt="Screenshot 2025-10-30 at 2 18 18 PM"
src="https://github.com/user-attachments/assets/d11a437c-56dc-4733-b1cc-835cb792ce2f"
/>
<!-- [screenshots/recordings] -->
## **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]
> Normalize Polygon native token addressing to dedupe POL across token
sources and ensure correct rendering/exclusion.
>
> - **Bridge tokens**:
> - Normalize Polygon native token by mapping
`0x0000000000000000000000000000000000001010` to `zeroAddress()` in
`useTokens` `getTokenKey` for consistent deduplication across sources.
> - Respect exclusions for POL regardless of whether specified as
`zeroAddress()` or native address.
> - **Tests**:
> - Add comprehensive tests in `hooks/useTokens.test.ts` covering:
> - Duplicate prevention between `tokensWithBalance` and `topTokens`
(both address variants).
> - Mixed-chain behavior (ETH unaffected), `allTokens` normalization,
and exclusion cases.
> - **Constants**:
> - Introduce `POLYGON_NATIVE_TOKEN` in `constants/assets.ts`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3cde5f8. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent fb1ec2e commit cdad5de
File tree
3 files changed
+572
-1
lines changed- app/components/UI/Bridge
- constants
- hooks
3 files changed
+572
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments