@rhea-finance/cross-chain-aggregation-dex 2.1.8 → 2.1.9
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 +10 -0
- package/dist/executors/aptos.d.mts +1 -1
- package/dist/executors/aptos.d.ts +1 -1
- package/dist/executors/bitcoin.d.mts +1 -1
- package/dist/executors/bitcoin.d.ts +1 -1
- package/dist/executors/evm.d.mts +1 -1
- package/dist/executors/evm.d.ts +1 -1
- package/dist/executors/near.d.mts +1 -1
- package/dist/executors/near.d.ts +1 -1
- package/dist/executors/solana.d.mts +1 -1
- package/dist/executors/solana.d.ts +1 -1
- package/dist/executors/sui.d.mts +1 -1
- package/dist/executors/sui.d.ts +1 -1
- package/dist/executors/tron.d.mts +1 -1
- package/dist/executors/tron.d.ts +1 -1
- package/dist/executors/tron.js +50 -7
- package/dist/executors/tron.js.map +1 -1
- package/dist/executors/tron.mjs +50 -7
- package/dist/executors/tron.mjs.map +1 -1
- package/dist/executors/zcash.d.mts +1 -1
- package/dist/executors/zcash.d.ts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +71 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -17
- package/dist/index.mjs.map +1 -1
- package/dist/{shared-v1w63b8X.d.mts → shared-D_BnU1oa.d.mts} +11 -0
- package/dist/{shared-v1w63b8X.d.ts → shared-D_BnU1oa.d.ts} +11 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SwapQuoteRequestRaw, a as SwapQuoteDataRaw, b as SwapBuildRequestRaw, c as SwapBuildDataRaw, d as SwapOrderSubmitRequestRaw, e as SwapOrderSubmitDataRaw, f as SwapOrderStatusParamsRaw, g as SwapOrderStatusDataRaw, h as SwapReportRequestRaw, i as SwapReportDataRaw, j as SwapHistoryParamsRaw, k as SwapHistoryDataRaw, l as SwapHistoryAuthChallengeRequestRaw, m as SwapHistoryAuthChallengeRaw, n as SwapHistoryAuthVerifyRequestRaw, o as SwapHistoryAuthTokenRaw, p as SwapFromTokensDataRaw, q as SwapCrossChainToTokensDataRaw, Q as QuoteRequest, r as Quote, s as SwapMcaPayloadRaw, W as WaitMode, O as OrderPollingOptions, t as SwapLifecycleEvent, u as SwapExecutionResult, C as ChainRef, A as AssetRef, B as BaseUnitAmount, v as SwapHistoryRecordRaw, w as ChainExecutor, E as ExecutorRegistry, x as SwapBuild, y as ExecuteSwapInput, z as SwapInput, D as OrderReference, F as OrderStatusResult, G as WaitForOrderInput, H as SwapHistoryAuthProofRaw, N as NearTransaction, I as SwapMcaRelayerRequestRaw } from './shared-
|
|
2
|
-
export { ae as BuildContext, _ as ChainExecutionResult, aa as DepositInfo, a5 as EvmApproval, a6 as EvmSigningRequest, a4 as EvmTx, $ as ExecutionContext, a1 as ExecutorIdentityProvider, a2 as ExecutorMessageSigner, a0 as MessageSignOptions, Y as OrderStatus, ad as RouteSummary, X as SignRequestPreview, a7 as SolanaMetadata, J as SwapApiResponse, K as SwapApiTokenMetaRaw, R as SwapBuildApproveRaw, ac as SwapExecution, U as SwapHistoryWalletChainFamilyRaw, M as SwapMcaSignerPayloadRaw, ab as SwapReportContext, P as SwapSigningRequestRaw, L as SwapTokenListRowRaw, V as SwapWarning, T as TransactionConfirmation, a9 as TronApproval, a8 as TronUnsignedTransaction, a3 as assertBaseUnitAmount, Z as normalizeOrderStatus } from './shared-
|
|
1
|
+
import { S as SwapQuoteRequestRaw, a as SwapQuoteDataRaw, b as SwapBuildRequestRaw, c as SwapBuildDataRaw, d as SwapOrderSubmitRequestRaw, e as SwapOrderSubmitDataRaw, f as SwapOrderStatusParamsRaw, g as SwapOrderStatusDataRaw, h as SwapReportRequestRaw, i as SwapReportDataRaw, j as SwapHistoryParamsRaw, k as SwapHistoryDataRaw, l as SwapHistoryAuthChallengeRequestRaw, m as SwapHistoryAuthChallengeRaw, n as SwapHistoryAuthVerifyRequestRaw, o as SwapHistoryAuthTokenRaw, p as SwapFromTokensDataRaw, q as SwapCrossChainToTokensDataRaw, Q as QuoteRequest, r as Quote, s as SwapMcaPayloadRaw, W as WaitMode, O as OrderPollingOptions, t as SwapLifecycleEvent, u as SwapExecutionResult, C as ChainRef, A as AssetRef, B as BaseUnitAmount, v as SwapHistoryRecordRaw, w as ChainExecutor, E as ExecutorRegistry, x as SwapBuild, y as ExecuteSwapInput, z as SwapInput, D as OrderReference, F as OrderStatusResult, G as WaitForOrderInput, H as SwapHistoryAuthProofRaw, N as NearTransaction, I as SwapMcaRelayerRequestRaw } from './shared-D_BnU1oa.mjs';
|
|
2
|
+
export { ae as BuildContext, _ as ChainExecutionResult, aa as DepositInfo, a5 as EvmApproval, a6 as EvmSigningRequest, a4 as EvmTx, $ as ExecutionContext, a1 as ExecutorIdentityProvider, a2 as ExecutorMessageSigner, a0 as MessageSignOptions, Y as OrderStatus, ad as RouteSummary, X as SignRequestPreview, a7 as SolanaMetadata, J as SwapApiResponse, K as SwapApiTokenMetaRaw, R as SwapBuildApproveRaw, ac as SwapExecution, U as SwapHistoryWalletChainFamilyRaw, M as SwapMcaSignerPayloadRaw, ab as SwapReportContext, P as SwapSigningRequestRaw, L as SwapTokenListRowRaw, V as SwapWarning, T as TransactionConfirmation, a9 as TronApproval, a8 as TronUnsignedTransaction, a3 as assertBaseUnitAmount, Z as normalizeOrderStatus } from './shared-D_BnU1oa.mjs';
|
|
3
3
|
|
|
4
4
|
type SwapErrorCode = "HTTP_ERROR" | "API_ERROR" | "RATE_LIMITED" | "AUTH_FAILED" | "REQUEST_ABORTED" | "REQUEST_TIMEOUT" | "INVALID_REQUEST" | "INVALID_API_RESPONSE" | "QUOTE_EXPIRED" | "ROUTE_NOT_FOUND" | "EXECUTOR_NOT_FOUND" | "UNSUPPORTED_CHAIN" | "CHAIN_MISMATCH" | "INVALID_TRANSACTION" | "USER_REJECTED" | "INSUFFICIENT_BALANCE" | "APPROVAL_FAILED" | "SIGNING_FAILED" | "BROADCAST_FAILED" | "ORDER_SUBMIT_FAILED" | "ORDER_TIMEOUT" | "REPORT_FAILED";
|
|
5
5
|
type SwapErrorStage = "quote" | "build" | "approve" | "sign" | "broadcast" | "submit" | "report" | "status" | "tokens" | "history";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SwapQuoteRequestRaw, a as SwapQuoteDataRaw, b as SwapBuildRequestRaw, c as SwapBuildDataRaw, d as SwapOrderSubmitRequestRaw, e as SwapOrderSubmitDataRaw, f as SwapOrderStatusParamsRaw, g as SwapOrderStatusDataRaw, h as SwapReportRequestRaw, i as SwapReportDataRaw, j as SwapHistoryParamsRaw, k as SwapHistoryDataRaw, l as SwapHistoryAuthChallengeRequestRaw, m as SwapHistoryAuthChallengeRaw, n as SwapHistoryAuthVerifyRequestRaw, o as SwapHistoryAuthTokenRaw, p as SwapFromTokensDataRaw, q as SwapCrossChainToTokensDataRaw, Q as QuoteRequest, r as Quote, s as SwapMcaPayloadRaw, W as WaitMode, O as OrderPollingOptions, t as SwapLifecycleEvent, u as SwapExecutionResult, C as ChainRef, A as AssetRef, B as BaseUnitAmount, v as SwapHistoryRecordRaw, w as ChainExecutor, E as ExecutorRegistry, x as SwapBuild, y as ExecuteSwapInput, z as SwapInput, D as OrderReference, F as OrderStatusResult, G as WaitForOrderInput, H as SwapHistoryAuthProofRaw, N as NearTransaction, I as SwapMcaRelayerRequestRaw } from './shared-
|
|
2
|
-
export { ae as BuildContext, _ as ChainExecutionResult, aa as DepositInfo, a5 as EvmApproval, a6 as EvmSigningRequest, a4 as EvmTx, $ as ExecutionContext, a1 as ExecutorIdentityProvider, a2 as ExecutorMessageSigner, a0 as MessageSignOptions, Y as OrderStatus, ad as RouteSummary, X as SignRequestPreview, a7 as SolanaMetadata, J as SwapApiResponse, K as SwapApiTokenMetaRaw, R as SwapBuildApproveRaw, ac as SwapExecution, U as SwapHistoryWalletChainFamilyRaw, M as SwapMcaSignerPayloadRaw, ab as SwapReportContext, P as SwapSigningRequestRaw, L as SwapTokenListRowRaw, V as SwapWarning, T as TransactionConfirmation, a9 as TronApproval, a8 as TronUnsignedTransaction, a3 as assertBaseUnitAmount, Z as normalizeOrderStatus } from './shared-
|
|
1
|
+
import { S as SwapQuoteRequestRaw, a as SwapQuoteDataRaw, b as SwapBuildRequestRaw, c as SwapBuildDataRaw, d as SwapOrderSubmitRequestRaw, e as SwapOrderSubmitDataRaw, f as SwapOrderStatusParamsRaw, g as SwapOrderStatusDataRaw, h as SwapReportRequestRaw, i as SwapReportDataRaw, j as SwapHistoryParamsRaw, k as SwapHistoryDataRaw, l as SwapHistoryAuthChallengeRequestRaw, m as SwapHistoryAuthChallengeRaw, n as SwapHistoryAuthVerifyRequestRaw, o as SwapHistoryAuthTokenRaw, p as SwapFromTokensDataRaw, q as SwapCrossChainToTokensDataRaw, Q as QuoteRequest, r as Quote, s as SwapMcaPayloadRaw, W as WaitMode, O as OrderPollingOptions, t as SwapLifecycleEvent, u as SwapExecutionResult, C as ChainRef, A as AssetRef, B as BaseUnitAmount, v as SwapHistoryRecordRaw, w as ChainExecutor, E as ExecutorRegistry, x as SwapBuild, y as ExecuteSwapInput, z as SwapInput, D as OrderReference, F as OrderStatusResult, G as WaitForOrderInput, H as SwapHistoryAuthProofRaw, N as NearTransaction, I as SwapMcaRelayerRequestRaw } from './shared-D_BnU1oa.js';
|
|
2
|
+
export { ae as BuildContext, _ as ChainExecutionResult, aa as DepositInfo, a5 as EvmApproval, a6 as EvmSigningRequest, a4 as EvmTx, $ as ExecutionContext, a1 as ExecutorIdentityProvider, a2 as ExecutorMessageSigner, a0 as MessageSignOptions, Y as OrderStatus, ad as RouteSummary, X as SignRequestPreview, a7 as SolanaMetadata, J as SwapApiResponse, K as SwapApiTokenMetaRaw, R as SwapBuildApproveRaw, ac as SwapExecution, U as SwapHistoryWalletChainFamilyRaw, M as SwapMcaSignerPayloadRaw, ab as SwapReportContext, P as SwapSigningRequestRaw, L as SwapTokenListRowRaw, V as SwapWarning, T as TransactionConfirmation, a9 as TronApproval, a8 as TronUnsignedTransaction, a3 as assertBaseUnitAmount, Z as normalizeOrderStatus } from './shared-D_BnU1oa.js';
|
|
3
3
|
|
|
4
4
|
type SwapErrorCode = "HTTP_ERROR" | "API_ERROR" | "RATE_LIMITED" | "AUTH_FAILED" | "REQUEST_ABORTED" | "REQUEST_TIMEOUT" | "INVALID_REQUEST" | "INVALID_API_RESPONSE" | "QUOTE_EXPIRED" | "ROUTE_NOT_FOUND" | "EXECUTOR_NOT_FOUND" | "UNSUPPORTED_CHAIN" | "CHAIN_MISMATCH" | "INVALID_TRANSACTION" | "USER_REJECTED" | "INSUFFICIENT_BALANCE" | "APPROVAL_FAILED" | "SIGNING_FAILED" | "BROADCAST_FAILED" | "ORDER_SUBMIT_FAILED" | "ORDER_TIMEOUT" | "REPORT_FAILED";
|
|
5
5
|
type SwapErrorStage = "quote" | "build" | "approve" | "sign" | "broadcast" | "submit" | "report" | "status" | "tokens" | "history";
|
package/dist/index.js
CHANGED
|
@@ -922,6 +922,10 @@ function normalizeTronExecution(raw, chain) {
|
|
|
922
922
|
}
|
|
923
923
|
function isTronRawDataTx(value) {
|
|
924
924
|
if (typeof value !== "object" || value === null) return false;
|
|
925
|
+
const kind = Reflect.get(value, "kind");
|
|
926
|
+
if (typeof kind === "string" && kind.toLowerCase() === "tron_contract") {
|
|
927
|
+
return true;
|
|
928
|
+
}
|
|
925
929
|
const format = Reflect.get(value, "format");
|
|
926
930
|
if (typeof format === "string" && format.toLowerCase() === "tron-raw-data") {
|
|
927
931
|
return true;
|
|
@@ -1138,6 +1142,7 @@ function serializeQuoteRequest(request) {
|
|
|
1138
1142
|
quoteWaitingTimeMs: request.quoteWaitingTimeMs ?? DEFAULT_QUOTE_WAITING_TIME_MS,
|
|
1139
1143
|
sameChainTimeoutMs: request.sameChainTimeoutMs ?? DEFAULT_SAME_CHAIN_TIMEOUT_MS,
|
|
1140
1144
|
crossChainTimeoutMs: request.crossChainTimeoutMs ?? DEFAULT_CROSS_CHAIN_TIMEOUT_MS,
|
|
1145
|
+
...request.excludeDexs !== void 0 ? { excludeDexs: [...request.excludeDexs] } : {},
|
|
1141
1146
|
...request.confidentiality ? { confidentiality: request.confidentiality } : {},
|
|
1142
1147
|
sender: request.sender.trim(),
|
|
1143
1148
|
...request.recipient?.trim() ? { recipient: request.recipient.trim() } : {}
|
|
@@ -2594,18 +2599,63 @@ var SwapClient = class {
|
|
|
2594
2599
|
if (input.onEvent !== this.config.onEvent) input.onEvent?.(event);
|
|
2595
2600
|
};
|
|
2596
2601
|
try {
|
|
2602
|
+
let activeBuild = build;
|
|
2597
2603
|
const executor = this.registry.get(build.execution.kind);
|
|
2604
|
+
if (build.execution.kind === "tron-transaction" && build.execution.approval && !build.request) {
|
|
2605
|
+
throw new SwapSdkError(
|
|
2606
|
+
"INVALID_REQUEST",
|
|
2607
|
+
"sign",
|
|
2608
|
+
"Tron approval builds require the original build request to rebuild after approval"
|
|
2609
|
+
);
|
|
2610
|
+
}
|
|
2611
|
+
const needsTronRebuild = build.execution.kind === "tron-transaction" && Boolean(build.execution.approval) && Boolean(build.request);
|
|
2598
2612
|
const context = {
|
|
2599
2613
|
executionId: build.executionId,
|
|
2600
2614
|
signal: input.signal,
|
|
2601
2615
|
waitFor: input.waitFor ?? "submitted",
|
|
2602
2616
|
emit,
|
|
2603
|
-
...input.beforeSign ? { beforeSign: input.beforeSign } : {}
|
|
2617
|
+
...input.beforeSign ? { beforeSign: input.beforeSign } : {},
|
|
2618
|
+
...needsTronRebuild ? {
|
|
2619
|
+
refreshTronExecution: async () => {
|
|
2620
|
+
const request = build.request;
|
|
2621
|
+
if (!request) {
|
|
2622
|
+
throw new SwapSdkError(
|
|
2623
|
+
"INVALID_REQUEST",
|
|
2624
|
+
"build",
|
|
2625
|
+
"Missing build request to rebuild Tron swap after approval"
|
|
2626
|
+
);
|
|
2627
|
+
}
|
|
2628
|
+
const raw = await this.api.build(request, {
|
|
2629
|
+
signal: input.signal
|
|
2630
|
+
});
|
|
2631
|
+
const refreshed = normalizeBuild(
|
|
2632
|
+
raw,
|
|
2633
|
+
build.executionId,
|
|
2634
|
+
request
|
|
2635
|
+
);
|
|
2636
|
+
if (refreshed.execution.kind !== "tron-transaction") {
|
|
2637
|
+
throw new SwapSdkError(
|
|
2638
|
+
"INVALID_API_RESPONSE",
|
|
2639
|
+
"build",
|
|
2640
|
+
"Rebuilt Tron swap must return a tron-transaction execution"
|
|
2641
|
+
);
|
|
2642
|
+
}
|
|
2643
|
+
if (refreshed.execution.approval) {
|
|
2644
|
+
throw new SwapSdkError(
|
|
2645
|
+
"INVALID_API_RESPONSE",
|
|
2646
|
+
"build",
|
|
2647
|
+
"Tron approval is still required after rebuild"
|
|
2648
|
+
);
|
|
2649
|
+
}
|
|
2650
|
+
activeBuild = refreshed;
|
|
2651
|
+
return refreshed.execution;
|
|
2652
|
+
}
|
|
2653
|
+
} : {}
|
|
2604
2654
|
};
|
|
2605
2655
|
await executor.validate(build.execution, context);
|
|
2606
2656
|
emit({ type: "signing-requested", executionId: build.executionId });
|
|
2607
2657
|
const chainResult = await executor.execute(build.execution, context);
|
|
2608
|
-
let orderId = chainResult.orderId ??
|
|
2658
|
+
let orderId = chainResult.orderId ?? activeBuild.order?.orderId;
|
|
2609
2659
|
if (chainResult.signature) {
|
|
2610
2660
|
if (build.execution.kind !== "evm-signature") {
|
|
2611
2661
|
throw new SwapSdkError(
|
|
@@ -2630,33 +2680,33 @@ var SwapClient = class {
|
|
|
2630
2680
|
orderId = submitted.orderId;
|
|
2631
2681
|
}
|
|
2632
2682
|
const result = {
|
|
2633
|
-
executionId:
|
|
2683
|
+
executionId: activeBuild.executionId,
|
|
2634
2684
|
status: chainResult.status,
|
|
2635
|
-
router:
|
|
2685
|
+
router: activeBuild.router,
|
|
2636
2686
|
...chainResult.txHash ? { txHash: chainResult.txHash } : {},
|
|
2637
2687
|
...chainResult.txHashes ? { txHashes: chainResult.txHashes } : {},
|
|
2638
2688
|
...orderId ? { orderId } : {},
|
|
2639
|
-
...
|
|
2689
|
+
...activeBuild.deposit?.depositAddress ? { depositAddress: activeBuild.deposit.depositAddress } : {},
|
|
2640
2690
|
report: { status: "skipped" },
|
|
2641
|
-
raw: chainResult.raw ??
|
|
2691
|
+
raw: chainResult.raw ?? activeBuild.raw
|
|
2642
2692
|
};
|
|
2643
2693
|
emit({
|
|
2644
2694
|
type: "submitted",
|
|
2645
|
-
executionId:
|
|
2695
|
+
executionId: activeBuild.executionId,
|
|
2646
2696
|
...chainResult.txHash ? { txHash: chainResult.txHash } : {},
|
|
2647
2697
|
...orderId ? { orderId } : {}
|
|
2648
2698
|
});
|
|
2649
2699
|
if (chainResult.status === "source-confirmed") {
|
|
2650
2700
|
emit({
|
|
2651
2701
|
type: "source-confirmed",
|
|
2652
|
-
executionId:
|
|
2702
|
+
executionId: activeBuild.executionId
|
|
2653
2703
|
});
|
|
2654
2704
|
}
|
|
2655
2705
|
const waitMode = input.waitFor ?? "submitted";
|
|
2656
|
-
const requiresTrackedStatus =
|
|
2657
|
-
const reportRequest = this.createReportRequest(
|
|
2706
|
+
const requiresTrackedStatus = activeBuild.isCrossChain || activeBuild.request?.confidentiality === "basic";
|
|
2707
|
+
const reportRequest = this.createReportRequest(activeBuild, result);
|
|
2658
2708
|
if (reportRequest) {
|
|
2659
|
-
this.reportRequests.set(
|
|
2709
|
+
this.reportRequests.set(activeBuild.executionId, reportRequest);
|
|
2660
2710
|
}
|
|
2661
2711
|
const mustReportForStatus = requiresTrackedStatus && waitMode !== "submitted" && Boolean(reportRequest);
|
|
2662
2712
|
const shouldReportNow = Boolean(reportRequest) && this.reportMode !== "disabled" && (this.reportMode === "auto" || mustReportForStatus);
|
|
@@ -2679,18 +2729,22 @@ var SwapClient = class {
|
|
|
2679
2729
|
cause: error
|
|
2680
2730
|
};
|
|
2681
2731
|
result.report = { status: "failed", warning };
|
|
2682
|
-
emit({
|
|
2732
|
+
emit({
|
|
2733
|
+
type: "warning",
|
|
2734
|
+
executionId: activeBuild.executionId,
|
|
2735
|
+
warning
|
|
2736
|
+
});
|
|
2683
2737
|
}
|
|
2684
2738
|
}
|
|
2685
2739
|
const shouldPollOrderStatus = shouldPollSwapOrderStatus({
|
|
2686
2740
|
waitFor: waitMode,
|
|
2687
|
-
isCrossChain:
|
|
2688
|
-
confidentiality:
|
|
2741
|
+
isCrossChain: activeBuild.isCrossChain,
|
|
2742
|
+
confidentiality: activeBuild.request?.confidentiality,
|
|
2689
2743
|
reportRecordId
|
|
2690
2744
|
});
|
|
2691
2745
|
const statusLookup = resolveOrderStatusLookup({
|
|
2692
2746
|
recordId: reportRecordId ?? result.report?.recordId,
|
|
2693
|
-
router:
|
|
2747
|
+
router: activeBuild.order?.router ?? activeBuild.router
|
|
2694
2748
|
});
|
|
2695
2749
|
if (shouldPollOrderStatus && !statusLookup) {
|
|
2696
2750
|
throw new SwapSdkError(
|
|
@@ -2699,8 +2753,8 @@ var SwapClient = class {
|
|
|
2699
2753
|
"Swap submitted, but the report response did not include an id to query",
|
|
2700
2754
|
{
|
|
2701
2755
|
details: {
|
|
2702
|
-
executionId:
|
|
2703
|
-
router:
|
|
2756
|
+
executionId: activeBuild.executionId,
|
|
2757
|
+
router: activeBuild.router
|
|
2704
2758
|
}
|
|
2705
2759
|
}
|
|
2706
2760
|
);
|