@metamask/ramps-controller 15.1.0 → 17.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 +33 -1
- package/LICENSE +1 -0
- package/dist/RampsController-method-action-types.cjs.map +1 -1
- package/dist/RampsController-method-action-types.d.cts +1 -1
- package/dist/RampsController-method-action-types.d.mts +1 -1
- package/dist/RampsController-method-action-types.mjs.map +1 -1
- package/dist/RampsController.cjs +49 -85
- package/dist/RampsController.cjs.map +1 -1
- package/dist/RampsController.d.cts +10 -28
- package/dist/RampsController.d.cts.map +1 -1
- package/dist/RampsController.d.mts +10 -28
- package/dist/RampsController.d.mts.map +1 -1
- package/dist/RampsController.mjs +48 -83
- package/dist/RampsController.mjs.map +1 -1
- package/dist/errorNormalization.cjs +84 -0
- package/dist/errorNormalization.cjs.map +1 -0
- package/dist/errorNormalization.d.cts +56 -0
- package/dist/errorNormalization.d.cts.map +1 -0
- package/dist/errorNormalization.d.mts +56 -0
- package/dist/errorNormalization.d.mts.map +1 -0
- package/dist/errorNormalization.mjs +78 -0
- package/dist/errorNormalization.mjs.map +1 -0
- package/dist/featureFlags.cjs +39 -0
- package/dist/featureFlags.cjs.map +1 -0
- package/dist/featureFlags.d.cts +40 -0
- package/dist/featureFlags.d.cts.map +1 -0
- package/dist/featureFlags.d.mts +40 -0
- package/dist/featureFlags.d.mts.map +1 -0
- package/dist/featureFlags.mjs +35 -0
- package/dist/featureFlags.mjs.map +1 -0
- package/dist/index.cjs +17 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +8 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/dist/providerAvailability.cjs +103 -0
- package/dist/providerAvailability.cjs.map +1 -0
- package/dist/providerAvailability.d.cts +76 -0
- package/dist/providerAvailability.d.cts.map +1 -0
- package/dist/providerAvailability.d.mts +76 -0
- package/dist/providerAvailability.d.mts.map +1 -0
- package/dist/providerAvailability.mjs +96 -0
- package/dist/providerAvailability.mjs.map +1 -0
- package/dist/quoteClassification.cjs +44 -0
- package/dist/quoteClassification.cjs.map +1 -0
- package/dist/quoteClassification.d.cts +33 -0
- package/dist/quoteClassification.d.cts.map +1 -0
- package/dist/quoteClassification.d.mts +33 -0
- package/dist/quoteClassification.d.mts.map +1 -0
- package/dist/quoteClassification.mjs +38 -0
- package/dist/quoteClassification.mjs.map +1 -0
- package/package.json +3 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
|
|
2
2
|
import { BaseController } from "@metamask/base-controller";
|
|
3
3
|
import type { Messenger } from "@metamask/messenger";
|
|
4
|
+
import type { RemoteFeatureFlagControllerGetStateAction } from "@metamask/remote-feature-flag-controller";
|
|
4
5
|
import type { RampsControllerMethodActions } from "./RampsController-method-action-types.cjs";
|
|
5
6
|
import type { RampsErrorCode } from "./rampsErrorCodes.cjs";
|
|
6
7
|
import type { BuyWidget, Country, TokensResponse, Provider, State, RampAction, PaymentMethod, PaymentMethodsResponse, QuotesResponse, Quote, RampsToken, RampsServiceActions, RampsOrder } from "./RampsService.cjs";
|
|
@@ -157,7 +158,7 @@ export type RampsControllerActions = RampsControllerGetStateAction | RampsContro
|
|
|
157
158
|
/**
|
|
158
159
|
* Actions from other messengers that {@link RampsController} calls.
|
|
159
160
|
*/
|
|
160
|
-
type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction | RampsServiceGetBuyWidgetUrlAction | RampsServiceGetOrderAction | RampsServiceGetOrderFromCallbackAction | TransakServiceSetApiKeyAction | TransakServiceSetAccessTokenAction | TransakServiceClearAccessTokenAction | TransakServiceSendUserOtpAction | TransakServiceVerifyUserOtpAction | TransakServiceLogoutAction | TransakServiceGetUserDetailsAction | TransakServiceGetBuyQuoteAction | TransakServiceGetKycRequirementAction | TransakServiceGetAdditionalRequirementsAction | TransakServiceCreateOrderAction | TransakServiceGetOrderAction | TransakServiceGetUserLimitsAction | TransakServiceRequestOttAction | TransakServiceGeneratePaymentWidgetUrlAction | TransakServiceSubmitPurposeOfUsageFormAction | TransakServicePatchUserAction | TransakServiceSubmitSsnDetailsAction | TransakServiceConfirmPaymentAction | TransakServiceGetTranslationAction | TransakServiceGetIdProofStatusAction | TransakServiceCancelOrderAction | TransakServiceCancelAllActiveOrdersAction | TransakServiceGetActiveOrdersAction;
|
|
161
|
+
type AllowedActions = RemoteFeatureFlagControllerGetStateAction | RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction | RampsServiceGetBuyWidgetUrlAction | RampsServiceGetOrderAction | RampsServiceGetOrderFromCallbackAction | TransakServiceSetApiKeyAction | TransakServiceSetAccessTokenAction | TransakServiceClearAccessTokenAction | TransakServiceSendUserOtpAction | TransakServiceVerifyUserOtpAction | TransakServiceLogoutAction | TransakServiceGetUserDetailsAction | TransakServiceGetBuyQuoteAction | TransakServiceGetKycRequirementAction | TransakServiceGetAdditionalRequirementsAction | TransakServiceCreateOrderAction | TransakServiceGetOrderAction | TransakServiceGetUserLimitsAction | TransakServiceRequestOttAction | TransakServiceGeneratePaymentWidgetUrlAction | TransakServiceSubmitPurposeOfUsageFormAction | TransakServicePatchUserAction | TransakServiceSubmitSsnDetailsAction | TransakServiceConfirmPaymentAction | TransakServiceGetTranslationAction | TransakServiceGetIdProofStatusAction | TransakServiceCancelOrderAction | TransakServiceCancelAllActiveOrdersAction | TransakServiceGetActiveOrdersAction;
|
|
161
162
|
/**
|
|
162
163
|
* Published when the state of {@link RampsController} changes.
|
|
163
164
|
*/
|
|
@@ -189,16 +190,6 @@ export type RampsControllerMessenger = Messenger<typeof controllerName, RampsCon
|
|
|
189
190
|
/**
|
|
190
191
|
* Configuration options for the RampsController.
|
|
191
192
|
*/
|
|
192
|
-
/**
|
|
193
|
-
* Provider-class scope for fiat quote widening, resolved per `getQuotes` call.
|
|
194
|
-
*
|
|
195
|
-
* - `off`: native-only auto-selection (default; preserves prior behaviour).
|
|
196
|
-
* - `in-app`: also quote in-app WebView aggregator providers and select the
|
|
197
|
-
* best in-app quote.
|
|
198
|
-
* - `all`: additionally allow external-browser / custom-action providers
|
|
199
|
-
* (Phase 2).
|
|
200
|
-
*/
|
|
201
|
-
export type ProviderScope = 'off' | 'in-app' | 'all';
|
|
202
193
|
export type RampsControllerOptions = {
|
|
203
194
|
/** The messenger suited for this controller. */
|
|
204
195
|
messenger: RampsControllerMessenger;
|
|
@@ -208,25 +199,18 @@ export type RampsControllerOptions = {
|
|
|
208
199
|
requestCacheTTL?: number;
|
|
209
200
|
/** Maximum number of entries in the request cache. Defaults to 250. */
|
|
210
201
|
requestCacheMaxSize?: number;
|
|
211
|
-
/**
|
|
212
|
-
* Optional callback returning the current provider-class scope for fiat quote
|
|
213
|
-
* widening. Read per `getQuotes` call so a host-side toggle takes effect at
|
|
214
|
-
* runtime without reconstructing the controller. Defaults to `off`
|
|
215
|
-
* (native-only) when omitted.
|
|
216
|
-
*/
|
|
217
|
-
getProviderScope?: () => ProviderScope;
|
|
218
202
|
/**
|
|
219
203
|
* Optional callback returning the default redirect URL to use for the widened
|
|
220
|
-
*
|
|
204
|
+
* quote fetch when the caller omits `redirectUrl`. The quotes API only
|
|
221
205
|
* embeds a `buyURL`/`buyWidget` (the WebView page a non-native provider needs)
|
|
222
206
|
* when a `redirectUrl` is present, so supplying this default lets widened
|
|
223
|
-
*
|
|
224
|
-
* widened path; an explicit caller `redirectUrl` always wins and
|
|
225
|
-
* never injects. Defaults to a callback returning
|
|
207
|
+
* aggregator quotes carry a usable widget URL. Only applied on the
|
|
208
|
+
* widened path; an explicit caller `redirectUrl` always wins and the
|
|
209
|
+
* native-only default never injects. Defaults to a callback returning
|
|
210
|
+
* `undefined` when omitted.
|
|
226
211
|
*/
|
|
227
212
|
getDefaultRedirectUrl?: () => string | undefined;
|
|
228
213
|
};
|
|
229
|
-
export declare function normalizeProviderCode(providerCode: string): string;
|
|
230
214
|
/**
|
|
231
215
|
* Returns the internal MetaMask order code used for state lookups and polling.
|
|
232
216
|
* Prefers the code embedded in the canonical order `id` path over `providerOrderId`,
|
|
@@ -257,13 +241,11 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
257
241
|
* controller. Missing properties will be filled in with defaults.
|
|
258
242
|
* @param args.requestCacheTTL - Time to live for cached requests in milliseconds.
|
|
259
243
|
* @param args.requestCacheMaxSize - Maximum number of entries in the request cache.
|
|
260
|
-
* @param args.getProviderScope - Optional callback returning the current
|
|
261
|
-
* provider-class scope for fiat quote widening. Defaults to `off`.
|
|
262
244
|
* @param args.getDefaultRedirectUrl - Optional callback returning the default
|
|
263
|
-
* redirect URL used for the widened
|
|
245
|
+
* redirect URL used for the widened quote fetch when the caller omits
|
|
264
246
|
* `redirectUrl`. Defaults to a callback returning `undefined`.
|
|
265
247
|
*/
|
|
266
|
-
constructor({ messenger, state, requestCacheTTL, requestCacheMaxSize,
|
|
248
|
+
constructor({ messenger, state, requestCacheTTL, requestCacheMaxSize, getDefaultRedirectUrl, }: RampsControllerOptions);
|
|
267
249
|
/**
|
|
268
250
|
* Executes a request with caching, deduplication, and at most one in-flight
|
|
269
251
|
* request per resource type.
|
|
@@ -509,7 +491,7 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
509
491
|
*
|
|
510
492
|
* @param params - Object containing order identifiers and wallet info.
|
|
511
493
|
* @param params.orderId - Full order ID (e.g. "/providers/paypal/orders/abc123") or order code.
|
|
512
|
-
* @param params.providerCode -
|
|
494
|
+
* @param params.providerCode - Canonical provider code (e.g. "paypal", "transak").
|
|
513
495
|
* @param params.walletAddress - Wallet address for the order.
|
|
514
496
|
* @param params.chainId - Optional chain ID for the order.
|
|
515
497
|
*/
|
|
@@ -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;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;
|
|
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;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,yCAAyC,EAAE,iDAAiD;AAM1G,OAAO,KAAK,EAAE,4BAA4B,EAAE,kDAA8C;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA0B;AAExD,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,cAAc,EACd,QAAQ,EACR,KAAK,EACL,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,KAAK,EAEL,UAAU,EACV,mBAAmB,EACnB,UAAU,EACX,2BAAuB;AACxB,OAAO,EAAE,gBAAgB,EAAE,2BAAuB;AAClD,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC9B,2BAA2B,EAC3B,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,EACjC,0BAA0B,EAC1B,sCAAsC,EACvC,+CAA2C;AAC5C,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,YAAY,EACZ,qBAAqB,EAGtB,2BAAuB;AAWxB,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,qCAAqC,EACrC,mBAAmB,EAC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,GACtB,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAahC;;;;;OAKG;IACG,qBAAqB,CACzB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,uBAAuB,CAAC;IAWnC;;;;;OAKG;IACG,uBAAuB,CAC3B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,oBAAoB,CAAC;IAYhC;;;;;OAKG;IACG,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY/D;;;;;OAKG;IACG,4BAA4B,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAStD;;;;OAIG;IACG,sBAAsB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;CAQxD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
|
|
2
2
|
import { BaseController } from "@metamask/base-controller";
|
|
3
3
|
import type { Messenger } from "@metamask/messenger";
|
|
4
|
+
import type { RemoteFeatureFlagControllerGetStateAction } from "@metamask/remote-feature-flag-controller";
|
|
4
5
|
import type { RampsControllerMethodActions } from "./RampsController-method-action-types.mjs";
|
|
5
6
|
import type { RampsErrorCode } from "./rampsErrorCodes.mjs";
|
|
6
7
|
import type { BuyWidget, Country, TokensResponse, Provider, State, RampAction, PaymentMethod, PaymentMethodsResponse, QuotesResponse, Quote, RampsToken, RampsServiceActions, RampsOrder } from "./RampsService.mjs";
|
|
@@ -157,7 +158,7 @@ export type RampsControllerActions = RampsControllerGetStateAction | RampsContro
|
|
|
157
158
|
/**
|
|
158
159
|
* Actions from other messengers that {@link RampsController} calls.
|
|
159
160
|
*/
|
|
160
|
-
type AllowedActions = RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction | RampsServiceGetBuyWidgetUrlAction | RampsServiceGetOrderAction | RampsServiceGetOrderFromCallbackAction | TransakServiceSetApiKeyAction | TransakServiceSetAccessTokenAction | TransakServiceClearAccessTokenAction | TransakServiceSendUserOtpAction | TransakServiceVerifyUserOtpAction | TransakServiceLogoutAction | TransakServiceGetUserDetailsAction | TransakServiceGetBuyQuoteAction | TransakServiceGetKycRequirementAction | TransakServiceGetAdditionalRequirementsAction | TransakServiceCreateOrderAction | TransakServiceGetOrderAction | TransakServiceGetUserLimitsAction | TransakServiceRequestOttAction | TransakServiceGeneratePaymentWidgetUrlAction | TransakServiceSubmitPurposeOfUsageFormAction | TransakServicePatchUserAction | TransakServiceSubmitSsnDetailsAction | TransakServiceConfirmPaymentAction | TransakServiceGetTranslationAction | TransakServiceGetIdProofStatusAction | TransakServiceCancelOrderAction | TransakServiceCancelAllActiveOrdersAction | TransakServiceGetActiveOrdersAction;
|
|
161
|
+
type AllowedActions = RemoteFeatureFlagControllerGetStateAction | RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction | RampsServiceGetBuyWidgetUrlAction | RampsServiceGetOrderAction | RampsServiceGetOrderFromCallbackAction | TransakServiceSetApiKeyAction | TransakServiceSetAccessTokenAction | TransakServiceClearAccessTokenAction | TransakServiceSendUserOtpAction | TransakServiceVerifyUserOtpAction | TransakServiceLogoutAction | TransakServiceGetUserDetailsAction | TransakServiceGetBuyQuoteAction | TransakServiceGetKycRequirementAction | TransakServiceGetAdditionalRequirementsAction | TransakServiceCreateOrderAction | TransakServiceGetOrderAction | TransakServiceGetUserLimitsAction | TransakServiceRequestOttAction | TransakServiceGeneratePaymentWidgetUrlAction | TransakServiceSubmitPurposeOfUsageFormAction | TransakServicePatchUserAction | TransakServiceSubmitSsnDetailsAction | TransakServiceConfirmPaymentAction | TransakServiceGetTranslationAction | TransakServiceGetIdProofStatusAction | TransakServiceCancelOrderAction | TransakServiceCancelAllActiveOrdersAction | TransakServiceGetActiveOrdersAction;
|
|
161
162
|
/**
|
|
162
163
|
* Published when the state of {@link RampsController} changes.
|
|
163
164
|
*/
|
|
@@ -189,16 +190,6 @@ export type RampsControllerMessenger = Messenger<typeof controllerName, RampsCon
|
|
|
189
190
|
/**
|
|
190
191
|
* Configuration options for the RampsController.
|
|
191
192
|
*/
|
|
192
|
-
/**
|
|
193
|
-
* Provider-class scope for fiat quote widening, resolved per `getQuotes` call.
|
|
194
|
-
*
|
|
195
|
-
* - `off`: native-only auto-selection (default; preserves prior behaviour).
|
|
196
|
-
* - `in-app`: also quote in-app WebView aggregator providers and select the
|
|
197
|
-
* best in-app quote.
|
|
198
|
-
* - `all`: additionally allow external-browser / custom-action providers
|
|
199
|
-
* (Phase 2).
|
|
200
|
-
*/
|
|
201
|
-
export type ProviderScope = 'off' | 'in-app' | 'all';
|
|
202
193
|
export type RampsControllerOptions = {
|
|
203
194
|
/** The messenger suited for this controller. */
|
|
204
195
|
messenger: RampsControllerMessenger;
|
|
@@ -208,25 +199,18 @@ export type RampsControllerOptions = {
|
|
|
208
199
|
requestCacheTTL?: number;
|
|
209
200
|
/** Maximum number of entries in the request cache. Defaults to 250. */
|
|
210
201
|
requestCacheMaxSize?: number;
|
|
211
|
-
/**
|
|
212
|
-
* Optional callback returning the current provider-class scope for fiat quote
|
|
213
|
-
* widening. Read per `getQuotes` call so a host-side toggle takes effect at
|
|
214
|
-
* runtime without reconstructing the controller. Defaults to `off`
|
|
215
|
-
* (native-only) when omitted.
|
|
216
|
-
*/
|
|
217
|
-
getProviderScope?: () => ProviderScope;
|
|
218
202
|
/**
|
|
219
203
|
* Optional callback returning the default redirect URL to use for the widened
|
|
220
|
-
*
|
|
204
|
+
* quote fetch when the caller omits `redirectUrl`. The quotes API only
|
|
221
205
|
* embeds a `buyURL`/`buyWidget` (the WebView page a non-native provider needs)
|
|
222
206
|
* when a `redirectUrl` is present, so supplying this default lets widened
|
|
223
|
-
*
|
|
224
|
-
* widened path; an explicit caller `redirectUrl` always wins and
|
|
225
|
-
* never injects. Defaults to a callback returning
|
|
207
|
+
* aggregator quotes carry a usable widget URL. Only applied on the
|
|
208
|
+
* widened path; an explicit caller `redirectUrl` always wins and the
|
|
209
|
+
* native-only default never injects. Defaults to a callback returning
|
|
210
|
+
* `undefined` when omitted.
|
|
226
211
|
*/
|
|
227
212
|
getDefaultRedirectUrl?: () => string | undefined;
|
|
228
213
|
};
|
|
229
|
-
export declare function normalizeProviderCode(providerCode: string): string;
|
|
230
214
|
/**
|
|
231
215
|
* Returns the internal MetaMask order code used for state lookups and polling.
|
|
232
216
|
* Prefers the code embedded in the canonical order `id` path over `providerOrderId`,
|
|
@@ -257,13 +241,11 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
257
241
|
* controller. Missing properties will be filled in with defaults.
|
|
258
242
|
* @param args.requestCacheTTL - Time to live for cached requests in milliseconds.
|
|
259
243
|
* @param args.requestCacheMaxSize - Maximum number of entries in the request cache.
|
|
260
|
-
* @param args.getProviderScope - Optional callback returning the current
|
|
261
|
-
* provider-class scope for fiat quote widening. Defaults to `off`.
|
|
262
244
|
* @param args.getDefaultRedirectUrl - Optional callback returning the default
|
|
263
|
-
* redirect URL used for the widened
|
|
245
|
+
* redirect URL used for the widened quote fetch when the caller omits
|
|
264
246
|
* `redirectUrl`. Defaults to a callback returning `undefined`.
|
|
265
247
|
*/
|
|
266
|
-
constructor({ messenger, state, requestCacheTTL, requestCacheMaxSize,
|
|
248
|
+
constructor({ messenger, state, requestCacheTTL, requestCacheMaxSize, getDefaultRedirectUrl, }: RampsControllerOptions);
|
|
267
249
|
/**
|
|
268
250
|
* Executes a request with caching, deduplication, and at most one in-flight
|
|
269
251
|
* request per resource type.
|
|
@@ -509,7 +491,7 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
509
491
|
*
|
|
510
492
|
* @param params - Object containing order identifiers and wallet info.
|
|
511
493
|
* @param params.orderId - Full order ID (e.g. "/providers/paypal/orders/abc123") or order code.
|
|
512
|
-
* @param params.providerCode -
|
|
494
|
+
* @param params.providerCode - Canonical provider code (e.g. "paypal", "transak").
|
|
513
495
|
* @param params.walletAddress - Wallet address for the order.
|
|
514
496
|
* @param params.chainId - Optional chain ID for the order.
|
|
515
497
|
*/
|
|
@@ -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;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;
|
|
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;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,yCAAyC,EAAE,iDAAiD;AAM1G,OAAO,KAAK,EAAE,4BAA4B,EAAE,kDAA8C;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA0B;AAExD,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,cAAc,EACd,QAAQ,EACR,KAAK,EACL,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,KAAK,EAEL,UAAU,EACV,mBAAmB,EACnB,UAAU,EACX,2BAAuB;AACxB,OAAO,EAAE,gBAAgB,EAAE,2BAAuB;AAClD,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC9B,2BAA2B,EAC3B,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,EACjC,0BAA0B,EAC1B,sCAAsC,EACvC,+CAA2C;AAC5C,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,YAAY,EACZ,qBAAq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AO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC;IAanB;;;;;;OAMG;IACG,qBAAqB,CACzB,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAahC;;;;;OAKG;IACG,qBAAqB,CACzB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,uBAAuB,CAAC;IAWnC;;;;;OAKG;IACG,uBAAuB,CAC3B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,oBAAoB,CAAC;IAYhC;;;;;OAKG;IACG,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY/D;;;;;OAKG;IACG,4BAA4B,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAStD;;;;OAIG;IACG,sBAAsB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;CAQxD"}
|
package/dist/RampsController.mjs
CHANGED
|
@@ -9,9 +9,11 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
|
-
var _RampsController_instances, _RampsController_requestCacheTTL, _RampsController_requestCacheMaxSize,
|
|
12
|
+
var _RampsController_instances, _RampsController_requestCacheTTL, _RampsController_requestCacheMaxSize, _RampsController_getDefaultRedirectUrl, _RampsController_pendingRequests, _RampsController_pendingResourceCount, _RampsController_pendingResourceGeneration, _RampsController_orderPollingMeta, _RampsController_orderPollingTimer, _RampsController_isPolling, _RampsController_initPromise, _RampsController_clearPendingResourceCountForDependentResources, _RampsController_abortDependentRequests, _RampsController_isAllProvidersEnabled, _RampsController_mutateRequests, _RampsController_removeRequestState, _RampsController_cleanupState, _RampsController_requireRegion, _RampsController_isRegionCurrent, _RampsController_isTokenCurrent, _RampsController_isProviderCurrent, _RampsController_updateResourceField, _RampsController_setResourceLoading, _RampsController_setResourceError, _RampsController_updateRequestState, _RampsController_runInit, _RampsController_syncUserRegionFromCountriesCatalog, _RampsController_pickWidenedQuote, _RampsController_getSupportingProvidersForRegion, _RampsController_filterProviderIdsBySupport, _RampsController_resolveProviderIdsForQuote, _RampsController_getPreferredProviderIdsFromOrders, _RampsController_refreshOrder, _RampsController_pollPendingOrders, _RampsController_syncTransakAuthOnError, _RampsController_getNormalizedTransakError;
|
|
13
13
|
import { BaseController } from "@metamask/base-controller";
|
|
14
14
|
import { BrokenCircuitError } from "@metamask/controller-utils";
|
|
15
|
+
import { isHeadlessAllProvidersEnabled } from "./featureFlags.mjs";
|
|
16
|
+
import { getProvidersServingAsset } from "./providerAvailability.mjs";
|
|
15
17
|
import { RAMPS_ERROR_CODES } from "./rampsErrorCodes.mjs";
|
|
16
18
|
import { RampsOrderStatus } from "./RampsService.mjs";
|
|
17
19
|
import { DEFAULT_REQUEST_CACHE_TTL, DEFAULT_REQUEST_CACHE_MAX_SIZE, createCacheKey, isCacheExpired, createLoadingState, createSuccessState, createErrorState, RequestStatus } from "./RequestCache.mjs";
|
|
@@ -325,9 +327,6 @@ function findRegionFromCode(regionCode, countries) {
|
|
|
325
327
|
regionCode: normalizedCode,
|
|
326
328
|
};
|
|
327
329
|
}
|
|
328
|
-
export function normalizeProviderCode(providerCode) {
|
|
329
|
-
return providerCode.replace(/^\/providers\//u, '');
|
|
330
|
-
}
|
|
331
330
|
/**
|
|
332
331
|
* Returns the internal MetaMask order code used for state lookups and polling.
|
|
333
332
|
* Prefers the code embedded in the canonical order `id` path over `providerOrderId`,
|
|
@@ -435,13 +434,11 @@ export class RampsController extends BaseController {
|
|
|
435
434
|
* controller. Missing properties will be filled in with defaults.
|
|
436
435
|
* @param args.requestCacheTTL - Time to live for cached requests in milliseconds.
|
|
437
436
|
* @param args.requestCacheMaxSize - Maximum number of entries in the request cache.
|
|
438
|
-
* @param args.getProviderScope - Optional callback returning the current
|
|
439
|
-
* provider-class scope for fiat quote widening. Defaults to `off`.
|
|
440
437
|
* @param args.getDefaultRedirectUrl - Optional callback returning the default
|
|
441
|
-
* redirect URL used for the widened
|
|
438
|
+
* redirect URL used for the widened quote fetch when the caller omits
|
|
442
439
|
* `redirectUrl`. Defaults to a callback returning `undefined`.
|
|
443
440
|
*/
|
|
444
|
-
constructor({ messenger, state = {}, requestCacheTTL = DEFAULT_REQUEST_CACHE_TTL, requestCacheMaxSize = DEFAULT_REQUEST_CACHE_MAX_SIZE,
|
|
441
|
+
constructor({ messenger, state = {}, requestCacheTTL = DEFAULT_REQUEST_CACHE_TTL, requestCacheMaxSize = DEFAULT_REQUEST_CACHE_MAX_SIZE, getDefaultRedirectUrl, }) {
|
|
445
442
|
super({
|
|
446
443
|
messenger,
|
|
447
444
|
metadata: rampsControllerMetadata,
|
|
@@ -463,12 +460,7 @@ export class RampsController extends BaseController {
|
|
|
463
460
|
*/
|
|
464
461
|
_RampsController_requestCacheMaxSize.set(this, void 0);
|
|
465
462
|
/**
|
|
466
|
-
* Resolves the
|
|
467
|
-
* to `() => 'off'` (native-only) when no callback is injected.
|
|
468
|
-
*/
|
|
469
|
-
_RampsController_getProviderScope.set(this, void 0);
|
|
470
|
-
/**
|
|
471
|
-
* Resolves the default redirect URL for the widened in-app quote fetch when
|
|
463
|
+
* Resolves the default redirect URL for the widened quote fetch when
|
|
472
464
|
* the caller omits `redirectUrl`. Defaults to `() => undefined` when no
|
|
473
465
|
* callback is injected.
|
|
474
466
|
*/
|
|
@@ -494,7 +486,6 @@ export class RampsController extends BaseController {
|
|
|
494
486
|
_RampsController_initPromise.set(this, null);
|
|
495
487
|
__classPrivateFieldSet(this, _RampsController_requestCacheTTL, requestCacheTTL, "f");
|
|
496
488
|
__classPrivateFieldSet(this, _RampsController_requestCacheMaxSize, requestCacheMaxSize, "f");
|
|
497
|
-
__classPrivateFieldSet(this, _RampsController_getProviderScope, getProviderScope ?? (() => 'off'), "f");
|
|
498
489
|
__classPrivateFieldSet(this, _RampsController_getDefaultRedirectUrl, getDefaultRedirectUrl ?? (() => undefined), "f");
|
|
499
490
|
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
500
491
|
}
|
|
@@ -1010,19 +1001,17 @@ export class RampsController extends BaseController {
|
|
|
1010
1001
|
if (normalizedAssetIdForValidation === '') {
|
|
1011
1002
|
throw new Error('assetId is required.');
|
|
1012
1003
|
}
|
|
1013
|
-
// When
|
|
1014
|
-
// auto-selection path to every supporting provider and pick the best
|
|
1015
|
-
// quote from the results
|
|
1016
|
-
// `buyWidget.browser`). Only the auto-select/restrict path that MM Pay's
|
|
1004
|
+
// When the all-providers feature flag is enabled, widen the native-only
|
|
1005
|
+
// auto-selection path to every supporting provider and pick the best
|
|
1006
|
+
// quote from the results. Only the auto-select/restrict path that MM Pay's
|
|
1017
1007
|
// `getRampsQuote` uses is affected; explicit-`providers` callers and the
|
|
1018
|
-
// plain all-provider path are untouched.
|
|
1019
|
-
const
|
|
1020
|
-
const widenToInAppProviders = providerScope !== 'off' &&
|
|
1021
|
-
!options.providers &&
|
|
1008
|
+
// plain all-provider path are untouched (and never read the flag).
|
|
1009
|
+
const wantsAutoSelection = !options.providers &&
|
|
1022
1010
|
(options.autoSelectProvider === true ||
|
|
1023
1011
|
options.restrictToKnownOrNativeProviders === true);
|
|
1012
|
+
const widenToAllProviders = wantsAutoSelection && __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_isAllProvidersEnabled).call(this);
|
|
1024
1013
|
let providersToUse;
|
|
1025
|
-
let
|
|
1014
|
+
let widenedProviderCatalog = this.state.providers.data;
|
|
1026
1015
|
if (options.providers) {
|
|
1027
1016
|
providersToUse = options.restrictToKnownOrNativeProviders
|
|
1028
1017
|
? await __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_filterProviderIdsBySupport).call(this, {
|
|
@@ -1032,7 +1021,7 @@ export class RampsController extends BaseController {
|
|
|
1032
1021
|
})
|
|
1033
1022
|
: options.providers;
|
|
1034
1023
|
}
|
|
1035
|
-
else if (
|
|
1024
|
+
else if (widenToAllProviders) {
|
|
1036
1025
|
// `#getSupportingProvidersForRegion` also hydrates the provider catalog
|
|
1037
1026
|
// when controller state is empty, so all-provider quoting cannot silently
|
|
1038
1027
|
// return zero providers here.
|
|
@@ -1040,7 +1029,7 @@ export class RampsController extends BaseController {
|
|
|
1040
1029
|
assetId: normalizedAssetIdForValidation,
|
|
1041
1030
|
region: regionToUse,
|
|
1042
1031
|
});
|
|
1043
|
-
|
|
1032
|
+
widenedProviderCatalog = supporting;
|
|
1044
1033
|
providersToUse = supporting.map((provider) => provider.id);
|
|
1045
1034
|
}
|
|
1046
1035
|
else if (options.autoSelectProvider ||
|
|
@@ -1072,12 +1061,12 @@ export class RampsController extends BaseController {
|
|
|
1072
1061
|
// Under headless-buy gating, an empty resolved provider list means no
|
|
1073
1062
|
// eligible (native/supporting) provider exists. Return an empty response
|
|
1074
1063
|
// rather than passing `[]` to the service, which omits the provider filter
|
|
1075
|
-
// and would quote every provider. This also guards the widened
|
|
1064
|
+
// and would quote every provider. This also guards the widened path:
|
|
1076
1065
|
// a caller may trigger widening with `autoSelectProvider` alone (no
|
|
1077
1066
|
// `restrictToKnownOrNativeProviders`), and an empty supporting set must not
|
|
1078
1067
|
// fall through to unfiltered quotes from providers that do not support the
|
|
1079
1068
|
// asset.
|
|
1080
|
-
if ((options.restrictToKnownOrNativeProviders ||
|
|
1069
|
+
if ((options.restrictToKnownOrNativeProviders || widenToAllProviders) &&
|
|
1081
1070
|
providersToUse.length === 0) {
|
|
1082
1071
|
return { success: [], sorted: [], error: [], customActions: [] };
|
|
1083
1072
|
}
|
|
@@ -1086,11 +1075,12 @@ export class RampsController extends BaseController {
|
|
|
1086
1075
|
const normalizedAssetId = normalizedAssetIdForValidation;
|
|
1087
1076
|
const normalizedWalletAddress = options.walletAddress.trim();
|
|
1088
1077
|
// The quotes API only embeds a `buyURL`/`buyWidget` when a `redirectUrl` is
|
|
1089
|
-
// present, so on the widened
|
|
1078
|
+
// present, so on the widened path (where MM Pay omits one) supply the
|
|
1090
1079
|
// injected default so aggregator quotes carry a usable widget URL. An
|
|
1091
|
-
// explicit caller `redirectUrl` always wins, and
|
|
1080
|
+
// explicit caller `redirectUrl` always wins, and the native-only path
|
|
1081
|
+
// (flag off) never injects.
|
|
1092
1082
|
const effectiveRedirectUrl = options.redirectUrl ??
|
|
1093
|
-
(
|
|
1083
|
+
(widenToAllProviders ? __classPrivateFieldGet(this, _RampsController_getDefaultRedirectUrl, "f").call(this) : undefined);
|
|
1094
1084
|
const cacheKey = createCacheKey('getQuotes', [
|
|
1095
1085
|
normalizedRegion,
|
|
1096
1086
|
normalizedFiat,
|
|
@@ -1119,22 +1109,21 @@ export class RampsController extends BaseController {
|
|
|
1119
1109
|
forceRefresh: options.forceRefresh,
|
|
1120
1110
|
ttl: options.ttl ?? DEFAULT_QUOTES_TTL,
|
|
1121
1111
|
});
|
|
1122
|
-
if (!
|
|
1112
|
+
if (!widenToAllProviders) {
|
|
1123
1113
|
return response;
|
|
1124
1114
|
}
|
|
1125
|
-
// Reduce the widened multi-provider result to the single best
|
|
1115
|
+
// Reduce the widened multi-provider result to the single best quote
|
|
1126
1116
|
// and place it at `success[0]`, since single-pick consumers
|
|
1127
1117
|
// (`getRampsQuote` -> `success?.[0]`) rely on index 0 while `success[]`
|
|
1128
1118
|
// order is server-defined rather than ranked.
|
|
1129
|
-
const selectedQuote = __classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1130
|
-
scope: providerScope,
|
|
1119
|
+
const selectedQuote = __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_pickWidenedQuote).call(this, response, {
|
|
1131
1120
|
amount: options.amount,
|
|
1132
1121
|
fiat: normalizedFiat,
|
|
1133
|
-
providers:
|
|
1122
|
+
providers: widenedProviderCatalog,
|
|
1134
1123
|
});
|
|
1135
1124
|
if (!selectedQuote) {
|
|
1136
|
-
// No
|
|
1137
|
-
//
|
|
1125
|
+
// No quote fits the published provider limits: surface "no quote"
|
|
1126
|
+
// rather than handing the single-pick consumer an out-of-limits quote.
|
|
1138
1127
|
return {
|
|
1139
1128
|
success: [],
|
|
1140
1129
|
sorted: response.sorted,
|
|
@@ -1247,7 +1236,7 @@ export class RampsController extends BaseController {
|
|
|
1247
1236
|
*
|
|
1248
1237
|
* @param params - Object containing order identifiers and wallet info.
|
|
1249
1238
|
* @param params.orderId - Full order ID (e.g. "/providers/paypal/orders/abc123") or order code.
|
|
1250
|
-
* @param params.providerCode -
|
|
1239
|
+
* @param params.providerCode - Canonical provider code (e.g. "paypal", "transak").
|
|
1251
1240
|
* @param params.walletAddress - Wallet address for the order.
|
|
1252
1241
|
* @param params.chainId - Optional chain ID for the order.
|
|
1253
1242
|
*/
|
|
@@ -1257,11 +1246,10 @@ export class RampsController extends BaseController {
|
|
|
1257
1246
|
if (!orderCode?.trim()) {
|
|
1258
1247
|
return;
|
|
1259
1248
|
}
|
|
1260
|
-
const normalizedProviderCode = normalizeProviderCode(providerCode);
|
|
1261
1249
|
const stubOrder = {
|
|
1262
1250
|
providerOrderId: orderCode,
|
|
1263
1251
|
provider: {
|
|
1264
|
-
id:
|
|
1252
|
+
id: providerCode,
|
|
1265
1253
|
name: '',
|
|
1266
1254
|
environmentType: '',
|
|
1267
1255
|
description: '',
|
|
@@ -1764,7 +1752,7 @@ export class RampsController extends BaseController {
|
|
|
1764
1752
|
}
|
|
1765
1753
|
}
|
|
1766
1754
|
}
|
|
1767
|
-
_RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheMaxSize = new WeakMap(),
|
|
1755
|
+
_RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheMaxSize = new WeakMap(), _RampsController_getDefaultRedirectUrl = new WeakMap(), _RampsController_pendingRequests = new WeakMap(), _RampsController_pendingResourceCount = new WeakMap(), _RampsController_pendingResourceGeneration = new WeakMap(), _RampsController_orderPollingMeta = new WeakMap(), _RampsController_orderPollingTimer = new WeakMap(), _RampsController_isPolling = new WeakMap(), _RampsController_initPromise = new WeakMap(), _RampsController_instances = new WeakSet(), _RampsController_clearPendingResourceCountForDependentResources = function _RampsController_clearPendingResourceCountForDependentResources() {
|
|
1768
1756
|
for (const resourceType of DEPENDENT_RESOURCE_KEYS) {
|
|
1769
1757
|
__classPrivateFieldGet(this, _RampsController_pendingResourceCount, "f").delete(resourceType);
|
|
1770
1758
|
const generation = __classPrivateFieldGet(this, _RampsController_pendingResourceGeneration, "f").get(resourceType) ?? 0;
|
|
@@ -1779,6 +1767,14 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
|
|
|
1779
1767
|
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_removeRequestState).call(this, cacheKey);
|
|
1780
1768
|
}
|
|
1781
1769
|
}
|
|
1770
|
+
}, _RampsController_isAllProvidersEnabled = function _RampsController_isAllProvidersEnabled() {
|
|
1771
|
+
try {
|
|
1772
|
+
const remoteFeatureFlagState = this.messenger.call('RemoteFeatureFlagController:getState');
|
|
1773
|
+
return isHeadlessAllProvidersEnabled(remoteFeatureFlagState);
|
|
1774
|
+
}
|
|
1775
|
+
catch {
|
|
1776
|
+
return false;
|
|
1777
|
+
}
|
|
1782
1778
|
}, _RampsController_mutateRequests = function _RampsController_mutateRequests(fn) {
|
|
1783
1779
|
this.update((state) => {
|
|
1784
1780
|
const requests = state.requests;
|
|
@@ -1890,14 +1886,10 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
|
|
|
1890
1886
|
this.update((state) => {
|
|
1891
1887
|
state.userRegion = userRegion;
|
|
1892
1888
|
});
|
|
1893
|
-
},
|
|
1894
|
-
const providerByCode = new Map(providers.map((provider) => [
|
|
1895
|
-
normalizeProviderCode(provider.id),
|
|
1896
|
-
provider,
|
|
1897
|
-
]));
|
|
1898
|
-
const customActionProviderCodes = new Set(response.customActions.map((action) => normalizeProviderCode(action.buy.providerId)));
|
|
1889
|
+
}, _RampsController_pickWidenedQuote = function _RampsController_pickWidenedQuote(response, { amount, fiat, providers, }) {
|
|
1890
|
+
const providerByCode = new Map(providers.map((provider) => [provider.id, provider]));
|
|
1899
1891
|
const fitsProviderLimits = (quote) => {
|
|
1900
|
-
const provider = providerByCode.get(
|
|
1892
|
+
const provider = providerByCode.get(quote.provider);
|
|
1901
1893
|
const limit = provider?.limits?.fiat?.[fiat]?.[quote.quote.paymentMethod];
|
|
1902
1894
|
if (!limit) {
|
|
1903
1895
|
// No published limits for this provider/payment method: treat as
|
|
@@ -1906,37 +1898,18 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
|
|
|
1906
1898
|
}
|
|
1907
1899
|
return amount >= limit.minAmount && amount <= limit.maxAmount;
|
|
1908
1900
|
};
|
|
1909
|
-
const
|
|
1910
|
-
// `all` (Phase 2) skips the in-app-only exclusions; both scopes still
|
|
1911
|
-
// enforce provider limits up front.
|
|
1912
|
-
if (scope !== 'all') {
|
|
1913
|
-
const providerCode = normalizeProviderCode(quote.provider);
|
|
1914
|
-
if (customActionProviderCodes.has(providerCode)) {
|
|
1915
|
-
return false;
|
|
1916
|
-
}
|
|
1917
|
-
// Defensive: the wire may carry an inline `isCustomAction` flag that is
|
|
1918
|
-
// absent from the published `Quote` type.
|
|
1919
|
-
if (quote.quote.isCustomAction === true) {
|
|
1920
|
-
return false;
|
|
1921
|
-
}
|
|
1922
|
-
if (quote.quote.buyWidget?.browser === 'IN_APP_OS_BROWSER') {
|
|
1923
|
-
return false;
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
return fitsProviderLimits(quote);
|
|
1927
|
-
};
|
|
1928
|
-
const candidates = response.success.filter(isEligible);
|
|
1901
|
+
const candidates = response.success.filter(fitsProviderLimits);
|
|
1929
1902
|
if (candidates.length === 0) {
|
|
1930
1903
|
return undefined;
|
|
1931
1904
|
}
|
|
1932
|
-
const candidateByCode = new Map(candidates.map((quote) => [
|
|
1905
|
+
const candidateByCode = new Map(candidates.map((quote) => [quote.provider, quote]));
|
|
1933
1906
|
const pickBySortOrder = (sortBy) => {
|
|
1934
1907
|
const order = response.sorted.find((entry) => entry.sortBy === sortBy)?.ids;
|
|
1935
1908
|
if (!order) {
|
|
1936
1909
|
return undefined;
|
|
1937
1910
|
}
|
|
1938
1911
|
for (const providerId of order) {
|
|
1939
|
-
const match = candidateByCode.get(
|
|
1912
|
+
const match = candidateByCode.get(providerId);
|
|
1940
1913
|
if (match) {
|
|
1941
1914
|
return match;
|
|
1942
1915
|
}
|
|
@@ -1970,18 +1943,10 @@ async function _RampsController_getSupportingProvidersForRegion({ assetId, regio
|
|
|
1970
1943
|
else {
|
|
1971
1944
|
({ providers } = await this.getProviders(normalizedRegion));
|
|
1972
1945
|
}
|
|
1973
|
-
//
|
|
1974
|
-
//
|
|
1975
|
-
//
|
|
1976
|
-
|
|
1977
|
-
const normalizedAssetId = assetId.toLowerCase();
|
|
1978
|
-
const supporting = providers.filter((provider) => {
|
|
1979
|
-
const map = provider?.supportedCryptoCurrencies;
|
|
1980
|
-
if (!map) {
|
|
1981
|
-
return false;
|
|
1982
|
-
}
|
|
1983
|
-
return Object.keys(map).some((key) => key.toLowerCase() === normalizedAssetId);
|
|
1984
|
-
});
|
|
1946
|
+
// Case-insensitive CAIP-19 matching is shared with headless-buy consumers
|
|
1947
|
+
// via `getProvidersServingAsset`, so the controller and the UI region gate
|
|
1948
|
+
// cannot disagree about which providers serve the asset.
|
|
1949
|
+
const supporting = getProvidersServingAsset(providers, assetId);
|
|
1985
1950
|
return { supporting, all: providers };
|
|
1986
1951
|
}, _RampsController_filterProviderIdsBySupport =
|
|
1987
1952
|
/**
|