@metamask/ramps-controller 13.1.0 → 13.3.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 +25 -2
- package/dist/RampsController.cjs +166 -58
- package/dist/RampsController.cjs.map +1 -1
- package/dist/RampsController.d.cts +5 -0
- package/dist/RampsController.d.cts.map +1 -1
- package/dist/RampsController.d.mts +5 -0
- package/dist/RampsController.d.mts.map +1 -1
- package/dist/RampsController.mjs +166 -58
- package/dist/RampsController.mjs.map +1 -1
- package/dist/RampsService.cjs +8 -3
- package/dist/RampsService.cjs.map +1 -1
- package/dist/RampsService.d.cts.map +1 -1
- package/dist/RampsService.d.mts.map +1 -1
- package/dist/RampsService.mjs +8 -3
- package/dist/RampsService.mjs.map +1 -1
- package/dist/RequestCache.cjs +7 -2
- package/dist/RequestCache.cjs.map +1 -1
- package/dist/RequestCache.d.cts +5 -1
- package/dist/RequestCache.d.cts.map +1 -1
- package/dist/RequestCache.d.mts +5 -1
- package/dist/RequestCache.d.mts.map +1 -1
- package/dist/RequestCache.mjs +7 -2
- package/dist/RequestCache.mjs.map +1 -1
- package/dist/TransakService.cjs +11 -5
- package/dist/TransakService.cjs.map +1 -1
- package/dist/TransakService.d.cts.map +1 -1
- package/dist/TransakService.d.mts.map +1 -1
- package/dist/TransakService.mjs +11 -5
- package/dist/TransakService.mjs.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/rampsErrorCodes.cjs +11 -0
- package/dist/rampsErrorCodes.cjs.map +1 -0
- package/dist/rampsErrorCodes.d.cts +9 -0
- package/dist/rampsErrorCodes.d.cts.map +1 -0
- package/dist/rampsErrorCodes.d.mts +9 -0
- package/dist/rampsErrorCodes.d.mts.map +1 -0
- package/dist/rampsErrorCodes.mjs +8 -0
- package/dist/rampsErrorCodes.mjs.map +1 -0
- package/dist/selectors.cjs +5 -1
- package/dist/selectors.cjs.map +1 -1
- package/dist/selectors.d.cts +3 -0
- package/dist/selectors.d.cts.map +1 -1
- package/dist/selectors.d.mts +3 -0
- package/dist/selectors.d.mts.map +1 -1
- package/dist/selectors.mjs +5 -1
- package/dist/selectors.mjs.map +1 -1
- package/package.json +18 -18
|
@@ -2,6 +2,7 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@meta
|
|
|
2
2
|
import { BaseController } from "@metamask/base-controller";
|
|
3
3
|
import type { Messenger } from "@metamask/messenger";
|
|
4
4
|
import type { RampsControllerMethodActions } from "./RampsController-method-action-types.cjs";
|
|
5
|
+
import type { RampsErrorCode } from "./rampsErrorCodes.cjs";
|
|
5
6
|
import type { BuyWidget, Country, TokensResponse, Provider, State, RampAction, PaymentMethod, PaymentMethodsResponse, QuotesResponse, Quote, RampsToken, RampsServiceActions, RampsOrder } from "./RampsService.cjs";
|
|
6
7
|
import { RampsOrderStatus } from "./RampsService.cjs";
|
|
7
8
|
import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, RampsServiceGetBuyWidgetUrlAction, RampsServiceGetOrderAction, RampsServiceGetOrderFromCallbackAction } from "./RampsService-method-action-types.cjs";
|
|
@@ -61,6 +62,10 @@ export type ResourceState<TData, TSelected = null> = {
|
|
|
61
62
|
* Error message if the fetch failed, or null.
|
|
62
63
|
*/
|
|
63
64
|
error: string | null;
|
|
65
|
+
/**
|
|
66
|
+
* Stable error key for client-side localization, if available.
|
|
67
|
+
*/
|
|
68
|
+
errorKey?: RampsErrorCode | null;
|
|
64
69
|
};
|
|
65
70
|
/**
|
|
66
71
|
* Describes the transak-specific state managed by the RampsController.
|
|
@@ -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;
|
|
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;AAIrD,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,EACL,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,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,YAAY,EACb,6BAAyB;AAC1B,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAA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AIG;IACG,sBAAsB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;CAQxD"}
|
|
@@ -2,6 +2,7 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@meta
|
|
|
2
2
|
import { BaseController } from "@metamask/base-controller";
|
|
3
3
|
import type { Messenger } from "@metamask/messenger";
|
|
4
4
|
import type { RampsControllerMethodActions } from "./RampsController-method-action-types.mjs";
|
|
5
|
+
import type { RampsErrorCode } from "./rampsErrorCodes.mjs";
|
|
5
6
|
import type { BuyWidget, Country, TokensResponse, Provider, State, RampAction, PaymentMethod, PaymentMethodsResponse, QuotesResponse, Quote, RampsToken, RampsServiceActions, RampsOrder } from "./RampsService.mjs";
|
|
6
7
|
import { RampsOrderStatus } from "./RampsService.mjs";
|
|
7
8
|
import type { RampsServiceGetGeolocationAction, RampsServiceGetCountriesAction, RampsServiceGetTokensAction, RampsServiceGetProvidersAction, RampsServiceGetPaymentMethodsAction, RampsServiceGetQuotesAction, RampsServiceGetBuyWidgetUrlAction, RampsServiceGetOrderAction, RampsServiceGetOrderFromCallbackAction } from "./RampsService-method-action-types.mjs";
|
|
@@ -61,6 +62,10 @@ export type ResourceState<TData, TSelected = null> = {
|
|
|
61
62
|
* Error message if the fetch failed, or null.
|
|
62
63
|
*/
|
|
63
64
|
error: string | null;
|
|
65
|
+
/**
|
|
66
|
+
* Stable error key for client-side localization, if available.
|
|
67
|
+
*/
|
|
68
|
+
errorKey?: RampsErrorCode | null;
|
|
64
69
|
};
|
|
65
70
|
/**
|
|
66
71
|
* Describes the transak-specific state managed by the RampsController.
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"RampsController.d.mts","sourceRoot":"","sources":["../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AC;IAc7B;;;;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"}
|
package/dist/RampsController.mjs
CHANGED
|
@@ -9,8 +9,10 @@ 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, _RampsController_pendingRequests, _RampsController_pendingResourceCount, _RampsController_pendingResourceGeneration, _RampsController_orderPollingMeta, _RampsController_orderPollingTimer, _RampsController_isPolling, _RampsController_initPromise, _RampsController_clearPendingResourceCountForDependentResources, _RampsController_abortDependentRequests, _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_refreshOrder, _RampsController_pollPendingOrders, _RampsController_syncTransakAuthOnError;
|
|
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_mutateRequests, _RampsController_removeRequestState, _RampsController_cleanupState, _RampsController_requireRegion, _RampsController_isRegionCurrent, _RampsController_isTokenCurrent, _RampsController_isProviderCurrent, _RampsController_updateResourceField, _RampsController_setResourceLoading, _RampsController_setResourceError, _RampsController_updateRequestState, _RampsController_runInit, _RampsController_refreshOrder, _RampsController_pollPendingOrders, _RampsController_syncTransakAuthOnError, _RampsController_getNormalizedTransakError;
|
|
13
13
|
import { BaseController } from "@metamask/base-controller";
|
|
14
|
+
import { BrokenCircuitError } from "@metamask/controller-utils";
|
|
15
|
+
import { RAMPS_ERROR_CODES } from "./rampsErrorCodes.mjs";
|
|
14
16
|
import { RampsOrderStatus } from "./RampsService.mjs";
|
|
15
17
|
import { DEFAULT_REQUEST_CACHE_TTL, DEFAULT_REQUEST_CACHE_MAX_SIZE, createCacheKey, isCacheExpired, createLoadingState, createSuccessState, createErrorState, RequestStatus } from "./RequestCache.mjs";
|
|
16
18
|
// === GENERAL ===
|
|
@@ -65,6 +67,60 @@ export const RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = [
|
|
|
65
67
|
* Quotes are time-sensitive and should have a shorter cache duration.
|
|
66
68
|
*/
|
|
67
69
|
const DEFAULT_QUOTES_TTL = 15000;
|
|
70
|
+
const CIRCUIT_BREAKER_OPEN_ERROR = 'Execution prevented because the circuit breaker is open';
|
|
71
|
+
function hasStringMessage(error) {
|
|
72
|
+
return (typeof error === 'object' &&
|
|
73
|
+
error !== null &&
|
|
74
|
+
typeof error.message === 'string');
|
|
75
|
+
}
|
|
76
|
+
function hasHttpStatus(error) {
|
|
77
|
+
return (error instanceof Error &&
|
|
78
|
+
typeof error.httpStatus === 'number');
|
|
79
|
+
}
|
|
80
|
+
function getRampsErrorInfo(error) {
|
|
81
|
+
if (error instanceof BrokenCircuitError && hasStringMessage(error)) {
|
|
82
|
+
return {
|
|
83
|
+
errorKey: RAMPS_ERROR_CODES.CIRCUIT_BREAKER_OPEN,
|
|
84
|
+
message: error.message,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
let rawMessage;
|
|
88
|
+
if (hasStringMessage(error)) {
|
|
89
|
+
rawMessage = error.message;
|
|
90
|
+
}
|
|
91
|
+
else if (typeof error === 'string') {
|
|
92
|
+
rawMessage = error;
|
|
93
|
+
}
|
|
94
|
+
if (rawMessage?.includes(CIRCUIT_BREAKER_OPEN_ERROR)) {
|
|
95
|
+
return {
|
|
96
|
+
errorKey: RAMPS_ERROR_CODES.CIRCUIT_BREAKER_OPEN,
|
|
97
|
+
message: rawMessage,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
errorKey: null,
|
|
102
|
+
message: rawMessage ?? 'Unknown error',
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function getNormalizedRampsError(error) {
|
|
106
|
+
const errorInfo = getRampsErrorInfo(error);
|
|
107
|
+
return {
|
|
108
|
+
errorInfo,
|
|
109
|
+
normalizedError: normalizeRampsErrorForRethrow(error, errorInfo),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function normalizeRampsErrorForRethrow(error, errorInfo) {
|
|
113
|
+
if (!errorInfo.errorKey) {
|
|
114
|
+
return error;
|
|
115
|
+
}
|
|
116
|
+
if (error instanceof Error) {
|
|
117
|
+
error.errorKey = errorInfo.errorKey;
|
|
118
|
+
return error;
|
|
119
|
+
}
|
|
120
|
+
return Object.assign(new Error(errorInfo.message), {
|
|
121
|
+
errorKey: errorInfo.errorKey,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
68
124
|
/**
|
|
69
125
|
* The metadata for each property in {@link RampsControllerState}.
|
|
70
126
|
*/
|
|
@@ -175,12 +231,28 @@ const DEPENDENT_RESOURCE_KEYS = [
|
|
|
175
231
|
'paymentMethods',
|
|
176
232
|
];
|
|
177
233
|
const DEPENDENT_RESOURCE_KEYS_SET = new Set(DEPENDENT_RESOURCE_KEYS);
|
|
234
|
+
function getResourceState(state, resourceType) {
|
|
235
|
+
switch (resourceType) {
|
|
236
|
+
case 'countries':
|
|
237
|
+
return state.countries;
|
|
238
|
+
case 'providers':
|
|
239
|
+
return state.providers;
|
|
240
|
+
case 'tokens':
|
|
241
|
+
return state.tokens;
|
|
242
|
+
case 'paymentMethods':
|
|
243
|
+
return state.paymentMethods;
|
|
244
|
+
/* istanbul ignore next -- ResourceType is a closed internal union. */
|
|
245
|
+
default:
|
|
246
|
+
throw new Error(`Unsupported resource type: ${resourceType}`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
178
249
|
function resetResource(state, resourceType, defaultResource) {
|
|
179
|
-
const resource = state
|
|
250
|
+
const resource = getResourceState(state, resourceType);
|
|
180
251
|
resource.data = defaultResource.data;
|
|
181
252
|
resource.selected = defaultResource.selected;
|
|
182
253
|
resource.isLoading = defaultResource.isLoading;
|
|
183
254
|
resource.error = defaultResource.error;
|
|
255
|
+
resource.errorKey = defaultResource.errorKey ?? null;
|
|
184
256
|
}
|
|
185
257
|
/**
|
|
186
258
|
* Resets region-dependent resources (userRegion, providers, tokens, paymentMethods).
|
|
@@ -469,15 +541,15 @@ export class RampsController extends BaseController {
|
|
|
469
541
|
if (abortController.signal.aborted) {
|
|
470
542
|
throw error;
|
|
471
543
|
}
|
|
472
|
-
const
|
|
473
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateRequestState).call(this, cacheKey, createErrorState(
|
|
544
|
+
const { errorInfo, normalizedError } = getNormalizedRampsError(error);
|
|
545
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateRequestState).call(this, cacheKey, createErrorState(errorInfo.message, lastFetchedAt, errorInfo.errorKey));
|
|
474
546
|
if (resourceType) {
|
|
475
547
|
const isCurrent = !options?.isResultCurrent || options.isResultCurrent();
|
|
476
548
|
if (isCurrent) {
|
|
477
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_setResourceError).call(this, resourceType,
|
|
549
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_setResourceError).call(this, resourceType, errorInfo);
|
|
478
550
|
}
|
|
479
551
|
}
|
|
480
|
-
throw
|
|
552
|
+
throw normalizedError;
|
|
481
553
|
}
|
|
482
554
|
finally {
|
|
483
555
|
if (__classPrivateFieldGet(this, _RampsController_pendingRequests, "f").get(cacheKey)?.abortController ===
|
|
@@ -1174,7 +1246,12 @@ export class RampsController extends BaseController {
|
|
|
1174
1246
|
* @returns The OTP response containing a state token for verification.
|
|
1175
1247
|
*/
|
|
1176
1248
|
async transakSendUserOtp(email) {
|
|
1177
|
-
|
|
1249
|
+
try {
|
|
1250
|
+
return await this.messenger.call('TransakService:sendUserOtp', email);
|
|
1251
|
+
}
|
|
1252
|
+
catch (error) {
|
|
1253
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error).normalizedError;
|
|
1254
|
+
}
|
|
1178
1255
|
}
|
|
1179
1256
|
/**
|
|
1180
1257
|
* Verifies a one-time password and authenticates the user with Transak.
|
|
@@ -1186,9 +1263,14 @@ export class RampsController extends BaseController {
|
|
|
1186
1263
|
* @returns The access token for subsequent authenticated requests.
|
|
1187
1264
|
*/
|
|
1188
1265
|
async transakVerifyUserOtp(email, verificationCode, stateToken) {
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1266
|
+
try {
|
|
1267
|
+
const token = await this.messenger.call('TransakService:verifyUserOtp', email, verificationCode, stateToken);
|
|
1268
|
+
this.transakSetAuthenticated(true);
|
|
1269
|
+
return token;
|
|
1270
|
+
}
|
|
1271
|
+
catch (error) {
|
|
1272
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error).normalizedError;
|
|
1273
|
+
}
|
|
1192
1274
|
}
|
|
1193
1275
|
/**
|
|
1194
1276
|
* Logs the user out of Transak. Clears authentication state and user details
|
|
@@ -1198,8 +1280,10 @@ export class RampsController extends BaseController {
|
|
|
1198
1280
|
*/
|
|
1199
1281
|
async transakLogout() {
|
|
1200
1282
|
try {
|
|
1201
|
-
|
|
1202
|
-
|
|
1283
|
+
return await this.messenger.call('TransakService:logout');
|
|
1284
|
+
}
|
|
1285
|
+
catch (error) {
|
|
1286
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error).normalizedError;
|
|
1203
1287
|
}
|
|
1204
1288
|
finally {
|
|
1205
1289
|
this.transakClearAccessToken();
|
|
@@ -1218,6 +1302,7 @@ export class RampsController extends BaseController {
|
|
|
1218
1302
|
this.update((state) => {
|
|
1219
1303
|
state.nativeProviders.transak.userDetails.isLoading = true;
|
|
1220
1304
|
state.nativeProviders.transak.userDetails.error = null;
|
|
1305
|
+
delete state.nativeProviders.transak.userDetails.errorKey;
|
|
1221
1306
|
});
|
|
1222
1307
|
try {
|
|
1223
1308
|
const details = await this.messenger.call('TransakService:getUserDetails');
|
|
@@ -1228,13 +1313,15 @@ export class RampsController extends BaseController {
|
|
|
1228
1313
|
return details;
|
|
1229
1314
|
}
|
|
1230
1315
|
catch (error) {
|
|
1231
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1232
|
-
|
|
1316
|
+
const { errorInfo, normalizedError } = __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, {
|
|
1317
|
+
syncAuth: true,
|
|
1318
|
+
});
|
|
1233
1319
|
this.update((state) => {
|
|
1234
1320
|
state.nativeProviders.transak.userDetails.isLoading = false;
|
|
1235
|
-
state.nativeProviders.transak.userDetails.error =
|
|
1321
|
+
state.nativeProviders.transak.userDetails.error = errorInfo.message;
|
|
1322
|
+
state.nativeProviders.transak.userDetails.errorKey = errorInfo.errorKey;
|
|
1236
1323
|
});
|
|
1237
|
-
throw
|
|
1324
|
+
throw normalizedError;
|
|
1238
1325
|
}
|
|
1239
1326
|
}
|
|
1240
1327
|
/**
|
|
@@ -1252,6 +1339,7 @@ export class RampsController extends BaseController {
|
|
|
1252
1339
|
this.update((state) => {
|
|
1253
1340
|
state.nativeProviders.transak.buyQuote.isLoading = true;
|
|
1254
1341
|
state.nativeProviders.transak.buyQuote.error = null;
|
|
1342
|
+
delete state.nativeProviders.transak.buyQuote.errorKey;
|
|
1255
1343
|
});
|
|
1256
1344
|
try {
|
|
1257
1345
|
const quote = await this.messenger.call('TransakService:getBuyQuote', fiatCurrency, cryptoCurrency, network, paymentMethod, fiatAmount);
|
|
@@ -1262,12 +1350,13 @@ export class RampsController extends BaseController {
|
|
|
1262
1350
|
return quote;
|
|
1263
1351
|
}
|
|
1264
1352
|
catch (error) {
|
|
1265
|
-
const
|
|
1353
|
+
const { errorInfo, normalizedError } = __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error);
|
|
1266
1354
|
this.update((state) => {
|
|
1267
1355
|
state.nativeProviders.transak.buyQuote.isLoading = false;
|
|
1268
|
-
state.nativeProviders.transak.buyQuote.error =
|
|
1356
|
+
state.nativeProviders.transak.buyQuote.error = errorInfo.message;
|
|
1357
|
+
state.nativeProviders.transak.buyQuote.errorKey = errorInfo.errorKey;
|
|
1269
1358
|
});
|
|
1270
|
-
throw
|
|
1359
|
+
throw normalizedError;
|
|
1271
1360
|
}
|
|
1272
1361
|
}
|
|
1273
1362
|
/**
|
|
@@ -1281,6 +1370,7 @@ export class RampsController extends BaseController {
|
|
|
1281
1370
|
this.update((state) => {
|
|
1282
1371
|
state.nativeProviders.transak.kycRequirement.isLoading = true;
|
|
1283
1372
|
state.nativeProviders.transak.kycRequirement.error = null;
|
|
1373
|
+
delete state.nativeProviders.transak.kycRequirement.errorKey;
|
|
1284
1374
|
});
|
|
1285
1375
|
try {
|
|
1286
1376
|
const requirement = await this.messenger.call('TransakService:getKycRequirement', quoteId);
|
|
@@ -1291,13 +1381,16 @@ export class RampsController extends BaseController {
|
|
|
1291
1381
|
return requirement;
|
|
1292
1382
|
}
|
|
1293
1383
|
catch (error) {
|
|
1294
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1295
|
-
|
|
1384
|
+
const { errorInfo, normalizedError } = __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, {
|
|
1385
|
+
syncAuth: true,
|
|
1386
|
+
});
|
|
1296
1387
|
this.update((state) => {
|
|
1297
1388
|
state.nativeProviders.transak.kycRequirement.isLoading = false;
|
|
1298
|
-
state.nativeProviders.transak.kycRequirement.error =
|
|
1389
|
+
state.nativeProviders.transak.kycRequirement.error = errorInfo.message;
|
|
1390
|
+
state.nativeProviders.transak.kycRequirement.errorKey =
|
|
1391
|
+
errorInfo.errorKey;
|
|
1299
1392
|
});
|
|
1300
|
-
throw
|
|
1393
|
+
throw normalizedError;
|
|
1301
1394
|
}
|
|
1302
1395
|
}
|
|
1303
1396
|
/**
|
|
@@ -1311,8 +1404,8 @@ export class RampsController extends BaseController {
|
|
|
1311
1404
|
return await this.messenger.call('TransakService:getAdditionalRequirements', quoteId);
|
|
1312
1405
|
}
|
|
1313
1406
|
catch (error) {
|
|
1314
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1315
|
-
|
|
1407
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1408
|
+
.normalizedError;
|
|
1316
1409
|
}
|
|
1317
1410
|
}
|
|
1318
1411
|
/**
|
|
@@ -1329,8 +1422,8 @@ export class RampsController extends BaseController {
|
|
|
1329
1422
|
return await this.messenger.call('TransakService:createOrder', quoteId, walletAddress, paymentMethodId);
|
|
1330
1423
|
}
|
|
1331
1424
|
catch (error) {
|
|
1332
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1333
|
-
|
|
1425
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1426
|
+
.normalizedError;
|
|
1334
1427
|
}
|
|
1335
1428
|
}
|
|
1336
1429
|
/**
|
|
@@ -1342,7 +1435,12 @@ export class RampsController extends BaseController {
|
|
|
1342
1435
|
* @returns The deposit order details.
|
|
1343
1436
|
*/
|
|
1344
1437
|
async transakGetOrder(orderId, wallet, paymentDetails) {
|
|
1345
|
-
|
|
1438
|
+
try {
|
|
1439
|
+
return await this.messenger.call('TransakService:getOrder', orderId, wallet, paymentDetails);
|
|
1440
|
+
}
|
|
1441
|
+
catch (error) {
|
|
1442
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error).normalizedError;
|
|
1443
|
+
}
|
|
1346
1444
|
}
|
|
1347
1445
|
/**
|
|
1348
1446
|
* Fetches the user's spending limits for a given currency and payment method.
|
|
@@ -1357,8 +1455,8 @@ export class RampsController extends BaseController {
|
|
|
1357
1455
|
return await this.messenger.call('TransakService:getUserLimits', fiatCurrency, paymentMethod, kycType);
|
|
1358
1456
|
}
|
|
1359
1457
|
catch (error) {
|
|
1360
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1361
|
-
|
|
1458
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1459
|
+
.normalizedError;
|
|
1362
1460
|
}
|
|
1363
1461
|
}
|
|
1364
1462
|
/**
|
|
@@ -1371,8 +1469,8 @@ export class RampsController extends BaseController {
|
|
|
1371
1469
|
return await this.messenger.call('TransakService:requestOtt');
|
|
1372
1470
|
}
|
|
1373
1471
|
catch (error) {
|
|
1374
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1375
|
-
|
|
1472
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1473
|
+
.normalizedError;
|
|
1376
1474
|
}
|
|
1377
1475
|
}
|
|
1378
1476
|
/**
|
|
@@ -1398,8 +1496,8 @@ export class RampsController extends BaseController {
|
|
|
1398
1496
|
return await this.messenger.call('TransakService:submitPurposeOfUsageForm', purpose);
|
|
1399
1497
|
}
|
|
1400
1498
|
catch (error) {
|
|
1401
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1402
|
-
|
|
1499
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1500
|
+
.normalizedError;
|
|
1403
1501
|
}
|
|
1404
1502
|
}
|
|
1405
1503
|
/**
|
|
@@ -1413,8 +1511,8 @@ export class RampsController extends BaseController {
|
|
|
1413
1511
|
return await this.messenger.call('TransakService:patchUser', data);
|
|
1414
1512
|
}
|
|
1415
1513
|
catch (error) {
|
|
1416
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1417
|
-
|
|
1514
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1515
|
+
.normalizedError;
|
|
1418
1516
|
}
|
|
1419
1517
|
}
|
|
1420
1518
|
/**
|
|
@@ -1429,8 +1527,8 @@ export class RampsController extends BaseController {
|
|
|
1429
1527
|
return await this.messenger.call('TransakService:submitSsnDetails', ssn, quoteId);
|
|
1430
1528
|
}
|
|
1431
1529
|
catch (error) {
|
|
1432
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1433
|
-
|
|
1530
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1531
|
+
.normalizedError;
|
|
1434
1532
|
}
|
|
1435
1533
|
}
|
|
1436
1534
|
/**
|
|
@@ -1445,8 +1543,8 @@ export class RampsController extends BaseController {
|
|
|
1445
1543
|
return await this.messenger.call('TransakService:confirmPayment', orderId, paymentMethodId);
|
|
1446
1544
|
}
|
|
1447
1545
|
catch (error) {
|
|
1448
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1449
|
-
|
|
1546
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1547
|
+
.normalizedError;
|
|
1450
1548
|
}
|
|
1451
1549
|
}
|
|
1452
1550
|
/**
|
|
@@ -1456,7 +1554,12 @@ export class RampsController extends BaseController {
|
|
|
1456
1554
|
* @returns The translated Transak-specific identifiers.
|
|
1457
1555
|
*/
|
|
1458
1556
|
async transakGetTranslation(request) {
|
|
1459
|
-
|
|
1557
|
+
try {
|
|
1558
|
+
return await this.messenger.call('TransakService:getTranslation', request);
|
|
1559
|
+
}
|
|
1560
|
+
catch (error) {
|
|
1561
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error).normalizedError;
|
|
1562
|
+
}
|
|
1460
1563
|
}
|
|
1461
1564
|
/**
|
|
1462
1565
|
* Checks the status of an ID proof submission for KYC.
|
|
@@ -1469,8 +1572,8 @@ export class RampsController extends BaseController {
|
|
|
1469
1572
|
return await this.messenger.call('TransakService:getIdProofStatus', workFlowRunId);
|
|
1470
1573
|
}
|
|
1471
1574
|
catch (error) {
|
|
1472
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1473
|
-
|
|
1575
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1576
|
+
.normalizedError;
|
|
1474
1577
|
}
|
|
1475
1578
|
}
|
|
1476
1579
|
/**
|
|
@@ -1484,8 +1587,8 @@ export class RampsController extends BaseController {
|
|
|
1484
1587
|
return await this.messenger.call('TransakService:cancelOrder', depositOrderId);
|
|
1485
1588
|
}
|
|
1486
1589
|
catch (error) {
|
|
1487
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1488
|
-
|
|
1590
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1591
|
+
.normalizedError;
|
|
1489
1592
|
}
|
|
1490
1593
|
}
|
|
1491
1594
|
/**
|
|
@@ -1499,8 +1602,8 @@ export class RampsController extends BaseController {
|
|
|
1499
1602
|
return await this.messenger.call('TransakService:cancelAllActiveOrders');
|
|
1500
1603
|
}
|
|
1501
1604
|
catch (error) {
|
|
1502
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1503
|
-
|
|
1605
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1606
|
+
.normalizedError;
|
|
1504
1607
|
}
|
|
1505
1608
|
}
|
|
1506
1609
|
/**
|
|
@@ -1513,8 +1616,8 @@ export class RampsController extends BaseController {
|
|
|
1513
1616
|
return await this.messenger.call('TransakService:getActiveOrders');
|
|
1514
1617
|
}
|
|
1515
1618
|
catch (error) {
|
|
1516
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1517
|
-
|
|
1619
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1620
|
+
.normalizedError;
|
|
1518
1621
|
}
|
|
1519
1622
|
}
|
|
1520
1623
|
}
|
|
@@ -1563,15 +1666,17 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
|
|
|
1563
1666
|
return current === normalizedProviderId;
|
|
1564
1667
|
}, _RampsController_updateResourceField = function _RampsController_updateResourceField(resourceType, field, value) {
|
|
1565
1668
|
this.update((state) => {
|
|
1566
|
-
const resource = state
|
|
1567
|
-
|
|
1568
|
-
resource[field] = value;
|
|
1569
|
-
}
|
|
1669
|
+
const resource = getResourceState(state, resourceType);
|
|
1670
|
+
resource[field] = value;
|
|
1570
1671
|
});
|
|
1571
1672
|
}, _RampsController_setResourceLoading = function _RampsController_setResourceLoading(resourceType, loading) {
|
|
1572
1673
|
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateResourceField).call(this, resourceType, 'isLoading', loading);
|
|
1573
|
-
}, _RampsController_setResourceError = function _RampsController_setResourceError(resourceType,
|
|
1574
|
-
|
|
1674
|
+
}, _RampsController_setResourceError = function _RampsController_setResourceError(resourceType, errorInfo) {
|
|
1675
|
+
this.update((state) => {
|
|
1676
|
+
const resource = getResourceState(state, resourceType);
|
|
1677
|
+
resource.error = errorInfo?.message ?? null;
|
|
1678
|
+
resource.errorKey = errorInfo?.errorKey ?? null;
|
|
1679
|
+
});
|
|
1575
1680
|
}, _RampsController_updateRequestState = function _RampsController_updateRequestState(cacheKey, requestState) {
|
|
1576
1681
|
const maxSize = __classPrivateFieldGet(this, _RampsController_requestCacheMaxSize, "f");
|
|
1577
1682
|
const ttl = __classPrivateFieldGet(this, _RampsController_requestCacheTTL, "f");
|
|
@@ -1691,10 +1796,13 @@ async function _RampsController_refreshOrder(order) {
|
|
|
1691
1796
|
__classPrivateFieldSet(this, _RampsController_isPolling, false, "f");
|
|
1692
1797
|
}
|
|
1693
1798
|
}, _RampsController_syncTransakAuthOnError = function _RampsController_syncTransakAuthOnError(error) {
|
|
1694
|
-
if (error
|
|
1695
|
-
'httpStatus' in error &&
|
|
1696
|
-
error.httpStatus === 401) {
|
|
1799
|
+
if (hasHttpStatus(error) && error.httpStatus === 401) {
|
|
1697
1800
|
this.transakSetAuthenticated(false);
|
|
1698
1801
|
}
|
|
1802
|
+
}, _RampsController_getNormalizedTransakError = function _RampsController_getNormalizedTransakError(error, options = {}) {
|
|
1803
|
+
if (options.syncAuth) {
|
|
1804
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1805
|
+
}
|
|
1806
|
+
return getNormalizedRampsError(error);
|
|
1699
1807
|
};
|
|
1700
1808
|
//# sourceMappingURL=RampsController.mjs.map
|