@metamask-previews/ramps-controller 29.0.0-preview-e53b41ba2 → 29.0.0-preview-c62310f6e

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