feat(card): refactor spending limit screen#27918
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. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #27918 +/- ##
==========================================
+ Coverage 82.52% 82.56% +0.04%
==========================================
Files 4800 4828 +28
Lines 123748 124025 +277
Branches 27576 27644 +68
==========================================
+ Hits 102122 102405 +283
+ Misses 14567 14565 -2
+ Partials 7059 7055 -4 ☔ 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:
Primary tag: SmokeCard (directly tests Card integration features including spending limit flows). The changes do not touch shared navigation infrastructure, Engine, controllers, or other feature areas, so other tags are not warranted. Performance Test Selection: |
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.
|
✅ E2E Fixture Validation — Schema is up to date |
|




Description
Refactors the Card Spending limit screen and related asset selection so default token choice and list ordering follow wallet fiat value for the currently selected MetaMask account, replaces the multi–quick-select asset row with a settings-style summary card, and moves full vs. restricted limit + amount into a dedicated bottom sheet.
Why: Quick-select assumed fixed symbols (e.g. mUSD-first) and did not consistently reflect real balances or account switches. Asset lists should align with how much the user actually holds per account, and the main screen should read like compact “settings” rows instead of several tappable asset tiles.
What changed:
constants.ts: AddsCARD_CHAIN_IDS(Linea, Base, Monad hex0x8f, Solana) using@metamask/transaction-controllerchain IDs where applicable; keepscaipChainIdToNetworkderived fromcardNetworkInfos.useSpendingLimit:quickSelectTokens,handleQuickSelectToken, andisOtherSelected.useTokensWithBalance({ chainIds: CARD_CHAIN_IDS })so default token candidates are sorted bytokenFiatAmount(highest first); if none have positive fiat, falls back to Linea mUSD when present. Candidates come from NotEnabled allowances when applicable, otherwisebuildTokenListFromSettings+sdk.getSupportedTokensByChainId.setHasInitialized(false), clear selection) so defaults are not stale across account switches.handleAccountSelectopens the account selector;handleOtherSelectopensAssetSelectionBottomSheetwithexcludedTokensset to the current row token;handleLimitSelectopens the new spending-limit options sheet.returnedLimitType/returnedCustomLimitfrom the options sheet viauseFocusEffect(same pattern as token return params).SpendingLimit.tsx: Setup header copy (setup_title/setup_description); settings card with three rows — Account, Token (labelSYMBOL on NETWORK) with chevron → asset picker, Spending limit row → options sheet; footer Cancel / Confirm.SpendingLimitOptionsSheet.tsx(new modal route): Full access vs Spending limit (with numeric input),LimitOptionItemstyling tweaks (input alignment,maxLength={12}), confirm navigates back with limit params.Routes/ Card stack: RegistersCARD.MODALS.SPENDING_LIMIT_OPTIONSfor the options sheet.AssetSelectionBottomSheet: OptionalexcludedTokensin navigation params to hide the token already shown on the spending-limit Token row;NotEnabledtokens are sorted by fiat usingrawFiatNumberon enriched rows.useAssetBalances: UsesCARD_CHAIN_IDSforuseTokensWithBalance(adds Monad, aligns with card networks); exposesrawFiatNumberonAssetBalanceInfofor sorting.AssetCard:caipChainIdsupport and optionalonPress— token icon and network badge use the token’s real chain, not Linea-only.locales/languages/en.json: New/updatedcard.card_spending_limitstrings (setup_title,setup_description,account_label,token_label, copy tweaks; Restricted label renamed to Spending limit where used).useSpendingLimit.test.ts,SpendingLimit.test.tsx,AssetSelectionBottomSheet.test.tsxupdated for new hooks, navigation params, and UI structure.Changelog
CHANGELOG entry: Card spending limit screen uses account-scoped wallet fiat to pick and order default tokens; main view is a settings card (account, token, limit) with asset sheet exclusions and fiat sort for NotEnabled tokens; full vs restricted limit is configured in a dedicated bottom sheet.
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Simulator.Screen.Recording.-.iPhone.17.-.2026-03-25.at.22.58.19.mov
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Refactors card spending-limit UX and selection logic, adding new modal navigation and changing default token selection/sorting based on wallet fiat balances; regressions could affect which token/limit a user configures or sees by default, especially across account switches.
Overview
Refactors the Card Spending Limit flow into a settings-style screen with
Account,Token, andSpending limitrows, replacing the prior quick-select token tiles and in-place limit options.Adds a new
SpendingLimitOptionsSheetmodal to configure full vs restricted limits (with sanitized/max-length input) and returns values via route params;useSpendingLimitnow drives navigation to the account selector, token picker (excluding the currently selected token), and the new limit sheet, and resets selection when the active internal account changes.Updates
AssetSelectionBottomSheetto supportexcludedTokensand to sortNotEnabledtokens by wallet fiat value (viarawFiatNumberfromuseAssetBalances), standardizes supported card chain IDs viaCARD_CHAIN_IDS, and refreshes related strings/tests.Written by Cursor Bugbot for commit 68e7178. This will update automatically on new commits. Configure here.