feat: pre-fetch swap popular tokens#29587
Conversation
94b916d to
304a891
Compare
9122844
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 258018b. Configure here.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: The PR introduces significant refactoring of the Bridge/Swap token selector system and test infrastructure changes:
Not selected:
Performance Test Selection: |
|




Description
Changes
useInitialBridgeTokensso that the same logic can be used to pre-fetch the popular tokens during navigationUI/Bridge/types.tsutils/cacheUtils.tsChangelog
CHANGELOG entry: feat: pre-fetch swap popular tokens
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-4403
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Adds new token prefetch/caching and changes the swap/bridge token selector data flow, which could affect API load, abort/race behavior, and what tokens users see during loading/failure states.
Overview
Prefetches popular swap/bridge tokens during navigation via
useSwapBridgeNavigation, gated bybasicFunctionalityEnabled, to reduce empty-state time when opening the token selector.Refactors token fetching responsibilities by introducing
useInitialBridgeTokens(buildsincludeAssetsfrom owned balances, providesfetchPopularTokens, and centralizes 15-min caching inutils/cacheUtils.ts) and simplifyingusePopularTokensto be a thin fetch/abort wrapper.Improves token selector loading UX by showing owned tokens (and partial results) as placeholders while popular/search requests are pending or fail, and by adjusting search/includeAssets handling to avoid stale results and race conditions.
Type and utility cleanup: moves
SecurityData*,PopularToken, andIncludeAssetintoUI/Bridge/types.ts, updates call sites/tests accordingly, and enhancesgetTokenImageSourceto derive an icon URL fromaddress/chainIdwhen no image URL is provided.Reviewed by Cursor Bugbot for commit d7d2fbb. Bugbot is set up for automated code reviews on this repo. Configure here.