Skip to content

chore: remove tokensChainsCache from assets selectors, transactions utils, and test fixtures#28925

Merged
juanmigdr merged 4 commits into
mainfrom
chore/tokensChainsCache-cleanup-assets-core
Apr 17, 2026
Merged

chore: remove tokensChainsCache from assets selectors, transactions utils, and test fixtures#28925
juanmigdr merged 4 commits into
mainfrom
chore/tokensChainsCache-cleanup-assets-core

Conversation

@juanmigdr

@juanmigdr juanmigdr commented Apr 16, 2026

Copy link
Copy Markdown
Member

Description

Removes all usages of the deprecated tokensChainsCache field from TokenListController across the codebase.

This includes:

  • Deleting app/selectors/tokenListController.ts which exposed selectTokenList, selectERC20TokensByChain, and selectERC20TokensByChainInternal — all deprecated selectors that read from tokensChainsCache
  • Refactoring selectAsset and assetToToken in assets-list.ts to source aggregators directly from the token stored in allTokens (via TokensController) instead of looking it up in tokensChainsCache
  • Removing the early-return shortcut in isSmartContractAddress that checked tokensChainsCache before querying the network
  • Removing the TokenListController.tokensChainsCache mask from the Sentry state filter
  • Cleaning up all test fixtures and mocks that referenced tokensChainsCache

Changelog

CHANGELOG entry: remove tokensChainsCache from assets selectors, transactions utils, and test fixtures

Related issues

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

Manual testing steps

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

Before

After

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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.

Note

Medium Risk
Touches asset-to-token mapping and contract-address detection behavior; mistakes could cause missing token metadata (e.g., aggregators) or extra network calls/perf regressions from removing the cache short-circuit.

Overview
Removes the deprecated TokenListController selectors (selectTokenList, selectERC20TokensByChain) and updates callers/tests to no longer mock or depend on them.

Updates selectAsset in assets-list to stop reading TokenListController.tokensChainsCache; aggregators (and rwaData) are now sourced from TokensController.allTokens, and related state fixtures/tests are adjusted accordingly.

Simplifies isSmartContractAddress in util/transactions by dropping the mainnet token-cache short-circuit, and cleans up Sentry state masking to no longer reference TokenListController.tokensChainsCache.

Reviewed by Cursor Bugbot for commit 016a367. Bugbot is set up for automated code reviews on this repo. Configure here.

@juanmigdr juanmigdr requested a review from a team as a code owner April 16, 2026 13:50
@github-actions github-actions Bot added size-M risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 16, 2026
@juanmigdr juanmigdr enabled auto-merge April 16, 2026 14:01
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 16, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fb8f6ea. Configure here.

Comment thread app/util/logs/__snapshots__/index.test.ts.snap Outdated
@juanmigdr juanmigdr disabled auto-merge April 16, 2026 14:24
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeConfirmations, SmokeWalletPlatform, SmokeTrade
  • Selected Performance tags: @PerformanceAssetLoading
  • Risk Level: medium
  • AI Confidence: 78%
click to see 🤖 AI reasoning details

E2E Test Selection:

The PR removes deprecated tokensChainsCache references across the codebase:

  1. tokenListController.ts (DELETED): The file containing selectTokenList and selectERC20TokensByChain selectors is deleted. Confirmed no remaining imports exist in production code (only test mocks that were also cleaned up).

  2. assets-list.ts (selectAsset/assetToToken refactor): The assetToToken function now gets aggregators from allTokens (the actual stored token data) instead of looking them up from tokensChainsCache. This affects token metadata display in TokenListItem, TokenDetails, and Earn components. This is a behavioral change in how token aggregators are sourced — if allTokens doesn't have aggregators populated, they'll be empty. This touches the asset list and token details views → SmokeWalletPlatform.

  3. transactions/index.js (isSmartContractAddress): Removed the early-return optimization that checked tokensChainsCache for mainnet contract addresses. Now all contract address checks go through the network query path. This could affect confirmation flows where contract detection is used (ERC-20 approvals, contract interactions) → SmokeConfirmations.

  4. sentry/utils.ts: Cleanup of Sentry state masking — no functional impact on app behavior.

  5. Test files: Unit test updates reflecting the above changes — no direct E2E impact.

SmokeTrade is included because swap/bridge flows use token metadata (including aggregators) for token selection and display, and the selectAsset change affects how token aggregators are resolved.

SmokeConfirmations is included because isSmartContractAddress is used in transaction confirmation flows to detect contract addresses, and removing the cache shortcut changes the code path.

SmokeWalletPlatform is included because token list display and transaction history rely on selectAsset which now sources aggregators differently.

No dependency tags needed beyond these three based on the tag descriptions (SmokeTrade + SmokeConfirmations are already paired per tag description).

Performance Test Selection:
The selectAsset and assetToToken refactor changes how token aggregators are resolved — from a direct cache lookup in tokensChainsCache to a find() operation on allTokens. This could have minor performance implications for asset loading and token list rendering, particularly with large token lists. The @PerformanceAssetLoading tag covers token list rendering and balance fetching which are directly affected by the assets-list.ts selector changes.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
11 value mismatches detected (expected — fixture represents an existing user).
View details

@juanmigdr juanmigdr added this pull request to the merge queue Apr 17, 2026
Merged via the queue into main with commit cabe1a2 Apr 17, 2026
296 of 305 checks passed
@juanmigdr juanmigdr deleted the chore/tokensChainsCache-cleanup-assets-core branch April 17, 2026 11:02
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 17, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.75.0 Issue or pull request that will be included in release 7.75.0 label Apr 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.75.0 Issue or pull request that will be included in release 7.75.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-M team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants