@metamask/ramps-controller 16.0.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 +20 -1
- package/dist/RampsController.cjs +42 -70
- package/dist/RampsController.cjs.map +1 -1
- package/dist/RampsController.d.cts +9 -26
- package/dist/RampsController.d.cts.map +1 -1
- package/dist/RampsController.d.mts +9 -26
- package/dist/RampsController.d.mts.map +1 -1
- package/dist/RampsController.mjs +42 -70
- 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 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -0
- 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,21 +199,15 @@ 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
|
};
|
|
@@ -256,13 +241,11 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
256
241
|
* controller. Missing properties will be filled in with defaults.
|
|
257
242
|
* @param args.requestCacheTTL - Time to live for cached requests in milliseconds.
|
|
258
243
|
* @param args.requestCacheMaxSize - Maximum number of entries in the request cache.
|
|
259
|
-
* @param args.getProviderScope - Optional callback returning the current
|
|
260
|
-
* provider-class scope for fiat quote widening. Defaults to `off`.
|
|
261
244
|
* @param args.getDefaultRedirectUrl - Optional callback returning the default
|
|
262
|
-
* redirect URL used for the widened
|
|
245
|
+
* redirect URL used for the widened quote fetch when the caller omits
|
|
263
246
|
* `redirectUrl`. Defaults to a callback returning `undefined`.
|
|
264
247
|
*/
|
|
265
|
-
constructor({ messenger, state, requestCacheTTL, requestCacheMaxSize,
|
|
248
|
+
constructor({ messenger, state, requestCacheTTL, requestCacheMaxSize, getDefaultRedirectUrl, }: RampsControllerOptions);
|
|
266
249
|
/**
|
|
267
250
|
* Executes a request with caching, deduplication, and at most one in-flight
|
|
268
251
|
* request per resource type.
|
|
@@ -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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B;;;;OAIG;IACG,iBAAiB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAStD;;;;;;;;OAQG;IACH,+BAA+B,CAC7B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,eAAe,EACtB,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACnC,MAAM;IAUT;;;;;OAKG;IACG,+BAA+B,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAYvE;;;;;OAKG;IACG,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IASpE;;;;;;OAMG;IACG,uBAAuB,CAC3B,GAAG,EAAE,MAAM,EACX,OAAO,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"}
|
|
@@ -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,21 +199,15 @@ 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
|
};
|
|
@@ -256,13 +241,11 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
256
241
|
* controller. Missing properties will be filled in with defaults.
|
|
257
242
|
* @param args.requestCacheTTL - Time to live for cached requests in milliseconds.
|
|
258
243
|
* @param args.requestCacheMaxSize - Maximum number of entries in the request cache.
|
|
259
|
-
* @param args.getProviderScope - Optional callback returning the current
|
|
260
|
-
* provider-class scope for fiat quote widening. Defaults to `off`.
|
|
261
244
|
* @param args.getDefaultRedirectUrl - Optional callback returning the default
|
|
262
|
-
* redirect URL used for the widened
|
|
245
|
+
* redirect URL used for the widened quote fetch when the caller omits
|
|
263
246
|
* `redirectUrl`. Defaults to a callback returning `undefined`.
|
|
264
247
|
*/
|
|
265
|
-
constructor({ messenger, state, requestCacheTTL, requestCacheMaxSize,
|
|
248
|
+
constructor({ messenger, state, requestCacheTTL, requestCacheMaxSize, getDefaultRedirectUrl, }: RampsControllerOptions);
|
|
266
249
|
/**
|
|
267
250
|
* Executes a request with caching, deduplication, and at most one in-flight
|
|
268
251
|
* request per resource type.
|
|
@@ -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,i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CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IASpE;;;;;;OAMG;IACG,uBAAuB,CAC3B,GAAG,EAAE,MAAM,EACX,OAAO,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";
|
|
@@ -432,13 +434,11 @@ export class RampsController extends BaseController {
|
|
|
432
434
|
* controller. Missing properties will be filled in with defaults.
|
|
433
435
|
* @param args.requestCacheTTL - Time to live for cached requests in milliseconds.
|
|
434
436
|
* @param args.requestCacheMaxSize - Maximum number of entries in the request cache.
|
|
435
|
-
* @param args.getProviderScope - Optional callback returning the current
|
|
436
|
-
* provider-class scope for fiat quote widening. Defaults to `off`.
|
|
437
437
|
* @param args.getDefaultRedirectUrl - Optional callback returning the default
|
|
438
|
-
* redirect URL used for the widened
|
|
438
|
+
* redirect URL used for the widened quote fetch when the caller omits
|
|
439
439
|
* `redirectUrl`. Defaults to a callback returning `undefined`.
|
|
440
440
|
*/
|
|
441
|
-
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, }) {
|
|
442
442
|
super({
|
|
443
443
|
messenger,
|
|
444
444
|
metadata: rampsControllerMetadata,
|
|
@@ -460,12 +460,7 @@ export class RampsController extends BaseController {
|
|
|
460
460
|
*/
|
|
461
461
|
_RampsController_requestCacheMaxSize.set(this, void 0);
|
|
462
462
|
/**
|
|
463
|
-
* Resolves the
|
|
464
|
-
* to `() => 'off'` (native-only) when no callback is injected.
|
|
465
|
-
*/
|
|
466
|
-
_RampsController_getProviderScope.set(this, void 0);
|
|
467
|
-
/**
|
|
468
|
-
* 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
|
|
469
464
|
* the caller omits `redirectUrl`. Defaults to `() => undefined` when no
|
|
470
465
|
* callback is injected.
|
|
471
466
|
*/
|
|
@@ -491,7 +486,6 @@ export class RampsController extends BaseController {
|
|
|
491
486
|
_RampsController_initPromise.set(this, null);
|
|
492
487
|
__classPrivateFieldSet(this, _RampsController_requestCacheTTL, requestCacheTTL, "f");
|
|
493
488
|
__classPrivateFieldSet(this, _RampsController_requestCacheMaxSize, requestCacheMaxSize, "f");
|
|
494
|
-
__classPrivateFieldSet(this, _RampsController_getProviderScope, getProviderScope ?? (() => 'off'), "f");
|
|
495
489
|
__classPrivateFieldSet(this, _RampsController_getDefaultRedirectUrl, getDefaultRedirectUrl ?? (() => undefined), "f");
|
|
496
490
|
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
497
491
|
}
|
|
@@ -1007,19 +1001,17 @@ export class RampsController extends BaseController {
|
|
|
1007
1001
|
if (normalizedAssetIdForValidation === '') {
|
|
1008
1002
|
throw new Error('assetId is required.');
|
|
1009
1003
|
}
|
|
1010
|
-
// When
|
|
1011
|
-
// auto-selection path to every supporting provider and pick the best
|
|
1012
|
-
// quote from the results
|
|
1013
|
-
// `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
|
|
1014
1007
|
// `getRampsQuote` uses is affected; explicit-`providers` callers and the
|
|
1015
|
-
// plain all-provider path are untouched.
|
|
1016
|
-
const
|
|
1017
|
-
const widenToInAppProviders = providerScope !== 'off' &&
|
|
1018
|
-
!options.providers &&
|
|
1008
|
+
// plain all-provider path are untouched (and never read the flag).
|
|
1009
|
+
const wantsAutoSelection = !options.providers &&
|
|
1019
1010
|
(options.autoSelectProvider === true ||
|
|
1020
1011
|
options.restrictToKnownOrNativeProviders === true);
|
|
1012
|
+
const widenToAllProviders = wantsAutoSelection && __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_isAllProvidersEnabled).call(this);
|
|
1021
1013
|
let providersToUse;
|
|
1022
|
-
let
|
|
1014
|
+
let widenedProviderCatalog = this.state.providers.data;
|
|
1023
1015
|
if (options.providers) {
|
|
1024
1016
|
providersToUse = options.restrictToKnownOrNativeProviders
|
|
1025
1017
|
? await __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_filterProviderIdsBySupport).call(this, {
|
|
@@ -1029,7 +1021,7 @@ export class RampsController extends BaseController {
|
|
|
1029
1021
|
})
|
|
1030
1022
|
: options.providers;
|
|
1031
1023
|
}
|
|
1032
|
-
else if (
|
|
1024
|
+
else if (widenToAllProviders) {
|
|
1033
1025
|
// `#getSupportingProvidersForRegion` also hydrates the provider catalog
|
|
1034
1026
|
// when controller state is empty, so all-provider quoting cannot silently
|
|
1035
1027
|
// return zero providers here.
|
|
@@ -1037,7 +1029,7 @@ export class RampsController extends BaseController {
|
|
|
1037
1029
|
assetId: normalizedAssetIdForValidation,
|
|
1038
1030
|
region: regionToUse,
|
|
1039
1031
|
});
|
|
1040
|
-
|
|
1032
|
+
widenedProviderCatalog = supporting;
|
|
1041
1033
|
providersToUse = supporting.map((provider) => provider.id);
|
|
1042
1034
|
}
|
|
1043
1035
|
else if (options.autoSelectProvider ||
|
|
@@ -1069,12 +1061,12 @@ export class RampsController extends BaseController {
|
|
|
1069
1061
|
// Under headless-buy gating, an empty resolved provider list means no
|
|
1070
1062
|
// eligible (native/supporting) provider exists. Return an empty response
|
|
1071
1063
|
// rather than passing `[]` to the service, which omits the provider filter
|
|
1072
|
-
// and would quote every provider. This also guards the widened
|
|
1064
|
+
// and would quote every provider. This also guards the widened path:
|
|
1073
1065
|
// a caller may trigger widening with `autoSelectProvider` alone (no
|
|
1074
1066
|
// `restrictToKnownOrNativeProviders`), and an empty supporting set must not
|
|
1075
1067
|
// fall through to unfiltered quotes from providers that do not support the
|
|
1076
1068
|
// asset.
|
|
1077
|
-
if ((options.restrictToKnownOrNativeProviders ||
|
|
1069
|
+
if ((options.restrictToKnownOrNativeProviders || widenToAllProviders) &&
|
|
1078
1070
|
providersToUse.length === 0) {
|
|
1079
1071
|
return { success: [], sorted: [], error: [], customActions: [] };
|
|
1080
1072
|
}
|
|
@@ -1083,11 +1075,12 @@ export class RampsController extends BaseController {
|
|
|
1083
1075
|
const normalizedAssetId = normalizedAssetIdForValidation;
|
|
1084
1076
|
const normalizedWalletAddress = options.walletAddress.trim();
|
|
1085
1077
|
// The quotes API only embeds a `buyURL`/`buyWidget` when a `redirectUrl` is
|
|
1086
|
-
// present, so on the widened
|
|
1078
|
+
// present, so on the widened path (where MM Pay omits one) supply the
|
|
1087
1079
|
// injected default so aggregator quotes carry a usable widget URL. An
|
|
1088
|
-
// explicit caller `redirectUrl` always wins, and
|
|
1080
|
+
// explicit caller `redirectUrl` always wins, and the native-only path
|
|
1081
|
+
// (flag off) never injects.
|
|
1089
1082
|
const effectiveRedirectUrl = options.redirectUrl ??
|
|
1090
|
-
(
|
|
1083
|
+
(widenToAllProviders ? __classPrivateFieldGet(this, _RampsController_getDefaultRedirectUrl, "f").call(this) : undefined);
|
|
1091
1084
|
const cacheKey = createCacheKey('getQuotes', [
|
|
1092
1085
|
normalizedRegion,
|
|
1093
1086
|
normalizedFiat,
|
|
@@ -1116,22 +1109,21 @@ export class RampsController extends BaseController {
|
|
|
1116
1109
|
forceRefresh: options.forceRefresh,
|
|
1117
1110
|
ttl: options.ttl ?? DEFAULT_QUOTES_TTL,
|
|
1118
1111
|
});
|
|
1119
|
-
if (!
|
|
1112
|
+
if (!widenToAllProviders) {
|
|
1120
1113
|
return response;
|
|
1121
1114
|
}
|
|
1122
|
-
// Reduce the widened multi-provider result to the single best
|
|
1115
|
+
// Reduce the widened multi-provider result to the single best quote
|
|
1123
1116
|
// and place it at `success[0]`, since single-pick consumers
|
|
1124
1117
|
// (`getRampsQuote` -> `success?.[0]`) rely on index 0 while `success[]`
|
|
1125
1118
|
// order is server-defined rather than ranked.
|
|
1126
|
-
const selectedQuote = __classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1127
|
-
scope: providerScope,
|
|
1119
|
+
const selectedQuote = __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_pickWidenedQuote).call(this, response, {
|
|
1128
1120
|
amount: options.amount,
|
|
1129
1121
|
fiat: normalizedFiat,
|
|
1130
|
-
providers:
|
|
1122
|
+
providers: widenedProviderCatalog,
|
|
1131
1123
|
});
|
|
1132
1124
|
if (!selectedQuote) {
|
|
1133
|
-
// No
|
|
1134
|
-
//
|
|
1125
|
+
// No quote fits the published provider limits: surface "no quote"
|
|
1126
|
+
// rather than handing the single-pick consumer an out-of-limits quote.
|
|
1135
1127
|
return {
|
|
1136
1128
|
success: [],
|
|
1137
1129
|
sorted: response.sorted,
|
|
@@ -1760,7 +1752,7 @@ export class RampsController extends BaseController {
|
|
|
1760
1752
|
}
|
|
1761
1753
|
}
|
|
1762
1754
|
}
|
|
1763
|
-
_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() {
|
|
1764
1756
|
for (const resourceType of DEPENDENT_RESOURCE_KEYS) {
|
|
1765
1757
|
__classPrivateFieldGet(this, _RampsController_pendingResourceCount, "f").delete(resourceType);
|
|
1766
1758
|
const generation = __classPrivateFieldGet(this, _RampsController_pendingResourceGeneration, "f").get(resourceType) ?? 0;
|
|
@@ -1775,6 +1767,14 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
|
|
|
1775
1767
|
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_removeRequestState).call(this, cacheKey);
|
|
1776
1768
|
}
|
|
1777
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
|
+
}
|
|
1778
1778
|
}, _RampsController_mutateRequests = function _RampsController_mutateRequests(fn) {
|
|
1779
1779
|
this.update((state) => {
|
|
1780
1780
|
const requests = state.requests;
|
|
@@ -1886,9 +1886,8 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
|
|
|
1886
1886
|
this.update((state) => {
|
|
1887
1887
|
state.userRegion = userRegion;
|
|
1888
1888
|
});
|
|
1889
|
-
},
|
|
1889
|
+
}, _RampsController_pickWidenedQuote = function _RampsController_pickWidenedQuote(response, { amount, fiat, providers, }) {
|
|
1890
1890
|
const providerByCode = new Map(providers.map((provider) => [provider.id, provider]));
|
|
1891
|
-
const customActionProviderCodes = new Set(response.customActions.map((action) => action.buy.providerId));
|
|
1892
1891
|
const fitsProviderLimits = (quote) => {
|
|
1893
1892
|
const provider = providerByCode.get(quote.provider);
|
|
1894
1893
|
const limit = provider?.limits?.fiat?.[fiat]?.[quote.quote.paymentMethod];
|
|
@@ -1899,26 +1898,7 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
|
|
|
1899
1898
|
}
|
|
1900
1899
|
return amount >= limit.minAmount && amount <= limit.maxAmount;
|
|
1901
1900
|
};
|
|
1902
|
-
const
|
|
1903
|
-
// `all` (Phase 2) skips the in-app-only exclusions; both scopes still
|
|
1904
|
-
// enforce provider limits up front.
|
|
1905
|
-
if (scope !== 'all') {
|
|
1906
|
-
const providerCode = quote.provider;
|
|
1907
|
-
if (customActionProviderCodes.has(providerCode)) {
|
|
1908
|
-
return false;
|
|
1909
|
-
}
|
|
1910
|
-
// Defensive: the wire may carry an inline `isCustomAction` flag that is
|
|
1911
|
-
// absent from the published `Quote` type.
|
|
1912
|
-
if (quote.quote.isCustomAction === true) {
|
|
1913
|
-
return false;
|
|
1914
|
-
}
|
|
1915
|
-
if (quote.quote.buyWidget?.browser === 'IN_APP_OS_BROWSER') {
|
|
1916
|
-
return false;
|
|
1917
|
-
}
|
|
1918
|
-
}
|
|
1919
|
-
return fitsProviderLimits(quote);
|
|
1920
|
-
};
|
|
1921
|
-
const candidates = response.success.filter(isEligible);
|
|
1901
|
+
const candidates = response.success.filter(fitsProviderLimits);
|
|
1922
1902
|
if (candidates.length === 0) {
|
|
1923
1903
|
return undefined;
|
|
1924
1904
|
}
|
|
@@ -1963,18 +1943,10 @@ async function _RampsController_getSupportingProvidersForRegion({ assetId, regio
|
|
|
1963
1943
|
else {
|
|
1964
1944
|
({ providers } = await this.getProviders(normalizedRegion));
|
|
1965
1945
|
}
|
|
1966
|
-
//
|
|
1967
|
-
//
|
|
1968
|
-
//
|
|
1969
|
-
|
|
1970
|
-
const normalizedAssetId = assetId.toLowerCase();
|
|
1971
|
-
const supporting = providers.filter((provider) => {
|
|
1972
|
-
const map = provider?.supportedCryptoCurrencies;
|
|
1973
|
-
if (!map) {
|
|
1974
|
-
return false;
|
|
1975
|
-
}
|
|
1976
|
-
return Object.keys(map).some((key) => key.toLowerCase() === normalizedAssetId);
|
|
1977
|
-
});
|
|
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);
|
|
1978
1950
|
return { supporting, all: providers };
|
|
1979
1951
|
}, _RampsController_filterProviderIdsBySupport =
|
|
1980
1952
|
/**
|