Skip to content

fix(ramps): show login-with-email action in unified buy v2 BasicInfo#31580

Open
amitabh94 wants to merge 9 commits into
mainfrom
fix/ub2-transak-phone-registered-logout
Open

fix(ramps): show login-with-email action in unified buy v2 BasicInfo#31580
amitabh94 wants to merge 9 commits into
mainfrom
fix/ub2-transak-phone-registered-logout

Conversation

@amitabh94

@amitabh94 amitabh94 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Description

Unified Buy v2 (NativeFlow/BasicInfo) submits personal details via @metamask/ramps-controller, which throws TransakApiError with top-level errorCode and apiMessage. The screen was still checking a legacy Axios response shape, so Transak error code 2020 (phone already registered) was never detected and the Log in with email logout CTA stayed hidden.

This PR:

  1. Detects phone-already-registered errors with isTransakPhoneRegisteredError and reads the user-facing message via getTransakApiMessage from @metamask/ramps-controller (MetaMask/core#9135).
  2. Preserves quote context when routing back to Enter Email after logout so re-auth can resume the buy flow.
  3. Bumps @metamask/ramps-controller to ^14.3.0 (core chore: Update dependabot.yml to use new team label #9135 shipped in 14.3.0).

Deposit v1 already handled 2020 via the legacy SDK/Axios path (#22183); this aligns UB2 with the controller error model.

Changelog

CHANGELOG entry: null

Related issues

Fixes: TRAM-3654

Manual testing steps

Feature: Unified Buy v2 phone already registered logout

  Scenario: user sees login-with-email when phone is registered to another account
    Given unified buy v2 is enabled and user is authenticated with email A
    And user reaches NativeFlow BasicInfo with a valid buy quote

    When user submits BasicInfo with a phone number already registered to email B
    Then an error banner is shown with localized phone-already-registered copy
    And a "Log in with email" action is visible

    When user taps "Log in with email"
    Then user is logged out of the Transak session
    And user is navigated to Enter Email with quote context preserved
    And user can authenticate with email B and continue the buy flow

Unit tests: yarn jest app/components/UI/Ramp/Views/NativeFlow/BasicInfo.test.tsx

RC QA: TestFlight build 5530 from fix/ub2-transak-phone-registered-logout (RC workflow run 27652822118).

Screenshots/Recordings

N/A — pending QA on RC TestFlight build 5530. Will attach before/after recordings once verified.

Before

ScreenRecording_06-15-2026.15-54-19_1.MP4

N/A

After

ScreenRecording_06-18-2026.14-10-51_1.MP4

N/A

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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

Medium Risk
Changes buy-flow error handling and post-logout navigation in ramps KYC; scoped to one screen but affects recovery when phone conflicts with another Transak account.

Overview
Unified Buy v2 BasicInfo now treats Transak failures from @metamask/ramps-controller correctly instead of reading a legacy Axios response.data.error shape. Phone already registered (error 2020) is detected with isTransakPhoneRegisteredError, and copy comes from getTransakApiMessage, so the Log in with email banner action can appear when the phone is tied to another account.

After logout, navigation always goes through createV2EnterEmailNavDetails with quote fields (amount, currency, assetId, optional headlessSessionId) so users can re-auth and continue the buy. @metamask/ramps-controller is bumped to ^14.3.0; unit tests use TransakApiError and assert the logout button and post-logout navigation.

Reviewed by Cursor Bugbot for commit 8c57e51. Bugbot is set up for automated code reviews on this repo. Configure here.

Unified buy v2 receives TransakApiError objects from ramps-controller, so
error code 2020 was never detected and the logout CTA stayed hidden. Parse
both controller and legacy Axios error shapes and preserve quote params when
routing back to Enter Email after logout.

Co-authored-by: Cursor <cursoragent@cursor.com>
@amitabh94 amitabh94 requested a review from a team as a code owner June 11, 2026 16:50
@github-actions

Copy link
Copy Markdown
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.

@mm-token-exchange-service mm-token-exchange-service Bot added the team-money-movement issues related to Money Movement features label Jun 11, 2026
@github-actions github-actions Bot added the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jun 11, 2026
@mm-token-exchange-service mm-token-exchange-service Bot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Jun 11, 2026
@mm-token-exchange-service

mm-token-exchange-service Bot commented Jun 11, 2026

Copy link
Copy Markdown

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Pre-merge author checklist has unchecked items (e.g. "I've documented my code using JSDoc format if applicable"). Every box must be consciously checked — see docs/readme/ready-for-review.md.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

@github-actions github-actions Bot added size-M risk:medium AI analysis: medium risk labels Jun 11, 2026
@amitabh94

amitabh94 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Tracks TRAM-3654 — Unified Buy v2: show login-with-email action for Transak phone-already-registered error.

@amitabh94

amitabh94 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Coordination

  • Depends on core: MetaMask/core#9135 for TRANSAK_ERROR_CODES, isTransakPhoneRegisteredError, and related Transak error helpers.
  • Jira: TRAM-3654
  • Follow-up: After core is released and bumped in mobile, refactor to use controller exports instead of local parseTransakApiError.

Wire @metamask-previews/ramps-controller@14.2.0-preview-69b6829ad and use
isTransakPhoneRegisteredError/getTransakApiMessage from core #9135 instead
of the local parseTransakApiError helper.

Co-authored-by: Cursor <cursoragent@cursor.com>
@amitabh94

Copy link
Copy Markdown
Contributor Author

Pushed preview wiring: @metamask-previews/ramps-controller@14.2.0-preview-69b6829ad (core #9135). Triggered main-rc build from this branch via Build Mobile App workflow.

Use @metamask-previews/ramps-controller@14.2.0-preview-b92250061 directly in
dependencies instead of previewBuilds so yarn install --immutable resolves
correctly in CI.

Co-authored-by: Cursor <cursoragent@cursor.com>
pull Bot pushed a commit to Reality2byte/core that referenced this pull request Jun 17, 2026
…etaMask#9135)

## Explanation

Unified Buy v2 (and other `@metamask/ramps-controller` consumers) need
to detect specific Transak API failures from `TransakApiError` — for
example error code `2020` when a phone number is already registered to a
different email. Today, mobile duplicated string literals and ad-hoc
`instanceof` / Axios-shaped parsing because ramps-controller only
exported `TransakApiError` itself, not reusable helpers or known codes.

This PR adds shared Transak error codes and small type guards/helpers so
consumers can branch on `errorCode` and read `apiMessage` consistently:

- `TRANSAK_ERROR_CODES` (`ORDER_EXISTS: '4005'`,
`PHONE_ALREADY_REGISTERED: '2020'`) and `TransakErrorCode`
- `isTransakApiError`, `getTransakErrorCode`, `getTransakApiMessage`,
`isTransakErrorCode`, `isTransakPhoneRegisteredError`

`TransakService` now uses `TRANSAK_ERROR_CODES.ORDER_EXISTS` instead of
a private `'4005'` constant so order-exists retry logic and public
exports stay aligned.

No breaking changes. Changelog updated under
`@metamask/ramps-controller` Unreleased.

## References

- [TRAM-3654](https://consensyssoftware.atlassian.net/browse/TRAM-3654)
— Unified Buy v2: show login-with-email action for Transak
phone-already-registered error
- Mobile consumer:
[MetaMask/metamask-mobile#31580](MetaMask/metamask-mobile#31580)
— depends on this release before dropping local error parsing

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them _(N/A — additive exports only)_

[TRAM-3654]:
https://consensyssoftware.atlassian.net/browse/TRAM-3654?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
@amitabh94 amitabh94 added no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed Run smoke E2E labels Jun 18, 2026
@mm-token-exchange-service mm-token-exchange-service Bot removed INVALID-PR-TEMPLATE PR's body doesn't match template labels Jun 18, 2026
amitabh94 and others added 3 commits June 21, 2026 22:57
Replace preview pin now that core #9135 shipped in @metamask/ramps-controller@14.3.0.

Co-authored-by: Cursor <cursoragent@cursor.com>
Collapse transaction-pay-controller's stale ^14.1.1 resolution so the tree
uses a single @metamask/ramps-controller@14.3.0 instance.

Co-authored-by: Cursor <cursoragent@cursor.com>
Align transitive ^28.1.x resolutions with ramps-controller@14.3.0's ^28.2.0
requirement so the tree uses a single profile-sync-controller instance.

Co-authored-by: Cursor <cursoragent@cursor.com>
@amitabh94

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

@amitabh94 amitabh94 enabled auto-merge June 22, 2026 05:06
@github-actions github-actions Bot added risk:high AI analysis: high risk and removed risk:medium AI analysis: medium risk labels Jun 22, 2026
auto-merge was automatically disabled June 22, 2026 05:08

Head branch was pushed to by a user without write access

Copilot AI commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved. The conflicts were in package.json and yarn.lock:

  • package.json: kept ramps-controller: ^14.3.0 (our bump) and took profile-sync-controller: ^28.2.0 from main (the higher version).
  • yarn.lock: resolved both profile-sync-controller and ramps-controller lockfile entries consistently with the above package versions — both still resolve to their same pinned versions (28.2.0 and 14.3.0 respectively).

All 26 BasicInfo unit tests continue to pass.

@amitabh94 amitabh94 enabled auto-merge June 22, 2026 05:11
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.27%. Comparing base (981e9a2) to head (8c57e51).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../components/UI/Ramp/Views/NativeFlow/BasicInfo.tsx 57.14% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #31580   +/-   ##
=======================================
  Coverage   83.27%   83.27%           
=======================================
  Files        5842     5843    +1     
  Lines      153510   153510           
  Branches    36220    36220           
=======================================
+ Hits       127829   127832    +3     
+ Misses      16916    16909    -7     
- Partials     8765     8769    +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@amitabh94 amitabh94 removed pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. risk:high AI analysis: high risk labels Jun 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeSwap, SmokeStake, SmokeWalletPlatform, SmokeMoney, SmokePerps, SmokeMultiChainAPI, SmokePredictions, SmokeSeedlessOnboarding, SmokeBrowser, SmokeSnaps
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: high
  • AI Confidence: 100%
click to see 🤖 AI reasoning details

E2E Test Selection:
Hard rule (controller-version-update): @MetaMask controller package version updated in package.json: @metamask/ramps-controller. Running all tests.

Performance Test Selection:
The changes are limited to error handling logic and navigation in the Transak KYC BasicInfo form, plus a minor ramps-controller package bump. These changes do not affect app launch, login, onboarding, asset loading, account list rendering, swaps, perps, or predictions performance. No performance-sensitive code paths are modified.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed Run smoke E2E size-M team-money-movement issues related to Money Movement features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants