@metamask/ramps-controller 18.0.0 → 19.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 +35 -1
- package/dist/RampsController-method-action-types.cjs.map +1 -1
- package/dist/RampsController-method-action-types.d.cts +30 -1
- package/dist/RampsController-method-action-types.d.cts.map +1 -1
- package/dist/RampsController-method-action-types.d.mts +30 -1
- package/dist/RampsController-method-action-types.d.mts.map +1 -1
- package/dist/RampsController-method-action-types.mjs.map +1 -1
- package/dist/RampsController.cjs +60 -18
- package/dist/RampsController.cjs.map +1 -1
- package/dist/RampsController.d.cts +31 -17
- package/dist/RampsController.d.cts.map +1 -1
- package/dist/RampsController.d.mts +31 -17
- package/dist/RampsController.d.mts.map +1 -1
- package/dist/RampsController.mjs +61 -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 +31 -1
- package/dist/RampsService-method-action-types.d.cts.map +1 -1
- package/dist/RampsService-method-action-types.d.mts +31 -1
- 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 +75 -1
- package/dist/RampsService.cjs.map +1 -1
- package/dist/RampsService.d.cts +52 -0
- package/dist/RampsService.d.cts.map +1 -1
- package/dist/RampsService.d.mts +52 -0
- package/dist/RampsService.d.mts.map +1 -1
- package/dist/RampsService.mjs +73 -0
- package/dist/RampsService.mjs.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/providerAvailability.cjs +1 -1
- package/dist/providerAvailability.cjs.map +1 -1
- package/dist/providerAvailability.d.cts.map +1 -1
- package/dist/providerAvailability.d.mts.map +1 -1
- package/dist/providerAvailability.mjs +1 -1
- package/dist/providerAvailability.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -4,7 +4,7 @@ import type { Messenger } from "@metamask/messenger";
|
|
|
4
4
|
import type { RemoteFeatureFlagControllerGetStateAction } from "@metamask/remote-feature-flag-controller";
|
|
5
5
|
import type { RampsControllerMethodActions } from "./RampsController-method-action-types.cjs";
|
|
6
6
|
import type { RampsErrorCode } from "./rampsErrorCodes.cjs";
|
|
7
|
-
import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, RampsServiceGetBuyWidgetUrlAction, RampsServiceGetOrderAction, RampsServiceGetOrderFromCallbackAction } from "./RampsService-method-action-types.cjs";
|
|
7
|
+
import type { RampsServiceGetDefaultRedirectCallbackUrlAction, RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, RampsServiceGetBuyWidgetUrlAction, RampsServiceGetOrderAction, RampsServiceGetOrderFromCallbackAction } from "./RampsService-method-action-types.cjs";
|
|
8
8
|
import type { BuyWidget, Country, TokensResponse, Provider, State, RampAction, PaymentMethod, PaymentMethodsResponse, QuotesResponse, Quote, RampsToken, RampsServiceActions, RampsOrder } from "./RampsService.cjs";
|
|
9
9
|
import { RampsOrderStatus } from "./RampsService.cjs";
|
|
10
10
|
import type { RequestCache as RequestCacheType, RequestState, ExecuteRequestOptions } from "./RequestCache.cjs";
|
|
@@ -158,7 +158,7 @@ export type RampsControllerActions = RampsControllerGetStateAction | RampsContro
|
|
|
158
158
|
/**
|
|
159
159
|
* Actions from other messengers that {@link RampsController} calls.
|
|
160
160
|
*/
|
|
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 | TransakServiceCreateWidgetUrlAction | TransakServiceSubmitPurposeOfUsageFormAction | TransakServicePatchUserAction | TransakServiceSubmitSsnDetailsAction | TransakServiceConfirmPaymentAction | TransakServiceGetTranslationAction | TransakServiceGetIdProofStatusAction | TransakServiceCancelOrderAction | TransakServiceCancelAllActiveOrdersAction | TransakServiceGetActiveOrdersAction;
|
|
161
|
+
type AllowedActions = RemoteFeatureFlagControllerGetStateAction | RampsServiceGetDefaultRedirectCallbackUrlAction | RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction | RampsServiceGetBuyWidgetUrlAction | RampsServiceGetOrderAction | RampsServiceGetOrderFromCallbackAction | TransakServiceSetApiKeyAction | TransakServiceSetAccessTokenAction | TransakServiceClearAccessTokenAction | TransakServiceSendUserOtpAction | TransakServiceVerifyUserOtpAction | TransakServiceLogoutAction | TransakServiceGetUserDetailsAction | TransakServiceGetBuyQuoteAction | TransakServiceGetKycRequirementAction | TransakServiceGetAdditionalRequirementsAction | TransakServiceCreateOrderAction | TransakServiceGetOrderAction | TransakServiceGetUserLimitsAction | TransakServiceRequestOttAction | TransakServiceGeneratePaymentWidgetUrlAction | TransakServiceCreateWidgetUrlAction | TransakServiceSubmitPurposeOfUsageFormAction | TransakServicePatchUserAction | TransakServiceSubmitSsnDetailsAction | TransakServiceConfirmPaymentAction | TransakServiceGetTranslationAction | TransakServiceGetIdProofStatusAction | TransakServiceCancelOrderAction | TransakServiceCancelAllActiveOrdersAction | TransakServiceGetActiveOrdersAction;
|
|
162
162
|
/**
|
|
163
163
|
* Published when the state of {@link RampsController} changes.
|
|
164
164
|
*/
|
|
@@ -199,17 +199,6 @@ export type RampsControllerOptions = {
|
|
|
199
199
|
requestCacheTTL?: number;
|
|
200
200
|
/** Maximum number of entries in the request cache. Defaults to 250. */
|
|
201
201
|
requestCacheMaxSize?: number;
|
|
202
|
-
/**
|
|
203
|
-
* Optional callback returning the default redirect URL to use for the widened
|
|
204
|
-
* quote fetch when the caller omits `redirectUrl`. The quotes API only
|
|
205
|
-
* embeds a `buyURL`/`buyWidget` (the WebView page a non-native provider needs)
|
|
206
|
-
* when a `redirectUrl` is present, so supplying this default lets widened
|
|
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.
|
|
211
|
-
*/
|
|
212
|
-
getDefaultRedirectUrl?: () => string | undefined;
|
|
213
202
|
};
|
|
214
203
|
/**
|
|
215
204
|
* Returns the internal MetaMask order code used for state lookups and polling.
|
|
@@ -241,11 +230,8 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
241
230
|
* controller. Missing properties will be filled in with defaults.
|
|
242
231
|
* @param args.requestCacheTTL - Time to live for cached requests in milliseconds.
|
|
243
232
|
* @param args.requestCacheMaxSize - Maximum number of entries in the request cache.
|
|
244
|
-
* @param args.getDefaultRedirectUrl - Optional callback returning the default
|
|
245
|
-
* redirect URL used for the widened quote fetch when the caller omits
|
|
246
|
-
* `redirectUrl`. Defaults to a callback returning `undefined`.
|
|
247
233
|
*/
|
|
248
|
-
constructor({ messenger, state, requestCacheTTL, requestCacheMaxSize,
|
|
234
|
+
constructor({ messenger, state, requestCacheTTL, requestCacheMaxSize, }: RampsControllerOptions);
|
|
249
235
|
/**
|
|
250
236
|
* Executes a request with caching, deduplication, and at most one in-flight
|
|
251
237
|
* request per resource type.
|
|
@@ -310,6 +296,34 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
310
296
|
setSelectedProvider(providerOrId: string | Provider | null, options?: {
|
|
311
297
|
autoSelected?: boolean;
|
|
312
298
|
}): void;
|
|
299
|
+
/**
|
|
300
|
+
* Switches to the first provider in state that serves the given asset,
|
|
301
|
+
* when the currently selected provider does not.
|
|
302
|
+
*
|
|
303
|
+
* This is the controller-level equivalent of UB2's BuildQuote tier-1
|
|
304
|
+
* silent-switch effect and MMPay's `useEnsureCompatibleProvider` hook: it
|
|
305
|
+
* keeps provider-asset compatibility logic in one place rather than
|
|
306
|
+
* duplicating `providerServesAsset` + find-and-switch across multiple UI
|
|
307
|
+
* layers.
|
|
308
|
+
*
|
|
309
|
+
* The compatibility check prefers the current provider's entry in
|
|
310
|
+
* `providers.data` over the `providers.selected` copy, which can be stale
|
|
311
|
+
* once a fresh providers list arrives.
|
|
312
|
+
*
|
|
313
|
+
* No-op when:
|
|
314
|
+
* - `providers.data` is empty (providers not yet loaded)
|
|
315
|
+
* - the currently selected provider already serves the asset
|
|
316
|
+
* - no provider in the list serves the asset (no safe fallback)
|
|
317
|
+
*
|
|
318
|
+
* @param assetId - CAIP-19 asset id of the deposit asset.
|
|
319
|
+
* @param options - Optional settings forwarded to `setSelectedProvider`.
|
|
320
|
+
* @param options.autoSelected - When true, marks the new selection as
|
|
321
|
+
* system-guessed (soft selection). Defaults to true.
|
|
322
|
+
* @returns `true` if the selected provider was changed, `false` otherwise.
|
|
323
|
+
*/
|
|
324
|
+
setSelectedProviderForAsset(assetId: string, options?: {
|
|
325
|
+
autoSelected?: boolean;
|
|
326
|
+
}): boolean;
|
|
313
327
|
/**
|
|
314
328
|
* Initializes the controller by fetching the user's region from geolocation.
|
|
315
329
|
* This should be called once at app startup to set up the initial region.
|
|
@@ -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;AACrD,OAAO,KAAK,EAAE,yCAAyC,EAAE,iDAAiD;
|
|
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;AAa1G,OAAO,KAAK,EAAE,4BAA4B,EAAE,kDAAiD;AAC7F,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA6B;AAE3D,OAAO,KAAK,EACV,+CAA+C,EAC/C,gCAAgC,EAChC,8BAA8B,EAC9B,2BAA2B,EAC3B,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,EACjC,0BAA0B,EAC1B,sCAAsC,EACvC,+CAA8C;AAC/C,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,2BAA0B;AAC3B,OAAO,EAAE,gBAAgB,EAAE,2BAA0B;AACrD,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,YAAY,EACZ,qBAAqB,EAGtB,2BAA0B;AAW3B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MAAM,CAAC;IAclB;;;;;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"}
|
|
@@ -4,7 +4,7 @@ import type { Messenger } from "@metamask/messenger";
|
|
|
4
4
|
import type { RemoteFeatureFlagControllerGetStateAction } from "@metamask/remote-feature-flag-controller";
|
|
5
5
|
import type { RampsControllerMethodActions } from "./RampsController-method-action-types.mjs";
|
|
6
6
|
import type { RampsErrorCode } from "./rampsErrorCodes.mjs";
|
|
7
|
-
import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, RampsServiceGetBuyWidgetUrlAction, RampsServiceGetOrderAction, RampsServiceGetOrderFromCallbackAction } from "./RampsService-method-action-types.mjs";
|
|
7
|
+
import type { RampsServiceGetDefaultRedirectCallbackUrlAction, RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, RampsServiceGetBuyWidgetUrlAction, RampsServiceGetOrderAction, RampsServiceGetOrderFromCallbackAction } from "./RampsService-method-action-types.mjs";
|
|
8
8
|
import type { BuyWidget, Country, TokensResponse, Provider, State, RampAction, PaymentMethod, PaymentMethodsResponse, QuotesResponse, Quote, RampsToken, RampsServiceActions, RampsOrder } from "./RampsService.mjs";
|
|
9
9
|
import { RampsOrderStatus } from "./RampsService.mjs";
|
|
10
10
|
import type { RequestCache as RequestCacheType, RequestState, ExecuteRequestOptions } from "./RequestCache.mjs";
|
|
@@ -158,7 +158,7 @@ export type RampsControllerActions = RampsControllerGetStateAction | RampsContro
|
|
|
158
158
|
/**
|
|
159
159
|
* Actions from other messengers that {@link RampsController} calls.
|
|
160
160
|
*/
|
|
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 | TransakServiceCreateWidgetUrlAction | TransakServiceSubmitPurposeOfUsageFormAction | TransakServicePatchUserAction | TransakServiceSubmitSsnDetailsAction | TransakServiceConfirmPaymentAction | TransakServiceGetTranslationAction | TransakServiceGetIdProofStatusAction | TransakServiceCancelOrderAction | TransakServiceCancelAllActiveOrdersAction | TransakServiceGetActiveOrdersAction;
|
|
161
|
+
type AllowedActions = RemoteFeatureFlagControllerGetStateAction | RampsServiceGetDefaultRedirectCallbackUrlAction | RampsServiceGetGeolocationAction | RampsServiceGetCountriesAction | RampsServiceGetTokensAction | RampsServiceGetProvidersAction | RampsServiceGetPaymentMethodsAction | RampsServiceGetQuotesAction | RampsServiceGetBuyWidgetUrlAction | RampsServiceGetOrderAction | RampsServiceGetOrderFromCallbackAction | TransakServiceSetApiKeyAction | TransakServiceSetAccessTokenAction | TransakServiceClearAccessTokenAction | TransakServiceSendUserOtpAction | TransakServiceVerifyUserOtpAction | TransakServiceLogoutAction | TransakServiceGetUserDetailsAction | TransakServiceGetBuyQuoteAction | TransakServiceGetKycRequirementAction | TransakServiceGetAdditionalRequirementsAction | TransakServiceCreateOrderAction | TransakServiceGetOrderAction | TransakServiceGetUserLimitsAction | TransakServiceRequestOttAction | TransakServiceGeneratePaymentWidgetUrlAction | TransakServiceCreateWidgetUrlAction | TransakServiceSubmitPurposeOfUsageFormAction | TransakServicePatchUserAction | TransakServiceSubmitSsnDetailsAction | TransakServiceConfirmPaymentAction | TransakServiceGetTranslationAction | TransakServiceGetIdProofStatusAction | TransakServiceCancelOrderAction | TransakServiceCancelAllActiveOrdersAction | TransakServiceGetActiveOrdersAction;
|
|
162
162
|
/**
|
|
163
163
|
* Published when the state of {@link RampsController} changes.
|
|
164
164
|
*/
|
|
@@ -199,17 +199,6 @@ export type RampsControllerOptions = {
|
|
|
199
199
|
requestCacheTTL?: number;
|
|
200
200
|
/** Maximum number of entries in the request cache. Defaults to 250. */
|
|
201
201
|
requestCacheMaxSize?: number;
|
|
202
|
-
/**
|
|
203
|
-
* Optional callback returning the default redirect URL to use for the widened
|
|
204
|
-
* quote fetch when the caller omits `redirectUrl`. The quotes API only
|
|
205
|
-
* embeds a `buyURL`/`buyWidget` (the WebView page a non-native provider needs)
|
|
206
|
-
* when a `redirectUrl` is present, so supplying this default lets widened
|
|
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.
|
|
211
|
-
*/
|
|
212
|
-
getDefaultRedirectUrl?: () => string | undefined;
|
|
213
202
|
};
|
|
214
203
|
/**
|
|
215
204
|
* Returns the internal MetaMask order code used for state lookups and polling.
|
|
@@ -241,11 +230,8 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
241
230
|
* controller. Missing properties will be filled in with defaults.
|
|
242
231
|
* @param args.requestCacheTTL - Time to live for cached requests in milliseconds.
|
|
243
232
|
* @param args.requestCacheMaxSize - Maximum number of entries in the request cache.
|
|
244
|
-
* @param args.getDefaultRedirectUrl - Optional callback returning the default
|
|
245
|
-
* redirect URL used for the widened quote fetch when the caller omits
|
|
246
|
-
* `redirectUrl`. Defaults to a callback returning `undefined`.
|
|
247
233
|
*/
|
|
248
|
-
constructor({ messenger, state, requestCacheTTL, requestCacheMaxSize,
|
|
234
|
+
constructor({ messenger, state, requestCacheTTL, requestCacheMaxSize, }: RampsControllerOptions);
|
|
249
235
|
/**
|
|
250
236
|
* Executes a request with caching, deduplication, and at most one in-flight
|
|
251
237
|
* request per resource type.
|
|
@@ -310,6 +296,34 @@ export declare class RampsController extends BaseController<typeof controllerNam
|
|
|
310
296
|
setSelectedProvider(providerOrId: string | Provider | null, options?: {
|
|
311
297
|
autoSelected?: boolean;
|
|
312
298
|
}): void;
|
|
299
|
+
/**
|
|
300
|
+
* Switches to the first provider in state that serves the given asset,
|
|
301
|
+
* when the currently selected provider does not.
|
|
302
|
+
*
|
|
303
|
+
* This is the controller-level equivalent of UB2's BuildQuote tier-1
|
|
304
|
+
* silent-switch effect and MMPay's `useEnsureCompatibleProvider` hook: it
|
|
305
|
+
* keeps provider-asset compatibility logic in one place rather than
|
|
306
|
+
* duplicating `providerServesAsset` + find-and-switch across multiple UI
|
|
307
|
+
* layers.
|
|
308
|
+
*
|
|
309
|
+
* The compatibility check prefers the current provider's entry in
|
|
310
|
+
* `providers.data` over the `providers.selected` copy, which can be stale
|
|
311
|
+
* once a fresh providers list arrives.
|
|
312
|
+
*
|
|
313
|
+
* No-op when:
|
|
314
|
+
* - `providers.data` is empty (providers not yet loaded)
|
|
315
|
+
* - the currently selected provider already serves the asset
|
|
316
|
+
* - no provider in the list serves the asset (no safe fallback)
|
|
317
|
+
*
|
|
318
|
+
* @param assetId - CAIP-19 asset id of the deposit asset.
|
|
319
|
+
* @param options - Optional settings forwarded to `setSelectedProvider`.
|
|
320
|
+
* @param options.autoSelected - When true, marks the new selection as
|
|
321
|
+
* system-guessed (soft selection). Defaults to true.
|
|
322
|
+
* @returns `true` if the selected provider was changed, `false` otherwise.
|
|
323
|
+
*/
|
|
324
|
+
setSelectedProviderForAsset(assetId: string, options?: {
|
|
325
|
+
autoSelected?: boolean;
|
|
326
|
+
}): boolean;
|
|
313
327
|
/**
|
|
314
328
|
* Initializes the controller by fetching the user's region from geolocation.
|
|
315
329
|
* This should be called once at app startup to set up the initial region.
|
|
@@ -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;AACrD,OAAO,KAAK,EAAE,yCAAyC,EAAE,iDAAiD;
|
|
1
|
+
{"version":3,"file":"RampsController.d.mts","sourceRoot":"","sources":["../src/RampsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAA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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,11 +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_pendingRequests, _RampsController_pendingResourceCount, _RampsController_pendingResourceGeneration, _RampsController_orderPollingMeta, _RampsController_orderPollingTimer, _RampsController_isPolling, _RampsController_initPromise, _RampsController_clearPendingResourceCountForDependentResources, _RampsController_abortDependentRequests, _RampsController_resolveAllProvidersFlag, _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
15
|
import { getHeadlessProviderAllowlist, isHeadlessAllProvidersEnabled, normalizeHeadlessProviderId } from "./featureFlags.mjs";
|
|
16
|
-
import { getProvidersServingAsset } from "./providerAvailability.mjs";
|
|
16
|
+
import { getProvidersServingAsset, providerServesAsset } from "./providerAvailability.mjs";
|
|
17
17
|
import { RAMPS_ERROR_CODES } from "./rampsErrorCodes.mjs";
|
|
18
18
|
import { RampsOrderStatus } from "./RampsService.mjs";
|
|
19
19
|
import { DEFAULT_REQUEST_CACHE_TTL, DEFAULT_REQUEST_CACHE_MAX_SIZE, createCacheKey, isCacheExpired, createLoadingState, createSuccessState, createErrorState, RequestStatus } from "./RequestCache.mjs";
|
|
@@ -30,6 +30,7 @@ export const controllerName = 'RampsController';
|
|
|
30
30
|
* these actions from the root messenger so the controller can function.
|
|
31
31
|
*/
|
|
32
32
|
export const RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = [
|
|
33
|
+
'RampsService:getDefaultRedirectCallbackUrl',
|
|
33
34
|
'RampsService:getGeolocation',
|
|
34
35
|
'RampsService:getCountries',
|
|
35
36
|
'RampsService:getTokens',
|
|
@@ -370,6 +371,7 @@ const MESSENGER_EXPOSED_METHODS = [
|
|
|
370
371
|
'getRequestState',
|
|
371
372
|
'setUserRegion',
|
|
372
373
|
'setSelectedProvider',
|
|
374
|
+
'setSelectedProviderForAsset',
|
|
373
375
|
'init',
|
|
374
376
|
'getCountries',
|
|
375
377
|
'getTokens',
|
|
@@ -436,11 +438,8 @@ export class RampsController extends BaseController {
|
|
|
436
438
|
* controller. Missing properties will be filled in with defaults.
|
|
437
439
|
* @param args.requestCacheTTL - Time to live for cached requests in milliseconds.
|
|
438
440
|
* @param args.requestCacheMaxSize - Maximum number of entries in the request cache.
|
|
439
|
-
* @param args.getDefaultRedirectUrl - Optional callback returning the default
|
|
440
|
-
* redirect URL used for the widened quote fetch when the caller omits
|
|
441
|
-
* `redirectUrl`. Defaults to a callback returning `undefined`.
|
|
442
441
|
*/
|
|
443
|
-
constructor({ messenger, state = {}, requestCacheTTL = DEFAULT_REQUEST_CACHE_TTL, requestCacheMaxSize = DEFAULT_REQUEST_CACHE_MAX_SIZE,
|
|
442
|
+
constructor({ messenger, state = {}, requestCacheTTL = DEFAULT_REQUEST_CACHE_TTL, requestCacheMaxSize = DEFAULT_REQUEST_CACHE_MAX_SIZE, }) {
|
|
444
443
|
super({
|
|
445
444
|
messenger,
|
|
446
445
|
metadata: rampsControllerMetadata,
|
|
@@ -461,12 +460,6 @@ export class RampsController extends BaseController {
|
|
|
461
460
|
* Maximum number of entries in the request cache.
|
|
462
461
|
*/
|
|
463
462
|
_RampsController_requestCacheMaxSize.set(this, void 0);
|
|
464
|
-
/**
|
|
465
|
-
* Resolves the default redirect URL for the widened quote fetch when
|
|
466
|
-
* the caller omits `redirectUrl`. Defaults to `() => undefined` when no
|
|
467
|
-
* callback is injected.
|
|
468
|
-
*/
|
|
469
|
-
_RampsController_getDefaultRedirectUrl.set(this, void 0);
|
|
470
463
|
/**
|
|
471
464
|
* Map of pending requests for deduplication.
|
|
472
465
|
* Key is the cache key, value is the pending request with abort controller.
|
|
@@ -488,7 +481,6 @@ export class RampsController extends BaseController {
|
|
|
488
481
|
_RampsController_initPromise.set(this, null);
|
|
489
482
|
__classPrivateFieldSet(this, _RampsController_requestCacheTTL, requestCacheTTL, "f");
|
|
490
483
|
__classPrivateFieldSet(this, _RampsController_requestCacheMaxSize, requestCacheMaxSize, "f");
|
|
491
|
-
__classPrivateFieldSet(this, _RampsController_getDefaultRedirectUrl, getDefaultRedirectUrl ?? (() => undefined), "f");
|
|
492
484
|
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
493
485
|
}
|
|
494
486
|
/**
|
|
@@ -721,6 +713,52 @@ export class RampsController extends BaseController {
|
|
|
721
713
|
});
|
|
722
714
|
}
|
|
723
715
|
}
|
|
716
|
+
/**
|
|
717
|
+
* Switches to the first provider in state that serves the given asset,
|
|
718
|
+
* when the currently selected provider does not.
|
|
719
|
+
*
|
|
720
|
+
* This is the controller-level equivalent of UB2's BuildQuote tier-1
|
|
721
|
+
* silent-switch effect and MMPay's `useEnsureCompatibleProvider` hook: it
|
|
722
|
+
* keeps provider-asset compatibility logic in one place rather than
|
|
723
|
+
* duplicating `providerServesAsset` + find-and-switch across multiple UI
|
|
724
|
+
* layers.
|
|
725
|
+
*
|
|
726
|
+
* The compatibility check prefers the current provider's entry in
|
|
727
|
+
* `providers.data` over the `providers.selected` copy, which can be stale
|
|
728
|
+
* once a fresh providers list arrives.
|
|
729
|
+
*
|
|
730
|
+
* No-op when:
|
|
731
|
+
* - `providers.data` is empty (providers not yet loaded)
|
|
732
|
+
* - the currently selected provider already serves the asset
|
|
733
|
+
* - no provider in the list serves the asset (no safe fallback)
|
|
734
|
+
*
|
|
735
|
+
* @param assetId - CAIP-19 asset id of the deposit asset.
|
|
736
|
+
* @param options - Optional settings forwarded to `setSelectedProvider`.
|
|
737
|
+
* @param options.autoSelected - When true, marks the new selection as
|
|
738
|
+
* system-guessed (soft selection). Defaults to true.
|
|
739
|
+
* @returns `true` if the selected provider was changed, `false` otherwise.
|
|
740
|
+
*/
|
|
741
|
+
setSelectedProviderForAsset(assetId, options) {
|
|
742
|
+
const providers = this.state.providers.data;
|
|
743
|
+
if (!providers?.length) {
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
746
|
+
const selectedId = this.state.providers.selected?.id;
|
|
747
|
+
const currentProvider = providers.find((provider) => provider.id === selectedId) ??
|
|
748
|
+
this.state.providers.selected;
|
|
749
|
+
if (currentProvider && providerServesAsset(currentProvider, assetId)) {
|
|
750
|
+
return false;
|
|
751
|
+
}
|
|
752
|
+
const compatible = providers.find((provider) => provider.id !== selectedId && providerServesAsset(provider, assetId));
|
|
753
|
+
if (!compatible) {
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
this.setSelectedProvider(compatible, {
|
|
757
|
+
autoSelected: true,
|
|
758
|
+
...options,
|
|
759
|
+
});
|
|
760
|
+
return true;
|
|
761
|
+
}
|
|
724
762
|
/**
|
|
725
763
|
* Initializes the controller by fetching the user's region from geolocation.
|
|
726
764
|
* This should be called once at app startup to set up the initial region.
|
|
@@ -1083,12 +1121,16 @@ export class RampsController extends BaseController {
|
|
|
1083
1121
|
const normalizedAssetId = normalizedAssetIdForValidation;
|
|
1084
1122
|
const normalizedWalletAddress = options.walletAddress.trim();
|
|
1085
1123
|
// The quotes API only embeds a `buyURL`/`buyWidget` when a `redirectUrl` is
|
|
1086
|
-
// present, so on the widened path (where MM Pay omits one)
|
|
1087
|
-
//
|
|
1088
|
-
//
|
|
1089
|
-
//
|
|
1124
|
+
// present, so on the widened path (where MM Pay omits one) ask the service
|
|
1125
|
+
// for the callback URL of the environment it is configured with, so
|
|
1126
|
+
// aggregator quotes carry a usable widget URL that always matches the
|
|
1127
|
+
// environment the quotes came from. An explicit caller `redirectUrl`
|
|
1128
|
+
// always wins, and the native-only path (flag off) never injects, so
|
|
1129
|
+
// neither reaches the service.
|
|
1090
1130
|
const effectiveRedirectUrl = options.redirectUrl ??
|
|
1091
|
-
(widenToAllProviders
|
|
1131
|
+
(widenToAllProviders
|
|
1132
|
+
? this.messenger.call('RampsService:getDefaultRedirectCallbackUrl')
|
|
1133
|
+
: undefined);
|
|
1092
1134
|
const cacheKey = createCacheKey('getQuotes', [
|
|
1093
1135
|
normalizedRegion,
|
|
1094
1136
|
normalizedFiat,
|
|
@@ -1780,7 +1822,7 @@ export class RampsController extends BaseController {
|
|
|
1780
1822
|
}
|
|
1781
1823
|
}
|
|
1782
1824
|
}
|
|
1783
|
-
_RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheMaxSize = new WeakMap(),
|
|
1825
|
+
_RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheMaxSize = 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() {
|
|
1784
1826
|
for (const resourceType of DEPENDENT_RESOURCE_KEYS) {
|
|
1785
1827
|
__classPrivateFieldGet(this, _RampsController_pendingResourceCount, "f").delete(resourceType);
|
|
1786
1828
|
const generation = __classPrivateFieldGet(this, _RampsController_pendingResourceGeneration, "f").get(resourceType) ?? 0;
|