@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/README.md CHANGED
@@ -382,7 +382,7 @@ if (result.status === "completed") {
382
382
  }
383
383
  ```
384
384
 
385
- After `POST /api/swap/report` returns an `id`, the SDK always polls `GET /api/swap/order-status?orderId=<report id>`. That report id is the only status key. The SDK does not query by `recordId` or source `txHash`. Confidential swaps also require order-status polling when they are same-chain. For confidential Near Intents builds, the SDK uses `deposit.orderId` when present and otherwise uses `deposit.depositAddress` as the status key. If a cross-chain or confidential swap provides none of these identifiers, the SDK throws `INVALID_API_RESPONSE` at the `status` stage instead of treating source-chain confirmation as completion.
385
+ After `POST /api/swap/report` returns an `id`, the SDK polls `GET /api/swap/order-status?orderId=<report id>&router=<swap router>`. The router comes from the swap response. The SDK does not query by `recordId` or source `txHash`. Confidential swaps also require order-status polling when they are same-chain. For confidential Near Intents builds, the SDK uses `deposit.orderId` when present and otherwise uses `deposit.depositAddress` as the status key. If a cross-chain or confidential swap provides none of these identifiers, the SDK throws `INVALID_API_RESPONSE` at the `status` stage instead of treating source-chain confirmation as completion.
386
386
 
387
387
  The default polling interval is 5 seconds. There is no default polling timeout, so polling continues until the order reaches a terminal state or the supplied `AbortSignal` is aborted.
388
388
 
package/dist/index.d.mts CHANGED
@@ -386,8 +386,7 @@ declare function shouldPollSwapOrderStatus(input: {
386
386
  declare function resolveSwapReportRecordId(reportData: unknown): string;
387
387
  type OrderStatusLookup = OrderReference;
388
388
  /**
389
- * Status queries use `orderId`.
390
- * The report response `id` is that orderId and is sent alone.
389
+ * Status queries use the report id as `orderId`, plus the swap response `router`.
391
390
  */
392
391
  declare function buildOrderStatusQuery(params: SwapOrderStatusParamsRaw): Record<string, string | number>;
393
392
  declare function resolveOrderStatusLookup(input: {
package/dist/index.d.ts CHANGED
@@ -386,8 +386,7 @@ declare function shouldPollSwapOrderStatus(input: {
386
386
  declare function resolveSwapReportRecordId(reportData: unknown): string;
387
387
  type OrderStatusLookup = OrderReference;
388
388
  /**
389
- * Status queries use `orderId`.
390
- * The report response `id` is that orderId and is sent alone.
389
+ * Status queries use the report id as `orderId`, plus the swap response `router`.
391
390
  */
392
391
  declare function buildOrderStatusQuery(params: SwapOrderStatusParamsRaw): Record<string, string | number>;
393
392
  declare function resolveOrderStatusLookup(input: {
package/dist/index.js CHANGED
@@ -49,29 +49,31 @@ function resolveSwapReportRecordId(reportData) {
49
49
  }
50
50
  function buildOrderStatusQuery(params) {
51
51
  const reportId = String(params.recordId ?? "").trim();
52
- if (reportId) {
53
- return { orderId: reportId };
54
- }
55
- const orderId = params.orderId?.trim();
52
+ const orderId = reportId || params.orderId?.trim();
56
53
  if (!orderId) return {};
57
54
  const query = { orderId };
58
55
  const router = params.router?.trim();
59
56
  if (router) query.router = router;
60
- const chainId = params.chainId;
61
- if (chainId !== void 0 && chainId !== null && String(chainId).trim() !== "") {
62
- query.chainId = chainId;
57
+ if (!reportId) {
58
+ const chainId = params.chainId;
59
+ if (chainId !== void 0 && chainId !== null && String(chainId).trim() !== "") {
60
+ query.chainId = chainId;
61
+ }
63
62
  }
64
63
  return query;
65
64
  }
66
65
  function resolveOrderStatusLookup(input) {
67
66
  const reportId = String(input.recordId ?? "").trim();
68
- if (reportId) {
69
- return { orderId: reportId };
70
- }
71
- const orderId = input.orderId?.trim();
67
+ const orderId = reportId || input.orderId?.trim();
72
68
  if (!orderId) return void 0;
73
69
  const router = input.router?.trim();
74
- const chainId = input.chainId !== void 0 && input.chainId !== null && String(input.chainId).trim() !== "" ? String(input.chainId).trim() : void 0;
70
+ const chainId = reportId ? void 0 : input.chainId !== void 0 && input.chainId !== null && String(input.chainId).trim() !== "" ? String(input.chainId).trim() : void 0;
71
+ if (reportId) {
72
+ return {
73
+ orderId,
74
+ ...router ? { router } : {}
75
+ };
76
+ }
75
77
  return {
76
78
  orderId,
77
79
  ...router ? { router } : {},
@@ -92,7 +94,10 @@ function assertOrderStatusParams(params) {
92
94
  function orderStatusParamsFromHistoryItem(item) {
93
95
  const reportId = String(item.id ?? "").trim();
94
96
  if (reportId) {
95
- return { orderId: reportId };
97
+ return {
98
+ orderId: reportId,
99
+ ...item.router ? { router: item.router } : {}
100
+ };
96
101
  }
97
102
  return {
98
103
  ...item.orderId ? { orderId: item.orderId } : {},
@@ -2292,7 +2297,8 @@ var McaSwapService = class {
2292
2297
  }
2293
2298
  if (input.waitFor === "completed") {
2294
2299
  const statusLookup = resolveOrderStatusLookup({
2295
- recordId: reportRecordId ?? result.report?.recordId
2300
+ recordId: reportRecordId ?? result.report?.recordId,
2301
+ router
2296
2302
  });
2297
2303
  if (!statusLookup) {
2298
2304
  throw new SwapSdkError(
@@ -2606,7 +2612,8 @@ var SwapClient = class {
2606
2612
  reportRecordId
2607
2613
  });
2608
2614
  const statusLookup = resolveOrderStatusLookup({
2609
- recordId: reportRecordId ?? result.report?.recordId
2615
+ recordId: reportRecordId ?? result.report?.recordId,
2616
+ router: build.order?.router ?? build.router
2610
2617
  });
2611
2618
  if (shouldPollOrderStatus && !statusLookup) {
2612
2619
  throw new SwapSdkError(