@rhea-finance/cross-chain-aggregation-dex 2.0.8 → 2.0.9

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/dist/index.mjs CHANGED
@@ -29,8 +29,15 @@ function asSwapSdkError(error, stage) {
29
29
  // src/utils/orderStatus.ts
30
30
  function resolveSwapReportRecordId(reportData) {
31
31
  if (!reportData || typeof reportData !== "object") return "";
32
- const id = reportData.id;
33
- return id === void 0 || id === null ? "" : String(id).trim();
32
+ const record = reportData;
33
+ for (const key of ["id", "recordId", "record_id"]) {
34
+ const value = record[key];
35
+ if (value !== void 0 && value !== null) {
36
+ const normalized = String(value).trim();
37
+ if (normalized) return normalized;
38
+ }
39
+ }
40
+ return "";
34
41
  }
35
42
  function buildOrderStatusQuery(params) {
36
43
  const normalizedRecordId = String(params.recordId ?? "").trim();
@@ -2295,8 +2302,10 @@ var McaSwapService = class {
2295
2302
  raw
2296
2303
  };
2297
2304
  emit({ type: "submitted", executionId, orderId });
2305
+ const mustReportForStatus = input.waitFor === "completed";
2306
+ const shouldReportNow = this.reportMode !== "disabled" && (this.reportMode === "auto" || mustReportForStatus);
2298
2307
  let reportRecordId;
2299
- if (this.reportMode === "auto") {
2308
+ if (shouldReportNow) {
2300
2309
  try {
2301
2310
  const reportData = await this.client.reportRaw(reportRequest, {
2302
2311
  signal: input.signal
@@ -2597,12 +2606,16 @@ var SwapClient = class {
2597
2606
  executionId: build.executionId
2598
2607
  });
2599
2608
  }
2609
+ const waitsForCompletion = (input.waitFor ?? "submitted") === "completed";
2610
+ const requiresOrderStatus = build.isCrossChain || build.request?.confidentiality === "basic";
2600
2611
  const reportRequest = this.createReportRequest(build, result);
2601
2612
  if (reportRequest) {
2602
2613
  this.reportRequests.set(build.executionId, reportRequest);
2603
2614
  }
2615
+ const mustReportForStatus = waitsForCompletion && requiresOrderStatus && Boolean(reportRequest);
2616
+ const shouldReportNow = Boolean(reportRequest) && this.reportMode !== "disabled" && (this.reportMode === "auto" || mustReportForStatus);
2604
2617
  let reportRecordId;
2605
- if (this.reportMode === "auto" && reportRequest) {
2618
+ if (shouldReportNow && reportRequest) {
2606
2619
  try {
2607
2620
  const reportData = await this.api.report(reportRequest, {
2608
2621
  signal: input.signal
@@ -2622,8 +2635,6 @@ var SwapClient = class {
2622
2635
  emit({ type: "warning", executionId: build.executionId, warning });
2623
2636
  }
2624
2637
  }
2625
- const waitsForCompletion = (input.waitFor ?? "submitted") === "completed";
2626
- const requiresOrderStatus = build.isCrossChain || build.request?.confidentiality === "basic";
2627
2638
  const statusLookup = resolveOrderStatusLookup({
2628
2639
  recordId: reportRecordId ?? result.report?.recordId,
2629
2640
  orderId,