Skip to content

feat(ramps-controller)!: derive widened Headless Buy default redirect URL from environment - #9752

Draft
saustrie-consensys wants to merge 2 commits into
mainfrom
tram-3757-redirect-url
Draft

feat(ramps-controller)!: derive widened Headless Buy default redirect URL from environment#9752
saustrie-consensys wants to merge 2 commits into
mainfrom
tram-3757-redirect-url

Conversation

@saustrie-consensys

@saustrie-consensys saustrie-consensys commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Explanation

On the widened Headless Buy all-providers path, MetaMask Pay's quote request omits redirectUrl. The quotes API only embeds a buyURL/buyWidget (the WebView page a non-native provider needs) 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 (ramps-controller-init.ts), which review flagged as an unusual controller-init pattern for a value core can derive itself.

This PR moves the derivation into core:

  • Adds getDefaultRedirectCallbackUrl(environment), which maps each RampsEnvironment to its fake-callback URL: on-ramp-content.api (production), on-ramp-content.uat-api (staging), on-ramp.dev-api (development, which has no on-ramp-content.dev-api deployment), and localhost:3000 (local). This intentionally does not reuse getBaseUrl, whose Regions host is on-ramp{-cache}, not on-ramp-content.
  • Replaces the getDefaultRedirectUrl callback option on RampsControllerOptions with a required environment option. The widened quote path derives the default from it. There is no Staging fallback: consumers must pass the same environment used by RampsService and by callback-matching UI code.

Behaviour is preserved: an explicit caller redirectUrl still wins, and the native-only (flag-off) path still injects nothing.

Breaking change

getDefaultRedirectUrl is removed from RampsControllerOptions, and environment is required. Consumers must:

  1. Pass environment (same value as RampsService) instead of injecting a URL callback.
  2. Migrate any callback-matching UI that still hardcodes or separately resolves the fake-callback URL so it stays aligned with that environment (mobile: replace getRampCallbackBaseUrl() call sites together with the controller init change).

The only current consumer is MetaMask Mobile. Adoption is tracked in TRAM-3757 and will land as a follow-up after this package releases; a consumer draft PR is not open yet.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

… URL from environment

Move the widened-path default redirect ("fake callback") URL derivation into
the controller instead of accepting a client-injected URL callback.

- Add `getDefaultRedirectCallbackUrl(environment)` mapping each `RampsEnvironment`
  to its `on-ramp-content` fake-callback host (dev uses `on-ramp.dev-api`, which
  has no content deployment; local uses `localhost:3000`).
- Replace the `getDefaultRedirectUrl` callback option on `RampsControllerOptions`
  with an `environment` option (defaults to Staging, matching `RampsService`);
  the widened quote path derives the default from it.

BREAKING: `getDefaultRedirectUrl` is removed from `RampsControllerOptions`;
clients pass `environment` instead of injecting a URL callback. Behaviour is
preserved: an explicit caller `redirectUrl` still wins, and the native-only
(flag-off) path still injects nothing.

Co-authored-by: Cursor <cursoragent@cursor.com>
Make RampsControllerOptions.environment required so a production consumer
cannot silently fall back to the Staging fake-callback after dropping
getDefaultRedirectUrl. Document that the same environment must be used by
RampsService and callback-matching UI.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant