@metamask/ramps-controller 8.1.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +33 -1
  2. package/dist/RampsController.cjs +36 -217
  3. package/dist/RampsController.cjs.map +1 -1
  4. package/dist/RampsController.d.cts +27 -52
  5. package/dist/RampsController.d.cts.map +1 -1
  6. package/dist/RampsController.d.mts +27 -52
  7. package/dist/RampsController.d.mts.map +1 -1
  8. package/dist/RampsController.mjs +36 -217
  9. package/dist/RampsController.mjs.map +1 -1
  10. package/dist/RampsService-method-action-types.cjs.map +1 -1
  11. package/dist/RampsService-method-action-types.d.cts +32 -1
  12. package/dist/RampsService-method-action-types.d.cts.map +1 -1
  13. package/dist/RampsService-method-action-types.d.mts +32 -1
  14. package/dist/RampsService-method-action-types.d.mts.map +1 -1
  15. package/dist/RampsService-method-action-types.mjs.map +1 -1
  16. package/dist/RampsService.cjs +83 -1
  17. package/dist/RampsService.cjs.map +1 -1
  18. package/dist/RampsService.d.cts +122 -0
  19. package/dist/RampsService.d.cts.map +1 -1
  20. package/dist/RampsService.d.mts +122 -0
  21. package/dist/RampsService.d.mts.map +1 -1
  22. package/dist/RampsService.mjs +82 -0
  23. package/dist/RampsService.mjs.map +1 -1
  24. package/dist/RequestCache.cjs.map +1 -1
  25. package/dist/RequestCache.d.cts +1 -1
  26. package/dist/RequestCache.d.cts.map +1 -1
  27. package/dist/RequestCache.d.mts +1 -1
  28. package/dist/RequestCache.d.mts.map +1 -1
  29. package/dist/RequestCache.mjs.map +1 -1
  30. package/dist/TransakService.cjs +17 -15
  31. package/dist/TransakService.cjs.map +1 -1
  32. package/dist/TransakService.d.cts.map +1 -1
  33. package/dist/TransakService.d.mts.map +1 -1
  34. package/dist/TransakService.mjs +17 -15
  35. package/dist/TransakService.mjs.map +1 -1
  36. package/dist/index.cjs +2 -1
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +3 -3
  39. package/dist/index.d.cts.map +1 -1
  40. package/dist/index.d.mts +3 -3
  41. package/dist/index.d.mts.map +1 -1
  42. package/dist/index.mjs +1 -1
  43. package/dist/index.mjs.map +1 -1
  44. package/package.json +4 -5
@@ -9,7 +9,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
10
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
11
  };
12
- var _RampsController_instances, _RampsController_requestCacheTTL, _RampsController_requestCacheMaxSize, _RampsController_pendingRequests, _RampsController_pendingResourceCount, _RampsController_quotePollingInterval, _RampsController_quotePollingOptions, _RampsController_clearPendingResourceCountForDependentResources, _RampsController_abortDependentRequests, _RampsController_mutateRequests, _RampsController_removeRequestState, _RampsController_cleanupState, _RampsController_fireAndForget, _RampsController_restartPollingIfActive, _RampsController_requireRegion, _RampsController_isRegionCurrent, _RampsController_isTokenCurrent, _RampsController_isProviderCurrent, _RampsController_updateResourceField, _RampsController_setResourceLoading, _RampsController_setResourceError, _RampsController_updateRequestState, _RampsController_syncWidgetUrl, _RampsController_syncTransakAuthOnError;
12
+ var _RampsController_instances, _RampsController_requestCacheTTL, _RampsController_requestCacheMaxSize, _RampsController_pendingRequests, _RampsController_pendingResourceCount, _RampsController_clearPendingResourceCountForDependentResources, _RampsController_abortDependentRequests, _RampsController_mutateRequests, _RampsController_removeRequestState, _RampsController_cleanupState, _RampsController_fireAndForget, _RampsController_requireRegion, _RampsController_isRegionCurrent, _RampsController_isTokenCurrent, _RampsController_isProviderCurrent, _RampsController_updateResourceField, _RampsController_setResourceLoading, _RampsController_setResourceError, _RampsController_updateRequestState, _RampsController_syncTransakAuthOnError;
13
13
  import { BaseController } from "@metamask/base-controller";
14
14
  import { DEFAULT_REQUEST_CACHE_TTL, DEFAULT_REQUEST_CACHE_MAX_SIZE, createCacheKey, isCacheExpired, createLoadingState, createSuccessState, createErrorState, RequestStatus } from "./RequestCache.mjs";
15
15
  // === GENERAL ===
@@ -32,6 +32,8 @@ export const RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = [
32
32
  'RampsService:getPaymentMethods',
33
33
  'RampsService:getQuotes',
34
34
  'RampsService:getBuyWidgetUrl',
35
+ 'RampsService:getOrder',
36
+ 'RampsService:getOrderFromCallback',
35
37
  'TransakService:setApiKey',
36
38
  'TransakService:setAccessToken',
37
39
  'TransakService:clearAccessToken',
@@ -96,18 +98,6 @@ const rampsControllerMetadata = {
96
98
  includeInStateLogs: true,
97
99
  usedInUi: true,
98
100
  },
99
- quotes: {
100
- persist: false,
101
- includeInDebugSnapshot: true,
102
- includeInStateLogs: false,
103
- usedInUi: true,
104
- },
105
- widgetUrl: {
106
- persist: false,
107
- includeInDebugSnapshot: true,
108
- includeInStateLogs: false,
109
- usedInUi: true,
110
- },
111
101
  requests: {
112
102
  persist: false,
113
103
  includeInDebugSnapshot: true,
@@ -153,8 +143,6 @@ export function getDefaultRampsControllerState() {
153
143
  providers: createDefaultResourceState([], null),
154
144
  tokens: createDefaultResourceState(null, null),
155
145
  paymentMethods: createDefaultResourceState([], null),
156
- quotes: createDefaultResourceState(null, null),
157
- widgetUrl: createDefaultResourceState(null),
158
146
  requests: {},
159
147
  nativeProviders: {
160
148
  transak: {
@@ -170,7 +158,6 @@ const DEPENDENT_RESOURCE_KEYS = [
170
158
  'providers',
171
159
  'tokens',
172
160
  'paymentMethods',
173
- 'quotes',
174
161
  ];
175
162
  const DEPENDENT_RESOURCE_KEYS_SET = new Set(DEPENDENT_RESOURCE_KEYS);
176
163
  function resetResource(state, resourceType, defaultResource) {
@@ -182,20 +169,7 @@ function resetResource(state, resourceType, defaultResource) {
182
169
  resource.error = def.error;
183
170
  }
184
171
  /**
185
- * Resets the widgetUrl resource to its default state.
186
- * Mutates state in place; use from within controller update() for atomic updates.
187
- *
188
- * @param state - The state object to mutate.
189
- */
190
- function resetWidgetUrl(state) {
191
- const def = getDefaultRampsControllerState().widgetUrl;
192
- state.widgetUrl.data = def.data;
193
- state.widgetUrl.selected = def.selected;
194
- state.widgetUrl.isLoading = def.isLoading;
195
- state.widgetUrl.error = def.error;
196
- }
197
- /**
198
- * Resets region-dependent resources (userRegion, providers, tokens, paymentMethods, quotes).
172
+ * Resets region-dependent resources (userRegion, providers, tokens, paymentMethods).
199
173
  * Mutates state in place; use from within controller update() for atomic updates.
200
174
  *
201
175
  * @param state - The state object to mutate.
@@ -210,7 +184,6 @@ function resetDependentResources(state, options) {
210
184
  for (const key of DEPENDENT_RESOURCE_KEYS) {
211
185
  resetResource(state, key, defaultState[key]);
212
186
  }
213
- resetWidgetUrl(state);
214
187
  }
215
188
  // === HELPER FUNCTIONS ===
216
189
  /**
@@ -320,16 +293,6 @@ export class RampsController extends BaseController {
320
293
  * Used so isLoading is only cleared when the last request for that resource finishes.
321
294
  */
322
295
  _RampsController_pendingResourceCount.set(this, new Map());
323
- /**
324
- * Interval ID for automatic quote polling.
325
- * Set when startQuotePolling() is called, cleared when stopQuotePolling() is called.
326
- */
327
- _RampsController_quotePollingInterval.set(this, null);
328
- /**
329
- * Options used for quote polling (walletAddress, amount, redirectUrl).
330
- * Stored so polling can be restarted when dependencies change.
331
- */
332
- _RampsController_quotePollingOptions.set(this, null);
333
296
  __classPrivateFieldSet(this, _RampsController_requestCacheTTL, requestCacheTTL, "f");
334
297
  __classPrivateFieldSet(this, _RampsController_requestCacheMaxSize, requestCacheMaxSize, "f");
335
298
  }
@@ -500,7 +463,6 @@ export class RampsController extends BaseController {
500
463
  if (regionChanged) {
501
464
  __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_abortDependentRequests).call(this);
502
465
  __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_clearPendingResourceCountForDependentResources).call(this);
503
- this.stopQuotePolling();
504
466
  }
505
467
  this.update((state) => {
506
468
  if (regionChanged) {
@@ -537,7 +499,6 @@ export class RampsController extends BaseController {
537
499
  */
538
500
  setSelectedProvider(providerId) {
539
501
  if (providerId === null) {
540
- this.stopQuotePolling();
541
502
  this.update((state) => {
542
503
  state.providers.selected = null;
543
504
  resetResource(state, 'paymentMethods');
@@ -556,14 +517,8 @@ export class RampsController extends BaseController {
556
517
  this.update((state) => {
557
518
  state.providers.selected = provider;
558
519
  resetResource(state, 'paymentMethods');
559
- state.quotes.selected = null;
560
- resetWidgetUrl(state);
561
520
  });
562
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_fireAndForget).call(this, this.getPaymentMethods(regionCode, { provider: provider.id }).then(() => {
563
- // Restart quote polling after payment methods are fetched
564
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_restartPollingIfActive).call(this);
565
- return undefined;
566
- }));
521
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_fireAndForget).call(this, this.getPaymentMethods(regionCode, { provider: provider.id }));
567
522
  }
568
523
  /**
569
524
  * Initializes the controller by fetching the user's region from geolocation.
@@ -652,7 +607,6 @@ export class RampsController extends BaseController {
652
607
  */
653
608
  setSelectedToken(assetId) {
654
609
  if (!assetId) {
655
- this.stopQuotePolling();
656
610
  this.update((state) => {
657
611
  state.tokens.selected = null;
658
612
  resetResource(state, 'paymentMethods');
@@ -672,13 +626,8 @@ export class RampsController extends BaseController {
672
626
  this.update((state) => {
673
627
  state.tokens.selected = token;
674
628
  resetResource(state, 'paymentMethods');
675
- state.quotes.selected = null;
676
- resetWidgetUrl(state);
677
629
  });
678
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_fireAndForget).call(this, this.getPaymentMethods(regionCode, { assetId: token.assetId }).then(() => {
679
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_restartPollingIfActive).call(this);
680
- return undefined;
681
- }));
630
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_fireAndForget).call(this, this.getPaymentMethods(regionCode, { assetId: token.assetId }));
682
631
  }
683
632
  /**
684
633
  * Fetches the list of providers for a given region.
@@ -810,12 +759,10 @@ export class RampsController extends BaseController {
810
759
  this.update((state) => {
811
760
  state.paymentMethods.selected = paymentMethod;
812
761
  });
813
- // Restart quote polling if active
814
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_restartPollingIfActive).call(this);
815
762
  }
816
763
  /**
817
764
  * Fetches quotes from all providers for a given set of parameters.
818
- * The quotes are saved in the controller state once fetched.
765
+ * Uses the controller's request cache; callers manage the response in local state.
819
766
  *
820
767
  * @param options - The parameters for fetching quotes.
821
768
  * @param options.region - User's region code. If not provided, uses userRegion from state.
@@ -884,135 +831,27 @@ export class RampsController extends BaseController {
884
831
  redirectUrl: options.redirectUrl,
885
832
  action,
886
833
  };
887
- const response = await this.executeRequest(cacheKey, async () => {
834
+ return this.executeRequest(cacheKey, async () => {
888
835
  return this.messenger.call('RampsService:getQuotes', params);
889
836
  }, {
890
837
  forceRefresh: options.forceRefresh,
891
838
  ttl: options.ttl ?? DEFAULT_QUOTES_TTL,
892
- resourceType: 'quotes',
893
- isResultCurrent: () => __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_isRegionCurrent).call(this, normalizedRegion),
894
- });
895
- this.update((state) => {
896
- const userRegionCode = state.userRegion?.regionCode;
897
- if (userRegionCode === undefined || userRegionCode === normalizedRegion) {
898
- state.quotes.data = response;
899
- }
900
- });
901
- return response;
902
- }
903
- /**
904
- * Starts automatic quote polling with a 15-second refresh interval.
905
- * Fetches quotes immediately and then every 15 seconds.
906
- * If the response contains exactly one quote, it is auto-selected.
907
- * If multiple quotes are returned, the existing selection is preserved if still valid.
908
- *
909
- * Returns early (no-op) if the selected payment method is not yet set,
910
- * allowing callers to invoke this before payment-method selection is finalized.
911
- *
912
- * @param options - Parameters for fetching quotes.
913
- * @param options.walletAddress - The destination wallet address.
914
- * @param options.amount - The amount (in fiat for buy, crypto for sell).
915
- * @param options.redirectUrl - Optional redirect URL after order completion.
916
- * @throws If required dependencies (region, token, provider) are not set.
917
- */
918
- startQuotePolling(options) {
919
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_requireRegion).call(this);
920
- const token = this.state.tokens.selected;
921
- const provider = this.state.providers.selected;
922
- const paymentMethod = this.state.paymentMethods.selected;
923
- if (!token) {
924
- throw new Error('Token is required. Cannot start quote polling without a selected token.');
925
- }
926
- if (!provider) {
927
- throw new Error('Provider is required. Cannot start quote polling without a selected provider.');
928
- }
929
- if (!paymentMethod) {
930
- return;
931
- }
932
- // Stop any existing polling first
933
- this.stopQuotePolling();
934
- // Store options for restarts (must be after stop to avoid being cleared)
935
- __classPrivateFieldSet(this, _RampsController_quotePollingOptions, options, "f");
936
- // Define the fetch function
937
- const fetchQuotes = () => {
938
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_fireAndForget).call(this, this.getQuotes({
939
- assetId: token.assetId,
940
- amount: options.amount,
941
- walletAddress: options.walletAddress,
942
- redirectUrl: options.redirectUrl,
943
- paymentMethods: [paymentMethod.id],
944
- providers: [provider.id],
945
- forceRefresh: true,
946
- }).then((response) => {
947
- let newSelectedQuote = null;
948
- // Auto-select logic: only when exactly one quote is returned
949
- this.update((state) => {
950
- if (response.success.length === 1) {
951
- newSelectedQuote = response.success[0];
952
- state.quotes.selected = newSelectedQuote;
953
- }
954
- else {
955
- // Keep existing selection if still valid, but update with fresh data
956
- const currentSelection = state.quotes.selected;
957
- if (currentSelection) {
958
- const freshQuote = response.success.find((quote) => quote.provider === currentSelection.provider &&
959
- quote.quote.paymentMethod ===
960
- currentSelection.quote.paymentMethod);
961
- newSelectedQuote = freshQuote ?? null;
962
- state.quotes.selected = newSelectedQuote;
963
- }
964
- }
965
- });
966
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncWidgetUrl).call(this, newSelectedQuote);
967
- return undefined;
968
- }));
969
- };
970
- // Fetch immediately
971
- fetchQuotes();
972
- // Set up 15-second polling
973
- __classPrivateFieldSet(this, _RampsController_quotePollingInterval, setInterval(fetchQuotes, 15000), "f");
974
- }
975
- /**
976
- * Stops automatic quote polling.
977
- * Does not clear quotes data or selection, only stops the interval.
978
- */
979
- stopQuotePolling() {
980
- if (__classPrivateFieldGet(this, _RampsController_quotePollingInterval, "f") !== null) {
981
- clearInterval(__classPrivateFieldGet(this, _RampsController_quotePollingInterval, "f"));
982
- __classPrivateFieldSet(this, _RampsController_quotePollingInterval, null, "f");
983
- }
984
- __classPrivateFieldSet(this, _RampsController_quotePollingOptions, null, "f");
985
- }
986
- /**
987
- * Manually sets the selected quote.
988
- * Automatically triggers a widget URL fetch for the new quote.
989
- *
990
- * @param quote - The quote to select, or null to clear the selection.
991
- */
992
- setSelectedQuote(quote) {
993
- this.update((state) => {
994
- state.quotes.selected = quote;
995
839
  });
996
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncWidgetUrl).call(this, quote);
997
840
  }
998
841
  /**
999
842
  * Cleans up controller resources.
1000
- * Stops any active quote polling to prevent memory leaks.
1001
843
  * Should be called when the controller is no longer needed.
1002
844
  */
1003
845
  destroy() {
1004
- this.stopQuotePolling();
1005
846
  super.destroy();
1006
847
  }
1007
848
  /**
1008
849
  * Fetches the widget URL from a quote for redirect providers.
1009
850
  * Makes a request to the buyURL endpoint via the RampsService to get the
1010
- * actual provider widget URL, using the injected fetch and retry policy.
851
+ * actual provider widget URL.
1011
852
  *
1012
853
  * @param quote - The quote to fetch the widget URL from.
1013
854
  * @returns Promise resolving to the widget URL string, or null if not available.
1014
- * @deprecated Read `state.widgetUrl` instead. The widget URL is now automatically
1015
- * fetched and stored in state whenever the selected quote changes.
1016
855
  */
1017
856
  async getWidgetUrl(quote) {
1018
857
  const buyUrl = quote.quote?.buyURL;
@@ -1027,6 +866,32 @@ export class RampsController extends BaseController {
1027
866
  return null;
1028
867
  }
1029
868
  }
869
+ /**
870
+ * Fetches an order from the unified V2 API endpoint.
871
+ * Returns a normalized RampsOrder for all provider types (aggregator and native).
872
+ *
873
+ * @param providerCode - The provider code (e.g., "transak", "transak-native", "moonpay").
874
+ * @param orderCode - The order identifier.
875
+ * @param wallet - The wallet address associated with the order.
876
+ * @returns The unified order data.
877
+ */
878
+ async getOrder(providerCode, orderCode, wallet) {
879
+ return await this.messenger.call('RampsService:getOrder', providerCode, orderCode, wallet);
880
+ }
881
+ /**
882
+ * Extracts an order from a provider callback URL.
883
+ * Sends the callback URL to the V2 backend for provider-specific parsing,
884
+ * then fetches the full order. This is the V2 equivalent of the aggregator
885
+ * SDK's `getOrderFromCallback`.
886
+ *
887
+ * @param providerCode - The provider code (e.g., "transak", "moonpay").
888
+ * @param callbackUrl - The full callback URL the provider redirected to.
889
+ * @param wallet - The wallet address associated with the order.
890
+ * @returns The unified order data.
891
+ */
892
+ async getOrderFromCallback(providerCode, callbackUrl, wallet) {
893
+ return await this.messenger.call('RampsService:getOrderFromCallback', providerCode, callbackUrl, wallet);
894
+ }
1030
895
  /**
1031
896
  * Sets the Transak API key used for all Transak API requests.
1032
897
  *
@@ -1422,7 +1287,7 @@ export class RampsController extends BaseController {
1422
1287
  }
1423
1288
  }
1424
1289
  }
1425
- _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheMaxSize = new WeakMap(), _RampsController_pendingRequests = new WeakMap(), _RampsController_pendingResourceCount = new WeakMap(), _RampsController_quotePollingInterval = new WeakMap(), _RampsController_quotePollingOptions = new WeakMap(), _RampsController_instances = new WeakSet(), _RampsController_clearPendingResourceCountForDependentResources = function _RampsController_clearPendingResourceCountForDependentResources() {
1290
+ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheMaxSize = new WeakMap(), _RampsController_pendingRequests = new WeakMap(), _RampsController_pendingResourceCount = new WeakMap(), _RampsController_instances = new WeakSet(), _RampsController_clearPendingResourceCountForDependentResources = function _RampsController_clearPendingResourceCountForDependentResources() {
1426
1291
  for (const resourceType of DEPENDENT_RESOURCE_KEYS) {
1427
1292
  __classPrivateFieldGet(this, _RampsController_pendingResourceCount, "f").delete(resourceType);
1428
1293
  }
@@ -1445,24 +1310,11 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
1445
1310
  delete requests[cacheKey];
1446
1311
  });
1447
1312
  }, _RampsController_cleanupState = function _RampsController_cleanupState() {
1448
- this.stopQuotePolling();
1449
1313
  __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_abortDependentRequests).call(this);
1450
1314
  __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_clearPendingResourceCountForDependentResources).call(this);
1451
1315
  this.update((state) => resetDependentResources(state, { clearUserRegionData: true }));
1452
1316
  }, _RampsController_fireAndForget = function _RampsController_fireAndForget(promise) {
1453
1317
  promise.catch((_error) => undefined);
1454
- }, _RampsController_restartPollingIfActive = function _RampsController_restartPollingIfActive() {
1455
- if (__classPrivateFieldGet(this, _RampsController_quotePollingInterval, "f") !== null && __classPrivateFieldGet(this, _RampsController_quotePollingOptions, "f")) {
1456
- const options = __classPrivateFieldGet(this, _RampsController_quotePollingOptions, "f");
1457
- this.stopQuotePolling();
1458
- try {
1459
- this.startQuotePolling(options);
1460
- }
1461
- catch {
1462
- // Dependencies not met yet, polling will need to be manually restarted
1463
- // when dependencies are available
1464
- }
1465
- }
1466
1318
  }, _RampsController_requireRegion = function _RampsController_requireRegion() {
1467
1319
  const regionCode = this.state.userRegion?.regionCode;
1468
1320
  if (!regionCode) {
@@ -1518,39 +1370,6 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
1518
1370
  }
1519
1371
  }
1520
1372
  });
1521
- }, _RampsController_syncWidgetUrl = function _RampsController_syncWidgetUrl(quote) {
1522
- const buyUrl = quote?.quote?.buyURL;
1523
- if (!buyUrl) {
1524
- this.update((state) => {
1525
- resetWidgetUrl(state);
1526
- });
1527
- return;
1528
- }
1529
- if (this.state.widgetUrl.data === null) {
1530
- this.update((state) => {
1531
- state.widgetUrl.isLoading = true;
1532
- state.widgetUrl.error = null;
1533
- });
1534
- }
1535
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_fireAndForget).call(this, this.messenger
1536
- .call('RampsService:getBuyWidgetUrl', buyUrl)
1537
- .then((buyWidget) => {
1538
- this.update((state) => {
1539
- state.widgetUrl.data = buyWidget;
1540
- state.widgetUrl.isLoading = false;
1541
- state.widgetUrl.error = null;
1542
- });
1543
- return undefined;
1544
- })
1545
- .catch((error) => {
1546
- this.update((state) => {
1547
- state.widgetUrl.isLoading = false;
1548
- state.widgetUrl.error =
1549
- error instanceof Error
1550
- ? error.message
1551
- : 'Failed to fetch widget URL';
1552
- });
1553
- }));
1554
1373
  }, _RampsController_syncTransakAuthOnError = function _RampsController_syncTransakAuthOnError(error) {
1555
1374
  if (error instanceof Error &&
1556
1375
  'httpStatus' in error &&