@metamask-previews/ramps-controller 13.2.0-preview-7cef09c77 → 13.2.0-preview-a1caffc9c
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 +0 -8
- package/dist/RampsController.cjs +58 -166
- package/dist/RampsController.cjs.map +1 -1
- package/dist/RampsController.d.cts +0 -5
- package/dist/RampsController.d.cts.map +1 -1
- package/dist/RampsController.d.mts +0 -5
- package/dist/RampsController.d.mts.map +1 -1
- package/dist/RampsController.mjs +58 -166
- package/dist/RampsController.mjs.map +1 -1
- package/dist/RequestCache.cjs +2 -7
- package/dist/RequestCache.cjs.map +1 -1
- package/dist/RequestCache.d.cts +1 -5
- package/dist/RequestCache.d.cts.map +1 -1
- package/dist/RequestCache.d.mts +1 -5
- package/dist/RequestCache.d.mts.map +1 -1
- package/dist/RequestCache.mjs +2 -7
- package/dist/RequestCache.mjs.map +1 -1
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/dist/selectors.cjs +1 -5
- package/dist/selectors.cjs.map +1 -1
- package/dist/selectors.d.cts +0 -3
- package/dist/selectors.d.cts.map +1 -1
- package/dist/selectors.d.mts +0 -3
- package/dist/selectors.d.mts.map +1 -1
- package/dist/selectors.mjs +1 -5
- package/dist/selectors.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/rampsErrorCodes.cjs +0 -11
- package/dist/rampsErrorCodes.cjs.map +0 -1
- package/dist/rampsErrorCodes.d.cts +0 -9
- package/dist/rampsErrorCodes.d.cts.map +0 -1
- package/dist/rampsErrorCodes.d.mts +0 -9
- package/dist/rampsErrorCodes.d.mts.map +0 -1
- package/dist/rampsErrorCodes.mjs +0 -8
- package/dist/rampsErrorCodes.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,14 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Changed
|
|
11
|
-
|
|
12
|
-
- Bump `@metamask/messenger` from `^1.1.1` to `^1.2.0` ([#8632](https://github.com/MetaMask/core/pull/8632))
|
|
13
|
-
|
|
14
|
-
### Fixed
|
|
15
|
-
|
|
16
|
-
- 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)).
|
|
17
|
-
|
|
18
10
|
## [13.2.0]
|
|
19
11
|
|
|
20
12
|
### Changed
|
package/dist/RampsController.cjs
CHANGED
|
@@ -10,12 +10,10 @@ 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;
|
|
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");
|
|
19
17
|
const RampsService_1 = require("./RampsService.cjs");
|
|
20
18
|
const RequestCache_1 = require("./RequestCache.cjs");
|
|
21
19
|
// === GENERAL ===
|
|
@@ -70,60 +68,6 @@ exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = [
|
|
|
70
68
|
* Quotes are time-sensitive and should have a shorter cache duration.
|
|
71
69
|
*/
|
|
72
70
|
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
|
-
}
|
|
127
71
|
/**
|
|
128
72
|
* The metadata for each property in {@link RampsControllerState}.
|
|
129
73
|
*/
|
|
@@ -235,28 +179,12 @@ const DEPENDENT_RESOURCE_KEYS = [
|
|
|
235
179
|
'paymentMethods',
|
|
236
180
|
];
|
|
237
181
|
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
|
-
}
|
|
253
182
|
function resetResource(state, resourceType, defaultResource) {
|
|
254
|
-
const resource =
|
|
183
|
+
const resource = state[resourceType];
|
|
255
184
|
resource.data = defaultResource.data;
|
|
256
185
|
resource.selected = defaultResource.selected;
|
|
257
186
|
resource.isLoading = defaultResource.isLoading;
|
|
258
187
|
resource.error = defaultResource.error;
|
|
259
|
-
resource.errorKey = defaultResource.errorKey ?? null;
|
|
260
188
|
}
|
|
261
189
|
/**
|
|
262
190
|
* Resets region-dependent resources (userRegion, providers, tokens, paymentMethods).
|
|
@@ -546,15 +474,15 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
546
474
|
if (abortController.signal.aborted) {
|
|
547
475
|
throw error;
|
|
548
476
|
}
|
|
549
|
-
const
|
|
550
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateRequestState).call(this, cacheKey, (0, RequestCache_1.createErrorState)(
|
|
477
|
+
const errorMessage = error?.message ?? 'Unknown error';
|
|
478
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateRequestState).call(this, cacheKey, (0, RequestCache_1.createErrorState)(errorMessage, lastFetchedAt));
|
|
551
479
|
if (resourceType) {
|
|
552
480
|
const isCurrent = !options?.isResultCurrent || options.isResultCurrent();
|
|
553
481
|
if (isCurrent) {
|
|
554
|
-
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_setResourceError).call(this, resourceType,
|
|
482
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_setResourceError).call(this, resourceType, errorMessage);
|
|
555
483
|
}
|
|
556
484
|
}
|
|
557
|
-
throw
|
|
485
|
+
throw error;
|
|
558
486
|
}
|
|
559
487
|
finally {
|
|
560
488
|
if (__classPrivateFieldGet(this, _RampsController_pendingRequests, "f").get(cacheKey)?.abortController ===
|
|
@@ -1251,12 +1179,7 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1251
1179
|
* @returns The OTP response containing a state token for verification.
|
|
1252
1180
|
*/
|
|
1253
1181
|
async transakSendUserOtp(email) {
|
|
1254
|
-
|
|
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
|
-
}
|
|
1182
|
+
return this.messenger.call('TransakService:sendUserOtp', email);
|
|
1260
1183
|
}
|
|
1261
1184
|
/**
|
|
1262
1185
|
* Verifies a one-time password and authenticates the user with Transak.
|
|
@@ -1268,14 +1191,9 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1268
1191
|
* @returns The access token for subsequent authenticated requests.
|
|
1269
1192
|
*/
|
|
1270
1193
|
async transakVerifyUserOtp(email, verificationCode, stateToken) {
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
return token;
|
|
1275
|
-
}
|
|
1276
|
-
catch (error) {
|
|
1277
|
-
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error).normalizedError;
|
|
1278
|
-
}
|
|
1194
|
+
const token = await this.messenger.call('TransakService:verifyUserOtp', email, verificationCode, stateToken);
|
|
1195
|
+
this.transakSetAuthenticated(true);
|
|
1196
|
+
return token;
|
|
1279
1197
|
}
|
|
1280
1198
|
/**
|
|
1281
1199
|
* Logs the user out of Transak. Clears authentication state and user details
|
|
@@ -1285,10 +1203,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1285
1203
|
*/
|
|
1286
1204
|
async transakLogout() {
|
|
1287
1205
|
try {
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
catch (error) {
|
|
1291
|
-
throw __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_getNormalizedTransakError).call(this, error).normalizedError;
|
|
1206
|
+
const result = await this.messenger.call('TransakService:logout');
|
|
1207
|
+
return result;
|
|
1292
1208
|
}
|
|
1293
1209
|
finally {
|
|
1294
1210
|
this.transakClearAccessToken();
|
|
@@ -1307,7 +1223,6 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1307
1223
|
this.update((state) => {
|
|
1308
1224
|
state.nativeProviders.transak.userDetails.isLoading = true;
|
|
1309
1225
|
state.nativeProviders.transak.userDetails.error = null;
|
|
1310
|
-
delete state.nativeProviders.transak.userDetails.errorKey;
|
|
1311
1226
|
});
|
|
1312
1227
|
try {
|
|
1313
1228
|
const details = await this.messenger.call('TransakService:getUserDetails');
|
|
@@ -1318,15 +1233,13 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1318
1233
|
return details;
|
|
1319
1234
|
}
|
|
1320
1235
|
catch (error) {
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
});
|
|
1236
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1237
|
+
const errorMessage = error?.message ?? 'Unknown error';
|
|
1324
1238
|
this.update((state) => {
|
|
1325
1239
|
state.nativeProviders.transak.userDetails.isLoading = false;
|
|
1326
|
-
state.nativeProviders.transak.userDetails.error =
|
|
1327
|
-
state.nativeProviders.transak.userDetails.errorKey = errorInfo.errorKey;
|
|
1240
|
+
state.nativeProviders.transak.userDetails.error = errorMessage;
|
|
1328
1241
|
});
|
|
1329
|
-
throw
|
|
1242
|
+
throw error;
|
|
1330
1243
|
}
|
|
1331
1244
|
}
|
|
1332
1245
|
/**
|
|
@@ -1344,7 +1257,6 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1344
1257
|
this.update((state) => {
|
|
1345
1258
|
state.nativeProviders.transak.buyQuote.isLoading = true;
|
|
1346
1259
|
state.nativeProviders.transak.buyQuote.error = null;
|
|
1347
|
-
delete state.nativeProviders.transak.buyQuote.errorKey;
|
|
1348
1260
|
});
|
|
1349
1261
|
try {
|
|
1350
1262
|
const quote = await this.messenger.call('TransakService:getBuyQuote', fiatCurrency, cryptoCurrency, network, paymentMethod, fiatAmount);
|
|
@@ -1355,13 +1267,12 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1355
1267
|
return quote;
|
|
1356
1268
|
}
|
|
1357
1269
|
catch (error) {
|
|
1358
|
-
const
|
|
1270
|
+
const errorMessage = error?.message ?? 'Unknown error';
|
|
1359
1271
|
this.update((state) => {
|
|
1360
1272
|
state.nativeProviders.transak.buyQuote.isLoading = false;
|
|
1361
|
-
state.nativeProviders.transak.buyQuote.error =
|
|
1362
|
-
state.nativeProviders.transak.buyQuote.errorKey = errorInfo.errorKey;
|
|
1273
|
+
state.nativeProviders.transak.buyQuote.error = errorMessage;
|
|
1363
1274
|
});
|
|
1364
|
-
throw
|
|
1275
|
+
throw error;
|
|
1365
1276
|
}
|
|
1366
1277
|
}
|
|
1367
1278
|
/**
|
|
@@ -1375,7 +1286,6 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1375
1286
|
this.update((state) => {
|
|
1376
1287
|
state.nativeProviders.transak.kycRequirement.isLoading = true;
|
|
1377
1288
|
state.nativeProviders.transak.kycRequirement.error = null;
|
|
1378
|
-
delete state.nativeProviders.transak.kycRequirement.errorKey;
|
|
1379
1289
|
});
|
|
1380
1290
|
try {
|
|
1381
1291
|
const requirement = await this.messenger.call('TransakService:getKycRequirement', quoteId);
|
|
@@ -1386,16 +1296,13 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1386
1296
|
return requirement;
|
|
1387
1297
|
}
|
|
1388
1298
|
catch (error) {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
});
|
|
1299
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1300
|
+
const errorMessage = error?.message ?? 'Unknown error';
|
|
1392
1301
|
this.update((state) => {
|
|
1393
1302
|
state.nativeProviders.transak.kycRequirement.isLoading = false;
|
|
1394
|
-
state.nativeProviders.transak.kycRequirement.error =
|
|
1395
|
-
state.nativeProviders.transak.kycRequirement.errorKey =
|
|
1396
|
-
errorInfo.errorKey;
|
|
1303
|
+
state.nativeProviders.transak.kycRequirement.error = errorMessage;
|
|
1397
1304
|
});
|
|
1398
|
-
throw
|
|
1305
|
+
throw error;
|
|
1399
1306
|
}
|
|
1400
1307
|
}
|
|
1401
1308
|
/**
|
|
@@ -1409,8 +1316,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1409
1316
|
return await this.messenger.call('TransakService:getAdditionalRequirements', quoteId);
|
|
1410
1317
|
}
|
|
1411
1318
|
catch (error) {
|
|
1412
|
-
|
|
1413
|
-
|
|
1319
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1320
|
+
throw error;
|
|
1414
1321
|
}
|
|
1415
1322
|
}
|
|
1416
1323
|
/**
|
|
@@ -1427,8 +1334,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1427
1334
|
return await this.messenger.call('TransakService:createOrder', quoteId, walletAddress, paymentMethodId);
|
|
1428
1335
|
}
|
|
1429
1336
|
catch (error) {
|
|
1430
|
-
|
|
1431
|
-
|
|
1337
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1338
|
+
throw error;
|
|
1432
1339
|
}
|
|
1433
1340
|
}
|
|
1434
1341
|
/**
|
|
@@ -1440,12 +1347,7 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1440
1347
|
* @returns The deposit order details.
|
|
1441
1348
|
*/
|
|
1442
1349
|
async transakGetOrder(orderId, wallet, paymentDetails) {
|
|
1443
|
-
|
|
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
|
-
}
|
|
1350
|
+
return this.messenger.call('TransakService:getOrder', orderId, wallet, paymentDetails);
|
|
1449
1351
|
}
|
|
1450
1352
|
/**
|
|
1451
1353
|
* Fetches the user's spending limits for a given currency and payment method.
|
|
@@ -1460,8 +1362,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1460
1362
|
return await this.messenger.call('TransakService:getUserLimits', fiatCurrency, paymentMethod, kycType);
|
|
1461
1363
|
}
|
|
1462
1364
|
catch (error) {
|
|
1463
|
-
|
|
1464
|
-
|
|
1365
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1366
|
+
throw error;
|
|
1465
1367
|
}
|
|
1466
1368
|
}
|
|
1467
1369
|
/**
|
|
@@ -1474,8 +1376,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1474
1376
|
return await this.messenger.call('TransakService:requestOtt');
|
|
1475
1377
|
}
|
|
1476
1378
|
catch (error) {
|
|
1477
|
-
|
|
1478
|
-
|
|
1379
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1380
|
+
throw error;
|
|
1479
1381
|
}
|
|
1480
1382
|
}
|
|
1481
1383
|
/**
|
|
@@ -1501,8 +1403,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1501
1403
|
return await this.messenger.call('TransakService:submitPurposeOfUsageForm', purpose);
|
|
1502
1404
|
}
|
|
1503
1405
|
catch (error) {
|
|
1504
|
-
|
|
1505
|
-
|
|
1406
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1407
|
+
throw error;
|
|
1506
1408
|
}
|
|
1507
1409
|
}
|
|
1508
1410
|
/**
|
|
@@ -1516,8 +1418,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1516
1418
|
return await this.messenger.call('TransakService:patchUser', data);
|
|
1517
1419
|
}
|
|
1518
1420
|
catch (error) {
|
|
1519
|
-
|
|
1520
|
-
|
|
1421
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1422
|
+
throw error;
|
|
1521
1423
|
}
|
|
1522
1424
|
}
|
|
1523
1425
|
/**
|
|
@@ -1532,8 +1434,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1532
1434
|
return await this.messenger.call('TransakService:submitSsnDetails', ssn, quoteId);
|
|
1533
1435
|
}
|
|
1534
1436
|
catch (error) {
|
|
1535
|
-
|
|
1536
|
-
|
|
1437
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1438
|
+
throw error;
|
|
1537
1439
|
}
|
|
1538
1440
|
}
|
|
1539
1441
|
/**
|
|
@@ -1548,8 +1450,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1548
1450
|
return await this.messenger.call('TransakService:confirmPayment', orderId, paymentMethodId);
|
|
1549
1451
|
}
|
|
1550
1452
|
catch (error) {
|
|
1551
|
-
|
|
1552
|
-
|
|
1453
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1454
|
+
throw error;
|
|
1553
1455
|
}
|
|
1554
1456
|
}
|
|
1555
1457
|
/**
|
|
@@ -1559,12 +1461,7 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1559
1461
|
* @returns The translated Transak-specific identifiers.
|
|
1560
1462
|
*/
|
|
1561
1463
|
async transakGetTranslation(request) {
|
|
1562
|
-
|
|
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
|
-
}
|
|
1464
|
+
return this.messenger.call('TransakService:getTranslation', request);
|
|
1568
1465
|
}
|
|
1569
1466
|
/**
|
|
1570
1467
|
* Checks the status of an ID proof submission for KYC.
|
|
@@ -1577,8 +1474,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1577
1474
|
return await this.messenger.call('TransakService:getIdProofStatus', workFlowRunId);
|
|
1578
1475
|
}
|
|
1579
1476
|
catch (error) {
|
|
1580
|
-
|
|
1581
|
-
|
|
1477
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1478
|
+
throw error;
|
|
1582
1479
|
}
|
|
1583
1480
|
}
|
|
1584
1481
|
/**
|
|
@@ -1592,8 +1489,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1592
1489
|
return await this.messenger.call('TransakService:cancelOrder', depositOrderId);
|
|
1593
1490
|
}
|
|
1594
1491
|
catch (error) {
|
|
1595
|
-
|
|
1596
|
-
|
|
1492
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1493
|
+
throw error;
|
|
1597
1494
|
}
|
|
1598
1495
|
}
|
|
1599
1496
|
/**
|
|
@@ -1607,8 +1504,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1607
1504
|
return await this.messenger.call('TransakService:cancelAllActiveOrders');
|
|
1608
1505
|
}
|
|
1609
1506
|
catch (error) {
|
|
1610
|
-
|
|
1611
|
-
|
|
1507
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1508
|
+
throw error;
|
|
1612
1509
|
}
|
|
1613
1510
|
}
|
|
1614
1511
|
/**
|
|
@@ -1621,8 +1518,8 @@ class RampsController extends base_controller_1.BaseController {
|
|
|
1621
1518
|
return await this.messenger.call('TransakService:getActiveOrders');
|
|
1622
1519
|
}
|
|
1623
1520
|
catch (error) {
|
|
1624
|
-
|
|
1625
|
-
|
|
1521
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncTransakAuthOnError).call(this, error);
|
|
1522
|
+
throw error;
|
|
1626
1523
|
}
|
|
1627
1524
|
}
|
|
1628
1525
|
}
|
|
@@ -1672,17 +1569,15 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
|
|
|
1672
1569
|
return current === normalizedProviderId;
|
|
1673
1570
|
}, _RampsController_updateResourceField = function _RampsController_updateResourceField(resourceType, field, value) {
|
|
1674
1571
|
this.update((state) => {
|
|
1675
|
-
const resource =
|
|
1676
|
-
resource
|
|
1572
|
+
const resource = state[resourceType];
|
|
1573
|
+
if (resource) {
|
|
1574
|
+
resource[field] = value;
|
|
1575
|
+
}
|
|
1677
1576
|
});
|
|
1678
1577
|
}, _RampsController_setResourceLoading = function _RampsController_setResourceLoading(resourceType, loading) {
|
|
1679
1578
|
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateResourceField).call(this, resourceType, 'isLoading', loading);
|
|
1680
|
-
}, _RampsController_setResourceError = function _RampsController_setResourceError(resourceType,
|
|
1681
|
-
this.
|
|
1682
|
-
const resource = getResourceState(state, resourceType);
|
|
1683
|
-
resource.error = errorInfo?.message ?? null;
|
|
1684
|
-
resource.errorKey = errorInfo?.errorKey ?? null;
|
|
1685
|
-
});
|
|
1579
|
+
}, _RampsController_setResourceError = function _RampsController_setResourceError(resourceType, error) {
|
|
1580
|
+
__classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_updateResourceField).call(this, resourceType, 'error', error);
|
|
1686
1581
|
}, _RampsController_updateRequestState = function _RampsController_updateRequestState(cacheKey, requestState) {
|
|
1687
1582
|
const maxSize = __classPrivateFieldGet(this, _RampsController_requestCacheMaxSize, "f");
|
|
1688
1583
|
const ttl = __classPrivateFieldGet(this, _RampsController_requestCacheTTL, "f");
|
|
@@ -1802,13 +1697,10 @@ async function _RampsController_refreshOrder(order) {
|
|
|
1802
1697
|
__classPrivateFieldSet(this, _RampsController_isPolling, false, "f");
|
|
1803
1698
|
}
|
|
1804
1699
|
}, _RampsController_syncTransakAuthOnError = function _RampsController_syncTransakAuthOnError(error) {
|
|
1805
|
-
if (
|
|
1700
|
+
if (error instanceof Error &&
|
|
1701
|
+
'httpStatus' in error &&
|
|
1702
|
+
error.httpStatus === 401) {
|
|
1806
1703
|
this.transakSetAuthenticated(false);
|
|
1807
1704
|
}
|
|
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);
|
|
1813
1705
|
};
|
|
1814
1706
|
//# sourceMappingURL=RampsController.cjs.map
|