Skip to content

feat: enhance useTransakRouting to resolve wallet address from headle…#31021

Merged
meltingice1337 merged 2 commits into
mainfrom
fix/TRAM-3598
Jun 4, 2026
Merged

feat: enhance useTransakRouting to resolve wallet address from headle…#31021
meltingice1337 merged 2 commits into
mainfrom
fix/TRAM-3598

Conversation

@meltingice1337

@meltingice1337 meltingice1337 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes the Headless Ramps "Add funds" (fiat deposit) flow used by MM Pay for Perps/Money Account deposits. After OTP login the Transak checkout prompted the user to enter a wallet address instead of going straight to payment, and it "fixed itself" on a second attempt.

This is a state-propagation race. startHeadlessBuy seeds the selected token asynchronously via setSelectedToken, but routeAfterAuthentication derived the wallet address from selectedToken?.chainId, which was still undefined on the first pass — so useRampAccountAddress returned null, an empty walletAddress= was sent to Transak, and Transak re-prompted. The fix derives the chain for the wallet address from the headless session's assetId (known synchronously the moment the session is created) and falls back to selectedToken only for the non-headless BuildQuote flow, so the address resolves correctly on the first attempt.

The asset, environment, and feature flags were all correct throughout; this was purely a seeding race.

Changelog

CHANGELOG entry: Fixed the "Add funds" fiat deposit flow (Perps/Money Account): the Transak checkout no longer prompts for a wallet address after OTP login.

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-3598

Manual testing steps

Verified the wallet address now resolves from the headless session assetId on the first attempt.

Feature: Add funds (fiat) for a Perps deposit via Headless Ramps + MM Pay

  Scenario: Transak skips the wallet-address prompt on the first attempt
    Given I have hard-refreshed the mobile app
    And I am logged out of Transak (fresh install)
    When I complete the email + OTP login in the Transak checkout
    Then the checkout goes straight to payment (or add-card details for a new user)
    And it does not prompt me to enter a wallet address

Screenshots/Recordings

Note: Both recordings below were captured after a hard refresh of the app. The hard refresh is what reliably reproduces the "Before" failure on the very first attempt — without it, stale propagated state can mask the bug and make it look like it works.

Before

Captured after a hard refresh — reproduces the wallet-address prompt after OTP on the first attempt.

ScreenRecording_06-03-2026.17-41-21_1.mp4

After

Captured after a hard refresh — with the fix, the first attempt succeeds (Transak skips straight to payment).

ScreenRecording_06-03-2026.17-45-25_1.mp4

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.

@github-actions

github-actions Bot commented Jun 3, 2026

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.

@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 3, 2026
@mm-token-exchange-service mm-token-exchange-service Bot added the team-money-movement issues related to Money Movement features label Jun 3, 2026
@github-actions github-actions Bot added the size-S label Jun 3, 2026
@meltingice1337 meltingice1337 removed 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 3, 2026
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeMoney
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are scoped to app/components/UI/Ramp/hooks/useTransakRouting.ts and its test file. This is a targeted bug fix (TRAM-3598) that corrects wallet address chain ID resolution in the Transak routing hook: instead of always using selectedToken.chainId (which may not be seeded yet asynchronously), it now first checks the headless session's assetId to derive the chain ID via getChainIdFromAssetId. This only affects the Ramp/fiat on-ramp flow (Transak payment widget URL generation). No confirmations, swaps, or other wallet flows are touched. SmokeMoney covers the ramp/buy flows that exercise this code path. No dependent tags are required since the fix is in address resolution logic, not in transaction execution or confirmation flows.

Performance Test Selection:
The change is a bug fix in wallet address chain ID resolution logic within the Transak routing hook. It does not affect UI rendering performance, list rendering, animations, data loading patterns, or any performance-sensitive code paths. No performance tests are warranted.

View GitHub Actions results

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.84%. Comparing base (c24bb5f) to head (a6fddfd).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #31021   +/-   ##
=======================================
  Coverage   82.84%   82.84%           
=======================================
  Files        5574     5574           
  Lines      143873   143864    -9     
  Branches    33409    33408    -1     
=======================================
- Hits       119187   119185    -2     
+ Misses      16693    16688    -5     
+ Partials     7993     7991    -2     

☔ View full report in Codecov by Sentry.
📢 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.

@meltingice1337 meltingice1337 marked this pull request as ready for review June 4, 2026 06:10
@meltingice1337 meltingice1337 requested a review from a team as a code owner June 4, 2026 06:10
@github-actions github-actions Bot added the risk:medium AI analysis: medium risk label Jun 4, 2026
@meltingice1337 meltingice1337 added this pull request to the merge queue Jun 4, 2026
@amitabh94

Copy link
Copy Markdown
Contributor

The PR description says that changes need to be made to transaction messenger file but I don't see any changes there. Did we miss that or do we need to update the PR description.

@meltingice1337

meltingice1337 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

The PR description says that changes need to be made to transaction messenger file but I don't see any changes there. Did we miss that or do we need to update the PR description.

We need a PR description update, I needed to merge with latest main as someone working on transaction pay controller told me that they fixed that already on the latest main.

Merged via the queue into main with commit 20ab8a9 Jun 4, 2026
261 of 265 checks passed
@meltingice1337 meltingice1337 deleted the fix/TRAM-3598 branch June 4, 2026 11:45
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 4, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.81.0 Issue or pull request that will be included in release 7.81.0 label Jun 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.81.0 Issue or pull request that will be included in release 7.81.0 risk:medium AI analysis: medium risk size-S team-money-movement issues related to Money Movement features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants