@metamask-previews/ramps-controller 29.0.0-preview-7410208d2 → 29.0.0-preview-e53b41ba2
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 -11
- package/dist/RampsController-method-action-types.d.ts +0 -12
- package/dist/RampsController-method-action-types.d.ts.map +1 -1
- package/dist/RampsController-method-action-types.js.map +1 -1
- package/dist/RampsController.d.ts +1 -23
- package/dist/RampsController.d.ts.map +1 -1
- package/dist/RampsController.js +7 -100
- package/dist/RampsController.js.map +1 -1
- package/dist/TransakService.d.ts +5 -18
- package/dist/TransakService.d.ts.map +1 -1
- package/dist/TransakService.js +114 -293
- package/dist/TransakService.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/rampsErrorCodes.d.ts +0 -1
- package/dist/rampsErrorCodes.d.ts.map +1 -1
- package/dist/rampsErrorCodes.js +0 -1
- package/dist/rampsErrorCodes.js.map +1 -1
- package/package.json +3 -4
package/dist/RampsController.js
CHANGED
|
@@ -297,7 +297,6 @@ function isFullAutorampAccount(value) {
|
|
|
297
297
|
* Quotes are time-sensitive and should have a shorter cache duration.
|
|
298
298
|
*/
|
|
299
299
|
const DEFAULT_QUOTES_TTL = 15000;
|
|
300
|
-
const allowNetworkAccess = () => true;
|
|
301
300
|
const CIRCUIT_BREAKER_OPEN_ERROR = 'Execution prevented because the circuit breaker is open';
|
|
302
301
|
function hasStringMessage(error) {
|
|
303
302
|
return (typeof error === 'object' &&
|
|
@@ -740,7 +739,6 @@ export class RampsController extends BaseController {
|
|
|
740
739
|
* Maximum number of entries in the request cache.
|
|
741
740
|
*/
|
|
742
741
|
#requestCacheMaxSize;
|
|
743
|
-
#isNetworkAccessAllowed;
|
|
744
742
|
#onOrderSyncErroneousSituation;
|
|
745
743
|
#trace;
|
|
746
744
|
#trackAutorampTransactionStatusChanged;
|
|
@@ -864,16 +862,6 @@ export class RampsController extends BaseController {
|
|
|
864
862
|
}
|
|
865
863
|
}
|
|
866
864
|
}
|
|
867
|
-
/**
|
|
868
|
-
* Throws before any request bookkeeping or state write when the host has
|
|
869
|
-
* revoked network access. Cache entries are not served while denied.
|
|
870
|
-
* Callers match on `errorKey`, never the message.
|
|
871
|
-
*/
|
|
872
|
-
#assertNetworkAccessAllowed() {
|
|
873
|
-
if (!this.#isNetworkAccessAllowed()) {
|
|
874
|
-
throw Object.assign(new Error('Ramps network access is not allowed by the host.'), { errorKey: RAMPS_ERROR_CODES.NETWORK_ACCESS_DENIED });
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
865
|
/**
|
|
878
866
|
* Constructs a new {@link RampsController}.
|
|
879
867
|
*
|
|
@@ -883,12 +871,11 @@ export class RampsController extends BaseController {
|
|
|
883
871
|
* controller. Missing properties will be filled in with defaults.
|
|
884
872
|
* @param args.requestCacheTTL - Time to live for cached requests in milliseconds.
|
|
885
873
|
* @param args.requestCacheMaxSize - Maximum number of entries in the request cache.
|
|
886
|
-
* @param args.isNetworkAccessAllowed - Host check for network access. Defaults to allowing access.
|
|
887
874
|
* @param args.onOrderSyncErroneousSituation - Optional order-sync error reporter.
|
|
888
875
|
* @param args.trace - Optional performance tracing callback for order sync.
|
|
889
876
|
* @param args.trackAutorampTransactionStatusChanged - Optional callback for a new autoramp transaction or a status change.
|
|
890
877
|
*/
|
|
891
|
-
constructor({ messenger, state = {}, requestCacheTTL = DEFAULT_REQUEST_CACHE_TTL, requestCacheMaxSize = DEFAULT_REQUEST_CACHE_MAX_SIZE,
|
|
878
|
+
constructor({ messenger, state = {}, requestCacheTTL = DEFAULT_REQUEST_CACHE_TTL, requestCacheMaxSize = DEFAULT_REQUEST_CACHE_MAX_SIZE, onOrderSyncErroneousSituation, trace, trackAutorampTransactionStatusChanged, }) {
|
|
892
879
|
super({
|
|
893
880
|
messenger,
|
|
894
881
|
metadata: rampsControllerMetadata,
|
|
@@ -902,7 +889,6 @@ export class RampsController extends BaseController {
|
|
|
902
889
|
});
|
|
903
890
|
this.#requestCacheTTL = requestCacheTTL;
|
|
904
891
|
this.#requestCacheMaxSize = requestCacheMaxSize;
|
|
905
|
-
this.#isNetworkAccessAllowed = isNetworkAccessAllowed;
|
|
906
892
|
this.#onOrderSyncErroneousSituation = onOrderSyncErroneousSituation;
|
|
907
893
|
this.#trace = trace;
|
|
908
894
|
this.#trackAutorampTransactionStatusChanged =
|
|
@@ -963,9 +949,6 @@ export class RampsController extends BaseController {
|
|
|
963
949
|
* @returns The result of the request (from cache, joined promise, or fetcher).
|
|
964
950
|
*/
|
|
965
951
|
async executeRequest(cacheKey, fetcher, options) {
|
|
966
|
-
// Also guarded here so callers of the exposed
|
|
967
|
-
// `RampsController:executeRequest` action cannot bypass the host gate.
|
|
968
|
-
this.#assertNetworkAccessAllowed();
|
|
969
952
|
// Get TTL for verifying cache expiration
|
|
970
953
|
const ttl = options?.ttl ?? this.#requestCacheTTL;
|
|
971
954
|
// DEDUPLICATION:
|
|
@@ -1354,7 +1337,6 @@ export class RampsController extends BaseController {
|
|
|
1354
1337
|
* @returns Promise that resolves when initialization is complete.
|
|
1355
1338
|
*/
|
|
1356
1339
|
async init(options) {
|
|
1357
|
-
this.#assertNetworkAccessAllowed();
|
|
1358
1340
|
if (!options?.forceRefresh && this.#initPromise !== null) {
|
|
1359
1341
|
return this.#initPromise;
|
|
1360
1342
|
}
|
|
@@ -1426,7 +1408,6 @@ export class RampsController extends BaseController {
|
|
|
1426
1408
|
* @returns An array of countries.
|
|
1427
1409
|
*/
|
|
1428
1410
|
async getCountries(options) {
|
|
1429
|
-
this.#assertNetworkAccessAllowed();
|
|
1430
1411
|
const cacheKey = createCacheKey('getCountries', []);
|
|
1431
1412
|
const countries = await this.executeRequest(cacheKey, async () => {
|
|
1432
1413
|
return this.messenger.call('RampsService:getCountries');
|
|
@@ -1448,7 +1429,6 @@ export class RampsController extends BaseController {
|
|
|
1448
1429
|
* @returns The tokens response containing topTokens and allTokens.
|
|
1449
1430
|
*/
|
|
1450
1431
|
async getTokens(region, action = 'buy', options) {
|
|
1451
|
-
this.#assertNetworkAccessAllowed();
|
|
1452
1432
|
const regionToUse = region ?? this.#requireRegion();
|
|
1453
1433
|
const normalizedRegion = regionToUse.toLowerCase().trim();
|
|
1454
1434
|
const cacheKey = createCacheKey('getTokens', [
|
|
@@ -1532,7 +1512,6 @@ export class RampsController extends BaseController {
|
|
|
1532
1512
|
* @returns The providers response containing providers array.
|
|
1533
1513
|
*/
|
|
1534
1514
|
async getProviders(region, options) {
|
|
1535
|
-
this.#assertNetworkAccessAllowed();
|
|
1536
1515
|
const regionToUse = region ?? this.#requireRegion();
|
|
1537
1516
|
const normalizedRegion = regionToUse.toLowerCase().trim();
|
|
1538
1517
|
const cacheKey = createCacheKey('getProviders', [
|
|
@@ -1572,7 +1551,6 @@ export class RampsController extends BaseController {
|
|
|
1572
1551
|
* @returns The payment methods response containing payments array.
|
|
1573
1552
|
*/
|
|
1574
1553
|
async getPaymentMethods(region, options) {
|
|
1575
|
-
this.#assertNetworkAccessAllowed();
|
|
1576
1554
|
const regionCode = region ?? this.#requireRegion();
|
|
1577
1555
|
const assetIdToUse = options?.assetId ?? this.state.tokens.selected?.assetId ?? '';
|
|
1578
1556
|
const providerToUse = options?.provider ?? this.state.providers.selected?.id ?? '';
|
|
@@ -1657,7 +1635,6 @@ export class RampsController extends BaseController {
|
|
|
1657
1635
|
* provider ids that contributed.
|
|
1658
1636
|
*/
|
|
1659
1637
|
async getPaymentMethodsForContext(options) {
|
|
1660
|
-
this.#assertNetworkAccessAllowed();
|
|
1661
1638
|
const regionToUse = options.region ?? this.#requireRegion();
|
|
1662
1639
|
const normalizedRegion = regionToUse.toLowerCase().trim();
|
|
1663
1640
|
const assetId = options.assetId.trim();
|
|
@@ -1821,7 +1798,6 @@ export class RampsController extends BaseController {
|
|
|
1821
1798
|
* @returns The quotes response containing success, sorted, error, and customActions.
|
|
1822
1799
|
*/
|
|
1823
1800
|
async getQuotes(options) {
|
|
1824
|
-
this.#assertNetworkAccessAllowed();
|
|
1825
1801
|
const regionToUse = options.region ?? this.#requireRegion();
|
|
1826
1802
|
const fiatToUse = options.fiat ?? this.state.userRegion?.country?.currency;
|
|
1827
1803
|
const paymentMethodsToUse = options.paymentMethods ??
|
|
@@ -2025,7 +2001,6 @@ export class RampsController extends BaseController {
|
|
|
2025
2001
|
* no quote is available.
|
|
2026
2002
|
*/
|
|
2027
2003
|
async getQuoteWithFees(options) {
|
|
2028
|
-
this.#assertNetworkAccessAllowed();
|
|
2029
2004
|
const { isFeeExcludedFromFiat = true, ...quoteOptions } = options;
|
|
2030
2005
|
const response = await this.getQuotes(quoteOptions);
|
|
2031
2006
|
const quote = response.success?.[0];
|
|
@@ -2363,9 +2338,6 @@ export class RampsController extends BaseController {
|
|
|
2363
2338
|
* Unchanged syncable payloads (including unchanged poll results) are ignored
|
|
2364
2339
|
* so `lastUpdatedAt` is not bumped and User Storage is not rewritten.
|
|
2365
2340
|
*
|
|
2366
|
-
* When network access is denied, the order is still written locally and the
|
|
2367
|
-
* remote push is deferred to the next full sync.
|
|
2368
|
-
*
|
|
2369
2341
|
* @param order - The RampsOrder to add or update.
|
|
2370
2342
|
*/
|
|
2371
2343
|
addOrder(order) {
|
|
@@ -2431,8 +2403,7 @@ export class RampsController extends BaseController {
|
|
|
2431
2403
|
// sync pass so mutations during the upload await are not dropped.
|
|
2432
2404
|
this.#orderSyncQueued = true;
|
|
2433
2405
|
}
|
|
2434
|
-
else if (!this.#isOrderSyncingInProgress
|
|
2435
|
-
this.#isNetworkAccessAllowed()) {
|
|
2406
|
+
else if (!this.#isOrderSyncingInProgress) {
|
|
2436
2407
|
updateOrderInUserStorage(healedOrder, {
|
|
2437
2408
|
getRampsControllerInstance: () => this,
|
|
2438
2409
|
getMessenger: () => this.messenger,
|
|
@@ -2447,9 +2418,6 @@ export class RampsController extends BaseController {
|
|
|
2447
2418
|
/**
|
|
2448
2419
|
* Removes a V2 order from controller state by providerOrderId.
|
|
2449
2420
|
*
|
|
2450
|
-
* When network access is denied, the order is still removed locally and the
|
|
2451
|
-
* remote tombstone is deferred to the next full sync.
|
|
2452
|
-
*
|
|
2453
2421
|
* @param providerOrderId - The provider order ID to remove.
|
|
2454
2422
|
*/
|
|
2455
2423
|
removeOrder(providerOrderId) {
|
|
@@ -2484,7 +2452,7 @@ export class RampsController extends BaseController {
|
|
|
2484
2452
|
this.#orderSyncQueued = true;
|
|
2485
2453
|
}
|
|
2486
2454
|
}
|
|
2487
|
-
else if (isLocalDeletion
|
|
2455
|
+
else if (isLocalDeletion) {
|
|
2488
2456
|
deleteOrderInUserStorage(orderToRemove, {
|
|
2489
2457
|
getRampsControllerInstance: () => this,
|
|
2490
2458
|
getMessenger: () => this.messenger,
|
|
@@ -2507,7 +2475,6 @@ export class RampsController extends BaseController {
|
|
|
2507
2475
|
* resolution is not dropped.
|
|
2508
2476
|
*/
|
|
2509
2477
|
async syncOrdersWithUserStorage() {
|
|
2510
|
-
this.#assertNetworkAccessAllowed();
|
|
2511
2478
|
this.#orderSyncQueued = true;
|
|
2512
2479
|
let syncError;
|
|
2513
2480
|
while (this.#orderSyncQueued || this.#orderSyncPromise) {
|
|
@@ -2524,12 +2491,6 @@ export class RampsController extends BaseController {
|
|
|
2524
2491
|
this.#orderSyncPromise = (async () => {
|
|
2525
2492
|
while (this.#orderSyncQueued) {
|
|
2526
2493
|
this.#orderSyncQueued = false;
|
|
2527
|
-
if (!this.#isNetworkAccessAllowed()) {
|
|
2528
|
-
// Do not start another User Storage pass after the host revoked
|
|
2529
|
-
// access. Local changes stay pending until the next allowed
|
|
2530
|
-
// `syncOrdersWithUserStorage` call.
|
|
2531
|
-
break;
|
|
2532
|
-
}
|
|
2533
2494
|
await syncOrdersWithUserStorageInternal({
|
|
2534
2495
|
onOrderSyncErroneousSituation: this.#onOrderSyncErroneousSituation,
|
|
2535
2496
|
}, {
|
|
@@ -2601,7 +2562,6 @@ export class RampsController extends BaseController {
|
|
|
2601
2562
|
* @returns The created/updated local {@link AutorampAccount}.
|
|
2602
2563
|
*/
|
|
2603
2564
|
async createAutoramp(request, options = {}) {
|
|
2604
|
-
this.#assertNetworkAccessAllowed();
|
|
2605
2565
|
const customerId = await this.resolveAutorampCustomerId();
|
|
2606
2566
|
const fiatCode = readCreateAutorampFiatCode(request);
|
|
2607
2567
|
const walletAddress = readCreateAutorampWalletAddress(request);
|
|
@@ -2624,7 +2584,6 @@ export class RampsController extends BaseController {
|
|
|
2624
2584
|
* @returns The vendor customer id.
|
|
2625
2585
|
*/
|
|
2626
2586
|
async resolveAutorampCustomerId() {
|
|
2627
|
-
this.#assertNetworkAccessAllowed();
|
|
2628
2587
|
return (await this.#resolveMoonpayCustomer()).id;
|
|
2629
2588
|
}
|
|
2630
2589
|
/**
|
|
@@ -2657,7 +2616,6 @@ export class RampsController extends BaseController {
|
|
|
2657
2616
|
* the address-list lookup fails (never treated as unregistered).
|
|
2658
2617
|
*/
|
|
2659
2618
|
async registerMoneyAccountWallet({ address, }) {
|
|
2660
|
-
this.#assertNetworkAccessAllowed();
|
|
2661
2619
|
let machine = transitionWalletRegistration(createInitialWalletRegistrationState(), { type: 'START' });
|
|
2662
2620
|
const toExistingResult = (status) => {
|
|
2663
2621
|
if (status.type === 'active') {
|
|
@@ -2838,7 +2796,6 @@ export class RampsController extends BaseController {
|
|
|
2838
2796
|
* @returns Independent KYC and autoramp facts for the current customer.
|
|
2839
2797
|
*/
|
|
2840
2798
|
async hydrateVbaOnboarding({ walletAddress, refreshKyc = false, refreshAutoramps = false, }) {
|
|
2841
|
-
this.#assertNetworkAccessAllowed();
|
|
2842
2799
|
if (this.#vbaOnboardingHydrationPromise) {
|
|
2843
2800
|
return await this.#vbaOnboardingHydrationPromise;
|
|
2844
2801
|
}
|
|
@@ -3087,7 +3044,6 @@ export class RampsController extends BaseController {
|
|
|
3087
3044
|
* cursor was removed during the fetch.
|
|
3088
3045
|
*/
|
|
3089
3046
|
async refreshAutoramp(autorampId) {
|
|
3090
|
-
this.#assertNetworkAccessAllowed();
|
|
3091
3047
|
const remote = await this.messenger.call('NeoBankService:getAutoramp', autorampId);
|
|
3092
3048
|
return this.#applyAutorampRemoteSnapshot(remote, { allowInsert: false });
|
|
3093
3049
|
}
|
|
@@ -3099,7 +3055,6 @@ export class RampsController extends BaseController {
|
|
|
3099
3055
|
* @returns The fetched abilities.
|
|
3100
3056
|
*/
|
|
3101
3057
|
async refreshCustomerAbilities() {
|
|
3102
|
-
this.#assertNetworkAccessAllowed();
|
|
3103
3058
|
const abilities = await this.messenger.call('NeoBankService:getCustomerAbilities');
|
|
3104
3059
|
this.update((state) => {
|
|
3105
3060
|
state.vbaCustomerAbilities = abilities;
|
|
@@ -3113,7 +3068,6 @@ export class RampsController extends BaseController {
|
|
|
3113
3068
|
* @returns Updated autoramp accounts (failed fetches are skipped).
|
|
3114
3069
|
*/
|
|
3115
3070
|
async refreshAutoramps() {
|
|
3116
|
-
this.#assertNetworkAccessAllowed();
|
|
3117
3071
|
const ids = this.state.autoramps.map((autoramp) => autoramp.id);
|
|
3118
3072
|
const updated = [];
|
|
3119
3073
|
for (const id of ids) {
|
|
@@ -3146,7 +3100,6 @@ export class RampsController extends BaseController {
|
|
|
3146
3100
|
* @returns Transaction summaries from the newest page.
|
|
3147
3101
|
*/
|
|
3148
3102
|
async refreshAutorampTransactions(autorampId) {
|
|
3149
|
-
this.#assertNetworkAccessAllowed();
|
|
3150
3103
|
const inFlight = this.#autorampTransactionRefreshes.get(autorampId);
|
|
3151
3104
|
if (inFlight) {
|
|
3152
3105
|
return await inFlight;
|
|
@@ -3250,11 +3203,6 @@ export class RampsController extends BaseController {
|
|
|
3250
3203
|
* @param order - The order to refresh (needs provider and providerOrderId).
|
|
3251
3204
|
*/
|
|
3252
3205
|
async #refreshOrder(order) {
|
|
3253
|
-
if (!this.#isNetworkAccessAllowed()) {
|
|
3254
|
-
// A denied call is host policy, not a provider failure. Skip without
|
|
3255
|
-
// counting an error so a later allowed poll is not delayed by backoff.
|
|
3256
|
-
return;
|
|
3257
|
-
}
|
|
3258
3206
|
const providerCode = order.provider?.id ?? '';
|
|
3259
3207
|
if (!providerCode || !order.providerOrderId || !order.walletAddress) {
|
|
3260
3208
|
return;
|
|
@@ -3364,7 +3312,6 @@ export class RampsController extends BaseController {
|
|
|
3364
3312
|
* @throws Rethrows errors from the RampsService (e.g. HttpError, network failures) so clients can react to fetch failures.
|
|
3365
3313
|
*/
|
|
3366
3314
|
async getBuyWidgetData(quote) {
|
|
3367
|
-
this.#assertNetworkAccessAllowed();
|
|
3368
3315
|
const buyUrl = quote.quote?.buyURL;
|
|
3369
3316
|
if (!buyUrl) {
|
|
3370
3317
|
return null;
|
|
@@ -3384,7 +3331,6 @@ export class RampsController extends BaseController {
|
|
|
3384
3331
|
* @throws Rethrows errors from the RampsService (e.g. HttpError, network failures) so clients can react to fetch failures.
|
|
3385
3332
|
*/
|
|
3386
3333
|
async getFallbackBuyWidgetData(fallback, options) {
|
|
3387
|
-
this.#assertNetworkAccessAllowed();
|
|
3388
3334
|
if (!fallback?.url) {
|
|
3389
3335
|
return null;
|
|
3390
3336
|
}
|
|
@@ -3412,9 +3358,6 @@ export class RampsController extends BaseController {
|
|
|
3412
3358
|
* Adds a minimal stub order to controller state; the existing order polling
|
|
3413
3359
|
* will fetch the full order when the provider has created it.
|
|
3414
3360
|
*
|
|
3415
|
-
* When network access is denied, the stub is still written locally and its
|
|
3416
|
-
* remote push is deferred to the next full sync.
|
|
3417
|
-
*
|
|
3418
3361
|
* @param params - Object containing order identifiers and wallet info.
|
|
3419
3362
|
* @param params.orderId - Full order ID (e.g. "/providers/paypal/orders/abc123") or order code.
|
|
3420
3363
|
* @param params.providerCode - Canonical provider code (e.g. "paypal", "transak").
|
|
@@ -3470,7 +3413,6 @@ export class RampsController extends BaseController {
|
|
|
3470
3413
|
* @returns The unified order data.
|
|
3471
3414
|
*/
|
|
3472
3415
|
async getOrder(providerCode, orderCode, wallet) {
|
|
3473
|
-
this.#assertNetworkAccessAllowed();
|
|
3474
3416
|
const hadOrderAtRequestStart = this.state.orders.some((existingOrder) => getInternalOrderCode(existingOrder) === orderCode);
|
|
3475
3417
|
const order = await this.messenger.call('RampsService:getOrder', providerCode, orderCode, wallet);
|
|
3476
3418
|
const healedWalletAddress = order.walletAddress || wallet;
|
|
@@ -3503,7 +3445,6 @@ export class RampsController extends BaseController {
|
|
|
3503
3445
|
* @returns The unified order data.
|
|
3504
3446
|
*/
|
|
3505
3447
|
async getOrderFromCallback(providerCode, callbackUrl, wallet) {
|
|
3506
|
-
this.#assertNetworkAccessAllowed();
|
|
3507
3448
|
const order = await this.messenger.call('RampsService:getOrderFromCallback', providerCode, callbackUrl, wallet);
|
|
3508
3449
|
return order;
|
|
3509
3450
|
}
|
|
@@ -3582,7 +3523,6 @@ export class RampsController extends BaseController {
|
|
|
3582
3523
|
* @returns The OTP response containing a state token for verification.
|
|
3583
3524
|
*/
|
|
3584
3525
|
async transakSendUserOtp(email) {
|
|
3585
|
-
this.#assertNetworkAccessAllowed();
|
|
3586
3526
|
try {
|
|
3587
3527
|
return await this.messenger.call('TransakService:sendUserOtp', email);
|
|
3588
3528
|
}
|
|
@@ -3600,7 +3540,6 @@ export class RampsController extends BaseController {
|
|
|
3600
3540
|
* @returns The access token for subsequent authenticated requests.
|
|
3601
3541
|
*/
|
|
3602
3542
|
async transakVerifyUserOtp(email, verificationCode, stateToken) {
|
|
3603
|
-
this.#assertNetworkAccessAllowed();
|
|
3604
3543
|
try {
|
|
3605
3544
|
const token = await this.messenger.call('TransakService:verifyUserOtp', email, verificationCode, stateToken);
|
|
3606
3545
|
this.transakSetAuthenticated(true);
|
|
@@ -3614,16 +3553,9 @@ export class RampsController extends BaseController {
|
|
|
3614
3553
|
* Logs the user out of Transak. Clears authentication state and user details
|
|
3615
3554
|
* regardless of whether the API call succeeds or fails.
|
|
3616
3555
|
*
|
|
3617
|
-
* When network access is denied, the local session is cleared and a message
|
|
3618
|
-
* is returned without calling the Transak service.
|
|
3619
|
-
*
|
|
3620
3556
|
* @returns A message indicating the logout result.
|
|
3621
3557
|
*/
|
|
3622
3558
|
async transakLogout() {
|
|
3623
|
-
if (!this.#isNetworkAccessAllowed()) {
|
|
3624
|
-
this.#clearTransakLocalSession();
|
|
3625
|
-
return 'Transak session cleared without network access';
|
|
3626
|
-
}
|
|
3627
3559
|
try {
|
|
3628
3560
|
return await this.messenger.call('TransakService:logout');
|
|
3629
3561
|
}
|
|
@@ -3631,19 +3563,12 @@ export class RampsController extends BaseController {
|
|
|
3631
3563
|
throw this.#getNormalizedTransakError(error).normalizedError;
|
|
3632
3564
|
}
|
|
3633
3565
|
finally {
|
|
3634
|
-
this
|
|
3566
|
+
this.transakClearAccessToken();
|
|
3567
|
+
this.update((state) => {
|
|
3568
|
+
state.nativeProviders.transak.userDetails.data = null;
|
|
3569
|
+
});
|
|
3635
3570
|
}
|
|
3636
3571
|
}
|
|
3637
|
-
/**
|
|
3638
|
-
* Clears the local Transak session without making a request. Used on logout
|
|
3639
|
-
* when network access is revoked, so users can still clear their data.
|
|
3640
|
-
*/
|
|
3641
|
-
#clearTransakLocalSession() {
|
|
3642
|
-
this.transakClearAccessToken();
|
|
3643
|
-
this.update((state) => {
|
|
3644
|
-
state.nativeProviders.transak.userDetails.data = null;
|
|
3645
|
-
});
|
|
3646
|
-
}
|
|
3647
3572
|
/**
|
|
3648
3573
|
* Fetches the authenticated user's details from Transak.
|
|
3649
3574
|
* Updates the userDetails resource state with loading/success/error states.
|
|
@@ -3651,7 +3576,6 @@ export class RampsController extends BaseController {
|
|
|
3651
3576
|
* @returns The user's profile and KYC details.
|
|
3652
3577
|
*/
|
|
3653
3578
|
async transakGetUserDetails() {
|
|
3654
|
-
this.#assertNetworkAccessAllowed();
|
|
3655
3579
|
this.update((state) => {
|
|
3656
3580
|
state.nativeProviders.transak.userDetails.isLoading = true;
|
|
3657
3581
|
state.nativeProviders.transak.userDetails.error = null;
|
|
@@ -3691,7 +3615,6 @@ export class RampsController extends BaseController {
|
|
|
3691
3615
|
* @returns The buy quote with pricing and fee details.
|
|
3692
3616
|
*/
|
|
3693
3617
|
async transakGetBuyQuote(fiatCurrency, cryptoCurrency, network, paymentMethod, fiatAmount, isFeeExcludedFromFiat = true) {
|
|
3694
|
-
this.#assertNetworkAccessAllowed();
|
|
3695
3618
|
this.update((state) => {
|
|
3696
3619
|
state.nativeProviders.transak.buyQuote.isLoading = true;
|
|
3697
3620
|
state.nativeProviders.transak.buyQuote.error = null;
|
|
@@ -3723,7 +3646,6 @@ export class RampsController extends BaseController {
|
|
|
3723
3646
|
* @returns The KYC requirement status and whether the user can place an order.
|
|
3724
3647
|
*/
|
|
3725
3648
|
async transakGetKycRequirement(quoteId) {
|
|
3726
|
-
this.#assertNetworkAccessAllowed();
|
|
3727
3649
|
this.update((state) => {
|
|
3728
3650
|
state.nativeProviders.transak.kycRequirement.isLoading = true;
|
|
3729
3651
|
state.nativeProviders.transak.kycRequirement.error = null;
|
|
@@ -3757,7 +3679,6 @@ export class RampsController extends BaseController {
|
|
|
3757
3679
|
* @returns The list of additional forms required.
|
|
3758
3680
|
*/
|
|
3759
3681
|
async transakGetAdditionalRequirements(quoteId) {
|
|
3760
|
-
this.#assertNetworkAccessAllowed();
|
|
3761
3682
|
try {
|
|
3762
3683
|
return await this.messenger.call('TransakService:getAdditionalRequirements', quoteId);
|
|
3763
3684
|
}
|
|
@@ -3776,7 +3697,6 @@ export class RampsController extends BaseController {
|
|
|
3776
3697
|
* @returns The created deposit order.
|
|
3777
3698
|
*/
|
|
3778
3699
|
async transakCreateOrder(quoteId, walletAddress, paymentMethodId) {
|
|
3779
|
-
this.#assertNetworkAccessAllowed();
|
|
3780
3700
|
try {
|
|
3781
3701
|
return await this.messenger.call('TransakService:createOrder', quoteId, walletAddress, paymentMethodId);
|
|
3782
3702
|
}
|
|
@@ -3794,7 +3714,6 @@ export class RampsController extends BaseController {
|
|
|
3794
3714
|
* @returns The deposit order details.
|
|
3795
3715
|
*/
|
|
3796
3716
|
async transakGetOrder(orderId, wallet, paymentDetails) {
|
|
3797
|
-
this.#assertNetworkAccessAllowed();
|
|
3798
3717
|
try {
|
|
3799
3718
|
return await this.messenger.call('TransakService:getOrder', orderId, wallet, paymentDetails);
|
|
3800
3719
|
}
|
|
@@ -3811,7 +3730,6 @@ export class RampsController extends BaseController {
|
|
|
3811
3730
|
* @returns The user's limits, spending, and remaining amounts.
|
|
3812
3731
|
*/
|
|
3813
3732
|
async transakGetUserLimits(fiatCurrency, paymentMethod, kycType) {
|
|
3814
|
-
this.#assertNetworkAccessAllowed();
|
|
3815
3733
|
try {
|
|
3816
3734
|
return await this.messenger.call('TransakService:getUserLimits', fiatCurrency, paymentMethod, kycType);
|
|
3817
3735
|
}
|
|
@@ -3826,7 +3744,6 @@ export class RampsController extends BaseController {
|
|
|
3826
3744
|
* @returns The OTT response containing the token.
|
|
3827
3745
|
*/
|
|
3828
3746
|
async transakRequestOtt() {
|
|
3829
|
-
this.#assertNetworkAccessAllowed();
|
|
3830
3747
|
try {
|
|
3831
3748
|
return await this.messenger.call('TransakService:requestOtt');
|
|
3832
3749
|
}
|
|
@@ -3858,7 +3775,6 @@ export class RampsController extends BaseController {
|
|
|
3858
3775
|
* @returns The single-use widget URL.
|
|
3859
3776
|
*/
|
|
3860
3777
|
async transakCreateWidgetUrl(quote, walletAddress, extraParams) {
|
|
3861
|
-
this.#assertNetworkAccessAllowed();
|
|
3862
3778
|
try {
|
|
3863
3779
|
return await this.messenger.call('TransakService:createWidgetUrl', quote, walletAddress, extraParams);
|
|
3864
3780
|
}
|
|
@@ -3874,7 +3790,6 @@ export class RampsController extends BaseController {
|
|
|
3874
3790
|
* @returns A promise that resolves when the form is submitted.
|
|
3875
3791
|
*/
|
|
3876
3792
|
async transakSubmitPurposeOfUsageForm(purpose) {
|
|
3877
|
-
this.#assertNetworkAccessAllowed();
|
|
3878
3793
|
try {
|
|
3879
3794
|
return await this.messenger.call('TransakService:submitPurposeOfUsageForm', purpose);
|
|
3880
3795
|
}
|
|
@@ -3890,7 +3805,6 @@ export class RampsController extends BaseController {
|
|
|
3890
3805
|
* @returns The API response data.
|
|
3891
3806
|
*/
|
|
3892
3807
|
async transakPatchUser(data) {
|
|
3893
|
-
this.#assertNetworkAccessAllowed();
|
|
3894
3808
|
try {
|
|
3895
3809
|
return await this.messenger.call('TransakService:patchUser', data);
|
|
3896
3810
|
}
|
|
@@ -3907,7 +3821,6 @@ export class RampsController extends BaseController {
|
|
|
3907
3821
|
* @returns The API response data.
|
|
3908
3822
|
*/
|
|
3909
3823
|
async transakSubmitSsnDetails(ssn, quoteId) {
|
|
3910
|
-
this.#assertNetworkAccessAllowed();
|
|
3911
3824
|
try {
|
|
3912
3825
|
return await this.messenger.call('TransakService:submitSsnDetails', ssn, quoteId);
|
|
3913
3826
|
}
|
|
@@ -3924,7 +3837,6 @@ export class RampsController extends BaseController {
|
|
|
3924
3837
|
* @returns Whether the payment confirmation was successful.
|
|
3925
3838
|
*/
|
|
3926
3839
|
async transakConfirmPayment(orderId, paymentMethodId) {
|
|
3927
|
-
this.#assertNetworkAccessAllowed();
|
|
3928
3840
|
try {
|
|
3929
3841
|
return await this.messenger.call('TransakService:confirmPayment', orderId, paymentMethodId);
|
|
3930
3842
|
}
|
|
@@ -3940,7 +3852,6 @@ export class RampsController extends BaseController {
|
|
|
3940
3852
|
* @returns The translated Transak-specific identifiers.
|
|
3941
3853
|
*/
|
|
3942
3854
|
async transakGetTranslation(request) {
|
|
3943
|
-
this.#assertNetworkAccessAllowed();
|
|
3944
3855
|
try {
|
|
3945
3856
|
return await this.messenger.call('TransakService:getTranslation', request);
|
|
3946
3857
|
}
|
|
@@ -3955,7 +3866,6 @@ export class RampsController extends BaseController {
|
|
|
3955
3866
|
* @returns The current ID proof status.
|
|
3956
3867
|
*/
|
|
3957
3868
|
async transakGetIdProofStatus(workFlowRunId) {
|
|
3958
|
-
this.#assertNetworkAccessAllowed();
|
|
3959
3869
|
try {
|
|
3960
3870
|
return await this.messenger.call('TransakService:getIdProofStatus', workFlowRunId);
|
|
3961
3871
|
}
|
|
@@ -3971,7 +3881,6 @@ export class RampsController extends BaseController {
|
|
|
3971
3881
|
* @returns A promise that resolves when the order is cancelled.
|
|
3972
3882
|
*/
|
|
3973
3883
|
async transakCancelOrder(depositOrderId) {
|
|
3974
|
-
this.#assertNetworkAccessAllowed();
|
|
3975
3884
|
try {
|
|
3976
3885
|
return await this.messenger.call('TransakService:cancelOrder', depositOrderId);
|
|
3977
3886
|
}
|
|
@@ -3987,7 +3896,6 @@ export class RampsController extends BaseController {
|
|
|
3987
3896
|
* @returns An array of errors from any failed cancellations (empty if all succeeded).
|
|
3988
3897
|
*/
|
|
3989
3898
|
async transakCancelAllActiveOrders() {
|
|
3990
|
-
this.#assertNetworkAccessAllowed();
|
|
3991
3899
|
try {
|
|
3992
3900
|
return await this.messenger.call('TransakService:cancelAllActiveOrders');
|
|
3993
3901
|
}
|
|
@@ -4002,7 +3910,6 @@ export class RampsController extends BaseController {
|
|
|
4002
3910
|
* @returns The list of active orders.
|
|
4003
3911
|
*/
|
|
4004
3912
|
async transakGetActiveOrders() {
|
|
4005
|
-
this.#assertNetworkAccessAllowed();
|
|
4006
3913
|
try {
|
|
4007
3914
|
return await this.messenger.call('TransakService:getActiveOrders');
|
|
4008
3915
|
}
|