Skip to content

feat: support ignoring non-evm tokens - #6981

Merged
juanmigdr merged 7 commits into
mainfrom
feat/support-ignore-non-evm
Oct 29, 2025
Merged

juanmigdr merged 7 commits into
mainfrom
feat/support-ignore-non-evm

Conversation

@juanmigdr

@juanmigdr juanmigdr commented Oct 28, 2025 •

Copy link
Copy Markdown
Member

Explanation

The feature to hide tokens is available for EVM assets but not for non-EVM assets. This task involves implementing a similar token hiding feature for non-EVM assets. This is crucial for improving user experience by allowing users to hide unwanted tokens, especially in light of spam and malicious token issues. The implementation should be prioritized to align with upcoming Solana campaigns.

NOTE:

  • Changes are needed on Mobile and extension to support this

References

https://consensyssoftware.atlassian.net/browse/ASSETS-1425

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, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Note

Introduce allIgnoredAssets and ignoreAssets in MultichainAssetsController and filter ignored non-EVM assets in selectors and balance calculations.

  • MultichainAssetsController:
    • Add allIgnoredAssets to state and default metadata; clean up on account removal.
    • New action ignoreAssets(accountId, assets); register handler and expose via messenger.
    • Filter ignored assets in accountAssetListUpdated handling.
    • Add helper #isAssetIgnored and related tests.
  • Balances (src/balances.ts):
    • Accept MultichainAssetsControllerState in calculators; exclude allIgnoredAssets from non‑EVM balance totals and change calculations.
  • Selectors (selectors/token-selectors.ts):
    • Extend AssetListState with allIgnoredAssets; omit ignored multichain assets in selectAllMultichainAssets.
  • Tests:
    • Update/expand tests across assets controller, balances, rates controller, and selectors to cover ignore behavior and new function signatures.
  • Changelog:
    • Note addition of ignoreAssets for non‑EVM chains.

Written by Cursor Bugbot for commit 0846036. This will update automatically on new commits. Configure here.

@juanmigdr
juanmigdr marked this pull request as ready for review October 29, 2025 15:55
@juanmigdr
juanmigdr requested a review from a team as a code owner October 29, 2025 15:55
cursor[bot]

This comment was marked as outdated.

@juanmigdr
juanmigdr requested a review from a team as a code owner October 29, 2025 16:26
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@juanmigdr
juanmigdr enabled auto-merge (squash) October 29, 2025 16:39
@juanmigdr
juanmigdr merged commit 740dfec into main Oct 29, 2025
255 checks passed
@juanmigdr
juanmigdr deleted the feat/support-ignore-non-evm branch October 29, 2025 17:02
github-merge-queue Bot pushed a commit to MetaMask/metamask-mobile that referenced this pull request Nov 10, 2025
<!--
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**
The feature to hide tokens is available for EVM assets but not for
non-EVM assets. This task involves implementing a similar token hiding
feature for non-EVM assets. This is crucial for improving user
experience by allowing users to hide unwanted tokens, especially in
light of spam and malicious token issues. The implementation should be
prioritized to align with upcoming Solana campaigns.

Furthermore, having the possibility of hiding tokens is not great if you
cannot add tokens back. Therefore I have implemented the whole logic to
add non-VEVM tokens to your wallet and remove them from ignored tokens
list.

In order to get this done the following PRs have been merged into Core:
- Support for adding non-evm tokens
[here](MetaMask/core#7016)
- Support for ignoring non-evm tokens
[here](MetaMask/core#6981)

Furthermore this PR solves a couple of bugs:
- Flashy behavior on the import token header when opening import token
screen
- Already added tokens could be re-added which was incorrect, they have
been disabled now

<!--
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: support importing and ignoring non-evm tokens

## **Related issues**

Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-1425

## **Manual testing steps**

```gherkin
Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]
```

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**


https://github.com/user-attachments/assets/77de0410-53b3-43cc-a6e4-2951db6b2b32

### **After**


https://github.com/user-attachments/assets/629c34bd-e0a9-4eef-bf3c-ec03be874b1a

## **Pre-merge author checklist**

- [ ] 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).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] 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]
> Enables importing and hiding non‑EVM tokens, updates Add Asset/search
UI to work across EVM/non‑EVM networks, and improves token removal,
explorer links, and already‑added token handling.
> 
> - **Non‑EVM token support**:
> - Add tokens via `MultichainAssetsController.addAssets` in
`SearchTokenAutocomplete`; retain EVM via `TokensController.addTokens`.
> - New `removeNonEvmToken` util to hide non‑EVM tokens; integrate in
`Tokens` and `AssetOptions`.
> - Disable re‑adding already‑added tokens (EVM via
`selectTokensByChainIdAndAddress`, non‑EVM via
`selectMultichainAssets`).
> - **Add Asset flow**:
> - Use `useTopTokens` to source token lists; show loading state; only
fetch token list for EVM.
> - Render custom Token/NFT tabs only on EVM networks; support non‑EVM
search/import.
>   - Network selector filters to EVM when not adding tokens.
> - **Search and lists**:
> - Refactor `AssetSearch` to `useTokenSearch` with `allTokens` prop and
debounced updates.
> - `MultiAssetListItems` switches to `FlashList`, shows network badges,
and disables already‑added tokens.
> - **Navigation/UI**:
> - Update Import screens to use `getImportTokenNavbarOptions`
(BottomSheetHeader).
> - Enable "Add token" button on non‑EVM networks in
`TokenListControlBar`.
> - **Asset details**:
> - `AssetOptions` handles CAIP addresses for explorers, hides "Remove
token" for native/wSOL, and supports non‑EVM removal with
notifications/metrics.
> - `ConfirmAddAsset` balances support non‑EVM addresses (hexified), and
header updated.
> - **Tests**:
> - Extensive unit/snapshot updates for new behaviors across search,
add, list, confirm, tokens, and asset options.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
f43d635. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Kylan Hurt <6249205+smilingkylan@users.noreply.github.com>
Co-authored-by: Luis Taniça <matallui@gmail.com>
Co-authored-by: Caainã Jeronimo <caainaje@gmail.com>
Co-authored-by: Kevin Bluer <kevin@bluer.com>
github-merge-queue Bot pushed a commit to MetaMask/metamask-extension that referenced this pull request Nov 10, 2025
<!--
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**
The feature to hide tokens is available for EVM assets but not for
non-EVM assets. This task involves implementing a similar token hiding
feature for non-EVM assets. This is crucial for improving user
experience by allowing users to hide unwanted tokens, especially in
light of spam and malicious token issues. The implementation should be
prioritized to align with upcoming Solana campaigns.

In order to get this done the following PRs have been merged:
- Support for ignoring non-evm tokens in core
[here](MetaMask/core#6981)
- Support for importing non-evm tokens in Extension
[here](#37501)

<!--
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?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/37423?quickstart=1)

## **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: support ignoring non-evm tokens

## **Related issues**

Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-1425

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**


https://github.com/user-attachments/assets/acdaf634-dee2-418a-bf8f-23c5832b9d53

### **After**


https://github.com/user-attachments/assets/512bcae8-d326-4987-8345-577207c69375

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/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]
> Adds support to hide/ignore non‑EVM assets via multichain API, passes
chainId for EVM token hides, removes isEvm prop from asset options, and
bumps assets controller.
> 
> - **Multichain/Background**:
> - Add `getApi()` method `multichainIgnoreAssets(assetIds, accountId)`
delegating to `MultichainAssetsController.ignoreAssets`.
> - **UI**:
>   - Update `HideTokenConfirmationModal` to:
> - Detect non‑EVM chains and dispatch
`multichainIgnoreAssets([address], accountId)`.
> - For EVM, dispatch `ignoreTokens` with `networkClientId` and
`chainId`.
> - Use selector `getInternalAccountBySelectedAccountGroupAndCaip` to
resolve account for non‑EVM.
>   - Simplify `AssetOptions`:
> - Remove `isEvm` prop and logic; show Hide option whenever
`!isNativeAsset`.
> - Adjust `native-asset.tsx` and `token-asset.tsx` to stop passing
`isEvm` to `AssetOptions`.
> - **Store/Actions**:
> - Add thunk `multichainIgnoreAssets(assetIds, accountId)`; keep
`ignoreTokens` flow for EVM, now provided `chainId` from UI.
> - **Tests**:
> - Update `hide-token-confirmation-modal` tests to assert `chainId`
passed to `ignoreTokens` and existing flows.
> - **Dependencies**:
>   - Bump `@metamask/assets-controllers` to `^87.1.1`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
731f870. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Bernardo Garces Chapero <bernardo.chapero@consensys.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants