Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent non-current network tokens from being hidden incorrectly #4967

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

salimtb
Copy link
Contributor

@salimtb salimtb commented Nov 24, 2024

Explanation

Current State

Currently, the ignoreTokens method in the TokensController is using a static set of tokens (ignoredTokens, detectedTokens, and tokens) 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

  • Updated the method to use allTokens, allDetectedTokens, and allIgnoredTokens, scoped by interactingChainId or the current network's chainId and selected address.
  • Ensured the ignoredTokens array is derived dynamically based on the active network and address, preventing interference from tokens of other networks.

How It Works

  • The changes introduce a more granular approach by retrieving the correct token lists (allTokens, allDetectedTokens, and allIgnoredTokens) scoped to the relevant network and address.
  • The method now dynamically calculates ignoredTokens for the active network, avoiding issues with overlapping or incorrect tokens.

These updates ensure that the ignoreTokens function operates correctly when handling network-specific tokens, reducing the risk of unintended behavior.


References

  • None.

Changelog

@metamask/assets-controllers

  • FIXED: Resolved an issue where ignoreTokens could incorrectly hide tokens from networks other than the current one.
  • CHANGED: Updated ignoreTokens logic to use network- and address-specific token lists (allTokens, allDetectedTokens, allIgnoredTokens).

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 highlighted breaking changes using the "BREAKING" category above as appropriate.
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes.

This format is ready to be used in your PR description field on platforms like GitHub.

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.

1 participant