Skip to content

Conversation

@Brunonascdev
Copy link
Contributor

@Brunonascdev Brunonascdev commented Nov 3, 2025

Description

This PR addresses several issues affecting the Card experience, ensuring proper asset display, navigation flow, and data consistency across components.

Fixes

  • Fixed an issue where assets were not loading correctly after opening the Card Home screen.
  • Corrected balance handling on the Change Asset Bottom Sheet — it now displays availableBalance for enabled tokens and the user’s total balance for disabled ones.
  • Restored asset icons on all asset-related bottom sheets.
  • Fixed incorrect titles on the Spending Limit screen:
    • Selecting a token that isn’t enabled now correctly shows “Change token and network.”
    • Pressing “Manage spending limit” on Card Home now correctly shows “Enable token.”
  • Resolved concurrency issues caused by promise caching in the useLoadCardData hook.

Changelog

CHANGELOG entry: Fixed issue where assets failed to load after opening the Card Home screen.
CHANGELOG entry: Fixed balance display on the Change Asset Bottom Sheet to correctly show availableBalance for enabled tokens and user balance for disabled tokens.
CHANGELOG entry: Restored missing asset icons on asset bottom sheets.
CHANGELOG entry: Fixed incorrect Spending Limit title when selecting a token that’s not enabled (now shows “Change token and network”).
CHANGELOG entry: Fixed incorrect Spending Limit title when pressing “Manage spending limit” on Card Home (now shows “Enable token”).
CHANGELOG entry: Resolved concurrency and caching issues in useLoadCardData hook.

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Replaces balance logic with aggregated hook, adds pull-to-refresh and spending limit progress/warning on Card Home, fixes navigation/metrics/caching, strengthens delegation/external wallet flows, and adds extensive tests.

  • Card Home UI:
    • Add pull-to-refresh and toast on enable-card failure.
    • Show Spending Limit progress bar and close-to-limit warning; hide controls when enabling assets/card.
    • Use balanceFormatted fallback when fiat unavailable; update metrics gating and properties.
  • Asset Selection / Spending Limit:
    • Use useAssetBalances with per-token keying; show correct balances (available vs wallet), restore icons, exclude Solana where needed.
    • Adjust manage flow routing/params and block navigation during delegation; improved input validation and button states.
  • Hooks & Data Flow:
    • Replace useAssetBalance/useAssetsList with useAssetBalances (map-based, multi-token).
    • Revise useLoadCardData with explicit (re)fetch controls, cache-clearing on auth errors, and concurrency fixes.
    • New hooks/util: delegation handling (user-cancel aware), external wallet details with timeout, delegation settings caching, chain/name mapping, safe chainId formatting.
  • SDK:
    • Simplify provider init; add allowance querying robustness (skip non-EVM, timeout) and remove unused mapping.
  • State & i18n:
    • Add global cache clear on logout; new error string for enable-card.
  • Tests:
    • Add/expand tests for AssetSelectionBottomSheet, SpendingLimit, CardHome, delegation, balances, external wallet details, delegation settings, priority token loading, and utilities; update snapshots.

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

@Brunonascdev Brunonascdev self-assigned this Nov 3, 2025
@Brunonascdev Brunonascdev requested a review from a team as a code owner November 3, 2025 14:15
@Brunonascdev Brunonascdev added the team-card Card Team label Nov 3, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

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.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

// Some locales use comma as decimal separator (e.g., "4,95551" instead of "4.95551")
const normalizedBalance = (balanceToUse || '0').replace(',', '.');
const rawTokenBalance = parseFloat(normalizedBalance);
const balanceFormatted = `${parseFloat(normalizedBalance).toFixed(6)} ${token.symbol}`;
Copy link

Choose a reason for hiding this comment

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

Bug: NaN Propagates Through Number Formatting Edgecase

If parseFloat() receives an invalid balance string, it returns NaN. This can cause toFixed(6) to either display "NaN" in the UI or throw a TypeError when attempting to format the invalid number.

Additional Locations (1)

Fix in Cursor Fix in Web

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 4, 2025

@Brunonascdev Brunonascdev added this pull request to the merge queue Nov 4, 2025
Merged via the queue into main with commit 0b3c740 Nov 4, 2025
86 of 87 checks passed
@Brunonascdev Brunonascdev deleted the fix/card-delegation-issues branch November 4, 2025 02:05
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2025
@metamaskbot metamaskbot added the release-7.59.0 Issue or pull request that will be included in release 7.59.0 label Nov 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.59.0 Issue or pull request that will be included in release 7.59.0 size-XL team-card Card Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants