Skip to content

Commit 6886442

Browse files
authored
fix(geolocation-controller): point to API Platform geolocation-api instead of legacy Ramps endpoint (#9417)
## Explanation `GeolocationApiService` (used by Ramp, Perps, Rewards, Card, mUSD, and Money Account across extension and mobile) still fetches from the legacy Ramps-owned `on-ramp.{env}api.cx.metamask.io/geolocation` endpoint. That endpoint is slated for deprecation now that geolocation is a platform-owned service. API Platform's replacement, `geolocation.{env}api.cx.metamask.io/v1/geolocation`, has been live since March and returns the same plain-text ISO 3166-2 response format, so this is a same-contract URL swap with no consumer-facing changes. ## Open item before merge API Platform has **not yet provisioned a dedicated UAT deployment** for `geolocation-api` (confirmed: `geolocation.uat-api.cx.metamask.io` does not resolve, and the UAT workload config in `va-mmcx-geolocation-api-workload` is empty). This PR temporarily maps `Env.UAT` to the production URL so UAT testing isn't broken by this change. That mapping should be revisited once a real UAT deployment exists. Opening as **draft** pending confirmation from API Platform (`@api-platform-devs`) that: - the PROD/DEV URLs are correct and stable - the UAT-points-at-PROD interim approach is acceptable on their end ## References - `packages/geolocation-controller` is owned by `@metamask-mobile-platform` per CODEOWNERS - API Platform docs: https://docs.cx.metamask.io/api/geolocation/ Supersedes #9415 (opened from a fork by mistake, which broke the changelog-diff CI check). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Wide downstream use (Ramp, Perps, Rewards, etc.) makes any geolocation outage impactful, though the API contract is unchanged; UAT hitting production is an interim operational caveat. > > **Overview** > **`GeolocationApiService`** now calls API Platform’s **`geolocation-api`** host and **`/v1/geolocation`** path instead of the legacy Ramps **`on-ramp.*`** **`/geolocation`** URLs that are being deprecated. The response contract is unchanged (plain-text ISO 3166-2). > > **`getGeolocationUrl`** builds **`https://geolocation.api.cx.metamask.io`** for production and UAT, and **`https://geolocation.dev-api.cx.metamask.io`** for DEV. **UAT** no longer uses a separate **`uat-`** host and temporarily shares the production URL until API Platform provisions a UAT deployment. Tests and the changelog reflect the new URLs and UAT behavior. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 411259b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent c881134 commit 6886442

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

packages/geolocation-controller/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Changed
1111

12+
- Point `GeolocationApiService` at API Platform's `geolocation-api` service instead of the legacy Ramps-owned `on-ramp` geolocation endpoint, which is slated for deprecation ([#9417](https://github.com/MetaMask/core/pull/9417))
13+
- UAT temporarily resolves to the production URL since API Platform has not yet provisioned a dedicated UAT deployment for this service
1214
- Bump `@metamask/controller-utils` from `^12.0.0` to `^12.3.0` ([#8774](https://github.com/MetaMask/core/pull/8774), [#9058](https://github.com/MetaMask/core/pull/9058), [#9083](https://github.com/MetaMask/core/pull/9083), [#9218](https://github.com/MetaMask/core/pull/9218))
1315
- Bump `@metamask/messenger` from `^1.2.0` to `^2.0.0` ([#9392](https://github.com/MetaMask/core/pull/9392))
1416

packages/geolocation-controller/src/geolocation-api-service/geolocation-api-service.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ describe('GeolocationApiService', () => {
4444
await rootMessenger.call('GeolocationApiService:fetchGeolocation');
4545

4646
expect(mockFetch).toHaveBeenCalledWith(
47-
'https://on-ramp.api.cx.metamask.io/geolocation',
47+
'https://geolocation.api.cx.metamask.io/v1/geolocation',
4848
);
4949
});
5050

51-
it('fetches from the UAT URL when env is UAT', async () => {
51+
it('fetches from the production URL when env is UAT, since API Platform has not provisioned a dedicated UAT deployment', async () => {
5252
const mockFetch = createMockFetch('FR');
5353
const { rootMessenger } = getService({
5454
options: { fetch: mockFetch, env: Env.UAT },
@@ -57,7 +57,7 @@ describe('GeolocationApiService', () => {
5757
await rootMessenger.call('GeolocationApiService:fetchGeolocation');
5858

5959
expect(mockFetch).toHaveBeenCalledWith(
60-
'https://on-ramp.uat-api.cx.metamask.io/geolocation',
60+
'https://geolocation.api.cx.metamask.io/v1/geolocation',
6161
);
6262
});
6363

@@ -70,7 +70,7 @@ describe('GeolocationApiService', () => {
7070
await rootMessenger.call('GeolocationApiService:fetchGeolocation');
7171

7272
expect(mockFetch).toHaveBeenCalledWith(
73-
'https://on-ramp.dev-api.cx.metamask.io/geolocation',
73+
'https://geolocation.dev-api.cx.metamask.io/v1/geolocation',
7474
);
7575
});
7676
});

packages/geolocation-controller/src/geolocation-api-service/geolocation-api-service.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { GeolocationApiServiceMethodActions } from './geolocation-api-servi
1111

1212
const DEFAULT_TTL_MS = 5 * 60 * 1000;
1313

14-
const ENDPOINT_PATH = '/geolocation';
14+
const ENDPOINT_PATH = '/v1/geolocation';
1515

1616
// === GENERAL ===
1717

@@ -68,12 +68,17 @@ export type GeolocationApiServiceMessenger = Messenger<
6868
/**
6969
* Returns the base URL for the geolocation API for the given environment.
7070
*
71+
* Served by API Platform's `geolocation-api` service, not the legacy
72+
* Ramps-owned `on-ramp` endpoint this previously pointed to. API Platform has
73+
* not yet provisioned a dedicated UAT deployment for this service, so UAT
74+
* temporarily resolves to the production URL until one exists.
75+
*
7176
* @param env - The environment to get the URL for.
7277
* @returns The full URL for the geolocation endpoint.
7378
*/
7479
function getGeolocationUrl(env: Env): string {
75-
const envPrefix = env === Env.PRD ? '' : `${env}-`;
76-
return `https://on-ramp.${envPrefix}api.cx.metamask.io${ENDPOINT_PATH}`;
80+
const envPrefix = env === Env.DEV ? 'dev-' : '';
81+
return `https://geolocation.${envPrefix}api.cx.metamask.io${ENDPOINT_PATH}`;
7782
}
7883

7984
/**

0 commit comments

Comments
 (0)