-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(ramps): uses api endpoint to determine ramp eligibility #22279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
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. |
…aMask/metamask-mobile into TRAM-2834-ramp-eligibility-api-fetch
| const baseUrl = getBaseUrl(); | ||
| const response = await fetch( | ||
| `/endpoint-coming-soon?region=${rampGeodetectedRegion}`, | ||
| `${baseUrl}/regions/countries/${rampGeodetectedRegion}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use URL object to construct URLs, as it handles bass URLs trailing slashes, encoding, etc...
const url = new URL(`/regions/countries/${rampGeodetectedRegion}`, baseUrl).toString();
await fetch(url);
|



Description
This PR updates the Ramps Smart Routing hook to use the actual API endpoints now that they are available in production and staging environments.
What is the reason for the change?
The smart routing feature was previously using a placeholder endpoint (
/endpoint-coming-soon) while waiting for the backend API to be deployed. The API endpoints are now available and ready to be integrated.What is the improvement/solution?
https://on-ramp-content.api.cx.metamask.io/regions/countries/{region-code}https://on-ramp-content.uat-api.cx.metamask.io/regions/countries/{region-code}process.env.METAMASK_ENVIRONMENTdirectly to determine which endpoint to useproduction,beta,rcdev,exp,test,e2e, and all others default to stagingChangelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-2807
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Hook now fetches ramp eligibility from environment-specific endpoints with error handling; tests expanded and Babel config updated to preserve env vars.
app/components/UI/Ramp/hooks/useRampsSmartRouting.ts)process.env.METAMASK_ENVIRONMENT(PRODUCTIONvsSTAGING).'/regions/countries/{region}'; validateresponse.okand throw on errors; log and route toERRORon failure.useRampsSmartRouting.test.ts)production,beta,rc,dev,exp,test,e2e).us-ca.babel.config.tests.js)useRampsSmartRouting.tsand its tests from inline env var transform to allow runtime env-based behavior.Written by Cursor Bugbot for commit 77d4425. This will update automatically on new commits. Configure here.