@rhea-finance/cross-chain-aggregation-dex 2.1.3 → 2.1.5
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 +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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 polls `GET /api/swap/order-status?
|
|
385
|
+
After `POST /api/swap/report` returns an `id`, the SDK polls `GET /api/swap/order-status?recordId=<report id>&router=<swap router>`. The router comes from the swap response. The SDK does not query by 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,7 +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 the report id as `
|
|
389
|
+
* Status queries use the report id as `recordId`, plus the swap response `router`.
|
|
390
390
|
*/
|
|
391
391
|
declare function buildOrderStatusQuery(params: SwapOrderStatusParamsRaw): Record<string, string | number>;
|
|
392
392
|
declare function resolveOrderStatusLookup(input: {
|
package/dist/index.d.ts
CHANGED
|
@@ -386,7 +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 the report id as `
|
|
389
|
+
* Status queries use the report id as `recordId`, plus the swap response `router`.
|
|
390
390
|
*/
|
|
391
391
|
declare function buildOrderStatusQuery(params: SwapOrderStatusParamsRaw): Record<string, string | number>;
|
|
392
392
|
declare function resolveOrderStatusLookup(input: {
|
package/dist/index.js
CHANGED
|
@@ -49,31 +49,35 @@ function resolveSwapReportRecordId(reportData) {
|
|
|
49
49
|
}
|
|
50
50
|
function buildOrderStatusQuery(params) {
|
|
51
51
|
const reportId = String(params.recordId ?? "").trim();
|
|
52
|
-
|
|
52
|
+
if (reportId) {
|
|
53
|
+
const query2 = { recordId: reportId };
|
|
54
|
+
const router2 = params.router?.trim();
|
|
55
|
+
if (router2) query2.router = router2;
|
|
56
|
+
return query2;
|
|
57
|
+
}
|
|
58
|
+
const orderId = params.orderId?.trim();
|
|
53
59
|
if (!orderId) return {};
|
|
54
60
|
const query = { orderId };
|
|
55
61
|
const router = params.router?.trim();
|
|
56
62
|
if (router) query.router = router;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
query.chainId = chainId;
|
|
61
|
-
}
|
|
63
|
+
const chainId = params.chainId;
|
|
64
|
+
if (chainId !== void 0 && chainId !== null && String(chainId).trim() !== "") {
|
|
65
|
+
query.chainId = chainId;
|
|
62
66
|
}
|
|
63
67
|
return query;
|
|
64
68
|
}
|
|
65
69
|
function resolveOrderStatusLookup(input) {
|
|
66
70
|
const reportId = String(input.recordId ?? "").trim();
|
|
67
|
-
const orderId = reportId || input.orderId?.trim();
|
|
68
|
-
if (!orderId) return void 0;
|
|
69
71
|
const router = input.router?.trim();
|
|
70
|
-
const chainId = reportId ? void 0 : input.chainId !== void 0 && input.chainId !== null && String(input.chainId).trim() !== "" ? String(input.chainId).trim() : void 0;
|
|
71
72
|
if (reportId) {
|
|
72
73
|
return {
|
|
73
|
-
|
|
74
|
+
recordId: reportId,
|
|
74
75
|
...router ? { router } : {}
|
|
75
76
|
};
|
|
76
77
|
}
|
|
78
|
+
const orderId = input.orderId?.trim();
|
|
79
|
+
if (!orderId) return void 0;
|
|
80
|
+
const chainId = input.chainId !== void 0 && input.chainId !== null && String(input.chainId).trim() !== "" ? String(input.chainId).trim() : void 0;
|
|
77
81
|
return {
|
|
78
82
|
orderId,
|
|
79
83
|
...router ? { router } : {},
|
|
@@ -86,7 +90,7 @@ function assertOrderStatusParams(params) {
|
|
|
86
90
|
throw new SwapSdkError(
|
|
87
91
|
"INVALID_REQUEST",
|
|
88
92
|
"status",
|
|
89
|
-
"Order status requires orderId"
|
|
93
|
+
"Order status requires recordId or orderId"
|
|
90
94
|
);
|
|
91
95
|
}
|
|
92
96
|
return lookup;
|
|
@@ -95,7 +99,7 @@ function orderStatusParamsFromHistoryItem(item) {
|
|
|
95
99
|
const reportId = String(item.id ?? "").trim();
|
|
96
100
|
if (reportId) {
|
|
97
101
|
return {
|
|
98
|
-
|
|
102
|
+
recordId: reportId,
|
|
99
103
|
...item.router ? { router: item.router } : {}
|
|
100
104
|
};
|
|
101
105
|
}
|
|
@@ -156,11 +160,11 @@ var ApiClient = class {
|
|
|
156
160
|
}
|
|
157
161
|
getOrderStatus(params, options = {}) {
|
|
158
162
|
const query = buildOrderStatusQuery(params);
|
|
159
|
-
if (!query.orderId) {
|
|
163
|
+
if (!query.recordId && !query.orderId) {
|
|
160
164
|
throw new SwapSdkError(
|
|
161
165
|
"INVALID_REQUEST",
|
|
162
166
|
"status",
|
|
163
|
-
"Order status requires orderId"
|
|
167
|
+
"Order status requires recordId or orderId"
|
|
164
168
|
);
|
|
165
169
|
}
|
|
166
170
|
return this.request("/api/swap/order-status", "status", {
|