@rhea-finance/cross-chain-aggregation-dex 2.0.9 → 2.1.1
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 +4 -4
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +19 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -27,6 +27,12 @@ function asSwapSdkError(error, stage) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// src/utils/orderStatus.ts
|
|
30
|
+
function shouldPollSwapOrderStatus(input) {
|
|
31
|
+
if (String(input.reportRecordId ?? "").trim()) return true;
|
|
32
|
+
const waitMode = input.waitFor ?? "submitted";
|
|
33
|
+
const requiresOrderStatus = input.isCrossChain || input.confidentiality === "basic";
|
|
34
|
+
return requiresOrderStatus && waitMode !== "submitted";
|
|
35
|
+
}
|
|
30
36
|
function resolveSwapReportRecordId(reportData) {
|
|
31
37
|
if (!reportData || typeof reportData !== "object") return "";
|
|
32
38
|
const record = reportData;
|
|
@@ -2062,41 +2068,13 @@ var McaSwapService = class {
|
|
|
2062
2068
|
"MCA NEAR withdraw is missing a status deposit address"
|
|
2063
2069
|
);
|
|
2064
2070
|
}
|
|
2065
|
-
|
|
2071
|
+
return this.client.executeSwap({
|
|
2066
2072
|
build,
|
|
2067
2073
|
waitFor: input.quote.executionMode === "withdraw-near" && input.waitFor === "completed" ? "source-confirmed" : input.waitFor,
|
|
2068
2074
|
orderPolling: input.orderPolling,
|
|
2069
2075
|
signal: input.signal,
|
|
2070
2076
|
onEvent: input.onEvent
|
|
2071
2077
|
});
|
|
2072
|
-
if (input.quote.executionMode === "withdraw-near" && input.waitFor === "completed") {
|
|
2073
|
-
const statusLookup = resolveOrderStatusLookup({
|
|
2074
|
-
recordId: result.report?.recordId,
|
|
2075
|
-
orderId: nearStatusKey,
|
|
2076
|
-
router: input.quote.route.router
|
|
2077
|
-
}) ?? { orderId: nearStatusKey, router: input.quote.route.router };
|
|
2078
|
-
const status = await this.client.waitForOrder({
|
|
2079
|
-
...statusLookup,
|
|
2080
|
-
...input.orderPolling,
|
|
2081
|
-
signal: input.signal
|
|
2082
|
-
});
|
|
2083
|
-
this.emitEvent(
|
|
2084
|
-
{
|
|
2085
|
-
type: "order-status",
|
|
2086
|
-
executionId: result.executionId,
|
|
2087
|
-
status: status.status
|
|
2088
|
-
},
|
|
2089
|
-
input.onEvent
|
|
2090
|
-
);
|
|
2091
|
-
result.status = status.status === "unknown" || status.status === "pending" ? "processing" : status.status;
|
|
2092
|
-
if (status.status === "completed") {
|
|
2093
|
-
this.emitEvent(
|
|
2094
|
-
{ type: "completed", executionId: result.executionId },
|
|
2095
|
-
input.onEvent
|
|
2096
|
-
);
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
return result;
|
|
2100
2078
|
}
|
|
2101
2079
|
reportIfManaged(result) {
|
|
2102
2080
|
const request = this.relayerReports.get(result.executionId);
|
|
@@ -2606,13 +2584,13 @@ var SwapClient = class {
|
|
|
2606
2584
|
executionId: build.executionId
|
|
2607
2585
|
});
|
|
2608
2586
|
}
|
|
2609
|
-
const
|
|
2610
|
-
const
|
|
2587
|
+
const waitMode = input.waitFor ?? "submitted";
|
|
2588
|
+
const requiresTrackedStatus = build.isCrossChain || build.request?.confidentiality === "basic";
|
|
2611
2589
|
const reportRequest = this.createReportRequest(build, result);
|
|
2612
2590
|
if (reportRequest) {
|
|
2613
2591
|
this.reportRequests.set(build.executionId, reportRequest);
|
|
2614
2592
|
}
|
|
2615
|
-
const mustReportForStatus =
|
|
2593
|
+
const mustReportForStatus = requiresTrackedStatus && waitMode !== "submitted" && Boolean(reportRequest);
|
|
2616
2594
|
const shouldReportNow = Boolean(reportRequest) && this.reportMode !== "disabled" && (this.reportMode === "auto" || mustReportForStatus);
|
|
2617
2595
|
let reportRecordId;
|
|
2618
2596
|
if (shouldReportNow && reportRequest) {
|
|
@@ -2635,6 +2613,12 @@ var SwapClient = class {
|
|
|
2635
2613
|
emit({ type: "warning", executionId: build.executionId, warning });
|
|
2636
2614
|
}
|
|
2637
2615
|
}
|
|
2616
|
+
const shouldPollOrderStatus = shouldPollSwapOrderStatus({
|
|
2617
|
+
waitFor: waitMode,
|
|
2618
|
+
isCrossChain: build.isCrossChain,
|
|
2619
|
+
confidentiality: build.request?.confidentiality,
|
|
2620
|
+
reportRecordId
|
|
2621
|
+
});
|
|
2638
2622
|
const statusLookup = resolveOrderStatusLookup({
|
|
2639
2623
|
recordId: reportRecordId ?? result.report?.recordId,
|
|
2640
2624
|
orderId,
|
|
@@ -2642,7 +2626,7 @@ var SwapClient = class {
|
|
|
2642
2626
|
router: orderRouter ?? build.router,
|
|
2643
2627
|
chainId: orderChainId
|
|
2644
2628
|
});
|
|
2645
|
-
if (
|
|
2629
|
+
if (shouldPollOrderStatus && !statusLookup) {
|
|
2646
2630
|
throw new SwapSdkError(
|
|
2647
2631
|
"INVALID_API_RESPONSE",
|
|
2648
2632
|
"status",
|
|
@@ -2655,7 +2639,7 @@ var SwapClient = class {
|
|
|
2655
2639
|
}
|
|
2656
2640
|
);
|
|
2657
2641
|
}
|
|
2658
|
-
if (
|
|
2642
|
+
if (shouldPollOrderStatus && statusLookup) {
|
|
2659
2643
|
const status = await this.waitForOrder({
|
|
2660
2644
|
...statusLookup,
|
|
2661
2645
|
...input.orderPolling,
|
|
@@ -2919,6 +2903,6 @@ function delay(ms, signal) {
|
|
|
2919
2903
|
});
|
|
2920
2904
|
}
|
|
2921
2905
|
|
|
2922
|
-
export { ApiClient, DEFAULT_MCA_SIGNER_PRIORITY, ExecutorRegistry, SwapClient, SwapSdkError, asSwapSdkError, assertBaseUnitAmount, assertOrderStatusParams, buildMcaWithdrawRelayerRequest, buildNearMcaWithdrawTransactions, buildOrderStatusQuery, createExecutionId, extractMcaWithdrawBusiness, extractMcaWithdrawDepositAddress, extractMcaWithdrawSignerWallet, formatMcaWallet, formatUnits, fromApiChain, isSameMcaSignerIdentity, normalizeBuild, normalizeCrossChainToTokenList, normalizeFromTokenList, normalizeHistory, normalizeHistoryStatus, normalizeMcaQuote, normalizeOrderStatus, normalizeQuote, orderStatusParamsFromHistoryItem, parseUnits, resolveMcaDecreaseCollateral, resolveMcaRequiredCollateralDecrease, resolveMcaWithdrawPolicy, resolveOrderStatusLookup, resolveSourceTxHash, resolveSwapReportRecordId, selectMcaSigner, serializeMcaQuoteRequest, serializeQuoteRequest, toApiAssetAddress, toApiChain };
|
|
2906
|
+
export { ApiClient, DEFAULT_MCA_SIGNER_PRIORITY, ExecutorRegistry, SwapClient, SwapSdkError, asSwapSdkError, assertBaseUnitAmount, assertOrderStatusParams, buildMcaWithdrawRelayerRequest, buildNearMcaWithdrawTransactions, buildOrderStatusQuery, createExecutionId, extractMcaWithdrawBusiness, extractMcaWithdrawDepositAddress, extractMcaWithdrawSignerWallet, formatMcaWallet, formatUnits, fromApiChain, isSameMcaSignerIdentity, normalizeBuild, normalizeCrossChainToTokenList, normalizeFromTokenList, normalizeHistory, normalizeHistoryStatus, normalizeMcaQuote, normalizeOrderStatus, normalizeQuote, orderStatusParamsFromHistoryItem, parseUnits, resolveMcaDecreaseCollateral, resolveMcaRequiredCollateralDecrease, resolveMcaWithdrawPolicy, resolveOrderStatusLookup, resolveSourceTxHash, resolveSwapReportRecordId, selectMcaSigner, serializeMcaQuoteRequest, serializeQuoteRequest, shouldPollSwapOrderStatus, toApiAssetAddress, toApiChain };
|
|
2923
2907
|
//# sourceMappingURL=index.mjs.map
|
|
2924
2908
|
//# sourceMappingURL=index.mjs.map
|