@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
package/CHANGELOG.md CHANGED
@@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [10.0.0]
11
+
12
+ ### Changed
13
+
14
+ - **BREAKING:** Remove `state.quotes` and `state.widgetUrl` from RampsController state. Quote and widget URL data are now managed by consuming components ([#8013](https://github.com/MetaMask/core/pull/8013))
15
+ - **BREAKING:** Remove `fetchQuotesForSelection()` and `setSelectedQuote()`. Components call `getQuotes()` directly and manage selection locally ([#8013](https://github.com/MetaMask/core/pull/8013))
16
+ - Simplify `getWidgetUrl()` to a pure fetch-and-return API; it no longer reads or writes controller state ([#8013](https://github.com/MetaMask/core/pull/8013))
17
+ - Improve `TransakService` error handling ([#8010](https://github.com/MetaMask/core/pull/8010))
18
+ - **BREAKING:** Replace `startQuotePolling()`/`stopQuotePolling()` with `fetchQuotesForSelection()` — quotes are now fetched once per call instead of polling on a 15-second interval ([#7999](https://github.com/MetaMask/core/pull/7999))
19
+
20
+ ### Removed
21
+
22
+ - Remove `stopQuotePolling()` method (no interval to stop) ([#7999](https://github.com/MetaMask/core/pull/7999))
23
+ - Remove internal polling restart logic (`#restartPollingIfActive`) from `setSelectedProvider`, `setSelectedToken`, and `setSelectedPaymentMethod` ([#7999](https://github.com/MetaMask/core/pull/7999))
24
+
25
+ ### Fixed
26
+
27
+ - Fix RampsController flaky test ([#8018](https://github.com/MetaMask/core/pull/8018))
28
+
29
+ ## [9.0.0]
30
+
31
+ ### Added
32
+
33
+ - Add `getOrder` and `getOrderFromCallback` methods to `RampsService` and `RampsController` for V2 unified order polling, along with new `RampsOrder`, `RampsOrderFiatCurrency`, `RampsOrderCryptoCurrency`, `RampsOrderPaymentMethod`, and `RampsOrderStatus` types ([#7934](https://github.com/MetaMask/core/pull/7934))
34
+
35
+ ### Changed
36
+
37
+ - **BREAKING:** Use concrete types in `RampsOrder` instead of `string | Object` unions for `provider`, `cryptoCurrency`, `fiatCurrency`, `paymentMethod`, and `network` fields ([#8000](https://github.com/MetaMask/core/pull/8000))
38
+ - Bump `@metamask/controller-utils` from `^11.18.0` to `^11.19.0` ([#7995](https://github.com/MetaMask/core/pull/7995))
39
+
10
40
  ## [8.1.0]
11
41
 
12
42
  ### Added
@@ -153,7 +183,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
153
183
  - Add `OnRampService` for interacting with the OnRamp API
154
184
  - Add geolocation detection via IP address lookup
155
185
 
156
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/ramps-controller@8.1.0...HEAD
186
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/ramps-controller@10.0.0...HEAD
187
+ [10.0.0]: https://github.com/MetaMask/core/compare/@metamask/ramps-controller@9.0.0...@metamask/ramps-controller@10.0.0
188
+ [9.0.0]: https://github.com/MetaMask/core/compare/@metamask/ramps-controller@8.1.0...@metamask/ramps-controller@9.0.0
157
189
  [8.1.0]: https://github.com/MetaMask/core/compare/@metamask/ramps-controller@8.0.0...@metamask/ramps-controller@8.1.0
158
190
  [8.0.0]: https://github.com/MetaMask/core/compare/@metamask/ramps-controller@7.1.0...@metamask/ramps-controller@8.0.0
159
191
  [7.1.0]: https://github.com/MetaMask/core/compare/@metamask/ramps-controller@7.0.0...@metamask/ramps-controller@7.1.0
@@ -10,7 +10,7 @@ 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_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;
13
+ 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;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.RampsController = exports.getDefaultRampsControllerState = exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = exports.controllerName = void 0;
16
16
  const base_controller_1 = require("@metamask/base-controller");
@@ -35,6 +35,8 @@ exports.RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS = [
35
35
  'RampsService:getPaymentMethods',
36
36
  'RampsService:getQuotes',
37
37
  'RampsService:getBuyWidgetUrl',
38
+ 'RampsService:getOrder',
39
+ 'RampsService:getOrderFromCallback',
38
40
  'TransakService:setApiKey',
39
41
  'TransakService:setAccessToken',
40
42
  'TransakService:clearAccessToken',
@@ -99,18 +101,6 @@ const rampsControllerMetadata = {
99
101
  includeInStateLogs: true,
100
102
  usedInUi: true,
101
103
  },
102
- quotes: {
103
- persist: false,
104
- includeInDebugSnapshot: true,
105
- includeInStateLogs: false,
106
- usedInUi: true,
107
- },
108
- widgetUrl: {
109
- persist: false,
110
- includeInDebugSnapshot: true,
111
- includeInStateLogs: false,
112
- usedInUi: true,
113
- },
114
104
  requests: {
115
105
  persist: false,
116
106
  includeInDebugSnapshot: true,
@@ -156,8 +146,6 @@ function getDefaultRampsControllerState() {
156
146
  providers: createDefaultResourceState([], null),
157
147
  tokens: createDefaultResourceState(null, null),
158
148
  paymentMethods: createDefaultResourceState([], null),
159
- quotes: createDefaultResourceState(null, null),
160
- widgetUrl: createDefaultResourceState(null),
161
149
  requests: {},
162
150
  nativeProviders: {
163
151
  transak: {
@@ -174,7 +162,6 @@ const DEPENDENT_RESOURCE_KEYS = [
174
162
  'providers',
175
163
  'tokens',
176
164
  'paymentMethods',
177
- 'quotes',
178
165
  ];
179
166
  const DEPENDENT_RESOURCE_KEYS_SET = new Set(DEPENDENT_RESOURCE_KEYS);
180
167
  function resetResource(state, resourceType, defaultResource) {
@@ -186,20 +173,7 @@ function resetResource(state, resourceType, defaultResource) {
186
173
  resource.error = def.error;
187
174
  }
188
175
  /**
189
- * Resets the widgetUrl resource to its default state.
190
- * Mutates state in place; use from within controller update() for atomic updates.
191
- *
192
- * @param state - The state object to mutate.
193
- */
194
- function resetWidgetUrl(state) {
195
- const def = getDefaultRampsControllerState().widgetUrl;
196
- state.widgetUrl.data = def.data;
197
- state.widgetUrl.selected = def.selected;
198
- state.widgetUrl.isLoading = def.isLoading;
199
- state.widgetUrl.error = def.error;
200
- }
201
- /**
202
- * Resets region-dependent resources (userRegion, providers, tokens, paymentMethods, quotes).
176
+ * Resets region-dependent resources (userRegion, providers, tokens, paymentMethods).
203
177
  * Mutates state in place; use from within controller update() for atomic updates.
204
178
  *
205
179
  * @param state - The state object to mutate.
@@ -214,7 +188,6 @@ function resetDependentResources(state, options) {
214
188
  for (const key of DEPENDENT_RESOURCE_KEYS) {
215
189
  resetResource(state, key, defaultState[key]);
216
190
  }
217
- resetWidgetUrl(state);
218
191
  }
219
192
  // === HELPER FUNCTIONS ===
220
193
  /**
@@ -324,16 +297,6 @@ class RampsController extends base_controller_1.BaseController {
324
297
  * Used so isLoading is only cleared when the last request for that resource finishes.
325
298
  */
326
299
  _RampsController_pendingResourceCount.set(this, new Map());
327
- /**
328
- * Interval ID for automatic quote polling.
329
- * Set when startQuotePolling() is called, cleared when stopQuotePolling() is called.
330
- */
331
- _RampsController_quotePollingInterval.set(this, null);
332
- /**
333
- * Options used for quote polling (walletAddress, amount, redirectUrl).
334
- * Stored so polling can be restarted when dependencies change.
335
- */
336
- _RampsController_quotePollingOptions.set(this, null);
337
300
  __classPrivateFieldSet(this, _RampsController_requestCacheTTL, requestCacheTTL, "f");
338
301
  __classPrivateFieldSet(this, _RampsController_requestCacheMaxSize, requestCacheMaxSize, "f");
339
302
  }
@@ -504,7 +467,6 @@ class RampsController extends base_controller_1.BaseController {
504
467
  if (regionChanged) {
505
468
  __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_abortDependentRequests).call(this);
506
469
  __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_clearPendingResourceCountForDependentResources).call(this);
507
- this.stopQuotePolling();
508
470
  }
509
471
  this.update((state) => {
510
472
  if (regionChanged) {
@@ -541,7 +503,6 @@ class RampsController extends base_controller_1.BaseController {
541
503
  */
542
504
  setSelectedProvider(providerId) {
543
505
  if (providerId === null) {
544
- this.stopQuotePolling();
545
506
  this.update((state) => {
546
507
  state.providers.selected = null;
547
508
  resetResource(state, 'paymentMethods');
@@ -560,14 +521,8 @@ class RampsController extends base_controller_1.BaseController {
560
521
  this.update((state) => {
561
522
  state.providers.selected = provider;
562
523
  resetResource(state, 'paymentMethods');
563
- state.quotes.selected = null;
564
- resetWidgetUrl(state);
565
524
  });
566
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_fireAndForget).call(this, this.getPaymentMethods(regionCode, { provider: provider.id }).then(() => {
567
- // Restart quote polling after payment methods are fetched
568
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_restartPollingIfActive).call(this);
569
- return undefined;
570
- }));
525
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_fireAndForget).call(this, this.getPaymentMethods(regionCode, { provider: provider.id }));
571
526
  }
572
527
  /**
573
528
  * Initializes the controller by fetching the user's region from geolocation.
@@ -656,7 +611,6 @@ class RampsController extends base_controller_1.BaseController {
656
611
  */
657
612
  setSelectedToken(assetId) {
658
613
  if (!assetId) {
659
- this.stopQuotePolling();
660
614
  this.update((state) => {
661
615
  state.tokens.selected = null;
662
616
  resetResource(state, 'paymentMethods');
@@ -676,13 +630,8 @@ class RampsController extends base_controller_1.BaseController {
676
630
  this.update((state) => {
677
631
  state.tokens.selected = token;
678
632
  resetResource(state, 'paymentMethods');
679
- state.quotes.selected = null;
680
- resetWidgetUrl(state);
681
633
  });
682
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_fireAndForget).call(this, this.getPaymentMethods(regionCode, { assetId: token.assetId }).then(() => {
683
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_restartPollingIfActive).call(this);
684
- return undefined;
685
- }));
634
+ __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_fireAndForget).call(this, this.getPaymentMethods(regionCode, { assetId: token.assetId }));
686
635
  }
687
636
  /**
688
637
  * Fetches the list of providers for a given region.
@@ -814,12 +763,10 @@ class RampsController extends base_controller_1.BaseController {
814
763
  this.update((state) => {
815
764
  state.paymentMethods.selected = paymentMethod;
816
765
  });
817
- // Restart quote polling if active
818
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_restartPollingIfActive).call(this);
819
766
  }
820
767
  /**
821
768
  * Fetches quotes from all providers for a given set of parameters.
822
- * The quotes are saved in the controller state once fetched.
769
+ * Uses the controller's request cache; callers manage the response in local state.
823
770
  *
824
771
  * @param options - The parameters for fetching quotes.
825
772
  * @param options.region - User's region code. If not provided, uses userRegion from state.
@@ -888,135 +835,27 @@ class RampsController extends base_controller_1.BaseController {
888
835
  redirectUrl: options.redirectUrl,
889
836
  action,
890
837
  };
891
- const response = await this.executeRequest(cacheKey, async () => {
838
+ return this.executeRequest(cacheKey, async () => {
892
839
  return this.messenger.call('RampsService:getQuotes', params);
893
840
  }, {
894
841
  forceRefresh: options.forceRefresh,
895
842
  ttl: options.ttl ?? DEFAULT_QUOTES_TTL,
896
- resourceType: 'quotes',
897
- isResultCurrent: () => __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_isRegionCurrent).call(this, normalizedRegion),
898
- });
899
- this.update((state) => {
900
- const userRegionCode = state.userRegion?.regionCode;
901
- if (userRegionCode === undefined || userRegionCode === normalizedRegion) {
902
- state.quotes.data = response;
903
- }
904
- });
905
- return response;
906
- }
907
- /**
908
- * Starts automatic quote polling with a 15-second refresh interval.
909
- * Fetches quotes immediately and then every 15 seconds.
910
- * If the response contains exactly one quote, it is auto-selected.
911
- * If multiple quotes are returned, the existing selection is preserved if still valid.
912
- *
913
- * Returns early (no-op) if the selected payment method is not yet set,
914
- * allowing callers to invoke this before payment-method selection is finalized.
915
- *
916
- * @param options - Parameters for fetching quotes.
917
- * @param options.walletAddress - The destination wallet address.
918
- * @param options.amount - The amount (in fiat for buy, crypto for sell).
919
- * @param options.redirectUrl - Optional redirect URL after order completion.
920
- * @throws If required dependencies (region, token, provider) are not set.
921
- */
922
- startQuotePolling(options) {
923
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_requireRegion).call(this);
924
- const token = this.state.tokens.selected;
925
- const provider = this.state.providers.selected;
926
- const paymentMethod = this.state.paymentMethods.selected;
927
- if (!token) {
928
- throw new Error('Token is required. Cannot start quote polling without a selected token.');
929
- }
930
- if (!provider) {
931
- throw new Error('Provider is required. Cannot start quote polling without a selected provider.');
932
- }
933
- if (!paymentMethod) {
934
- return;
935
- }
936
- // Stop any existing polling first
937
- this.stopQuotePolling();
938
- // Store options for restarts (must be after stop to avoid being cleared)
939
- __classPrivateFieldSet(this, _RampsController_quotePollingOptions, options, "f");
940
- // Define the fetch function
941
- const fetchQuotes = () => {
942
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_fireAndForget).call(this, this.getQuotes({
943
- assetId: token.assetId,
944
- amount: options.amount,
945
- walletAddress: options.walletAddress,
946
- redirectUrl: options.redirectUrl,
947
- paymentMethods: [paymentMethod.id],
948
- providers: [provider.id],
949
- forceRefresh: true,
950
- }).then((response) => {
951
- let newSelectedQuote = null;
952
- // Auto-select logic: only when exactly one quote is returned
953
- this.update((state) => {
954
- if (response.success.length === 1) {
955
- newSelectedQuote = response.success[0];
956
- state.quotes.selected = newSelectedQuote;
957
- }
958
- else {
959
- // Keep existing selection if still valid, but update with fresh data
960
- const currentSelection = state.quotes.selected;
961
- if (currentSelection) {
962
- const freshQuote = response.success.find((quote) => quote.provider === currentSelection.provider &&
963
- quote.quote.paymentMethod ===
964
- currentSelection.quote.paymentMethod);
965
- newSelectedQuote = freshQuote ?? null;
966
- state.quotes.selected = newSelectedQuote;
967
- }
968
- }
969
- });
970
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncWidgetUrl).call(this, newSelectedQuote);
971
- return undefined;
972
- }));
973
- };
974
- // Fetch immediately
975
- fetchQuotes();
976
- // Set up 15-second polling
977
- __classPrivateFieldSet(this, _RampsController_quotePollingInterval, setInterval(fetchQuotes, 15000), "f");
978
- }
979
- /**
980
- * Stops automatic quote polling.
981
- * Does not clear quotes data or selection, only stops the interval.
982
- */
983
- stopQuotePolling() {
984
- if (__classPrivateFieldGet(this, _RampsController_quotePollingInterval, "f") !== null) {
985
- clearInterval(__classPrivateFieldGet(this, _RampsController_quotePollingInterval, "f"));
986
- __classPrivateFieldSet(this, _RampsController_quotePollingInterval, null, "f");
987
- }
988
- __classPrivateFieldSet(this, _RampsController_quotePollingOptions, null, "f");
989
- }
990
- /**
991
- * Manually sets the selected quote.
992
- * Automatically triggers a widget URL fetch for the new quote.
993
- *
994
- * @param quote - The quote to select, or null to clear the selection.
995
- */
996
- setSelectedQuote(quote) {
997
- this.update((state) => {
998
- state.quotes.selected = quote;
999
843
  });
1000
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_syncWidgetUrl).call(this, quote);
1001
844
  }
1002
845
  /**
1003
846
  * Cleans up controller resources.
1004
- * Stops any active quote polling to prevent memory leaks.
1005
847
  * Should be called when the controller is no longer needed.
1006
848
  */
1007
849
  destroy() {
1008
- this.stopQuotePolling();
1009
850
  super.destroy();
1010
851
  }
1011
852
  /**
1012
853
  * Fetches the widget URL from a quote for redirect providers.
1013
854
  * Makes a request to the buyURL endpoint via the RampsService to get the
1014
- * actual provider widget URL, using the injected fetch and retry policy.
855
+ * actual provider widget URL.
1015
856
  *
1016
857
  * @param quote - The quote to fetch the widget URL from.
1017
858
  * @returns Promise resolving to the widget URL string, or null if not available.
1018
- * @deprecated Read `state.widgetUrl` instead. The widget URL is now automatically
1019
- * fetched and stored in state whenever the selected quote changes.
1020
859
  */
1021
860
  async getWidgetUrl(quote) {
1022
861
  const buyUrl = quote.quote?.buyURL;
@@ -1031,6 +870,32 @@ class RampsController extends base_controller_1.BaseController {
1031
870
  return null;
1032
871
  }
1033
872
  }
873
+ /**
874
+ * Fetches an order from the unified V2 API endpoint.
875
+ * Returns a normalized RampsOrder for all provider types (aggregator and native).
876
+ *
877
+ * @param providerCode - The provider code (e.g., "transak", "transak-native", "moonpay").
878
+ * @param orderCode - The order identifier.
879
+ * @param wallet - The wallet address associated with the order.
880
+ * @returns The unified order data.
881
+ */
882
+ async getOrder(providerCode, orderCode, wallet) {
883
+ return await this.messenger.call('RampsService:getOrder', providerCode, orderCode, wallet);
884
+ }
885
+ /**
886
+ * Extracts an order from a provider callback URL.
887
+ * Sends the callback URL to the V2 backend for provider-specific parsing,
888
+ * then fetches the full order. This is the V2 equivalent of the aggregator
889
+ * SDK's `getOrderFromCallback`.
890
+ *
891
+ * @param providerCode - The provider code (e.g., "transak", "moonpay").
892
+ * @param callbackUrl - The full callback URL the provider redirected to.
893
+ * @param wallet - The wallet address associated with the order.
894
+ * @returns The unified order data.
895
+ */
896
+ async getOrderFromCallback(providerCode, callbackUrl, wallet) {
897
+ return await this.messenger.call('RampsService:getOrderFromCallback', providerCode, callbackUrl, wallet);
898
+ }
1034
899
  /**
1035
900
  * Sets the Transak API key used for all Transak API requests.
1036
901
  *
@@ -1427,7 +1292,7 @@ class RampsController extends base_controller_1.BaseController {
1427
1292
  }
1428
1293
  }
1429
1294
  exports.RampsController = RampsController;
1430
- _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() {
1295
+ _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() {
1431
1296
  for (const resourceType of DEPENDENT_RESOURCE_KEYS) {
1432
1297
  __classPrivateFieldGet(this, _RampsController_pendingResourceCount, "f").delete(resourceType);
1433
1298
  }
@@ -1450,24 +1315,11 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
1450
1315
  delete requests[cacheKey];
1451
1316
  });
1452
1317
  }, _RampsController_cleanupState = function _RampsController_cleanupState() {
1453
- this.stopQuotePolling();
1454
1318
  __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_abortDependentRequests).call(this);
1455
1319
  __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_clearPendingResourceCountForDependentResources).call(this);
1456
1320
  this.update((state) => resetDependentResources(state, { clearUserRegionData: true }));
1457
1321
  }, _RampsController_fireAndForget = function _RampsController_fireAndForget(promise) {
1458
1322
  promise.catch((_error) => undefined);
1459
- }, _RampsController_restartPollingIfActive = function _RampsController_restartPollingIfActive() {
1460
- if (__classPrivateFieldGet(this, _RampsController_quotePollingInterval, "f") !== null && __classPrivateFieldGet(this, _RampsController_quotePollingOptions, "f")) {
1461
- const options = __classPrivateFieldGet(this, _RampsController_quotePollingOptions, "f");
1462
- this.stopQuotePolling();
1463
- try {
1464
- this.startQuotePolling(options);
1465
- }
1466
- catch {
1467
- // Dependencies not met yet, polling will need to be manually restarted
1468
- // when dependencies are available
1469
- }
1470
- }
1471
1323
  }, _RampsController_requireRegion = function _RampsController_requireRegion() {
1472
1324
  const regionCode = this.state.userRegion?.regionCode;
1473
1325
  if (!regionCode) {
@@ -1523,39 +1375,6 @@ _RampsController_requestCacheTTL = new WeakMap(), _RampsController_requestCacheM
1523
1375
  }
1524
1376
  }
1525
1377
  });
1526
- }, _RampsController_syncWidgetUrl = function _RampsController_syncWidgetUrl(quote) {
1527
- const buyUrl = quote?.quote?.buyURL;
1528
- if (!buyUrl) {
1529
- this.update((state) => {
1530
- resetWidgetUrl(state);
1531
- });
1532
- return;
1533
- }
1534
- if (this.state.widgetUrl.data === null) {
1535
- this.update((state) => {
1536
- state.widgetUrl.isLoading = true;
1537
- state.widgetUrl.error = null;
1538
- });
1539
- }
1540
- __classPrivateFieldGet(this, _RampsController_instances, "m", _RampsController_fireAndForget).call(this, this.messenger
1541
- .call('RampsService:getBuyWidgetUrl', buyUrl)
1542
- .then((buyWidget) => {
1543
- this.update((state) => {
1544
- state.widgetUrl.data = buyWidget;
1545
- state.widgetUrl.isLoading = false;
1546
- state.widgetUrl.error = null;
1547
- });
1548
- return undefined;
1549
- })
1550
- .catch((error) => {
1551
- this.update((state) => {
1552
- state.widgetUrl.isLoading = false;
1553
- state.widgetUrl.error =
1554
- error instanceof Error
1555
- ? error.message
1556
- : 'Failed to fetch widget URL';
1557
- });
1558
- }));
1559
1378
  }, _RampsController_syncTransakAuthOnError = function _RampsController_syncTransakAuthOnError(error) {
1560
1379
  if (error instanceof Error &&
1561
1380
  'httpStatus' in error &&