Skip to content

Conversation

@sahar-fehri
Copy link
Contributor

@sahar-fehri sahar-fehri commented Dec 19, 2025

Explanation

This PR adds a useExternalServices option to the token selectors, allowing callers to exclude non-EVM (multichain) assets when basic functionality / external services are disabled.

Added a useExternalServices option that:
Short-circuits early in selectAllMultichainAssets when false, returning an empty object immediately
Avoids all expensive computation (parsing CAIP assets, building balances, fiat conversions) when multichain assets aren't needed
Defaults to true to maintain backward compatibility

References

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
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Adds a useExternalServices option to asset selectors to optionally exclude non‑EVM assets and short‑circuit multichain processing; updates tests and changelog.

  • Selectors
    • Add useExternalServices option to selectAllAssets and selectAssetsBySelectedAccountGroup (defaults to true).
    • In selectAllMultichainAssets, return {} when useExternalServices is false, excluding non‑EVM (multichain) assets.
    • Wire opts through selectors to control inclusion of multichain assets.
  • Tests (packages/assets-controllers/src/selectors/token-selectors.test.ts)
    • Add cases verifying inclusion/exclusion of Solana assets based on useExternalServices and default behavior.
    • Adjust Tron tests to pass useExternalServices where needed.
  • Changelog
    • Document new useExternalServices option and behavior in packages/assets-controllers/CHANGELOG.md.

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

@sahar-fehri sahar-fehri marked this pull request as ready for review December 19, 2025 13:53
@sahar-fehri sahar-fehri requested review from a team as code owners December 19, 2025 13:53
state,
opts: SelectAccountGroupAssetOpts = defaultSelectAccountGroupAssetOpts,
): AssetsByAccountGroup =>
selectAllAssets(state, { useExternalServices: opts.useExternalServices }),
Copy link

Choose a reason for hiding this comment

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

Bug: New opts object breaks selector memoization chain

The inline object { useExternalServices: opts.useExternalServices } is created fresh on every call to the first input selector. Since selectAllAssets and selectAllMultichainAssets use default reselect memoization (strict reference equality), this new object reference invalidates their cache on every call. The expensive computation inside selectAllMultichainAssets — including parsing CAIP assets, building balance maps, and fiat conversions — will rerun even when the state hasn't changed. Before this change, selectAllAssets was called directly as an input selector without opts, so its memoization worked correctly.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants