@metamask-previews/ramps-controller 13.2.0-preview-95a687acf → 13.2.0-preview-4e0ae1bc9
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 +4 -0
- 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/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/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 +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
12
12
|
- Bump `@metamask/messenger` from `^1.1.1` to `^1.2.0` ([#8632](https://github.com/MetaMask/core/pull/8632))
|
|
13
13
|
- `RampsService` routes `RampsEnvironment.Development` to dev-api base URLs; regions requests in development omit the `-cache` hostname segment used in staging and production ([#8574](https://github.com/MetaMask/core/pull/8574))
|
|
14
14
|
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- Tag circuit-breaker errors in `RampsController` with a stable `CIRCUIT_BREAKER_OPEN` error key so clients can localize the fallback copy without depending on internal Cockatiel text ([#8596](https://github.com/MetaMask/core/pull/8596)).
|
|
18
|
+
|
|
15
19
|
## [13.2.0]
|
|
16
20
|
|
|
17
21
|
### Changed
|
package/dist/RampsController.cjs
CHANGED
|
@@ -10,10 +10,12 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
10
10
|
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");
|
|
11
11
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
12
|
};
|
|
13
|
-
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;
|
|
13
|
+
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;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.RampsController = exports.normalizeProviderCode = exports.getDefaultRampsControllerState = exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = exports.controllerName = void 0;
|
|
16
16
|
const base_controller_1 = require("@metamask/base-controller");
|
|
17
|
+
const controller_utils_1 = require("@metamask/controller-utils");
|
|
18
|
+
const rampsErrorCodes_1 = require("./rampsErrorCodes.cjs");
|
|
17
19
|
const RampsService_1 = require("./RampsService.cjs");
|
|
18
20
|
const RequestCache_1 = require("./RequestCache.cjs");
|
|
19
21
|
// === GENERAL ===
|
|
@@ -68,6 +70,60 @@ exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = [
|
|
|
68
70
|
* Quotes are time-sensitive and should have a shorter cache duration.
|
|
69
71
|
*/
|
|
70
72
|
const DEFAULT_QUOTES_TTL = 15000;
|
|
73
|
+
const CIRCUIT_BREAKER_OPEN_ERROR = 'Execution prevented because the circuit breaker is open';
|
|
74
|
+
function hasStringMessage(error) {
|
|
75
|
+
return (typeof error === 'object' &&
|
|
76
|
+
error !== null &&
|
|
77
|
+
typeof error.message === 'string');
|
|
78
|
+
}
|
|
79
|
+
function hasHttpStatus(error) {
|
|
80
|
+
return (error instanceof Error &&
|
|
81
|
+
typeof error.httpStatus === 'number');
|
|
82
|
+
}
|
|
83
|
+
function getRampsErrorInfo(error) {
|
|
84
|
+
if (error instanceof controller_utils_1.BrokenCircuitError && hasStringMessage(error)) {
|
|
85
|
+
return {
|
|
86
|
+
errorKey: rampsErrorCodes_1.RAMPS_ERROR_CODES.CIRCUIT_BREAKER_OPEN,
|
|
87
|
+
message: error.message,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
let rawMessage;
|
|
91
|
+
if (hasStringMessage(error)) {
|
|
92
|
+
rawMessage = error.message;
|
|
93
|
+
}
|
|
94
|
+
else if (typeof error === 'string') {
|
|
95
|
+
rawMessage = error;
|
|
96
|
+
}
|
|
97
|
+
if (rawMessage?.includes(CIRCUIT_BREAKER_OPEN_ERROR)) {
|
|
98
|
+
return {
|
|
99
|
+
errorKey: rampsErrorCodes_1.RAMPS_ERROR_CODES.CIRCUIT_BREAKER_OPEN,
|
|
100
|
+
message: rawMessage,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
errorKey: null,
|
|
105
|
+
message: rawMessage ?? 'Unknown error',
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function getNormalizedRampsError(error) {
|
|
109
|
+
const errorInfo = getRampsErrorInfo(error);
|
|
110
|
+
return {
|
|
111
|
+
errorInfo,
|
|
112
|
+
normalizedError: normalizeRampsErrorForRethrow(error, errorInfo),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function normalizeRampsErrorForRethrow(error, errorInfo) {
|
|
116
|
+
if (!errorInfo.errorKey) {
|
|
117
|
+
return error;
|
|
118
|
+
}
|
|
119
|
+
if (error instanceof Error) {
|
|
120
|
+
error.errorKey = errorInfo.errorKey;
|
|
121
|
+
return error;
|
|
122
|
+
}
|
|
123
|
+
return Object.assign(new Error(errorInfo.message), {
|
|
124
|
+
errorKey: errorInfo.errorKey,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
71
127
|
/**
|
|
72
128
|
* The metadata for each property in {@link RampsControllerState}.
|
|
73
129
|
*/
|
|
@@ -179,12 +235,28 @@ const DEPENDENT_RESOURCE_KEYS = [
|
|
|
179
235
|
'paymentMethods',
|
|
180
236
|
];
|
|
181
237
|
const DEPENDENT_RESOURCE_KEYS_SET = new Set(DEPENDENT_RESOURCE_KEYS);
|
|
238
|
+
function getResourceState(state, resourceType) {
|
|
239
|
+
switch (resourceType) {
|
|
240
|
+
case 'countries':
|
|
241
|
+
return state.countries;
|
|
242
|
+
case 'providers':
|
|
243
|
+
return state.providers;
|
|
244
|
+
case 'tokens':
|
|
245
|
+
return state.tokens;
|
|
246
|
+
case 'paymentMethods':
|
|
247
|
+
return state.paymentMethods;
|
|
248
|
+
/* istanbul ignore next -- ResourceType is a closed internal union. */
|
|
249
|
+
default:
|
|
250
|
+
throw new Error(`Unsupported resource type: ${resourceType}`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
182
253
|
function resetResource(state, resourceType, defaultResource) {
|
|
183
|
-
const resource = state
|
|
254
|
+
const resource = getResourceState(state, resourceType);
|
|
184
255
|
resource.data = defaultResource.data;
|
|
185
256
|
resource.selected = defaultResource.selected;
|
|
186
257
|
resource.isLoading = defaultResource.isLoading;
|
|
187
258
|
resource.error = defaultResource.error;
|
|
259
|
+
resource.errorKey = defaultResource.errorKey ?? null;
|
|
188
260
|
}
|
|
189
261
|
/**
|
|
190
262
|
* Resets region-dependent resources (userRegion, providers, tokens, paymentMethods).
|
|
@@ -474,15 +546,15 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
474
546
|
if (abortController.signal.aborted) {
|
|
475
547
|
throw error;
|
|
476
548
|
}
|
|
477
|
-
const
|
|
478
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateRequestState).call(this, cacheKey, (0, RequestCache_1.createErrorState)(
|
|
549
|
+
const { errorInfo, normalizedError } = getNormalizedRampsError(error);
|
|
550
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateRequestState).call(this, cacheKey, (0, RequestCache_1.createErrorState)(errorInfo.message, lastFetchedAt, errorInfo.errorKey));
|
|
479
551
|
if (resourceType) {
|
|
480
552
|
const isCurrent = !options?.isResultCurrent || options.isResultCurrent();
|
|
481
553
|
if (isCurrent) {
|
|
482
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_setResourceError).call(this, resourceType,
|
|
554
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_setResourceError).call(this, resourceType, errorInfo);
|
|
483
555
|
}
|
|
484
556
|
}
|
|
485
|
-
throw
|
|
557
|
+
throw normalizedError;
|
|
486
558
|
}
|
|
487
559
|
finally {
|
|
488
560
|
if (__classPrivateFieldGet(this, _RampsController_pendingRequests, "f").get(cacheKey)?.abortController ===
|
|
@@ -1179,7 +1251,12 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1179
1251
|
* @returns The OTP response containing a state token for verification.
|
|
1180
1252
|
*/
|
|
1181
1253
|
async transakSendUserOtp(email) {
|
|
1182
|
-
|
|
1254
|
+
try {
|
|
1255
|
+
return await this.messenger.call('TransakService:sendUserOtp', email);
|
|
1256
|
+
}
|
|
1257
|
+
catch (error) {
|
|
1258
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error).normalizedError;
|
|
1259
|
+
}
|
|
1183
1260
|
}
|
|
1184
1261
|
/**
|
|
1185
1262
|
* Verifies a one-time password and authenticates the user with Transak.
|
|
@@ -1191,9 +1268,14 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1191
1268
|
* @returns The access token for subsequent authenticated requests.
|
|
1192
1269
|
*/
|
|
1193
1270
|
async transakVerifyUserOtp(email, verificationCode, stateToken) {
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1271
|
+
try {
|
|
1272
|
+
const token = await this.messenger.call('TransakService:verifyUserOtp', email, verificationCode, stateToken);
|
|
1273
|
+
this.transakSetAuthenticated(true);
|
|
1274
|
+
return token;
|
|
1275
|
+
}
|
|
1276
|
+
catch (error) {
|
|
1277
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error).normalizedError;
|
|
1278
|
+
}
|
|
1197
1279
|
}
|
|
1198
1280
|
/**
|
|
1199
1281
|
* Logs the user out of Transak. Clears authentication state and user details
|
|
@@ -1203,8 +1285,10 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1203
1285
|
*/
|
|
1204
1286
|
async transakLogout() {
|
|
1205
1287
|
try {
|
|
1206
|
-
|
|
1207
|
-
|
|
1288
|
+
return await this.messenger.call('TransakService:logout');
|
|
1289
|
+
}
|
|
1290
|
+
catch (error) {
|
|
1291
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error).normalizedError;
|
|
1208
1292
|
}
|
|
1209
1293
|
finally {
|
|
1210
1294
|
this.transakClearAccessToken();
|
|
@@ -1223,6 +1307,7 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1223
1307
|
this.update((state) => {
|
|
1224
1308
|
state.nativeProviders.transak.userDetails.isLoading = true;
|
|
1225
1309
|
state.nativeProviders.transak.userDetails.error = null;
|
|
1310
|
+
delete state.nativeProviders.transak.userDetails.errorKey;
|
|
1226
1311
|
});
|
|
1227
1312
|
try {
|
|
1228
1313
|
const details = await this.messenger.call('TransakService:getUserDetails');
|
|
@@ -1233,13 +1318,15 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1233
1318
|
return details;
|
|
1234
1319
|
}
|
|
1235
1320
|
catch (error) {
|
|
1236
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1237
|
-
|
|
1321
|
+
const { errorInfo, normalizedError } = __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, {
|
|
1322
|
+
syncAuth: true,
|
|
1323
|
+
});
|
|
1238
1324
|
this.update((state) => {
|
|
1239
1325
|
state.nativeProviders.transak.userDetails.isLoading = false;
|
|
1240
|
-
state.nativeProviders.transak.userDetails.error =
|
|
1326
|
+
state.nativeProviders.transak.userDetails.error = errorInfo.message;
|
|
1327
|
+
state.nativeProviders.transak.userDetails.errorKey = errorInfo.errorKey;
|
|
1241
1328
|
});
|
|
1242
|
-
throw
|
|
1329
|
+
throw normalizedError;
|
|
1243
1330
|
}
|
|
1244
1331
|
}
|
|
1245
1332
|
/**
|
|
@@ -1257,6 +1344,7 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1257
1344
|
this.update((state) => {
|
|
1258
1345
|
state.nativeProviders.transak.buyQuote.isLoading = true;
|
|
1259
1346
|
state.nativeProviders.transak.buyQuote.error = null;
|
|
1347
|
+
delete state.nativeProviders.transak.buyQuote.errorKey;
|
|
1260
1348
|
});
|
|
1261
1349
|
try {
|
|
1262
1350
|
const quote = await this.messenger.call('TransakService:getBuyQuote', fiatCurrency, cryptoCurrency, network, paymentMethod, fiatAmount);
|
|
@@ -1267,12 +1355,13 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1267
1355
|
return quote;
|
|
1268
1356
|
}
|
|
1269
1357
|
catch (error) {
|
|
1270
|
-
const
|
|
1358
|
+
const { errorInfo, normalizedError } = __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error);
|
|
1271
1359
|
this.update((state) => {
|
|
1272
1360
|
state.nativeProviders.transak.buyQuote.isLoading = false;
|
|
1273
|
-
state.nativeProviders.transak.buyQuote.error =
|
|
1361
|
+
state.nativeProviders.transak.buyQuote.error = errorInfo.message;
|
|
1362
|
+
state.nativeProviders.transak.buyQuote.errorKey = errorInfo.errorKey;
|
|
1274
1363
|
});
|
|
1275
|
-
throw
|
|
1364
|
+
throw normalizedError;
|
|
1276
1365
|
}
|
|
1277
1366
|
}
|
|
1278
1367
|
/**
|
|
@@ -1286,6 +1375,7 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1286
1375
|
this.update((state) => {
|
|
1287
1376
|
state.nativeProviders.transak.kycRequirement.isLoading = true;
|
|
1288
1377
|
state.nativeProviders.transak.kycRequirement.error = null;
|
|
1378
|
+
delete state.nativeProviders.transak.kycRequirement.errorKey;
|
|
1289
1379
|
});
|
|
1290
1380
|
try {
|
|
1291
1381
|
const requirement = await this.messenger.call('TransakService:getKycRequirement', quoteId);
|
|
@@ -1296,13 +1386,16 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1296
1386
|
return requirement;
|
|
1297
1387
|
}
|
|
1298
1388
|
catch (error) {
|
|
1299
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1300
|
-
|
|
1389
|
+
const { errorInfo, normalizedError } = __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, {
|
|
1390
|
+
syncAuth: true,
|
|
1391
|
+
});
|
|
1301
1392
|
this.update((state) => {
|
|
1302
1393
|
state.nativeProviders.transak.kycRequirement.isLoading = false;
|
|
1303
|
-
state.nativeProviders.transak.kycRequirement.error =
|
|
1394
|
+
state.nativeProviders.transak.kycRequirement.error = errorInfo.message;
|
|
1395
|
+
state.nativeProviders.transak.kycRequirement.errorKey =
|
|
1396
|
+
errorInfo.errorKey;
|
|
1304
1397
|
});
|
|
1305
|
-
throw
|
|
1398
|
+
throw normalizedError;
|
|
1306
1399
|
}
|
|
1307
1400
|
}
|
|
1308
1401
|
/**
|
|
@@ -1316,8 +1409,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1316
1409
|
return await this.messenger.call('TransakService:getAdditionalRequirements', quoteId);
|
|
1317
1410
|
}
|
|
1318
1411
|
catch (error) {
|
|
1319
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1320
|
-
|
|
1412
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1413
|
+
.normalizedError;
|
|
1321
1414
|
}
|
|
1322
1415
|
}
|
|
1323
1416
|
/**
|
|
@@ -1334,8 +1427,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1334
1427
|
return await this.messenger.call('TransakService:createOrder', quoteId, walletAddress, paymentMethodId);
|
|
1335
1428
|
}
|
|
1336
1429
|
catch (error) {
|
|
1337
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1338
|
-
|
|
1430
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1431
|
+
.normalizedError;
|
|
1339
1432
|
}
|
|
1340
1433
|
}
|
|
1341
1434
|
/**
|
|
@@ -1347,7 +1440,12 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1347
1440
|
* @returns The deposit order details.
|
|
1348
1441
|
*/
|
|
1349
1442
|
async transakGetOrder(orderId, wallet, paymentDetails) {
|
|
1350
|
-
|
|
1443
|
+
try {
|
|
1444
|
+
return await this.messenger.call('TransakService:getOrder', orderId, wallet, paymentDetails);
|
|
1445
|
+
}
|
|
1446
|
+
catch (error) {
|
|
1447
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error).normalizedError;
|
|
1448
|
+
}
|
|
1351
1449
|
}
|
|
1352
1450
|
/**
|
|
1353
1451
|
* Fetches the user's spending limits for a given currency and payment method.
|
|
@@ -1362,8 +1460,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1362
1460
|
return await this.messenger.call('TransakService:getUserLimits', fiatCurrency, paymentMethod, kycType);
|
|
1363
1461
|
}
|
|
1364
1462
|
catch (error) {
|
|
1365
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1366
|
-
|
|
1463
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1464
|
+
.normalizedError;
|
|
1367
1465
|
}
|
|
1368
1466
|
}
|
|
1369
1467
|
/**
|
|
@@ -1376,8 +1474,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1376
1474
|
return await this.messenger.call('TransakService:requestOtt');
|
|
1377
1475
|
}
|
|
1378
1476
|
catch (error) {
|
|
1379
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1380
|
-
|
|
1477
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1478
|
+
.normalizedError;
|
|
1381
1479
|
}
|
|
1382
1480
|
}
|
|
1383
1481
|
/**
|
|
@@ -1403,8 +1501,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1403
1501
|
return await this.messenger.call('TransakService:submitPurposeOfUsageForm', purpose);
|
|
1404
1502
|
}
|
|
1405
1503
|
catch (error) {
|
|
1406
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1407
|
-
|
|
1504
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1505
|
+
.normalizedError;
|
|
1408
1506
|
}
|
|
1409
1507
|
}
|
|
1410
1508
|
/**
|
|
@@ -1418,8 +1516,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1418
1516
|
return await this.messenger.call('TransakService:patchUser', data);
|
|
1419
1517
|
}
|
|
1420
1518
|
catch (error) {
|
|
1421
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1422
|
-
|
|
1519
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1520
|
+
.normalizedError;
|
|
1423
1521
|
}
|
|
1424
1522
|
}
|
|
1425
1523
|
/**
|
|
@@ -1434,8 +1532,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1434
1532
|
return await this.messenger.call('TransakService:submitSsnDetails', ssn, quoteId);
|
|
1435
1533
|
}
|
|
1436
1534
|
catch (error) {
|
|
1437
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1438
|
-
|
|
1535
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1536
|
+
.normalizedError;
|
|
1439
1537
|
}
|
|
1440
1538
|
}
|
|
1441
1539
|
/**
|
|
@@ -1450,8 +1548,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1450
1548
|
return await this.messenger.call('TransakService:confirmPayment', orderId, paymentMethodId);
|
|
1451
1549
|
}
|
|
1452
1550
|
catch (error) {
|
|
1453
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1454
|
-
|
|
1551
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1552
|
+
.normalizedError;
|
|
1455
1553
|
}
|
|
1456
1554
|
}
|
|
1457
1555
|
/**
|
|
@@ -1461,7 +1559,12 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1461
1559
|
* @returns The translated Transak-specific identifiers.
|
|
1462
1560
|
*/
|
|
1463
1561
|
async transakGetTranslation(request) {
|
|
1464
|
-
|
|
1562
|
+
try {
|
|
1563
|
+
return await this.messenger.call('TransakService:getTranslation', request);
|
|
1564
|
+
}
|
|
1565
|
+
catch (error) {
|
|
1566
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error).normalizedError;
|
|
1567
|
+
}
|
|
1465
1568
|
}
|
|
1466
1569
|
/**
|
|
1467
1570
|
* Checks the status of an ID proof submission for KYC.
|
|
@@ -1474,8 +1577,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1474
1577
|
return await this.messenger.call('TransakService:getIdProofStatus', workFlowRunId);
|
|
1475
1578
|
}
|
|
1476
1579
|
catch (error) {
|
|
1477
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1478
|
-
|
|
1580
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1581
|
+
.normalizedError;
|
|
1479
1582
|
}
|
|
1480
1583
|
}
|
|
1481
1584
|
/**
|
|
@@ -1489,8 +1592,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1489
1592
|
return await this.messenger.call('TransakService:cancelOrder', depositOrderId);
|
|
1490
1593
|
}
|
|
1491
1594
|
catch (error) {
|
|
1492
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1493
|
-
|
|
1595
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1596
|
+
.normalizedError;
|
|
1494
1597
|
}
|
|
1495
1598
|
}
|
|
1496
1599
|
/**
|
|
@@ -1504,8 +1607,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1504
1607
|
return await this.messenger.call('TransakService:cancelAllActiveOrders');
|
|
1505
1608
|
}
|
|
1506
1609
|
catch (error) {
|
|
1507
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1508
|
-
|
|
1610
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1611
|
+
.normalizedError;
|
|
1509
1612
|
}
|
|
1510
1613
|
}
|
|
1511
1614
|
/**
|
|
@@ -1518,8 +1621,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1518
1621
|
return await this.messenger.call('TransakService:getActiveOrders');
|
|
1519
1622
|
}
|
|
1520
1623
|
catch (error) {
|
|
1521
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m",
|
|
1522
|
-
|
|
1624
|
+
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error, { syncAuth: true })
|
|
1625
|
+
.normalizedError;
|
|
1523
1626
|
}
|
|
1524
1627
|
}
|
|
1525
1628
|
}
|
|
@@ -1569,15 +1672,17 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
|
|
|
1569
1672
|
return current === normalizedProviderId;
|
|
1570
1673
|
}, _RampsController_updateResourceField = function _RampsController_updateResourceField(resourceType, field, value) {
|
|
1571
1674
|
this.update((state) => {
|
|
1572
|
-
const resource = state
|
|
1573
|
-
|
|
1574
|
-
resource[field] = value;
|
|
1575
|
-
}
|
|
1675
|
+
const resource = getResourceState(state, resourceType);
|
|
1676
|
+
resource[field] = value;
|
|
1576
1677
|
});
|
|
1577
1678
|
}, _RampsController_setResourceLoading = function _RampsController_setResourceLoading(resourceType, loading) {
|
|
1578
1679
|
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateResourceField).call(this, resourceType, 'isLoading', loading);
|
|
1579
|
-
}, _RampsController_setResourceError = function _RampsController_setResourceError(resourceType,
|
|
1580
|
-
|
|
1680
|
+
}, _RampsController_setResourceError = function _RampsController_setResourceError(resourceType, errorInfo) {
|
|
1681
|
+
this.update((state) => {
|
|
1682
|
+
const resource = getResourceState(state, resourceType);
|
|
1683
|
+
resource.error = errorInfo?.message ?? null;
|
|
1684
|
+
resource.errorKey = errorInfo?.errorKey ?? null;
|
|
1685
|
+
});
|
|
1581
1686
|
}, _RampsController_updateRequestState = function _RampsController_updateRequestState(cacheKey, requestState) {
|
|
1582
1687
|
const maxSize = __classPrivateFieldGet(this, _RampsController_requestCacheMaxSize, "f");
|
|
1583
1688
|
const ttl = __classPrivateFieldGet(this, _RampsController_requestCacheTTL, "f");
|
|
@@ -1697,10 +1802,13 @@ async function _RampsController_refreshOrder(order) {
|
|
|
1697
1802
|
__classPrivateFieldSet(this, _RampsController_isPolling, false, "f");
|
|
1698
1803
|
}
|
|
1699
1804
|
}, _RampsController_syncTransakAuthOnError = function _RampsController_syncTransakAuthOnError(error) {
|
|
1700
|
-
if (error
|
|
1701
|
-
'httpStatus' in error &&
|
|
1702
|
-
error.httpStatus === 401) {
|
|
1805
|
+
if (hasHttpStatus(error) && error.httpStatus === 401) {
|
|
1703
1806
|
this.transakSetAuthenticated(false);
|
|
1704
1807
|
}
|
|
1808
|
+
}, _RampsController_getNormalizedTransakError = function _RampsController_getNormalizedTransakError(error, options = {}) {
|
|
1809
|
+
if (options.syncAuth) {
|
|
1810
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1811
|
+
}
|
|
1812
|
+
return getNormalizedRampsError(error);
|
|
1705
1813
|
};
|
|
1706
1814
|
//# sourceMappingURL=RampsController.cjs.map
|