@metamask-previews/ramps-controller 20.0.0-preview-58a4a8b71 → 20.0.0-preview-4c8a5dfcb

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 CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Export `TERMINAL_ORDER_STATUSES` and `isTerminalOrderStatus()` so consuming clients can share the controller's terminal order status set instead of maintaining duplicate copies. ([#9679](https://github.com/MetaMask/core/pull/9679))
13
+
10
14
  ## [20.0.0]
11
15
 
12
16
  ### Changed
@@ -16,6 +16,7 @@ exports.RampsController = exports.getInternalOrderCode = exports.getDefaultRamps
16
16
  const base_controller_1 = require("@metamask/base-controller");
17
17
  const controller_utils_1 = require("@metamask/controller-utils");
18
18
  const featureFlags_js_1 = require("./featureFlags.cjs");
19
+ const orderStatus_js_1 = require("./orderStatus.cjs");
19
20
  const providerAvailability_js_1 = require("./providerAvailability.cjs");
20
21
  const rampsErrorCodes_js_1 = require("./rampsErrorCodes.cjs");
21
22
  const RampsService_js_1 = require("./RampsService.cjs");
@@ -355,18 +356,6 @@ function getInternalOrderCode(orderOrId) {
355
356
  }
356
357
  exports.getInternalOrderCode = getInternalOrderCode;
357
358
  // === ORDER POLLING CONSTANTS ===
358
- const TERMINAL_ORDER_STATUSES = new Set([
359
- RampsService_js_1.RampsOrderStatus.Completed,
360
- RampsService_js_1.RampsOrderStatus.Failed,
361
- RampsService_js_1.RampsOrderStatus.Cancelled,
362
- RampsService_js_1.RampsOrderStatus.IdExpired,
363
- ]);
364
- const PENDING_ORDER_STATUSES = new Set([
365
- RampsService_js_1.RampsOrderStatus.Pending,
366
- RampsService_js_1.RampsOrderStatus.Created,
367
- RampsService_js_1.RampsOrderStatus.Unknown,
368
- RampsService_js_1.RampsOrderStatus.Precreated,
369
- ]);
370
359
  const DEFAULT_POLLING_INTERVAL_MS = 30000;
371
360
  const MAX_ERROR_COUNT = 5;
372
361
  // === CONTROLLER DEFINITION ===
@@ -2169,7 +2158,7 @@ async function _RampsController_refreshOrder(order) {
2169
2158
  previousStatus,
2170
2159
  });
2171
2160
  }
2172
- if (TERMINAL_ORDER_STATUSES.has(updatedOrder.status)) {
2161
+ if (orderStatus_js_1.TERMINAL_ORDER_STATUSES.has(updatedOrder.status)) {
2173
2162
  __classPrivateFieldGet(this, _RampsController_orderPollingMeta, "f").delete(order.providerOrderId);
2174
2163
  }
2175
2164
  }
@@ -2188,7 +2177,7 @@ async function _RampsController_refreshOrder(order) {
2188
2177
  }
2189
2178
  __classPrivateFieldSet(this, _RampsController_isPolling, true, "f");
2190
2179
  try {
2191
- const pendingOrders = this.state.orders.filter((order) => PENDING_ORDER_STATUSES.has(order.status));
2180
+ const pendingOrders = this.state.orders.filter((order) => orderStatus_js_1.PENDING_ORDER_STATUSES.has(order.status));
2192
2181
  const now = Date.now();
2193
2182
  await Promise.allSettled(pendingOrders.map(async (order) => {
2194
2183
  const meta = __classPrivateFieldGet(this, _RampsController_orderPollingMeta, "f").get(order.providerOrderId);