Skip to content

chore: remove allDetectedTokens Earn references#30237

Merged
bergarces merged 7 commits into
mainfrom
all-detected-tokens-earn-references
May 15, 2026
Merged

chore: remove allDetectedTokens Earn references#30237
bergarces merged 7 commits into
mainfrom
all-detected-tokens-earn-references

Conversation

@bergarces
Copy link
Copy Markdown
Contributor

@bergarces bergarces commented May 15, 2026

Description

allDetectedTokens has been deprecated and empty for a long time. We are now removing all remaining references to that piece of state since we are in the process of deprecating many assets controllers.

This should not have any effect in the app, as the content of that piece of state is always empty.

Changelog

CHANGELOG entry: null

Related issues

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

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
Changes Earn network polling behavior by removing the TokensController.allDetectedTokens -> addTokens import path and by always triggering detectTokens on mount/account change, which could affect token-detection frequency and performance across lending chains.

Overview
Simplifies useEarnNetworkPolling by removing all usage of deprecated TokensController.allDetectedTokens and the follow-up TokensController.addTokens import flow; the hook now only triggers TokenDetectionController.detectTokens.

Polling hooks are updated to use the static lending LENDING_CHAIN_IDS list directly (no local state), and tests are adjusted accordingly, including dropping addTokens expectations and removing allDetectedTokens from Earn hook test fixtures.

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

@bergarces bergarces requested a review from a team as a code owner May 15, 2026 11:11
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Comment thread app/components/UI/Earn/hooks/useEarnNetworkPolling.test.ts
Comment thread app/components/UI/Earn/hooks/useEarnNetworkPolling.test.ts
});

setLendingChainIds(validChainIds);
}, [setLendingChainIds]);
Copy link
Copy Markdown
Contributor Author

@bergarces bergarces May 15, 2026

Choose a reason for hiding this comment

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

This is really not doing anything, other than causing the first render to call the other hooks with an empty array and then call them again on second render with an exact copy of LENDING_CHAIN_IDS.

I think both the useEffect and the useState are not necessary here.

}
}
}
};
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

detectTokens already sends messages to TokensController internally to add the tokens. It does not populate allDetectedTokens.

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

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 2 potential issues.

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 dedd488. Configure here.

Comment thread app/components/UI/Earn/hooks/useEarnNetworkPolling.ts Outdated
Comment thread app/components/UI/Earn/hooks/useEarnNetworkPolling.ts
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeStake, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are confined to the Earn/Stake feature's network polling hook and its tests:

  1. useEarnNetworkPolling.ts: Simplified refactoring - removed the intermediate useState for lendingChainIds (now uses LENDING_CHAIN_IDS constant directly), removed the complex importLendingTokens function that manually called TokensController.addTokens, and simplified the useEffect dependency array. Also fixed an incorrect import of RootState from a test file.

  2. Test files (useEarnNetworkPolling.test.ts, useEarnToken.test.ts, useEarnTokens.test.ts): Updated to match the simplified implementation - removed addTokens mocks and updated expectations.

Risk: Low - these are test file changes plus a simplification refactor of a polling hook. The core behavior (polling for token balances, currency rates, token rates, and token detection on lending chains) is preserved. The main change is that polling now starts immediately with LENDING_CHAIN_IDS instead of waiting for a useEffect to set state.

Tags selected:

  • SmokeStake: The useEarnNetworkPolling hook is directly used in the Earn/Stake feature (EarnTokenList component). Changes to this hook could affect staking and lending deposit/withdrawal flows.
  • SmokeConfirmations: Per SmokeStake tag description, when selecting SmokeStake, also select SmokeConfirmations since staking transactions involve on-chain confirmations.

No other tags are warranted as the changes are isolated to the Earn/Stake domain and don't touch shared infrastructure, navigation, accounts, networks, or other feature areas.

Performance Test Selection:
The changes simplify the polling logic by removing an intermediate useState and a complex token import flow. While this could theoretically improve performance (fewer re-renders, no chained async operations), the changes are in a hook-level refactor that doesn't affect UI rendering components, list rendering, or critical user flow timing. The polling hooks themselves (useTokenBalancesPolling, useCurrencyRatePolling, etc.) are unchanged. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@bergarces bergarces enabled auto-merge May 15, 2026 12:38
@bergarces bergarces added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit 5ceea8b May 15, 2026
102 checks passed
@bergarces bergarces deleted the all-detected-tokens-earn-references branch May 15, 2026 13:31
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.79.0 Issue or pull request that will be included in release 7.79.0 label May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.79.0 Issue or pull request that will be included in release 7.79.0 size-M team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants