feat(ramps-controller)!: derive widened Headless Buy default redirect URL from environment - #9752
Draft
saustrie-consensys wants to merge 2 commits into
Draft
feat(ramps-controller)!: derive widened Headless Buy default redirect URL from environment#9752saustrie-consensys wants to merge 2 commits into
saustrie-consensys wants to merge 2 commits into
Conversation
… 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>
saustrie-consensys
force-pushed
the
tram-3757-redirect-url
branch
from
August 1, 2026 17:45
25ecb5d to
92c3cd7
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
On the widened Headless Buy all-providers path, MetaMask Pay's quote request omits
redirectUrl. The quotes API only embeds abuyURL/buyWidget(the WebView page a non-native provider needs) when aredirectUrlis present, soRampsController.getQuotesmust supply a default there. Until now that default came from agetDefaultRedirectUrlcallback 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:
getDefaultRedirectCallbackUrl(environment), which maps eachRampsEnvironmentto its fake-callback URL:on-ramp-content.api(production),on-ramp-content.uat-api(staging),on-ramp.dev-api(development, which has noon-ramp-content.dev-apideployment), andlocalhost:3000(local). This intentionally does not reusegetBaseUrl, whose Regions host ison-ramp{-cache}, noton-ramp-content.getDefaultRedirectUrlcallback option onRampsControllerOptionswith a requiredenvironmentoption. The widened quote path derives the default from it. There is no Staging fallback: consumers must pass the same environment used byRampsServiceand by callback-matching UI code.Behaviour is preserved: an explicit caller
redirectUrlstill wins, and the native-only (flag-off) path still injects nothing.Breaking change
getDefaultRedirectUrlis removed fromRampsControllerOptions, andenvironmentis required. Consumers must:environment(same value asRampsService) instead of injecting a URL callback.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