Skip to content

Conversation

@runway-github
Copy link
Contributor

@runway-github runway-github bot commented Nov 14, 2025

Description

This PR hardens several Card flows:

  • Mailing-address consent now recreates or reuses onboarding consent
    defensively, mirroring the logic in the physical-address step.
  • useWrapWithCache, CardHome, and their test suites now treat cache
    errors and expired-card tokens consistently; the home screen shows a
    dedicated spinner while auth cleanup runs and only processes each auth
    error once.
  • Onboarding/Complete now calls
    navigation.dispatch(StackActions.replace(...)) (with updated tests) so
    we don’t stack duplicate routes after successful onboarding.
  • Card login path surfaces the new ACCOUNT_DISABLED error type with the
    correct localized messaging.
  • These fixes resolve missing-consent crashes, inconsistent
    priority-token balances, brittle token-expiration UX, and the lingering
    navigation issue after onboarding.

Changelog

CHANGELOG entry: Improved MetaMask Card onboarding and home flows
(defensive consent creation, consistent balance caching, robust
expired-token handling, and navigation fixes).

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

Strengthens Card onboarding and home flows with defensive consent creation/linking, robust auth error cleanup/navigation, corrected fiat balance formatting, improved cache/error handling, and SDK support for consent lookup plus ACCOUNT_DISABLED errors.

  • Card UI/Navigation:
    • CardHome: Detects auth errors once, clears token/state, and replaces route to Routes.CARD.WELCOME; shows loading spinner during cleanup; loads data on first open.
    • Onboarding/Complete: Uses navigation.dispatch(StackActions.replace(...)) to go to HOME/AUTHENTICATION; resets onboarding state.
  • Onboarding Consent (Defensive):
    • PhysicalAddress/MailingAddress: Reuse existing consent, create if missing, skip when already completed, link user post-registration, and clear consentSetId in Redux.
  • Hooks:
    • useAssetBalances: Handles tokenRateUndefined/loading sentinels, reformats raw fiat strings with currency detection, and falls back to token amounts; enriches raw values.
    • useWrapWithCache: Returns Error objects (not booleans), avoids auto-refetch on error/while loading, and only caches non-null results.
    • useGetCardExternalWalletDetails/useGetDelegationSettings: Include error objects; auto-fetch only when SDK/auth/settings ready.
    • useCardDetails: Surfaces real errors; preserves warnings and polling behavior.
    • useCardProviderAuthentication: Maps ACCOUNT_DISABLED to server message.
  • SDK/Types:
    • CardSDK: Adds getConsentSetByOnboardingId, maps disabled accounts to ACCOUNT_DISABLED error; various request/response hardening.
    • types: Add ACCOUNT_DISABLED, ConsentSet/GetOnboardingConsentResponse.
  • Tests:
    • Extensive updates/additions across components and hooks to validate new consent logic, navigation replaces, fiat formatting, cache/error behavior, and SDK endpoints.

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

0828e98

…ent issue + undefined balances (#22676)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

This PR hardens several Card flows:

- Mailing-address consent now recreates or reuses onboarding consent
defensively, mirroring the logic in the physical-address step.
- useWrapWithCache, CardHome, and their test suites now treat cache
errors and expired-card tokens consistently; the home screen shows a
dedicated spinner while auth cleanup runs and only processes each auth
error once.
- Onboarding/Complete now calls
navigation.dispatch(StackActions.replace(...)) (with updated tests) so
we don’t stack duplicate routes after successful onboarding.
- Card login path surfaces the new ACCOUNT_DISABLED error type with the
correct localized messaging.
- These fixes resolve missing-consent crashes, inconsistent
priority-token balances, brittle token-expiration UX, and the lingering
navigation issue after onboarding.

## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry: Improved MetaMask Card onboarding and home flows
(defensive consent creation, consistent balance caching, robust
expired-token handling, and navigation fixes).

## **Related issues**

Fixes:

## **Manual testing steps**

```gherkin
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**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Defensively manage consent across onboarding, improve auth-error
cleanup and navigation, refine balance fiat/caching logic, and add
ACCOUNT_DISABLED handling with new consent lookup API.
> 
> - **Onboarding**:
> - **Mailing/Physical Address**: Add defensive consent flow
(reuse/create via `getOnboardingConsentSetByOnboardingId`, link user,
clear `consentSetId`); maintain validations and success paths.
Navigation uses replace where appropriate.
> - **Complete screen**: Switch to
`navigation.dispatch(StackActions.replace(...))` and reset onboarding
state before redirect.
> - **Card Home**:
> - Add robust auth-error handling (single-run cleanup, token removal,
Redux reset/cache clear, `StackActions.replace` to welcome, loading
spinner during cleanup) and initial authenticated data load.
> - Preserve/compute balances and spending limit UI as before; minor UX
tweaks.
> - **Hooks**:
> - `useAssetBalances`: Rework fiat formatting and fallbacks (handle
`tokenRateUndefined`/loading strings, raw fiat parsing, proportional
fiat, currency detection), keep Solana/EVM paths; expose consistent map.
> - `useWrapWithCache`: Return real `Error`, avoid auto-retries on
error, prevent refetch while loading, skip caching null/undefined; same
API.
> - `useCardDetails`: Surface `error` object (not enum), keep polling,
warnings.
> - `useGetCardExternalWalletDetails`: Guard auto-fetch on error;
unchanged API.
> - `useGetDelegationSettings`/`useRegistrationSettings`: Align to
`Error` semantics.
> - **SDK/Types**:
> - `CardSDK.login`: detect and surface `ACCOUNT_DISABLED` error; OTP
flows unchanged.
> - Add `getConsentSetByOnboardingId` endpoint support; new
`ConsentSet`/`GetOnboardingConsentResponse` types.
> - **Tests**: Extensive updates/new cases across components and hooks
to cover consent recovery, navigation replace, auth cleanup order,
cache/error behavior, and fiat formatting.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9e3b88d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@runway-github runway-github bot requested a review from a team as a code owner November 14, 2025 18:17
@github-actions
Copy link
Contributor

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.

@metamaskbot metamaskbot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Nov 14, 2025
@joaoloureirop joaoloureirop enabled auto-merge (squash) November 14, 2025 18:21
@sonarqubecloud
Copy link

@joaoloureirop joaoloureirop merged commit c60a8c8 into release/7.58.3 Nov 14, 2025
147 of 151 checks passed
@joaoloureirop joaoloureirop deleted the runway-cherry-pick-7.58.3-1763144256 branch November 14, 2025 19:11
@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size-XL team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants