Skip to content

chore(ramp): adopt core-owned Headless Buy default redirect URL - #34207

Merged
saustrie-consensys merged 3 commits into
mainfrom
feat/tram-3757-ramps-redirect-url
Aug 4, 2026
Merged

chore(ramp): adopt core-owned Headless Buy default redirect URL#34207
saustrie-consensys merged 3 commits into
mainfrom
feat/tram-3757-ramps-redirect-url

Conversation

@saustrie-consensys

@saustrie-consensyssaustrie-consensys commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Description

Adopts the TRAM-3757 core change from MetaMask/core#9752 so Headless Buy and UB2 share one finish-line (fake-callback) URL derivation.

  • Bumps @metamask/ramps-controller to the stable published ^19.0.0 release.
  • Removes the client getDefaultRedirectUrl injection from ramps-controller-init.ts. Core now supplies the widened-path default through RampsService:getDefaultRedirectCallbackUrl.
  • Spreads RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS in the controller messenger so the new action cannot be forgotten on future upgrades.
  • Rewrites getRampCallbackBaseUrl() as getDefaultRedirectCallbackUrl(getRampsEnvironment()), deleting the duplicated host table. BuildQuote, Continue rewrite, Checkout completion matching, and the controller default now all use the same environment source (RAMPS_ENVIRONMENT, then METAMASK_ENVIRONMENT).

Changelog

CHANGELOG entry: null

Related issues

Fixes: TRAM-3757
Refs: MetaMask/core#9752

Manual testing steps

N/A - unit-covered wiring and package bump only. Covered by unit tests for getRampCallbackBaseUrl (parity with getDefaultRedirectCallbackUrl(getRampsEnvironment()), including RAMPS_ENVIRONMENT override), ramps-controller-init, and messenger construction.

Screenshots/Recordings

N/A - no user-visible UI change; wiring/package bump only.

Before

N/A

After

N/A, simply proving that UB2 still works.

ScreenRecording_08-04-2026.07-47-37_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
  • 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 ramp buy/checkout redirect URL resolution for headless and UB2 flows; behavior should match prior mapping but depends on core v19 and messenger delegation being correct.

Overview
Bumps @metamask/ramps-controller to ^19.0.0 (TRAM-3757 / core#9752) so the widened Headless Buy quote path gets its default redirect from core instead of the mobile client.

getRampCallbackBaseUrl() no longer maintains a local host switch on METAMASK_ENVIRONMENT; it delegates to getDefaultRedirectCallbackUrl(getRampsEnvironment()), aligning UB2 BuildQuote, checkout completion, and Continue rewrite with the same env source (RAMPS_ENVIRONMENT, then METAMASK_ENVIRONMENT). ramps-controller-init drops the getDefaultRedirectUrl injection into RampsController.

The ramps controller messenger now spreads RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS instead of a hand-maintained action list, so RampsService:getDefaultRedirectCallbackUrl stays delegated on upgrades. Tests assert parity with core and RAMPS_ENVIRONMENT override behavior.

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

@saustrie-consensyssaustrie-consensys added team-money-movement issues related to Money Movement features no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed labels Aug 3, 2026
@saustrie-consensyssaustrie-consensys self-assigned this Aug 3, 2026
@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.

@github-actionsgithub-actionsBot 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 Aug 3, 2026
@saustrie-consensys
saustrie-consensysforce-pushed the feat/tram-3757-ramps-redirect-url branch from 2202951 to 29ba630CompareAugust 3, 2026 15:14
@saustrie-consensys
saustrie-consensysforce-pushed the feat/tram-3757-ramps-redirect-url branch from 29ba630 to ad3f01bCompareAugust 3, 2026 15:14
@metamask-ci

Copy link
Copy Markdown
Contributor

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 tested on Android"). 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.

1 similar comment
@metamask-ci

Copy link
Copy Markdown
Contributor

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 tested on Android"). 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.

@socket-security

socket-securityBot commented Aug 3, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

DiffPackageSupply Chain
Security
VulnerabilityQualityMaintenanceLicense
Addednpm/​@​metamask/​ramps-controller@​19.0.09810079100100

View full report

@socket-security

socket-securityBot commented Aug 3, 2026

Copy link
Copy Markdown

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

pullBot pushed a commit to dmrazzy/core that referenced this pull request Aug 3, 2026
… URL from RampsService (MetaMask#9752)
## Explanation
On the widened Headless Buy all-providers path, MetaMask Pay's quote
request omits `redirectUrl`. The quotes API only embeds a
`buyURL`/`buyWidget` when a `redirectUrl` is present, so
`RampsController.getQuotes` must supply a default there. Until now that
default came from a `getDefaultRedirectUrl` callback injected by the
mobile client, which review flagged as an unusual controller-init
pattern for a value core can derive itself.
This PR moves ownership into core without giving `RampsController` a
second copy of the environment:
- Adds the exported pure `getDefaultRedirectCallbackUrl(environment)`
helper as the canonical environment-to-callback map (`on-ramp-content`
for production/staging, `on-ramp.dev-api` for development,
`localhost:3000` for local).
- Adds `RampsService.getDefaultRedirectCallbackUrl()` and the matching
messenger action, which returns that URL for the environment the service
was already constructed with. `baseUrlOverride` deliberately does not
apply: in production and staging the callback lives on
`on-ramp-content`, not the API/`on-ramp-cache` host that
`baseUrlOverride` replaces; using the API override here would break
client completion matching. `RampsEnvironment.Local` yields a localhost
callback pinned to port 3000.
- Removes `getDefaultRedirectUrl` from `RampsControllerOptions`. On the
widened path, when the caller omits `redirectUrl`, the controller calls
`RampsService:getDefaultRedirectCallbackUrl`. Explicit caller
`redirectUrl` still wins; the native-only (flag-off) path still injects
nothing.
If a host upgrades without delegating the new action, the entire
`RampsController:getQuotes` call rejects (including MM Pay fiat
quoting), rather than returning aggregator quotes without a widget URL.
That is intentional and covered by a unit test.
### Breaking change
1. Delegate `RampsService:getDefaultRedirectCallbackUrl` to the
`RampsController` messenger (prefer spreading
`RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS` instead of extending a
hand-written list), and drop any `getDefaultRedirectUrl` constructor
argument.
2. Reimplement mobile `getRampCallbackBaseUrl()` as
`getDefaultRedirectCallbackUrl(getRampsEnvironment())` in the same
upgrade so quote defaults and Checkout completion detection share one
environment source. Builds that set `RAMPS_ENVIRONMENT` differently from
`METAMASK_ENVIRONMENT` (notably some `exp` / `e2e-bs` flavors) can
otherwise mismatch.
## References
- Fixes TRAM-3757
- Follow-up from MetaMask/metamask-mobile#32682
(review thread
MetaMask/metamask-mobile#32682 (comment))
- Related: TRAM-3698 (the original missing buy-widget URL gap)
- Consumer draft: MetaMask/metamask-mobile#34207
## 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)
- [x] 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
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Breaking messenger and constructor contract for Headless Buy / MM Pay
quoting; mis-delegation fails the whole `getQuotes` call, and env
mismatch between service and UI callback detection could break checkout
completion.
> > **Overview**
> **Breaking:** Widened Headless Buy quotes no longer use an injected
`getDefaultRedirectUrl` on `RampsController`. When
`moneyHeadlessAllProviders` is on and the caller omits `redirectUrl`,
the controller calls **`RampsService:getDefaultRedirectCallbackUrl`**
and forwards that URL into `getQuotes` so aggregator quotes get a
`buyURL`/`buyWidget`. Explicit `redirectUrl` still wins; the native-only
path does not call the service.
> > Adds **`getDefaultRedirectCallbackUrl(environment)`** (canonical env →
`/regions/fake-callback` map, ignoring `baseUrlOverride`) plus
**`RampsService.getDefaultRedirectCallbackUrl()`** and the messenger
action/type, exported from the package. Hosts must delegate the new
action (listed in **`RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS`**) or
**`getQuotes` rejects**; mobile should align UI callback matching with
the same helper and environment source.
> > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
3b3ff32. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Bump @metamask/ramps-controller to the TRAM-3757 preview, drop the
client getDefaultRedirectUrl injection, spread
RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS for messenger delegation, and
make getRampCallbackBaseUrl a thin wrapper around
getDefaultRedirectCallbackUrl(getRampsEnvironment()) so UB2 quote,
Continue, Checkout, and the controller default share one environment
source.
Replace the preview pin with the stable ^19.0.0 release now that
redirect-URL support is published on npm.
@saustrie-consensys
saustrie-consensysforce-pushed the feat/tram-3757-ramps-redirect-url branch from ad3f01b to e6fe057CompareAugust 4, 2026 13:17
@saustrie-consensyssaustrie-consensys 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 Aug 4, 2026
@saustrie-consensys
saustrie-consensys marked this pull request as ready for review August 4, 2026 13:35
@saustrie-consensys
saustrie-consensys requested a review from a team as a code ownerAugust 4, 2026 13:35
@github-actionsgithub-actionsBot added the risk:high AI analysis: high risk label Aug 4, 2026
@saustrie-consensys

Copy link
Copy Markdown
ContributorAuthor

Triggered an RC installable build for this PR via Build Mobile App (main-rc, both platforms) from branch feat/tram-3757-ramps-redirect-url @ e6fe057f9ed05a07e71afba9546e5d36ba230919.

Workflow run: https://github.com/MetaMask/metamask-mobile/actions/runs/30916339056

When the run finishes:

  • Android: download the android-apk-main-rc artifact from the run Artifacts tab
  • iOS: download the ios-ipa-main-rc artifact (device IPA). This dispatch does not auto-upload to TestFlight; that is a separate workflow used for release-branch RCs.

@saustrie-consensys

Copy link
Copy Markdown
ContributorAuthor

Correction: two identical main-rc dispatches started for this branch; cancelled the later duplicate.

Use this run (already past prepare, building both platforms):
https://github.com/MetaMask/metamask-mobile/actions/runs/30916307092

Inputs: build_name=main-rc, platform=both, source_branch=feat/tram-3757-ramps-redirect-url.

Artifacts when green:

  • Android: android-apk-main-rc
  • iOS: ios-ipa-main-rc (device IPA; no automatic TestFlight upload from this workflow)

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeSwap, SmokeStake, SmokeWalletPlatform, SmokeMoney, SmokePerps, SmokeMultiChainAPI, SmokePredictions, SmokeSeedlessOnboarding, SmokeBrowser, SmokeSnaps, SmokeMMConnect
  • 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 focused on refactoring the ramps controller's redirect URL mechanism and messenger action registration. No rendering performance, asset loading, login/onboarding, or other performance-sensitive code paths are affected. The changes are architectural/internal to the ramps subsystem and do not impact measured performance scenarios.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@saustrie-consensys
saustrie-consensys added this pull request to the merge queueAug 4, 2026
Merged via the queue into main with commit af58537Aug 4, 2026
289 of 305 checks passed
@saustrie-consensys
saustrie-consensys deleted the feat/tram-3757-ramps-redirect-url branch August 4, 2026 17:00
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Aug 4, 2026
@metamask-cimetamask-ciBot added the release-8.7.0 Issue or pull request that will be included in release 8.7.0 label Aug 4, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelogno-changelog Indicates no external facing user changes, therefore no changelog documentation neededrelease-8.7.0Issue or pull request that will be included in release 8.7.0risk:highAI analysis: high risksize-Mteam-money-movementissues related to Money Movement features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@saustrie-consensys@amitabh94