Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ramps-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- **BREAKING:** `RampsControllerMessenger` now requires the `KycController:getSessionStatusForVendor`, `KycController:refreshSessionStatus`, `KycController:hasCompletedVendorDisclaimers`, and `KycController:hasCompletedSessionDisclaimers` actions to hydrate VBA onboarding ([#10278](https://github.com/MetaMask/core/pull/10278))
- The action types are declared structurally in the ramps package, so no dependency on `@metamask/kyc-controller` is added.
- Stop sending `crypto` on `RampsService.getPaymentMethods`. Payment methods are provider + region; the param was ignored by `/v2/regions/:region/payments` and split the CDN cache per token. `assetId` remains on the method for caller cache keys. ([#10307](https://github.com/MetaMask/core/pull/10307))

## [23.0.0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ export type RampsServiceGetProvidersAction = {
*
* @param options - Query parameters for filtering payment methods.
* @param options.region - User's region code (e.g., "us-al").
* @param options.assetId - CAIP-19 cryptocurrency identifier.
* @param options.assetId - CAIP-19 cryptocurrency identifier. Kept on the
* caller contract for local cache/staleness; not sent — `/payments` is scoped
* to provider + region (the API ignores `crypto`).
* @param options.provider - Provider ID path.
* @returns The payment methods response containing payments array.
*/
Expand Down
29 changes: 20 additions & 9 deletions packages/ramps-controller/src/RampsService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,6 @@ describe('RampsService', () => {
.get('/v2/regions/us-al/payments')
.query({
region: 'us-al',
crypto: 'eip155:1/slip44:60',
provider: '/providers/stripe',
sdk: '2.1.6',
controller: CONTROLLER_VERSION,
Expand Down Expand Up @@ -1788,12 +1787,30 @@ describe('RampsService', () => {
]);
});

it('does not send crypto on the payments URL', async () => {
const scope = nock('https://on-ramp-cache.uat-api.cx.metamask.io')
.get('/v2/regions/us-al/payments')
.query((query) => query.crypto === undefined)
.reply(200, mockPaymentMethodsResponse);
const { service } = getService();

const paymentMethodsPromise = service.getPaymentMethods({
region: 'us-al',
assetId: 'eip155:1/slip44:60',
provider: '/providers/stripe',
});
await jest.runAllTimersAsync();
await flushPromises();
await paymentMethodsPromise;

expect(scope.isDone()).toBe(true);
});

it('normalizes region case', async () => {
nock('https://on-ramp-cache.uat-api.cx.metamask.io')
.get('/v2/regions/us-al/payments')
.query({
region: 'us-al',
crypto: 'eip155:1/slip44:60',
provider: '/providers/stripe',
sdk: '2.1.6',
controller: CONTROLLER_VERSION,
Expand All @@ -1819,7 +1836,6 @@ describe('RampsService', () => {
.get('/v2/regions/us-al/payments')
.query({
region: 'us-al',
crypto: 'eip155:1/slip44:60',
provider: '/providers/stripe',
sdk: '2.1.6',
controller: CONTROLLER_VERSION,
Expand All @@ -1846,7 +1862,6 @@ describe('RampsService', () => {
.get('/v2/regions/us-al/payments')
.query({
region: 'us-al',
crypto: 'eip155:1/slip44:60',
provider: '/providers/stripe',
sdk: '2.1.6',
controller: CONTROLLER_VERSION,
Expand All @@ -1873,7 +1888,6 @@ describe('RampsService', () => {
.get('/v2/regions/us-al/payments')
.query({
region: 'us-al',
crypto: 'eip155:1/slip44:60',
provider: '/providers/stripe',
sdk: '2.1.6',
controller: CONTROLLER_VERSION,
Expand All @@ -1900,7 +1914,6 @@ describe('RampsService', () => {
.get('/v2/regions/us-al/payments')
.query({
region: 'us-al',
crypto: 'eip155:1/slip44:60',
provider: '/providers/stripe',
sdk: '2.1.6',
controller: CONTROLLER_VERSION,
Expand All @@ -1922,7 +1935,7 @@ describe('RampsService', () => {
await flushPromises();

await expect(paymentMethodsPromise).rejects.toThrow(
`Fetching 'https://on-ramp-cache.uat-api.cx.metamask.io/v2/regions/us-al/payments?sdk=2.1.6&controller=${CONTROLLER_VERSION}&context=mobile-ios&region=us-al&crypto=eip155%3A1%2Fslip44%3A60&provider=%2Fproviders%2Fstripe' failed with status '500'`,
`Fetching 'https://on-ramp-cache.uat-api.cx.metamask.io/v2/regions/us-al/payments?sdk=2.1.6&controller=${CONTROLLER_VERSION}&context=mobile-ios&region=us-al&provider=%2Fproviders%2Fstripe' failed with status '500'`,
);
});

Expand All @@ -1931,7 +1944,6 @@ describe('RampsService', () => {
.get('/v2/regions/us-al/payments')
.query({
region: 'us-al',
crypto: 'eip155:1/slip44:60',
provider: '/providers/stripe',
sdk: '2.1.6',
controller: CONTROLLER_VERSION,
Expand Down Expand Up @@ -1959,7 +1971,6 @@ describe('RampsService', () => {
.get('/v2/regions/us-al/payments')
.query({
region: 'us-al',
crypto: 'eip155:1/slip44:60',
provider: '/providers/stripe',
sdk: '2.1.6',
controller: CONTROLLER_VERSION,
Expand Down
5 changes: 3 additions & 2 deletions packages/ramps-controller/src/RampsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,9 @@ export class RampsService {
*
* @param options - Query parameters for filtering payment methods.
* @param options.region - User's region code (e.g., "us-al").
* @param options.assetId - CAIP-19 cryptocurrency identifier.
* @param options.assetId - CAIP-19 cryptocurrency identifier. Kept on the
* caller contract for local cache/staleness; not sent — `/payments` is scoped
* to provider + region (the API ignores `crypto`).
* @param options.provider - Provider ID path.
* @returns The payment methods response containing payments array.
*/
Expand All @@ -1348,7 +1350,6 @@ export class RampsService {
this.#addCommonParams(url);

url.searchParams.set('region', options.region.toLowerCase().trim());
url.searchParams.set('crypto', options.assetId);
url.searchParams.set('provider', options.provider);

const response = await this.#policy.execute(async () => {
Expand Down
Loading