@rhea-finance/cross-chain-aggregation-dex 2.0.9 → 2.1.0
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 +3 -3
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +16 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -27,6 +27,11 @@ function asSwapSdkError(error, stage) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// src/utils/orderStatus.ts
|
|
30
|
+
function shouldPollSwapOrderStatus(input) {
|
|
31
|
+
const waitMode = input.waitFor ?? "submitted";
|
|
32
|
+
const requiresOrderStatus = input.isCrossChain || input.confidentiality === "basic";
|
|
33
|
+
return requiresOrderStatus && waitMode !== "submitted";
|
|
34
|
+
}
|
|
30
35
|
function resolveSwapReportRecordId(reportData) {
|
|
31
36
|
if (!reportData || typeof reportData !== "object") return "";
|
|
32
37
|
const record = reportData;
|
|
@@ -2062,41 +2067,13 @@ var McaSwapService = class {
|
|
|
2062
2067
|
"MCA NEAR withdraw is missing a status deposit address"
|
|
2063
2068
|
);
|
|
2064
2069
|
}
|
|
2065
|
-
|
|
2070
|
+
return this.client.executeSwap({
|
|
2066
2071
|
build,
|
|
2067
2072
|
waitFor: input.quote.executionMode === "withdraw-near" && input.waitFor === "completed" ? "source-confirmed" : input.waitFor,
|
|
2068
2073
|
orderPolling: input.orderPolling,
|
|
2069
2074
|
signal: input.signal,
|
|
2070
2075
|
onEvent: input.onEvent
|
|
2071
2076
|
});
|
|
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
2077
|
}
|
|
2101
2078
|
reportIfManaged(result) {
|
|
2102
2079
|
const request = this.relayerReports.get(result.executionId);
|
|
@@ -2606,13 +2583,17 @@ var SwapClient = class {
|
|
|
2606
2583
|
executionId: build.executionId
|
|
2607
2584
|
});
|
|
2608
2585
|
}
|
|
2609
|
-
const
|
|
2610
|
-
const
|
|
2586
|
+
const waitMode = input.waitFor ?? "submitted";
|
|
2587
|
+
const shouldPollOrderStatus = shouldPollSwapOrderStatus({
|
|
2588
|
+
waitFor: waitMode,
|
|
2589
|
+
isCrossChain: build.isCrossChain,
|
|
2590
|
+
confidentiality: build.request?.confidentiality
|
|
2591
|
+
});
|
|
2611
2592
|
const reportRequest = this.createReportRequest(build, result);
|
|
2612
2593
|
if (reportRequest) {
|
|
2613
2594
|
this.reportRequests.set(build.executionId, reportRequest);
|
|
2614
2595
|
}
|
|
2615
|
-
const mustReportForStatus =
|
|
2596
|
+
const mustReportForStatus = shouldPollOrderStatus && Boolean(reportRequest);
|
|
2616
2597
|
const shouldReportNow = Boolean(reportRequest) && this.reportMode !== "disabled" && (this.reportMode === "auto" || mustReportForStatus);
|
|
2617
2598
|
let reportRecordId;
|
|
2618
2599
|
if (shouldReportNow && reportRequest) {
|
|
@@ -2642,7 +2623,7 @@ var SwapClient = class {
|
|
|
2642
2623
|
router: orderRouter ?? build.router,
|
|
2643
2624
|
chainId: orderChainId
|
|
2644
2625
|
});
|
|
2645
|
-
if (
|
|
2626
|
+
if (shouldPollOrderStatus && !statusLookup) {
|
|
2646
2627
|
throw new SwapSdkError(
|
|
2647
2628
|
"INVALID_API_RESPONSE",
|
|
2648
2629
|
"status",
|
|
@@ -2655,7 +2636,7 @@ var SwapClient = class {
|
|
|
2655
2636
|
}
|
|
2656
2637
|
);
|
|
2657
2638
|
}
|
|
2658
|
-
if (
|
|
2639
|
+
if (shouldPollOrderStatus && statusLookup) {
|
|
2659
2640
|
const status = await this.waitForOrder({
|
|
2660
2641
|
...statusLookup,
|
|
2661
2642
|
...input.orderPolling,
|
|
@@ -2919,6 +2900,6 @@ function delay(ms, signal) {
|
|
|
2919
2900
|
});
|
|
2920
2901
|
}
|
|
2921
2902
|
|
|
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 };
|
|
2903
|
+
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
2904
|
//# sourceMappingURL=index.mjs.map
|
|
2924
2905
|
//# sourceMappingURL=index.mjs.map
|