Skip to content

Commit a1be275

Browse files
pkowalskiamitabh94
andauthored
feat(ramps-controller): dev-api URLs for Development (#8574)
## Explanation `RampsEnvironment.Development` previously fell through the same branch as staging and sent all traffic to the UAT hosts (`on-ramp*.uat-api.cx.metamask.io`). This PR gives development its own API hosts on the `dev-api` subdomain, aligned with production/staging patterns. Implementation details: - **Orders (and other non-regions callers)** use `https://on-ramp.dev-api.cx.metamask.io`. - **Regions / cache-backed endpoints** use `https://on-ramp-cache.dev-api.cx.metamask.io` via the same `${cache}` suffix as other environments (so `getCountries` and related regions traffic stay on the cache host). Production, staging, and local base URLs are unchanged. Draft Mobile PR: MetaMask/metamask-mobile#29526 ## References - PR branch: `feature/enable-dev-ramps` - Follows the same `on-ramp${cache}.<env>-api.cx.metamask.io` shape as production and staging. ## Testing `yarn workspace @metamask/ramps-controller jest packages/ramps-controller/src/RampsService.test.ts` ## 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) - [ ] 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 (not applicable — no breaking changes; `Development` now targets dedicated dev hosts instead of UAT) ## Risk Low for production/staging users. Consumers that instantiate `RampsService` (or the controller) with `RampsEnvironment.Development` will hit new hostnames; confirm dev-api is reachable and feature-complete for your flows before relying on it. --------- Co-authored-by: Amitabh Aggarwal <[email protected]>
1 parent 5a9127d commit a1be275

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

packages/ramps-controller/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Changed
1111

1212
- Bump `@metamask/messenger` from `^1.1.1` to `^1.2.0` ([#8632](https://github.com/MetaMask/core/pull/8632))
13+
- `RampsService` routes `RampsEnvironment.Development` to dev-api base URLs; regions requests in development omit the `-cache` hostname segment used in staging and production ([#8574](https://github.com/MetaMask/core/pull/8574))
1314

1415
## [13.2.0]
1516

packages/ramps-controller/src/RampsService.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ describe('RampsService', () => {
6767
expect(geolocationResponse).toBe('us-tx');
6868
});
6969

70-
it('uses staging URL when environment is Development', async () => {
71-
nock('https://on-ramp.uat-api.cx.metamask.io')
70+
it('uses development URL when environment is Development', async () => {
71+
nock('https://on-ramp.dev-api.cx.metamask.io')
7272
.get('/geolocation')
7373
.query({
7474
sdk: '2.1.6',
@@ -423,8 +423,8 @@ describe('RampsService', () => {
423423
`);
424424
});
425425

426-
it('uses staging cache URL when environment is Development', async () => {
427-
nock('https://on-ramp-cache.uat-api.cx.metamask.io')
426+
it('uses development regions URL without cache hostname', async () => {
427+
nock('https://on-ramp.dev-api.cx.metamask.io')
428428
.get('/v2/regions/countries')
429429
.query({
430430
sdk: '2.1.6',

packages/ramps-controller/src/RampsService.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,8 @@ export type RampsServiceMessenger = Messenger<
710710

711711
/**
712712
* Gets the base URL for API requests based on the environment and service type.
713-
* The Regions service uses a cache URL, while other services use the standard URL.
713+
* The Regions service uses a cache hostname in production and staging only;
714+
* development serves regions from the same `on-ramp.dev-api` host (no `-cache`).
714715
*
715716
* @param environment - The environment to use.
716717
* @param service - The API service type (determines if cache URL is used).
@@ -720,14 +721,19 @@ function getBaseUrl(
720721
environment: RampsEnvironment,
721722
service: RampsApiService,
722723
): string {
723-
const cache = service === RampsApiService.Regions ? '-cache' : '';
724+
const cache =
725+
service === RampsApiService.Regions &&
726+
environment !== RampsEnvironment.Development
727+
? '-cache'
728+
: '';
724729

725730
switch (environment) {
726731
case RampsEnvironment.Production:
727732
return `https://on-ramp${cache}.api.cx.metamask.io`;
728733
case RampsEnvironment.Staging:
729-
case RampsEnvironment.Development:
730734
return `https://on-ramp${cache}.uat-api.cx.metamask.io`;
735+
case RampsEnvironment.Development:
736+
return `https://on-ramp${cache}.dev-api.cx.metamask.io`;
731737
case RampsEnvironment.Local:
732738
return 'http://localhost:3000';
733739
default:

0 commit comments

Comments
 (0)