-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chore(runway): cherry-pick fix(card): cp-7.58.3 physical address consent issue + undefined balances #22737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
joaoloureirop
merged 1 commit into
release/7.58.3
from
runway-cherry-pick-7.58.3-1763144256
Nov 14, 2025
Merged
chore(runway): cherry-pick fix(card): cp-7.58.3 physical address consent issue + undefined balances #22737
joaoloureirop
merged 1 commit into
release/7.58.3
from
runway-cherry-pick-7.58.3-1763144256
Nov 14, 2025
+2,818
−308
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…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 -->
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. |
joaoloureirop
approved these changes
Nov 14, 2025
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Description
This PR hardens several Card flows:
defensively, mirroring the logic in the physical-address step.
errors and expired-card tokens consistently; the home screen shows a
dedicated spinner while auth cleanup runs and only processes each auth
error once.
navigation.dispatch(StackActions.replace(...)) (with updated tests) so
we don’t stack duplicate routes after successful onboarding.
correct localized messaging.
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
Screenshots/Recordings
Before
After
Pre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Pre-merge reviewer checklist
app, test code being changed).
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.
CardHome: Detects auth errors once, clears token/state, and replaces route toRoutes.CARD.WELCOME; shows loading spinner during cleanup; loads data on first open.Onboarding/Complete: Usesnavigation.dispatch(StackActions.replace(...))to go to HOME/AUTHENTICATION; resets onboarding state.PhysicalAddress/MailingAddress: Reuse existing consent, create if missing, skip when already completed, link user post-registration, and clearconsentSetIdin Redux.useAssetBalances: HandlestokenRateUndefined/loading sentinels, reformats raw fiat strings with currency detection, and falls back to token amounts; enriches raw values.useWrapWithCache: ReturnsErrorobjects (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: MapsACCOUNT_DISABLEDto server message.CardSDK: AddsgetConsentSetByOnboardingId, maps disabled accounts toACCOUNT_DISABLEDerror; various request/response hardening.types: AddACCOUNT_DISABLED,ConsentSet/GetOnboardingConsentResponse.Written by Cursor Bugbot for commit eaef69b. This will update automatically on new commits. Configure here.
0828e98