You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: hide native tokens on Tempo networks (testnet and mainnet) (#7882)
## Explanation
<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:
* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->
**Context:**
Tempo is a EVM-ish chain that doesn't have the concept of native token.
This PR changes the behavior of asset-controller(s) so:
- Hides native tokens on those chains end-to-end: in
`AssetsController.getAssets`, in balance fetching
(AccountTrackerController and RPC balance fetcher), and in asset
selectors so the UI never shows Tempo native tokens.
- The portfolio USD value doesn't take in account the native token on
Tempo networks - Tempo testnet (`eip155:42431`) and Tempo mainnet
(`eip155:4217`) return arbitrary large numbers for native token balances
via `eth_getBalance`.
## References
<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?
For example:
* Fixes #12345
* Related to #67890
-->
## Checklist
- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Touches balance-fetching and asset-selection logic, which can impact
portfolio totals and token visibility across networks; changes are gated
to a specific chain allowlist and backed by targeted tests.
>
> **Overview**
> Native token handling is changed to **exclude Tempo networks
end-to-end**: `AssetsController.getAssets` now filters out native assets
on chain IDs listed in `CHAIN_IDS_WITH_NO_NATIVE_TOKEN`, and balance
fetching in `AccountTrackerController`/`rpc-balance-fetcher` now
short-circuits native balance retrieval (returning `0x0` for those
addresses) to avoid bogus `eth_getBalance` results.
>
> Selectors are updated to omit native assets for Tempo chains, and
`token-service.ts` forces `occurrenceFloor=1` for Tempo Mainnet. New
unit tests cover Tempo mainnet/testnet behavior and ensure non-Tempo
networks are unaffected; changelogs are updated accordingly.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e35e3ee. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Michele Esposito <michele@esposito.codes>
Co-authored-by: Maxime OUAIRY <maxime.ouairy-ext@consensys.net>
Co-authored-by: Arafet (CN - Hong Kong) <52028926+arafetbenmakhlouf@users.noreply.github.com>
0 commit comments