Uh oh!
There was an error while loading. Please reload this page.
fix: prevent non-current network tokens from being hidden incorrectly - #4967
Merged
Conversation
gambinish
approved these changes
Nov 25, 2024
github-merge-queueBot
pushed a commit
to MetaMask/metamask-extension
that referenced
this pull request
Nov 25, 2024
…#28674) <!-- 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** fix to prevent non current network tokens from being hidden incorrecly core PR: MetaMask/core#4967 <!-- 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? --> [](https://codespaces.new/MetaMask/metamask-extension/pull/28674?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. add different network accros different chains 2. choose ethereum as current chain 3. try to hide token of polygon for instance ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> https://github.com/user-attachments/assets/2637ed94-6ad1-4025-8000-963906aca187 ### **After** <!-- [screenshots/recordings] --> https://github.com/user-attachments/assets/4c5d6cbd-4af2-43c5-bcbd-879a71b9997e ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.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-extension/blob/develop/.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.
7 tasks
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Current State
Currently, the
ignoreTokensmethod in theTokensControlleris using a static set of tokens (ignoredTokens,detectedTokens, andtokens) without accounting for tokens scoped to specific networks. This causes issues when attempting to hide tokens that do not belong to the currently active network, potentially leading to incorrect behavior.Changes Introduced
allTokens,allDetectedTokens, andallIgnoredTokens, scoped byinteractingChainIdor the current network'schainIdand selected address.ignoredTokensarray is derived dynamically based on the active network and address, preventing interference from tokens of other networks.How It Works
allTokens,allDetectedTokens, andallIgnoredTokens) scoped to the relevant network and address.ignoredTokensfor the active network, avoiding issues with overlapping or incorrect tokens.These updates ensure that the
ignoreTokensfunction operates correctly when handling network-specific tokens, reducing the risk of unintended behavior.References
Changelog
@metamask/assets-controllersignoreTokenscould incorrectly hide tokens from networks other than the current one.ignoreTokenslogic to use network- and address-specific token lists (allTokens,allDetectedTokens,allIgnoredTokens).Checklist
This format is ready to be used in your PR description field on platforms like GitHub.