Skip to content

feat(ramps): Remove redundant normalizeProviderCode from mobile call#27893

Open
imyugioh wants to merge 3 commits intomainfrom
feat/ramps-3244-remove-provider-normalization-callsites
Open

feat(ramps): Remove redundant normalizeProviderCode from mobile call#27893
imyugioh wants to merge 3 commits intomainfrom
feat/ramps-3244-remove-provider-normalization-callsites

Conversation

@imyugioh
Copy link
Member

@imyugioh imyugioh commented Mar 24, 2026

Explanation

Removes redundant normalizeProviderCode() calls from mobile ramp call sites. Provider ID normalization (stripping the /providers/ prefix) now happens inside RampsService at URL construction time, so callers can pass provider.id as-is without pre-processing.

This is the mobile counterpart to the core change. The service's #toProviderSegment() helper accepts both /providers/transak and transak, so this removal is backward-compatible — the double-strip that existed before was harmless, and now we just strip once at the boundary.

Changes:

  1. BuildQuote.tsx — Pass selectedQuote.provider directly to addPrecreatedOrder and checkout navigation instead of wrapping in normalizeProviderCode().

  2. Checkout.tsx — Pass providerCode as-is to addPrecreatedOrder and getOrderFromCallback.

  3. OrderDetails.tsx — Pass order.provider?.id directly to refreshOrder.

  4. BankDetails.tsx — Pass order.provider?.id directly to refreshOrder.

  5. useTransakRouting.ts — Remove normalizeProviderCode import and usage at two call sites (redirect handling and external browser callback).

  6. unifiedOrderProcessor.ts — Pass data.provider?.id directly to getOrder instead of normalizing first.

  7. useTransakRouting.test.ts — Remove the normalizeProviderCode mock (no longer imported by the hook).

  8. unifiedOrderProcessor.test.ts — Update mock provider IDs to use /providers/ prefixed format to match real API responses.

  9. buildQuoteWithRedirectUrl.ts — Fix getProviderDeeplinkRedirectUrl to strip /providers/ prefix before building the deeplink URL. Without this, passing a raw provider.id like /providers/moonpay would produce a doubled path: metamask://on-ramp/providers//providers/moonpay, breaking external browser redirect flows (PayPal, InAppBrowser callbacks).

Link to core PR

Depends on: MetaMask/core#8289 (fix/ramps-3244-addPrecreatedOrder-id-format)

References

TRAM-3244

Checklist

Manual testing steps

Feature: Provider ID normalization removed from mobile

  Scenario: On-ramp buy flow works without normalizeProviderCode
    Given the app is built from this branch
    When user completes an on-ramp buy flow (aggregator or native)
    Then order is created, polled, and displayed correctly in Activity tab

  Scenario: Order details refresh works
    Given user has an existing pending order
    When user opens Order Details and pulls to refresh
    Then order refreshes successfully (no 400/404 from doubled path)

  Scenario: Transak native flow works
    Given user selects a Transak native provider
    When user completes bank details and callback redirect
    Then order is fetched and displayed correctly

  Scenario: Previously used provider detection still works
    Given user has completed orders in history
    When user starts a new buy flow
    Then the previously used provider is correctly recommended

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

Medium Risk
Changes how providerCode is passed through quote/checkout/order refresh and polling paths, which can break order creation/lookup if any downstream expects the stripped format. Also switches @metamask/ramps-controller to a preview build, increasing integration risk.

Overview
Removes normalizeProviderCode() usage across unified ramps flows so mobile now passes provider IDs (often /providers/...) through BuildQuote, Checkout, native BankDetails, OrderDetails, useTransakRouting, and unifiedOrderProcessor without pre-processing.

Fixes external-browser deeplink redirects by stripping the /providers/ prefix inside getProviderDeeplinkRedirectUrl, and updates tests to expect prefixed provider IDs. Updates the @metamask/ramps-controller dependency to a preview version to pick up the corresponding core-side normalization behavior.

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

@imyugioh imyugioh self-assigned this Mar 24, 2026
@imyugioh imyugioh added the team-money-movement issues related to Money Movement features label Mar 24, 2026
@imyugioh imyugioh marked this pull request as ready for review March 25, 2026 11:36
@imyugioh imyugioh requested a review from a team as a code owner March 25, 2026 11:36
@imyugioh imyugioh force-pushed the feat/ramps-3244-remove-provider-normalization-callsites branch from 1108dc2 to 35da184 Compare March 25, 2026 11:50
@github-actions github-actions bot added the risk-high Extensive testing required · High bug introduction risk label Mar 25, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@github-actions github-actions bot added risk-high Extensive testing required · High bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 25, 2026
@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeTrade, SmokeWalletPlatform, SmokeCard, SmokePerps, SmokeRamps, SmokeMultiChainAPI, SmokePredictions, FlaskBuildTests
  • Selected Performance tags: @PerformanceAccountList, @PerformanceOnboarding, @PerformanceLogin, @PerformanceSwaps, @PerformanceLaunch, @PerformanceAssetLoading, @PerformancePredict, @PerformancePreps
  • 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:
Hard rule (controller-version-update): @MetaMask controller package version updated in package.json: @metamask/ramps-controller. Running all tests.

View GitHub Actions results

@github-actions
Copy link
Contributor

E2E Fixture Validation — Schema is up to date
16 value mismatches detected (expected — fixture represents an existing user).
View details

@sonarqubecloud
Copy link

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

Labels

risk-high Extensive testing required · High bug introduction 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.

1 participant