fix(card): missing tokens when revoking using external tools#30209
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Tag selection rationale:
No other tags are needed — changes are isolated to the card controller provider and card selectors, with no impact on accounts, identity, network, browser, snaps, or other wallet features. Performance Test Selection: |
|



Description
This branch fixes MetaMask Card available funding assets so that after a user revokes a token allowance (e.g. via revoke.cash) or when another linked wallet still holds an active delegation, the currently selected wallet still gets a correct Inactive / not enabled row for supported tokens from Baanx delegation settings—instead of the token disappearing or being incorrectly deduplicated across wallets.
What changed (high level):
BaanxProvider.buildSupportedTokens— Replaces wallet-blind deduplication (address+chainIdonly) withhasPlaceholderForCurrentWallet: an existing row only blocks adding an Inactive placeholder for the same wallet (or legacy emptywalletAddress). Another wallet’s Active/Limited row no longer suppresses the current wallet’s placeholder. New Inactive placeholders are stamped withwalletAddress: currentWalletAddress(passed fromgetCardHomeData).selectCardAvailableTokens— Active and Limited assets from any linked wallet stay visible; Inactive rows are shown only when they belong to the selected EVM account (or have nowalletAddress), avoiding duplicate “not enabled” noise for other accounts.BaanxProvider.test.tscoversbuildSupportedTokens(empty funding list, same-wallet dedup, multi-wallet core case, null / emptydelegationSettings, contract enrichment).cardController.test.tscovers the selector filtering behaviour with mocked selected account.Intentionally not included: A feature-flag fallback that synthesizes tokens without
delegationSettings(would lack jurisdiction-correctdelegationContract). WhendelegationSettingsis missing or has nonetworks, behaviour stays returnfundingAssetsas-is (no synthetic list).Why
/v1/wallet/externalcan be empty after revocation while/v1/delegation/chain/configstill lists supported networks/tokens. Placeholders must be built from delegation settings per selected wallet, not deduplicated globally across wallets.availableFundingAssetsviaselectCardAvailableTokens; filtering Inactive by account keeps the asset list accurate for account switching and multi-wallet Baanx linkage.What changed (scoped paths)
BaanxProvider.ts:getCardHomeData(address, …)passesaddressintobuildSupportedTokens; wallet-aware placeholder dedup; InactivewalletAddressset to current address.cardController.ts:selectCardAvailableTokensusesselectSelectedEvmAccountand filters Inactive by current address.BaanxProvider.test.ts,cardController.test.ts.Out of scope (intentional)
delegationSettings/delegationContract.getOnChainAssets(still bypassesbuildSupportedTokens).Changelog
CHANGELOG entry: Fixed Card available asset list so supported tokens show per-wallet “not enabled” state after revocation or when another linked wallet still has an active delegation; inactive rows are scoped to the selected account in the token picker.
Related issues
Fixes:
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
Changes multi-wallet token placeholder and filtering logic for Card funding assets, which can affect what users see and can re-enable funding; risk is mitigated by added unit coverage but may impact edge cases around wallet selection and legacy empty
walletAddressrows.Overview
Fixes Card
availableFundingAssetsgeneration and display for multi-wallet scenarios so a supported token can still appear as Inactive/not enabled for the currently selected wallet even if another linked wallet has an Active/Limited entry or the external-wallet API returns no rows.BaanxProvider.getCardHomeDatanow passes the currentaddressintobuildSupportedTokens, which dedupes placeholders byaddress + chainId + walletAddress(with a legacy fallback for empty wallet) and stamps new inactive placeholders with the current wallet’s address while still enriching existing assets with the networkdelegationContract.selectCardAvailableTokensnow filtersInactiverows to the selected EVM account (or emptywalletAddress) while always showing Active/Limited rows from any linked wallet, reducing duplicate “not enabled” entries; new tests cover the wallet-aware placeholder and selector filtering behavior.Reviewed by Cursor Bugbot for commit 730da51. Bugbot is set up for automated code reviews on this repo. Configure here.