@rhea-finance/cross-chain-aggregation-dex 2.1.2 → 2.1.3

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
@@ -47,29 +47,31 @@ function resolveSwapReportRecordId(reportData) {
47
47
  }
48
48
  function buildOrderStatusQuery(params) {
49
49
  const reportId = String(params.recordId ?? "").trim();
50
- if (reportId) {
51
- return { orderId: reportId };
52
- }
53
- const orderId = params.orderId?.trim();
50
+ const orderId = reportId || params.orderId?.trim();
54
51
  if (!orderId) return {};
55
52
  const query = { orderId };
56
53
  const router = params.router?.trim();
57
54
  if (router) query.router = router;
58
- const chainId = params.chainId;
59
- if (chainId !== void 0 && chainId !== null && String(chainId).trim() !== "") {
60
- query.chainId = chainId;
55
+ if (!reportId) {
56
+ const chainId = params.chainId;
57
+ if (chainId !== void 0 && chainId !== null && String(chainId).trim() !== "") {
58
+ query.chainId = chainId;
59
+ }
61
60
  }
62
61
  return query;
63
62
  }
64
63
  function resolveOrderStatusLookup(input) {
65
64
  const reportId = String(input.recordId ?? "").trim();
66
- if (reportId) {
67
- return { orderId: reportId };
68
- }
69
- const orderId = input.orderId?.trim();
65
+ const orderId = reportId || input.orderId?.trim();
70
66
  if (!orderId) return void 0;
71
67
  const router = input.router?.trim();
72
- const chainId = input.chainId !== void 0 && input.chainId !== null && String(input.chainId).trim() !== "" ? String(input.chainId).trim() : void 0;
68
+ const chainId = reportId ? void 0 : input.chainId !== void 0 && input.chainId !== null && String(input.chainId).trim() !== "" ? String(input.chainId).trim() : void 0;
69
+ if (reportId) {
70
+ return {
71
+ orderId,
72
+ ...router ? { router } : {}
73
+ };
74
+ }
73
75
  return {
74
76
  orderId,
75
77
  ...router ? { router } : {},
@@ -90,7 +92,10 @@ function assertOrderStatusParams(params) {
90
92
  function orderStatusParamsFromHistoryItem(item) {
91
93
  const reportId = String(item.id ?? "").trim();
92
94
  if (reportId) {
93
- return { orderId: reportId };
95
+ return {
96
+ orderId: reportId,
97
+ ...item.router ? { router: item.router } : {}
98
+ };
94
99
  }
95
100
  return {
96
101
  ...item.orderId ? { orderId: item.orderId } : {},
@@ -2290,7 +2295,8 @@ var McaSwapService = class {
2290
2295
  }
2291
2296
  if (input.waitFor === "completed") {
2292
2297
  const statusLookup = resolveOrderStatusLookup({
2293
- recordId: reportRecordId ?? result.report?.recordId
2298
+ recordId: reportRecordId ?? result.report?.recordId,
2299
+ router
2294
2300
  });
2295
2301
  if (!statusLookup) {
2296
2302
  throw new SwapSdkError(
@@ -2604,7 +2610,8 @@ var SwapClient = class {
2604
2610
  reportRecordId
2605
2611
  });
2606
2612
  const statusLookup = resolveOrderStatusLookup({
2607
- recordId: reportRecordId ?? result.report?.recordId
2613
+ recordId: reportRecordId ?? result.report?.recordId,
2614
+ router: build.order?.router ?? build.router
2608
2615
  });
2609
2616
  if (shouldPollOrderStatus && !statusLookup) {
2610
2617
  throw new SwapSdkError(