@metamask/ramps-controller 7.0.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/dist/RampsController.cjs +36 -19
- package/dist/RampsController.cjs.map +1 -1
- package/dist/RampsController.d.cts +11 -10
- package/dist/RampsController.d.cts.map +1 -1
- package/dist/RampsController.d.mts +11 -10
- package/dist/RampsController.d.mts.map +1 -1
- package/dist/RampsController.mjs +36 -19
- package/dist/RampsController.mjs.map +1 -1
- package/dist/RampsService-method-action-types.cjs.map +1 -1
- package/dist/RampsService-method-action-types.d.cts +14 -2
- package/dist/RampsService-method-action-types.d.cts.map +1 -1
- package/dist/RampsService-method-action-types.d.mts +14 -2
- package/dist/RampsService-method-action-types.d.mts.map +1 -1
- package/dist/RampsService-method-action-types.mjs.map +1 -1
- package/dist/RampsService.cjs +28 -4
- package/dist/RampsService.cjs.map +1 -1
- package/dist/RampsService.d.cts +38 -7
- package/dist/RampsService.d.cts.map +1 -1
- package/dist/RampsService.d.mts +38 -7
- package/dist/RampsService.d.mts.map +1 -1
- package/dist/RampsService.mjs +28 -4
- package/dist/RampsService.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -6
|
@@ -2,7 +2,7 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@meta
|
|
|
2
2
|
import { BaseController } from "@metamask/base-controller";
|
|
3
3
|
import type { Messenger } from "@metamask/messenger";
|
|
4
4
|
import type { Country, TokensResponse, Provider, State, RampAction, PaymentMethod, PaymentMethodsResponse, QuotesResponse, Quote, RampsToken, RampsServiceActions } from "./RampsService.cjs";
|
|
5
|
-
import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction } from "./RampsService-method-action-types.cjs";
|
|
5
|
+
import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, RampsServiceGetBuyWidgetUrlAction } from "./RampsService-method-action-types.cjs";
|
|
6
6
|
import type { RequestCache as RequestCacheType, RequestState, ExecuteRequestOptions } from "./RequestCache.cjs";
|
|
7
7
|
/**
|
|
8
8
|
* The name of the {@link RampsController}, used to namespace the
|
|
@@ -118,7 +118,7 @@ export type RampsControllerActions = RampsControllerGetStateAction;
|
|
|
118
118
|
/**
|
|
119
119
|
* Actions from other messengers that {@link RampsController} calls.
|
|
120
120
|
*/
|
|
121
|
-
type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction;
|
|
121
|
+
type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction | RampsServiceGetBuyWidgetUrlAction;
|
|
122
122
|
/**
|
|
123
123
|
* Published when the state of {@link RampsController} changes.
|
|
124
124
|
*/
|
|
@@ -315,7 +315,7 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
315
315
|
* @param options.amount - The amount (in fiat for buy, crypto for sell).
|
|
316
316
|
* @param options.walletAddress - The destination wallet address.
|
|
317
317
|
* @param options.paymentMethods - Array of payment method IDs. If not provided, uses paymentMethods from state.
|
|
318
|
-
* @param options.
|
|
318
|
+
* @param options.providers - Optional provider IDs to filter quotes.
|
|
319
319
|
* @param options.redirectUrl - Optional redirect URL after order completion.
|
|
320
320
|
* @param options.action - The ramp action type. Defaults to 'buy'.
|
|
321
321
|
* @param options.forceRefresh - Whether to bypass cache.
|
|
@@ -325,11 +325,11 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
325
325
|
getQuotes(options: {
|
|
326
326
|
region?: string;
|
|
327
327
|
fiat?: string;
|
|
328
|
-
assetId
|
|
328
|
+
assetId?: string;
|
|
329
329
|
amount: number;
|
|
330
330
|
walletAddress: string;
|
|
331
331
|
paymentMethods?: string[];
|
|
332
|
-
|
|
332
|
+
providers?: string[];
|
|
333
333
|
redirectUrl?: string;
|
|
334
334
|
action?: RampAction;
|
|
335
335
|
forceRefresh?: boolean;
|
|
@@ -370,13 +370,14 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
370
370
|
*/
|
|
371
371
|
destroy(): void;
|
|
372
372
|
/**
|
|
373
|
-
*
|
|
374
|
-
*
|
|
373
|
+
* Fetches the widget URL from a quote for redirect providers.
|
|
374
|
+
* Makes a request to the buyURL endpoint via the RampsService to get the
|
|
375
|
+
* actual provider widget URL, using the injected fetch and retry policy.
|
|
375
376
|
*
|
|
376
|
-
* @param quote - The quote to
|
|
377
|
-
* @returns
|
|
377
|
+
* @param quote - The quote to fetch the widget URL from.
|
|
378
|
+
* @returns Promise resolving to the widget URL string, or null if not available.
|
|
378
379
|
*/
|
|
379
|
-
getWidgetUrl(quote: Quote): string | null
|
|
380
|
+
getWidgetUrl(quote: Quote): Promise<string | null>;
|
|
380
381
|
}
|
|
381
382
|
export {};
|
|
382
383
|
//# sourceMappingURL=RampsController.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RampsController.d.cts","sourceRoot":"","sources":["../src/RampsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAGrD,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,QAAQ,EACR,KAAK,EACL,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,KAAK,
|
|
1
|
+
{"version":3,"file":"RampsController.d.cts","sourceRoot":"","sources":["../src/RampsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAGrD,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,QAAQ,EACR,KAAK,EACL,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,KAAK,EACL,UAAU,EACV,mBAAmB,EACpB,2BAAuB;AACxB,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC9B,2BAA2B,EAC3B,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,EAClC,+CAA2C;AAC5C,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,YAAY,EACZ,qBAAqB,EAGtB,2BAAuB;AAcxB;;;;GAIG;AACH,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,yCAAyC,EAAE,SAAS,mBAAmB,CAAC,MAAM,CAAC,EASzF,CAAC;AAUJ;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,IAAI;IACnD;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IACZ;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,KAAK,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EAAE,MAAM,GAAG,IAAI;IAgCxD;;;;;;;;;;;;;;;;;OAiBG;IACG,SAAS,CAAC,OAAO,EAAE;QACvB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,UAAU,CAAC;QACpB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,cAAc,CAAC;IAsG3B;;;;;;;;;;;OAWG;IACH,iBAAiB,CAAC,OAAO,EAAE;QACzB,aAAa,EAAE,MAAM,CAAC;QACtB,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,IAAI;IA8ER;;;OAGG;IACH,gBAAgB,IAAI,IAAI;IAQxB;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI;IAM3C;;;;OAIG;IACM,OAAO,IAAI,IAAI;IAKxB;;;;;;;OAOG;IACG,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAiBzD"}
|
|
@@ -2,7 +2,7 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@meta
|
|
|
2
2
|
import { BaseController } from "@metamask/base-controller";
|
|
3
3
|
import type { Messenger } from "@metamask/messenger";
|
|
4
4
|
import type { Country, TokensResponse, Provider, State, RampAction, PaymentMethod, PaymentMethodsResponse, QuotesResponse, Quote, RampsToken, RampsServiceActions } from "./RampsService.mjs";
|
|
5
|
-
import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction } from "./RampsService-method-action-types.mjs";
|
|
5
|
+
import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, RampsServiceGetBuyWidgetUrlAction } from "./RampsService-method-action-types.mjs";
|
|
6
6
|
import type { RequestCache as RequestCacheType, RequestState, ExecuteRequestOptions } from "./RequestCache.mjs";
|
|
7
7
|
/**
|
|
8
8
|
* The name of the {@link RampsController}, used to namespace the
|
|
@@ -118,7 +118,7 @@ export type RampsControllerActions = RampsControllerGetStateAction;
|
|
|
118
118
|
/**
|
|
119
119
|
* Actions from other messengers that {@link RampsController} calls.
|
|
120
120
|
*/
|
|
121
|
-
type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction;
|
|
121
|
+
type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction | RampsServiceGetBuyWidgetUrlAction;
|
|
122
122
|
/**
|
|
123
123
|
* Published when the state of {@link RampsController} changes.
|
|
124
124
|
*/
|
|
@@ -315,7 +315,7 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
315
315
|
* @param options.amount - The amount (in fiat for buy, crypto for sell).
|
|
316
316
|
* @param options.walletAddress - The destination wallet address.
|
|
317
317
|
* @param options.paymentMethods - Array of payment method IDs. If not provided, uses paymentMethods from state.
|
|
318
|
-
* @param options.
|
|
318
|
+
* @param options.providers - Optional provider IDs to filter quotes.
|
|
319
319
|
* @param options.redirectUrl - Optional redirect URL after order completion.
|
|
320
320
|
* @param options.action - The ramp action type. Defaults to 'buy'.
|
|
321
321
|
* @param options.forceRefresh - Whether to bypass cache.
|
|
@@ -325,11 +325,11 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
325
325
|
getQuotes(options: {
|
|
326
326
|
region?: string;
|
|
327
327
|
fiat?: string;
|
|
328
|
-
assetId
|
|
328
|
+
assetId?: string;
|
|
329
329
|
amount: number;
|
|
330
330
|
walletAddress: string;
|
|
331
331
|
paymentMethods?: string[];
|
|
332
|
-
|
|
332
|
+
providers?: string[];
|
|
333
333
|
redirectUrl?: string;
|
|
334
334
|
action?: RampAction;
|
|
335
335
|
forceRefresh?: boolean;
|
|
@@ -370,13 +370,14 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
370
370
|
*/
|
|
371
371
|
destroy(): void;
|
|
372
372
|
/**
|
|
373
|
-
*
|
|
374
|
-
*
|
|
373
|
+
* Fetches the widget URL from a quote for redirect providers.
|
|
374
|
+
* Makes a request to the buyURL endpoint via the RampsService to get the
|
|
375
|
+
* actual provider widget URL, using the injected fetch and retry policy.
|
|
375
376
|
*
|
|
376
|
-
* @param quote - The quote to
|
|
377
|
-
* @returns
|
|
377
|
+
* @param quote - The quote to fetch the widget URL from.
|
|
378
|
+
* @returns Promise resolving to the widget URL string, or null if not available.
|
|
378
379
|
*/
|
|
379
|
-
getWidgetUrl(quote: Quote): string | null
|
|
380
|
+
getWidgetUrl(quote: Quote): Promise<string | null>;
|
|
380
381
|
}
|
|
381
382
|
export {};
|
|
382
383
|
//# sourceMappingURL=RampsController.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RampsController.d.mts","sourceRoot":"","sources":["../src/RampsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAGrD,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,QAAQ,EACR,KAAK,EACL,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,KAAK,
|
|
1
|
+
{"version":3,"file":"RampsController.d.mts","sourceRoot":"","sources":["../src/RampsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAGrD,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,QAAQ,EACR,KAAK,EACL,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,KAAK,EACL,UAAU,EACV,mBAAmB,EACpB,2BAAuB;AACxB,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC9B,2BAA2B,EAC3B,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,EAClC,+CAA2C;AAC5C,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,YAAY,EACZ,qBAAqB,EAGtB,2BAAuB;AAcxB;;;;GAIG;AACH,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,yCAAyC,EAAE,SAAS,mBAAmB,CAAC,MAAM,CAAC,EASzF,CAAC;AAUJ;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,IAAI;IACnD;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IACZ;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAE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AC;IAkFlC;;;;;;OAMG;IACH,wBAAwB,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI;IAgCxD;;;;;;;;;;;;;;;;;OAiBG;IACG,SAAS,CAAC,OAAO,EAAE;QACvB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,UAAU,CAAC;QACpB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,cAAc,CAAC;IAsG3B;;;;;;;;;;;OAWG;IACH,iBAAiB,CAAC,OAAO,EAAE;QACzB,aAAa,EAAE,MAAM,CAAC;QACtB,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,IAAI;IA8ER;;;OAGG;IACH,gBAAgB,IAAI,IAAI;IAQxB;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI;IAM3C;;;;OAIG;IACM,OAAO,IAAI,IAAI;IAKxB;;;;;;;OAOG;IACG,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAiBzD"}
|
package/dist/RampsController.mjs
CHANGED
|
@@ -31,6 +31,7 @@ export const RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = [
|
|
|
31
31
|
'RampsService:getProviders',
|
|
32
32
|
'RampsService:getPaymentMethods',
|
|
33
33
|
'RampsService:getQuotes',
|
|
34
|
+
'RampsService:getBuyWidgetUrl',
|
|
34
35
|
];
|
|
35
36
|
/**
|
|
36
37
|
* Default TTL for quotes requests (15 seconds).
|
|
@@ -614,7 +615,6 @@ export class RampsController extends BaseController {
|
|
|
614
615
|
state.quotes.selected = null;
|
|
615
616
|
});
|
|
616
617
|
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_fireAndForget).call(this, this.getPaymentMethods(regionCode, { assetId: token.assetId }).then(() => {
|
|
617
|
-
// Restart quote polling after payment methods are fetched
|
|
618
618
|
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_restartPollingIfActive).call(this);
|
|
619
619
|
return undefined;
|
|
620
620
|
}));
|
|
@@ -771,7 +771,7 @@ export class RampsController extends BaseController {
|
|
|
771
771
|
* @param options.amount - The amount (in fiat for buy, crypto for sell).
|
|
772
772
|
* @param options.walletAddress - The destination wallet address.
|
|
773
773
|
* @param options.paymentMethods - Array of payment method IDs. If not provided, uses paymentMethods from state.
|
|
774
|
-
* @param options.
|
|
774
|
+
* @param options.providers - Optional provider IDs to filter quotes.
|
|
775
775
|
* @param options.redirectUrl - Optional redirect URL after order completion.
|
|
776
776
|
* @param options.action - The ramp action type. Defaults to 'buy'.
|
|
777
777
|
* @param options.forceRefresh - Whether to bypass cache.
|
|
@@ -783,28 +783,34 @@ export class RampsController extends BaseController {
|
|
|
783
783
|
const fiatToUse = options.fiat ?? this.state.userRegion?.country?.currency;
|
|
784
784
|
const paymentMethodsToUse = options.paymentMethods ??
|
|
785
785
|
this.state.paymentMethods.data.map((pm) => pm.id);
|
|
786
|
+
const providersToUse = options.providers ??
|
|
787
|
+
this.state.providers.data.map((provider) => provider.id);
|
|
786
788
|
const action = options.action ?? 'buy';
|
|
789
|
+
const assetIdToUse = options.assetId ?? this.state.tokens.selected?.assetId;
|
|
787
790
|
if (!regionToUse) {
|
|
788
791
|
throw new Error('Region is required. Either provide a region parameter or ensure userRegion is set in controller state.');
|
|
789
792
|
}
|
|
790
793
|
if (!fiatToUse) {
|
|
791
794
|
throw new Error('Fiat currency is required. Either provide a fiat parameter or ensure userRegion is set in controller state.');
|
|
792
795
|
}
|
|
793
|
-
|
|
796
|
+
const normalizedAssetIdForValidation = (assetIdToUse ?? '').trim();
|
|
797
|
+
if (normalizedAssetIdForValidation === '') {
|
|
798
|
+
throw new Error('assetId is required.');
|
|
799
|
+
}
|
|
800
|
+
if (!paymentMethodsToUse ||
|
|
801
|
+
paymentMethodsToUse.length === 0 ||
|
|
802
|
+
paymentMethodsToUse.some((pm) => pm.trim() === '')) {
|
|
794
803
|
throw new Error('Payment methods are required. Either provide paymentMethods parameter or ensure paymentMethods are set in controller state.');
|
|
795
804
|
}
|
|
796
805
|
if (options.amount <= 0 || !Number.isFinite(options.amount)) {
|
|
797
806
|
throw new Error('Amount must be a positive finite number.');
|
|
798
807
|
}
|
|
799
|
-
if (!options.assetId || options.assetId.trim() === '') {
|
|
800
|
-
throw new Error('assetId is required.');
|
|
801
|
-
}
|
|
802
808
|
if (!options.walletAddress || options.walletAddress.trim() === '') {
|
|
803
809
|
throw new Error('walletAddress is required.');
|
|
804
810
|
}
|
|
805
811
|
const normalizedRegion = regionToUse.toLowerCase().trim();
|
|
806
812
|
const normalizedFiat = fiatToUse.toLowerCase().trim();
|
|
807
|
-
const normalizedAssetId =
|
|
813
|
+
const normalizedAssetId = normalizedAssetIdForValidation;
|
|
808
814
|
const normalizedWalletAddress = options.walletAddress.trim();
|
|
809
815
|
const cacheKey = createCacheKey('getQuotes', [
|
|
810
816
|
normalizedRegion,
|
|
@@ -813,7 +819,7 @@ export class RampsController extends BaseController {
|
|
|
813
819
|
options.amount,
|
|
814
820
|
normalizedWalletAddress,
|
|
815
821
|
[...paymentMethodsToUse].sort().join(','),
|
|
816
|
-
|
|
822
|
+
[...providersToUse].sort().join(','),
|
|
817
823
|
options.redirectUrl,
|
|
818
824
|
action,
|
|
819
825
|
]);
|
|
@@ -824,7 +830,7 @@ export class RampsController extends BaseController {
|
|
|
824
830
|
amount: options.amount,
|
|
825
831
|
walletAddress: normalizedWalletAddress,
|
|
826
832
|
paymentMethods: paymentMethodsToUse,
|
|
827
|
-
|
|
833
|
+
providers: providersToUse,
|
|
828
834
|
redirectUrl: options.redirectUrl,
|
|
829
835
|
action,
|
|
830
836
|
};
|
|
@@ -873,7 +879,7 @@ export class RampsController extends BaseController {
|
|
|
873
879
|
throw new Error('Provider is required. Cannot start quote polling without a selected provider.');
|
|
874
880
|
}
|
|
875
881
|
if (!paymentMethod) {
|
|
876
|
-
|
|
882
|
+
return;
|
|
877
883
|
}
|
|
878
884
|
// Stop any existing polling first
|
|
879
885
|
this.stopQuotePolling();
|
|
@@ -887,7 +893,7 @@ export class RampsController extends BaseController {
|
|
|
887
893
|
walletAddress: options.walletAddress,
|
|
888
894
|
redirectUrl: options.redirectUrl,
|
|
889
895
|
paymentMethods: [paymentMethod.id],
|
|
890
|
-
|
|
896
|
+
providers: [provider.id],
|
|
891
897
|
forceRefresh: true,
|
|
892
898
|
}).then((response) => {
|
|
893
899
|
// Auto-select logic: only when exactly one quote is returned
|
|
@@ -946,14 +952,26 @@ export class RampsController extends BaseController {
|
|
|
946
952
|
super.destroy();
|
|
947
953
|
}
|
|
948
954
|
/**
|
|
949
|
-
*
|
|
950
|
-
*
|
|
955
|
+
* Fetches the widget URL from a quote for redirect providers.
|
|
956
|
+
* Makes a request to the buyURL endpoint via the RampsService to get the
|
|
957
|
+
* actual provider widget URL, using the injected fetch and retry policy.
|
|
951
958
|
*
|
|
952
|
-
* @param quote - The quote to
|
|
953
|
-
* @returns
|
|
959
|
+
* @param quote - The quote to fetch the widget URL from.
|
|
960
|
+
* @returns Promise resolving to the widget URL string, or null if not available.
|
|
954
961
|
*/
|
|
955
|
-
getWidgetUrl(quote) {
|
|
956
|
-
|
|
962
|
+
async getWidgetUrl(quote) {
|
|
963
|
+
const buyUrl = quote.quote?.buyURL;
|
|
964
|
+
if (!buyUrl) {
|
|
965
|
+
return null;
|
|
966
|
+
}
|
|
967
|
+
try {
|
|
968
|
+
const buyWidget = await this.messenger.call('RampsService:getBuyWidgetUrl', buyUrl);
|
|
969
|
+
return buyWidget.url ?? null;
|
|
970
|
+
}
|
|
971
|
+
catch (error) {
|
|
972
|
+
console.error('Error fetching widget URL:', error);
|
|
973
|
+
return null;
|
|
974
|
+
}
|
|
957
975
|
}
|
|
958
976
|
}
|
|
959
977
|
_RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheMaxSize = new WeakMap(), _RampsController_pendingRequests = new WeakMap(), _RampsController_pendingResourceCount = new WeakMap(), _RampsController_quotePollingInterval = new WeakMap(), _RampsController_quotePollingOptions = new WeakMap(), _RampsController_instances = new WeakSet(), _RampsController_clearPendingResourceCountForDependentResources = function _RampsController_clearPendingResourceCountForDependentResources() {
|
|
@@ -1013,8 +1031,7 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
|
|
|
1013
1031
|
const keys = Object.keys(requests);
|
|
1014
1032
|
for (const key of keys) {
|
|
1015
1033
|
const entry = requests[key];
|
|
1016
|
-
if (entry &&
|
|
1017
|
-
entry.status === RequestStatus.SUCCESS &&
|
|
1034
|
+
if (entry?.status === RequestStatus.SUCCESS &&
|
|
1018
1035
|
isCacheExpired(entry, ttl)) {
|
|
1019
1036
|
delete requests[key];
|
|
1020
1037
|
}
|