fix(card): show Card tokens for the current account on account switch#30414
Conversation
|
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. |
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 c28ec40. Configure here.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #30414 +/- ##
=======================================
Coverage 82.03% 82.03%
=======================================
Files 5454 5455 +1
Lines 145830 145899 +69
Branches 33411 33436 +25
=======================================
+ Hits 119629 119691 +62
+ Misses 18016 18012 -4
- Partials 8185 8196 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Why SmokeMoney: These changes directly affect the Card home screen token display, Add Funds flow (which tokens are available to fund), and cashback view. The SmokeMoney tag covers card home, navbar entry, Add Funds flows, and card analytics - all of which depend on the modified selectors. Why not other tags: The changes are isolated to the Card/Money feature domain. No confirmations, swaps, network, or account management code was modified. The Performance Test Selection: |
|




Description
After switching the selected EVM account, the Spending Limit screen's Token selector rendered the "No tokens available" empty state, even when the new account had supported tokens that could be enabled. The root cause was introduced in #30028:
BaanxProvider.buildSupportedTokenssynthesized the "Not enabled" placeholder rows once at fetch time and stamped them with the account that was selected during the fetch.cardHomeDatais not refetched on a plain account switch, so the stalewalletAddresson those placeholders no longer matched the new selected account and the downstream filter inselectCardAvailableTokensremoved them all.Rather than triggering a network refetch on every account change (the
getCardHomeDatacall is heavy), this PR moves the placeholder synthesis into the selector layer so the list is recomputed reactively from data that is already in the store.BaanxProvider.buildSupportedTokensno longer creates inactive placeholders or takes acurrentWalletAddress. Its sole responsibility is now to enrich the realfundingAssetswith the matchingdelegationContractfromdelegationSettings.selectCardAvailableTokensnow combinescardHomeData, the selected EVM account, andselectCardFeatureFlag. It returns the filtered real entries plus Inactive placeholders synthesized fromdelegationSettingsviabuildDelegationTokenList, each stamped with the currently selected wallet address. Memoization keeps recomputation cheap.selectCardLineaUsdcTokenis rebased onselectCardAvailableTokensso the Cashback screen also benefits from the synthesized USDC-on-Linea placeholder.No data-fetching or controller subscription is added; the selector recomputes from already-cached state.
Changelog
CHANGELOG entry: Fixed a bug where the Card spending-limit token selector incorrectly showed "No tokens available" after switching accounts.
Related issues
Refs: #30028
Manual testing steps
Screenshots/Recordings
Before
N/A
After
N/A
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
Moves token placeholder synthesis from provider fetch-time to selector projection-time, changing what tokens are shown and how they’re sorted after account switches. Risk is moderate because it affects spending-limit and cashback token selection logic across wallets but is covered by updated tests.
Overview
Fixes an account-switch bug where the spending-limit token picker could show no tokens available by moving “Not enabled” placeholder creation out of
BaanxProvider.buildSupportedTokensand intoselectCardAvailableTokens, so placeholders are stamped with the currently selected EVM wallet without refetching home data.BaanxProvider.buildSupportedTokensnow only enriches realfundingAssetswithdelegationContract, while selectors synthesize delegation-derived placeholders viabuildDelegationTokenList, dedupe against real entries for the current wallet, and apply a deterministic sort (priority then status).selectCardLineaUsdcTokenis updated to fall back to the delegation-derived placeholder (for Cashback/Linea USDC), and tests are updated/expanded to validate placeholder behavior, account switching, and ordering.Reviewed by Cursor Bugbot for commit 336c0bd. Bugbot is set up for automated code reviews on this repo. Configure here.