0xtrails 0.2.6 → 0.4.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/dist/aave.d.ts +2 -0
- package/dist/aave.d.ts.map +1 -1
- package/dist/{ccip-Xjh9d1gb.js → ccip-BpQGQiWq.js} +7 -7
- package/dist/config.d.ts +0 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/error.d.ts +4 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/fees.d.ts +2 -2
- package/dist/fees.d.ts.map +1 -1
- package/dist/{index-BnhdZ8Ho.js → index-DsJM5F-V.js} +46084 -48697
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +741 -923
- package/dist/intentReceiptMonitor.d.ts +24 -0
- package/dist/intentReceiptMonitor.d.ts.map +1 -0
- package/dist/intentReceiptPoller.d.ts +69 -0
- package/dist/intentReceiptPoller.d.ts.map +1 -0
- package/dist/intents.d.ts +15 -11
- package/dist/intents.d.ts.map +1 -1
- package/dist/morpho.d.ts +6 -5
- package/dist/morpho.d.ts.map +1 -1
- package/dist/mutations.d.ts +16 -0
- package/dist/mutations.d.ts.map +1 -0
- package/dist/preconditions.d.ts +5 -4
- package/dist/preconditions.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +5 -190
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +9 -6
- package/dist/prices.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +3 -16
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts +17 -13
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/trails.d.ts +24 -40
- package/dist/trails.d.ts.map +1 -1
- package/dist/trailsClient.d.ts +5 -6
- package/dist/trailsClient.d.ts.map +1 -1
- package/dist/transactionIntent/constants.d.ts +7 -0
- package/dist/transactionIntent/constants.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +44 -0
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +30 -0
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/index.d.ts +4 -0
- package/dist/transactionIntent/deposits/index.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +30 -0
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -0
- package/dist/transactionIntent/execution/index.d.ts +2 -0
- package/dist/transactionIntent/execution/index.d.ts.map +1 -0
- package/dist/transactionIntent/execution/transactionState.d.ts +5 -0
- package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/crossChain.d.ts +82 -0
- package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/index.d.ts +4 -0
- package/dist/transactionIntent/handlers/index.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts +62 -0
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +72 -0
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -0
- package/dist/transactionIntent/index.d.ts +9 -0
- package/dist/transactionIntent/index.d.ts.map +1 -0
- package/dist/transactionIntent/quote/feeExtractors.d.ts +17 -0
- package/dist/transactionIntent/quote/feeExtractors.d.ts.map +1 -0
- package/dist/transactionIntent/quote/index.d.ts +4 -0
- package/dist/transactionIntent/quote/index.d.ts.map +1 -0
- package/dist/transactionIntent/quote/normalizeQuote.d.ts +34 -0
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -0
- package/dist/transactionIntent/quote/quoteHelpers.d.ts +5 -0
- package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/types.d.ts +131 -0
- package/dist/transactionIntent/types.d.ts.map +1 -0
- package/dist/transactionIntent/utils/balanceChecker.d.ts +18 -0
- package/dist/transactionIntent/utils/balanceChecker.d.ts.map +1 -0
- package/dist/transactionIntent/utils/index.d.ts +4 -0
- package/dist/transactionIntent/utils/index.d.ts.map +1 -0
- package/dist/transactionIntent/utils/lifiHelpers.d.ts +10 -0
- package/dist/transactionIntent/utils/lifiHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/utils/testnetHelpers.d.ts +3 -0
- package/dist/transactionIntent/utils/testnetHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/validators.d.ts +6 -0
- package/dist/transactionIntent/validators.d.ts.map +1 -0
- package/dist/transactions.d.ts +2 -1
- package/dist/transactions.d.ts.map +1 -1
- package/dist/widget/components/AccountSettings.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +0 -1
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/DynamicSizeInputField.d.ts +13 -0
- package/dist/widget/components/DynamicSizeInputField.d.ts.map +1 -0
- package/dist/widget/components/Earn.d.ts +0 -1
- package/dist/widget/components/Earn.d.ts.map +1 -1
- package/dist/widget/components/FeeOptions.d.ts +5 -13
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +0 -1
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/FundSwap.d.ts +0 -1
- package/dist/widget/components/FundSwap.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts +0 -1
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts +0 -1
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts +0 -18
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts +1 -0
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +0 -1
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +2 -2
- package/dist/widget/hooks/useCheckout.d.ts +17 -4
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +3 -4
- package/dist/widget/hooks/useQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFeeToken.d.ts +1 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +3 -4
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/hooks/useWalletConnectionContext.d.ts +25 -0
- package/dist/widget/hooks/useWalletConnectionContext.d.ts.map +1 -0
- package/dist/widget/index.js +1 -1
- package/dist/widget/widget.d.ts +12 -7
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +21 -23
- package/src/aave.ts +54 -1
- package/src/config.ts +57 -58
- package/src/constants.ts +8 -9
- package/src/error.ts +21 -3
- package/src/fees.ts +53 -42
- package/src/index.ts +35 -13
- package/src/intentReceiptMonitor.ts +102 -0
- package/src/intentReceiptPoller.ts +299 -0
- package/src/intents.ts +206 -172
- package/src/morpho.ts +58 -9
- package/src/mutations.ts +129 -0
- package/src/preconditions.ts +16 -21
- package/src/prepareSend.ts +80 -4514
- package/src/prices.ts +26 -22
- package/src/relaySdk.ts +2 -2
- package/src/sequenceWallet.ts +6 -73
- package/src/tokenBalances.ts +175 -69
- package/src/trails.ts +230 -722
- package/src/trailsClient.ts +10 -23
- package/src/transactionIntent/constants.ts +11 -0
- package/src/transactionIntent/deposits/depositOrchestrator.ts +210 -0
- package/src/transactionIntent/deposits/gaslessDeposit.ts +588 -0
- package/src/transactionIntent/deposits/index.ts +3 -0
- package/src/transactionIntent/deposits/standardDeposit.ts +379 -0
- package/src/transactionIntent/execution/index.ts +1 -0
- package/src/transactionIntent/execution/transactionState.ts +35 -0
- package/src/transactionIntent/handlers/crossChain.ts +1707 -0
- package/src/transactionIntent/handlers/index.ts +3 -0
- package/src/transactionIntent/handlers/sameChainDifferentToken.ts +323 -0
- package/src/transactionIntent/handlers/sameChainSameToken.ts +712 -0
- package/src/transactionIntent/index.ts +9 -0
- package/src/transactionIntent/quote/feeExtractors.ts +81 -0
- package/src/transactionIntent/quote/index.ts +3 -0
- package/src/transactionIntent/quote/normalizeQuote.ts +367 -0
- package/src/transactionIntent/quote/quoteHelpers.ts +53 -0
- package/src/transactionIntent/types.ts +157 -0
- package/src/transactionIntent/utils/balanceChecker.ts +96 -0
- package/src/transactionIntent/utils/index.ts +3 -0
- package/src/transactionIntent/utils/lifiHelpers.ts +68 -0
- package/src/transactionIntent/utils/testnetHelpers.ts +10 -0
- package/src/transactionIntent/validators.ts +57 -0
- package/src/transactions.ts +36 -53
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountIntentTransactionHistory.tsx +36 -36
- package/src/widget/components/AccountSettings.tsx +23 -6
- package/src/widget/components/ClassicSwap.tsx +28 -53
- package/src/widget/components/ConfigDisplay.tsx +0 -11
- package/src/widget/components/ConnectedWallets.tsx +30 -4
- package/src/widget/components/DynamicSizeInputField.tsx +109 -0
- package/src/widget/components/Earn.tsx +0 -16
- package/src/widget/components/FeeBreakdown.tsx +3 -3
- package/src/widget/components/FeeOption.tsx +2 -2
- package/src/widget/components/FeeOptions.tsx +151 -112
- package/src/widget/components/Fund.tsx +0 -3
- package/src/widget/components/FundMethods.tsx +4 -3
- package/src/widget/components/FundSwap.tsx +0 -1
- package/src/widget/components/Pay.tsx +11 -16
- package/src/widget/components/PoolDeposit.tsx +35 -32
- package/src/widget/components/PoolWithdraw.tsx +153 -256
- package/src/widget/components/QuoteDetails.tsx +899 -494
- package/src/widget/components/Swap.tsx +0 -1
- package/src/widget/components/TransferPendingVertical.tsx +12 -8
- package/src/widget/components/WaasFeeOptions.tsx +23 -7
- package/src/widget/components/WalletConfirmation.tsx +1 -1
- package/src/widget/hooks/useAmountUsd.ts +9 -9
- package/src/widget/hooks/useCheckout.ts +97 -9
- package/src/widget/hooks/useDefaultTokenSelection.tsx +27 -21
- package/src/widget/hooks/useQuote.ts +86 -33
- package/src/widget/hooks/useSelectedFeeToken.tsx +32 -37
- package/src/widget/hooks/useSendForm.ts +37 -47
- package/src/widget/hooks/useTokenList.ts +34 -26
- package/src/widget/hooks/useWalletConnectionContext.tsx +128 -0
- package/src/widget/widget.tsx +197 -207
- package/dist/apiClient.d.ts +0 -9
- package/dist/apiClient.d.ts.map +0 -1
- package/dist/intentEntrypoint.d.ts +0 -114
- package/dist/intentEntrypoint.d.ts.map +0 -1
- package/dist/metaTxnMonitor.d.ts +0 -15
- package/dist/metaTxnMonitor.d.ts.map +0 -1
- package/dist/metaTxns.d.ts +0 -11
- package/dist/metaTxns.d.ts.map +0 -1
- package/dist/relayer.d.ts +0 -43
- package/dist/relayer.d.ts.map +0 -1
- package/src/apiClient.ts +0 -35
- package/src/intentEntrypoint.ts +0 -203
- package/src/metaTxnMonitor.ts +0 -171
- package/src/metaTxns.ts +0 -45
- package/src/relayer.ts +0 -289
package/dist/index.js
CHANGED
|
@@ -1,185 +1,325 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
import {
|
|
3
|
-
import { useQuery as
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { zeroAddress as
|
|
6
|
-
import { useSwitchChain as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { l as t, u as pe, t as Cn, a as Sn, b as wn, g as Ee, c as kn, d as yn, e as En, f as be, h as bn, T as xn, p as Pn, i as Me, j as Rn, k as ye, m as He, n as Un, o as te, q as De, r as qn, s as On, v as Mn, w as Fe } from "./index-DsJM5F-V.js";
|
|
2
|
+
import { I as Yn, W as Zn, ae as et, ag as nt, U as tt, C as st, af as it, X as ot, K as rt, G as at, A as ct, ab as lt, L as dt, M as ut, B as gt, F as mt, x as ft, ac as It, $ as ht, _ as pt, a4 as vt, Y as Tt, a9 as At, y as Ct, R as St, Z as wt, ad as kt, V as yt, a7 as Et, E as bt, D as xt, aa as Pt, a5 as Rt, a2 as Ut, a3 as qt, a0 as Ot, a8 as Mt, a1 as Ht, a6 as Dt, N as Ft, H as Lt, O as Bt, P as Nt, J as $t, z as Gt, Q as Qt, S as jt } from "./index-DsJM5F-V.js";
|
|
3
|
+
import { useQuery as xe, useMutation as Ie } from "@tanstack/react-query";
|
|
4
|
+
import { useRef as Hn, useState as l, useCallback as Le, useEffect as b } from "react";
|
|
5
|
+
import { zeroAddress as he, isAddressEqual as ce, isAddress as Dn, ethAddress as Fn, createWalletClient as Be, custom as Ne } from "viem";
|
|
6
|
+
import { useSwitchChain as Ln, useSendTransaction as Bn, useEstimateGas as Nn, useWaitForTransactionReceipt as $n } from "wagmi";
|
|
7
|
+
const $e = 150, Gn = (u, i) => {
|
|
8
|
+
const r = xe({
|
|
9
|
+
queryKey: ["waitIntentReceipt", u],
|
|
10
|
+
queryFn: async () => {
|
|
11
|
+
if (!u)
|
|
12
|
+
throw new Error("Intent ID is required for monitoring");
|
|
13
|
+
t.console.log(
|
|
14
|
+
`[trails-sdk] 🔍 Monitoring intent receipt for ${u}`
|
|
15
|
+
);
|
|
16
|
+
const o = await i.waitIntentReceipt({
|
|
17
|
+
intentId: u
|
|
18
|
+
});
|
|
19
|
+
return t.console.log(
|
|
20
|
+
`[trails-sdk] 📊 Intent ${u} status: ${o.intentReceipt.status}, done: ${o.done}`
|
|
21
|
+
), o;
|
|
22
|
+
},
|
|
23
|
+
enabled: !!u,
|
|
24
|
+
refetchIntervalInBackground: !0,
|
|
25
|
+
refetchInterval: (o) => {
|
|
26
|
+
const a = o.state.data;
|
|
27
|
+
return a && a.done ? (t.console.log(
|
|
28
|
+
`[trails-sdk] ✅ Intent monitoring complete for ${u}`
|
|
29
|
+
), !1) : $e;
|
|
30
|
+
},
|
|
31
|
+
retry: (o, a) => o >= 30 ? (t.console.error(
|
|
32
|
+
`[trails-sdk] ❌ Giving up on intent ${u} after 30 failed API attempts:`,
|
|
33
|
+
a
|
|
34
|
+
), !1) : !0
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
intentReceipt: r.data?.intentReceipt ?? null,
|
|
38
|
+
done: r.data?.done ?? !1,
|
|
39
|
+
isLoading: r.isLoading,
|
|
40
|
+
isError: r.isError,
|
|
41
|
+
error: r.error
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
function Ge() {
|
|
45
|
+
const u = pe();
|
|
46
|
+
return Ie({
|
|
47
|
+
mutationFn: async (i) => {
|
|
48
|
+
t.console.log("[trails-sdk] useCommitIntent: Starting commit", {
|
|
49
|
+
intentId: i.intentId,
|
|
50
|
+
originIntentAddress: i.originIntentAddress
|
|
51
|
+
});
|
|
52
|
+
const r = i.calls[0]?.chainId, o = i.calls[1]?.chainId;
|
|
53
|
+
try {
|
|
54
|
+
Cn({
|
|
55
|
+
intentAddress: i.originIntentAddress,
|
|
56
|
+
userAddress: i.ownerAddress,
|
|
57
|
+
originChainId: r ? Number(r) : void 0,
|
|
58
|
+
destinationChainId: o ? Number(o) : void 0
|
|
59
|
+
});
|
|
60
|
+
const a = await u.commitIntent({ intent: i });
|
|
61
|
+
return t.console.log("[trails-sdk] useCommitIntent: Commit successful", {
|
|
62
|
+
intentId: i.intentId,
|
|
63
|
+
response: a
|
|
64
|
+
}), Sn({
|
|
65
|
+
intentAddress: i.originIntentAddress,
|
|
66
|
+
userAddress: i.ownerAddress,
|
|
67
|
+
originChainId: r ? Number(r) : void 0,
|
|
68
|
+
destinationChainId: o ? Number(o) : void 0
|
|
69
|
+
}), a;
|
|
70
|
+
} catch (a) {
|
|
71
|
+
throw wn({
|
|
72
|
+
error: Ee(a),
|
|
73
|
+
userAddress: i.ownerAddress,
|
|
74
|
+
intentAddress: i.originIntentAddress,
|
|
75
|
+
originChainId: r ? Number(r) : void 0,
|
|
76
|
+
destinationChainId: o ? Number(o) : void 0
|
|
77
|
+
}), a;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function Qe() {
|
|
83
|
+
const u = pe();
|
|
84
|
+
return Ie({
|
|
85
|
+
mutationFn: async ({
|
|
86
|
+
intentId: i,
|
|
87
|
+
depositTransactionHash: r,
|
|
88
|
+
depositSignature: o
|
|
89
|
+
}) => {
|
|
90
|
+
if (t.console.log("[trails-sdk] useExecuteIntent: Starting execution", {
|
|
91
|
+
intentId: i,
|
|
92
|
+
depositTransactionHash: r,
|
|
93
|
+
hasDepositSignature: !!o
|
|
94
|
+
}), !r && !o)
|
|
95
|
+
throw new Error(
|
|
96
|
+
"[trails-sdk] Either depositTransactionHash or depositSignature must be provided"
|
|
97
|
+
);
|
|
98
|
+
const a = await u.executeIntent({
|
|
99
|
+
intentId: i,
|
|
100
|
+
depositTransactionHash: r,
|
|
101
|
+
depositSignature: o
|
|
102
|
+
});
|
|
103
|
+
return t.console.log(
|
|
104
|
+
"[trails-sdk] useExecuteIntent: Execution successful",
|
|
105
|
+
{
|
|
106
|
+
intentId: i,
|
|
107
|
+
response: a
|
|
108
|
+
}
|
|
109
|
+
), a;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function Kn({
|
|
114
|
+
walletClient: u,
|
|
115
|
+
fromTokenAddress: i,
|
|
116
|
+
fromChainId: r,
|
|
117
|
+
toTokenAddress: o,
|
|
118
|
+
toChainId: a,
|
|
119
|
+
swapAmount: x,
|
|
120
|
+
tradeType: X,
|
|
121
|
+
toRecipient: L,
|
|
122
|
+
toCalldata: Q,
|
|
123
|
+
slippageTolerance: le,
|
|
124
|
+
onStatusUpdate: j,
|
|
125
|
+
quoteProvider: P,
|
|
126
|
+
paymasterUrl: W,
|
|
127
|
+
selectedFeeToken: R,
|
|
128
|
+
nodeGatewayEnv: k,
|
|
129
|
+
abortSignal: U
|
|
26
130
|
} = {}) {
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
}),
|
|
33
|
-
|
|
34
|
-
}),
|
|
35
|
-
})() :
|
|
36
|
-
env: N || $n()
|
|
37
|
-
}), U = On(), { supportedTokens: fe } = Rn(), { data: B, isLoading: L, error: Y, refetch: Se } = nn({
|
|
131
|
+
k && (globalThis.__testNodeGatewayEnv = k);
|
|
132
|
+
const A = Hn(new AbortController()), V = U ? (() => {
|
|
133
|
+
const p = new AbortController();
|
|
134
|
+
return U.addEventListener("abort", () => {
|
|
135
|
+
p.abort(), A.current?.abort();
|
|
136
|
+
}), A.current?.signal.addEventListener("abort", () => {
|
|
137
|
+
p.abort();
|
|
138
|
+
}), p.signal;
|
|
139
|
+
})() : A.current.signal, q = pe(), se = kn(), { supportedTokens: g } = yn(), ie = Ge(), h = Qe(), { data: B, isLoading: ve, error: N, refetch: $ } = xe({
|
|
38
140
|
queryKey: [
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
141
|
+
"prepareSend",
|
|
142
|
+
i,
|
|
143
|
+
r,
|
|
144
|
+
o,
|
|
145
|
+
a,
|
|
146
|
+
x?.toString(),
|
|
147
|
+
L,
|
|
148
|
+
Q,
|
|
149
|
+
X,
|
|
150
|
+
le,
|
|
151
|
+
P
|
|
50
152
|
],
|
|
51
153
|
queryFn: async () => {
|
|
52
154
|
try {
|
|
53
|
-
if (
|
|
155
|
+
if (A.current.signal.aborted && (t.console.log(
|
|
54
156
|
"[trails-sdk] Resetting aborted controller for new query"
|
|
55
|
-
),
|
|
157
|
+
), A.current = new AbortController()), !u || !q || !i || !o || !x || !L || !r || !a || !se)
|
|
56
158
|
return null;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
159
|
+
let p = [];
|
|
160
|
+
try {
|
|
161
|
+
p = (await En({
|
|
162
|
+
account: u.account.address,
|
|
163
|
+
indexerGatewayClient: se,
|
|
164
|
+
trailsClient: q
|
|
165
|
+
})).balances;
|
|
166
|
+
} catch (d) {
|
|
167
|
+
const f = Ee(d), v = f.includes("Cross-Origin") || f.includes("CORS") || f.includes("Same Origin Policy"), H = f.includes("fetch failed") || f.includes("network");
|
|
168
|
+
if (v || H)
|
|
169
|
+
t.console.warn(
|
|
170
|
+
"[trails-sdk] [useQuote] Network or CORS error fetching balances, proceeding with quote using zero balance:",
|
|
171
|
+
{
|
|
172
|
+
error: f,
|
|
173
|
+
account: u.account.address
|
|
174
|
+
}
|
|
175
|
+
), p = [];
|
|
176
|
+
else
|
|
177
|
+
throw d;
|
|
178
|
+
}
|
|
179
|
+
const _ = p.find(
|
|
180
|
+
(d) => d.chainId === r && (d.contractAddress?.toLowerCase() === i.toLowerCase() || !d.contractAddress && i === he)
|
|
181
|
+
)?.balance ?? "0";
|
|
182
|
+
let s = 0;
|
|
183
|
+
try {
|
|
184
|
+
const f = be(r)?.nativeCurrency?.symbol ?? "";
|
|
185
|
+
f && (s = (await bn(q, {
|
|
186
|
+
tokenSymbol: f,
|
|
187
|
+
tokenAddress: he,
|
|
188
|
+
chainId: r
|
|
189
|
+
}))?.priceUsd ?? 0, t.console.log(
|
|
190
|
+
"[trails-sdk] [useQuote] Origin native token price:",
|
|
191
|
+
{
|
|
192
|
+
chainId: r,
|
|
193
|
+
symbol: f,
|
|
194
|
+
priceUsd: s
|
|
195
|
+
}
|
|
196
|
+
));
|
|
197
|
+
} catch (d) {
|
|
198
|
+
t.console.error(
|
|
199
|
+
"[trails-sdk] [useQuote] Error getting origin native token price:",
|
|
200
|
+
d
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
const O = g?.find(
|
|
204
|
+
(d) => d.contractAddress?.toLowerCase() === i?.toLowerCase() && d.chainId === r
|
|
205
|
+
), oe = g?.find(
|
|
206
|
+
(d) => d.contractAddress?.toLowerCase() === o?.toLowerCase() && d.chainId === a
|
|
207
|
+
), de = O?.decimals;
|
|
208
|
+
if (!de)
|
|
69
209
|
throw t.console.error(
|
|
70
210
|
"[trails-sdk] [useQuote] Missing source token decimals:",
|
|
71
211
|
{
|
|
72
|
-
originToken:
|
|
73
|
-
fromTokenAddress:
|
|
74
|
-
fromChainId:
|
|
212
|
+
originToken: O,
|
|
213
|
+
fromTokenAddress: i,
|
|
214
|
+
fromChainId: r
|
|
75
215
|
}
|
|
76
216
|
), new Error("Source token decimals not found");
|
|
77
|
-
const
|
|
78
|
-
if (!
|
|
217
|
+
const K = oe?.decimals;
|
|
218
|
+
if (!K)
|
|
79
219
|
throw t.console.error(
|
|
80
220
|
"[trails-sdk] Missing destination token decimals:",
|
|
81
221
|
{
|
|
82
|
-
destinationToken:
|
|
83
|
-
toTokenAddress:
|
|
84
|
-
toChainId:
|
|
222
|
+
destinationToken: oe,
|
|
223
|
+
toTokenAddress: o,
|
|
224
|
+
toChainId: a
|
|
85
225
|
}
|
|
86
226
|
), new Error("Destination token decimals not found");
|
|
87
|
-
const
|
|
88
|
-
account:
|
|
89
|
-
originTokenAddress:
|
|
90
|
-
originChainId:
|
|
91
|
-
originTokenBalance:
|
|
92
|
-
destinationChainId:
|
|
93
|
-
recipient:
|
|
94
|
-
destinationTokenAddress:
|
|
95
|
-
swapAmount:
|
|
96
|
-
tradeType:
|
|
97
|
-
originTokenSymbol:
|
|
98
|
-
destinationTokenSymbol:
|
|
99
|
-
destinationCalldata:
|
|
100
|
-
client:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
destinationRelayer: ye,
|
|
105
|
-
sourceTokenDecimals: re,
|
|
106
|
-
destinationTokenDecimals: Q,
|
|
227
|
+
const J = oe?.symbol ?? "", ue = O?.symbol ?? "", G = {
|
|
228
|
+
account: u.account,
|
|
229
|
+
originTokenAddress: i,
|
|
230
|
+
originChainId: r,
|
|
231
|
+
originTokenBalance: _,
|
|
232
|
+
destinationChainId: a,
|
|
233
|
+
recipient: L,
|
|
234
|
+
destinationTokenAddress: o,
|
|
235
|
+
swapAmount: x.toString(),
|
|
236
|
+
tradeType: X ?? xn.EXACT_OUTPUT,
|
|
237
|
+
originTokenSymbol: ue,
|
|
238
|
+
destinationTokenSymbol: J,
|
|
239
|
+
destinationCalldata: Q,
|
|
240
|
+
client: u,
|
|
241
|
+
trailsClient: q,
|
|
242
|
+
sourceTokenDecimals: de,
|
|
243
|
+
destinationTokenDecimals: K,
|
|
107
244
|
fee: "0",
|
|
108
245
|
dryMode: !1,
|
|
109
|
-
onTransactionStateChange:
|
|
246
|
+
onTransactionStateChange: j ?? (() => {
|
|
110
247
|
}),
|
|
111
|
-
slippageTolerance:
|
|
112
|
-
quoteProvider:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
248
|
+
slippageTolerance: le?.toString(),
|
|
249
|
+
quoteProvider: P,
|
|
250
|
+
paymasterUrl: W,
|
|
251
|
+
selectedFeeToken: R ?? void 0,
|
|
252
|
+
abortSignal: V,
|
|
253
|
+
originNativeTokenPriceUsd: s,
|
|
254
|
+
commitIntentFn: ie.mutateAsync,
|
|
255
|
+
executeIntentFn: h.mutateAsync
|
|
117
256
|
};
|
|
118
|
-
t.console.log("[trails-sdk] options",
|
|
119
|
-
const { quote:
|
|
257
|
+
t.console.log("[trails-sdk] options", G);
|
|
258
|
+
const { quote: c, send: Te } = await Pn(G);
|
|
120
259
|
return {
|
|
121
260
|
quote: {
|
|
122
|
-
fromAmount:
|
|
123
|
-
toAmount:
|
|
124
|
-
fromAmountMin:
|
|
125
|
-
toAmountMin:
|
|
126
|
-
originToken:
|
|
127
|
-
destinationToken:
|
|
128
|
-
originChain:
|
|
129
|
-
destinationChain:
|
|
130
|
-
fees:
|
|
131
|
-
priceImpact:
|
|
132
|
-
completionEstimateSeconds:
|
|
133
|
-
slippageTolerance:
|
|
134
|
-
transactionStates:
|
|
135
|
-
originTokenRate:
|
|
136
|
-
destinationTokenRate:
|
|
137
|
-
quoteProvider:
|
|
138
|
-
fromAmountUsdDisplay:
|
|
139
|
-
toAmountUsdDisplay:
|
|
140
|
-
gasCostUsd:
|
|
141
|
-
gasCostUsdDisplay:
|
|
142
|
-
gasCost:
|
|
143
|
-
gasCostFormatted:
|
|
261
|
+
fromAmount: c.originAmount,
|
|
262
|
+
toAmount: c.destinationAmount,
|
|
263
|
+
fromAmountMin: c.originAmountMin,
|
|
264
|
+
toAmountMin: c.destinationAmountMin,
|
|
265
|
+
originToken: c.originToken,
|
|
266
|
+
destinationToken: c.destinationToken,
|
|
267
|
+
originChain: c.originChain,
|
|
268
|
+
destinationChain: c.destinationChain,
|
|
269
|
+
fees: c.fees,
|
|
270
|
+
priceImpact: c.priceImpact,
|
|
271
|
+
completionEstimateSeconds: c.completionEstimateSeconds,
|
|
272
|
+
slippageTolerance: c.slippageTolerance,
|
|
273
|
+
transactionStates: c.transactionStates,
|
|
274
|
+
originTokenRate: c.originTokenRate,
|
|
275
|
+
destinationTokenRate: c.destinationTokenRate,
|
|
276
|
+
quoteProvider: c.quoteProvider,
|
|
277
|
+
fromAmountUsdDisplay: c.originAmountUsdDisplay ?? void 0,
|
|
278
|
+
toAmountUsdDisplay: c.destinationAmountUsdDisplay ?? void 0,
|
|
279
|
+
gasCostUsd: c.gasCostUsd ?? void 0,
|
|
280
|
+
gasCostUsdDisplay: c.gasCostUsdDisplay ?? void 0,
|
|
281
|
+
gasCost: c.gasCost ?? void 0,
|
|
282
|
+
gasCostFormatted: c.gasCostFormatted ?? void 0
|
|
144
283
|
},
|
|
145
284
|
swap: async () => {
|
|
146
285
|
const {
|
|
147
|
-
|
|
148
|
-
destinationMetaTxnReceipt:
|
|
149
|
-
totalCompletionSeconds:
|
|
150
|
-
} = await
|
|
151
|
-
selectedFeeToken:
|
|
286
|
+
depositUserTxnReceipt: d,
|
|
287
|
+
destinationMetaTxnReceipt: f,
|
|
288
|
+
totalCompletionSeconds: v
|
|
289
|
+
} = await Te({
|
|
290
|
+
selectedFeeToken: R ?? void 0
|
|
152
291
|
});
|
|
153
292
|
return {
|
|
154
293
|
originTransaction: {
|
|
155
|
-
transactionHash:
|
|
156
|
-
explorerUrl:
|
|
157
|
-
txHash:
|
|
158
|
-
chainId:
|
|
294
|
+
transactionHash: d?.transactionHash,
|
|
295
|
+
explorerUrl: Me({
|
|
296
|
+
txHash: d?.transactionHash,
|
|
297
|
+
chainId: r
|
|
159
298
|
}),
|
|
160
|
-
receipt:
|
|
299
|
+
receipt: d
|
|
161
300
|
},
|
|
162
301
|
destinationTransaction: {
|
|
163
|
-
transactionHash:
|
|
164
|
-
explorerUrl:
|
|
165
|
-
txHash:
|
|
166
|
-
chainId:
|
|
302
|
+
transactionHash: f?.txnHash,
|
|
303
|
+
explorerUrl: Me({
|
|
304
|
+
txHash: f?.txnHash,
|
|
305
|
+
chainId: a
|
|
167
306
|
}),
|
|
168
|
-
receipt:
|
|
307
|
+
receipt: f
|
|
169
308
|
},
|
|
170
|
-
totalCompletionSeconds:
|
|
309
|
+
totalCompletionSeconds: v
|
|
171
310
|
};
|
|
172
311
|
}
|
|
173
312
|
};
|
|
174
|
-
} catch (
|
|
313
|
+
} catch (p) {
|
|
175
314
|
throw t.console.error(
|
|
176
315
|
"[trails-sdk] [useQuote] Error getting quote:",
|
|
177
|
-
|
|
178
|
-
),
|
|
316
|
+
p
|
|
317
|
+
), Ee(p);
|
|
179
318
|
}
|
|
180
319
|
},
|
|
181
320
|
// Prevent unnecessary refetching
|
|
182
|
-
enabled: !!(
|
|
321
|
+
enabled: !!(u && q && i && o && x && L && r && a && se && // !isLoadingTokens &&
|
|
322
|
+
g && g.length > 0),
|
|
183
323
|
staleTime: 30 * 1e3,
|
|
184
324
|
// Consider data fresh for 30 seconds
|
|
185
325
|
refetchOnWindowFocus: !1,
|
|
@@ -196,133 +336,112 @@ function tt({
|
|
|
196
336
|
return {
|
|
197
337
|
quote: B?.quote || null,
|
|
198
338
|
swap: B?.swap || null,
|
|
199
|
-
isLoadingQuote:
|
|
200
|
-
quoteError:
|
|
201
|
-
|
|
339
|
+
isLoadingQuote: ve,
|
|
340
|
+
quoteError: N,
|
|
341
|
+
quoteErrorPrettified: Rn(N),
|
|
342
|
+
refetchQuote: () => $(),
|
|
202
343
|
abort: () => {
|
|
203
344
|
t.console.log("[trails-sdk] useQuote abort() called"), t.console.log(
|
|
204
345
|
"[trails-sdk] Active operations before abort:",
|
|
205
|
-
|
|
206
|
-
),
|
|
346
|
+
ye.getAll()
|
|
347
|
+
), A.current.abort(), ye.abortAll(), t.console.log(
|
|
207
348
|
"[trails-sdk] Abort completed, active operations:",
|
|
208
|
-
|
|
349
|
+
ye.getAll()
|
|
209
350
|
);
|
|
210
351
|
}
|
|
211
352
|
};
|
|
212
353
|
}
|
|
213
|
-
|
|
214
|
-
function st(K) {
|
|
354
|
+
function zn(u) {
|
|
215
355
|
const {
|
|
216
|
-
account:
|
|
217
|
-
disableAutoExecute:
|
|
218
|
-
|
|
219
|
-
sequenceProjectAccessKey: P
|
|
220
|
-
} = K, T = Ze({
|
|
221
|
-
projectAccessKey: P
|
|
222
|
-
}), [x, q] = d(!k), [Z, ee] = d(!1), [z, ie] = d(
|
|
356
|
+
account: i,
|
|
357
|
+
disableAutoExecute: r = !1
|
|
358
|
+
} = u, o = pe({}), [a, x] = l(!r), [X, L] = l(!1), [Q, le] = l(
|
|
223
359
|
{}
|
|
224
|
-
), [
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
] =
|
|
360
|
+
), [j, P] = l(null), [W, R] = l(null), [k, U] = l(null), [A, V] = l(null), [q, se] = l(null), [g, ie] = l(), [h, B] = l(null), [
|
|
361
|
+
ve,
|
|
362
|
+
N
|
|
363
|
+
] = l(null), [$, p] = l(
|
|
228
364
|
null
|
|
229
|
-
), [
|
|
230
|
-
switchChain:
|
|
231
|
-
isPending:
|
|
232
|
-
error:
|
|
233
|
-
} =
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
error
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
value: o.value || void 0,
|
|
244
|
-
chainId: o.chainId || void 0
|
|
365
|
+
), [Pe, _] = l(null), [s, O] = l(null), [oe, de] = l({}), [K, J] = l(!1), [ue, G] = l(!1), {
|
|
366
|
+
switchChain: c,
|
|
367
|
+
isPending: Te,
|
|
368
|
+
error: Y
|
|
369
|
+
} = Ln(), M = Bn(), [d, f] = l(!1), [v, H] = l(null), [je, Ae] = l(null), [We, Re] = l({}), [Ve, ge] = l(null), {
|
|
370
|
+
data: me,
|
|
371
|
+
isError: Ce,
|
|
372
|
+
error: Se
|
|
373
|
+
} = Nn(
|
|
374
|
+
s?.to && s?.chainId && !s.error ? {
|
|
375
|
+
to: s.to || void 0,
|
|
376
|
+
data: s.data || void 0,
|
|
377
|
+
value: s.value || void 0,
|
|
378
|
+
chainId: s.chainId || void 0
|
|
245
379
|
} : void 0
|
|
246
|
-
),
|
|
380
|
+
), _e = Ge(), S = Ie({
|
|
247
381
|
mutationFn: async (e) => {
|
|
248
|
-
|
|
249
|
-
"[useTrails]
|
|
382
|
+
t.console.log(
|
|
383
|
+
"[useTrails] commitIntentMutation started with intent:",
|
|
250
384
|
e
|
|
251
|
-
)
|
|
252
|
-
throw t.console.error("[useTrails] API client not available"), new Error("API client not available");
|
|
253
|
-
if (!e.quoteProvider)
|
|
254
|
-
throw t.console.error("[useTrails] quoteProvider is required"), new Error("quoteProvider is required");
|
|
385
|
+
);
|
|
255
386
|
try {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
if (!n || !a)
|
|
387
|
+
const n = T.variables?.originChainId, m = T.variables?.destinationChainId;
|
|
388
|
+
if (!n || !m)
|
|
259
389
|
throw t.console.error(
|
|
260
390
|
"[useTrails] Could not determine origin/destination chain IDs for verification."
|
|
261
391
|
), new Error(
|
|
262
392
|
"Could not determine origin/destination chain IDs for verification."
|
|
263
393
|
);
|
|
264
|
-
|
|
265
|
-
|
|
394
|
+
t.console.log("[useTrails] Calculating intent address..."), t.console.log("[useTrails] Main signer:", e.ownerAddress), t.console.log("[useTrails] Calls:", e.calls);
|
|
395
|
+
const { originIntentAddress: w, destinationIntentAddress: y } = He(
|
|
396
|
+
e.ownerAddress,
|
|
266
397
|
e.calls
|
|
267
398
|
), {
|
|
268
|
-
originAddress:
|
|
269
|
-
destinationAddress:
|
|
270
|
-
} =
|
|
399
|
+
originAddress: ae,
|
|
400
|
+
destinationAddress: z
|
|
401
|
+
} = Un(
|
|
271
402
|
e.preconditions,
|
|
272
403
|
n,
|
|
273
|
-
|
|
404
|
+
m
|
|
274
405
|
);
|
|
275
406
|
t.console.log("[useTrails] Verification addresses:", {
|
|
276
|
-
calculatedOrigin:
|
|
277
|
-
calculatedDestination:
|
|
278
|
-
preconditionOrigin:
|
|
279
|
-
preconditionDestination:
|
|
407
|
+
calculatedOrigin: w.toString(),
|
|
408
|
+
calculatedDestination: y.toString(),
|
|
409
|
+
preconditionOrigin: ae,
|
|
410
|
+
preconditionDestination: z
|
|
280
411
|
});
|
|
281
|
-
const
|
|
282
|
-
ae
|
|
283
|
-
|
|
412
|
+
const E = !!ae && ce(
|
|
413
|
+
te(ae),
|
|
414
|
+
w
|
|
284
415
|
);
|
|
285
|
-
t.console.log("[useTrails] Origin verified:",
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
) || !
|
|
416
|
+
t.console.log("[useTrails] Origin verified:", E);
|
|
417
|
+
const C = z && ce(
|
|
418
|
+
te(z),
|
|
419
|
+
y
|
|
420
|
+
) || !z && n === m && ce(y, he);
|
|
290
421
|
t.console.log(
|
|
291
422
|
"[useTrails] Destination verified:",
|
|
292
|
-
|
|
423
|
+
C
|
|
293
424
|
);
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
success:
|
|
297
|
-
receivedOriginAddress:
|
|
298
|
-
receivedDestinationAddress:
|
|
299
|
-
calculatedOriginAddress:
|
|
300
|
-
calculatedDestinationAddress:
|
|
301
|
-
}), !
|
|
425
|
+
const qe = E && C;
|
|
426
|
+
if (ge({
|
|
427
|
+
success: qe,
|
|
428
|
+
receivedOriginAddress: ae,
|
|
429
|
+
receivedDestinationAddress: z,
|
|
430
|
+
calculatedOriginAddress: w.toString(),
|
|
431
|
+
calculatedDestinationAddress: y.toString()
|
|
432
|
+
}), !qe)
|
|
302
433
|
throw t.console.error("[useTrails] Address verification failed.", {
|
|
303
|
-
isOriginVerified:
|
|
304
|
-
isDestinationVerified:
|
|
434
|
+
isOriginVerified: E,
|
|
435
|
+
isDestinationVerified: C
|
|
305
436
|
}), new Error(
|
|
306
|
-
`Address verification failed. Origin verified: ${
|
|
437
|
+
`Address verification failed. Origin verified: ${E}, Destination verified: ${C}`
|
|
307
438
|
);
|
|
308
|
-
t.console.log("[useTrails] Committing intent
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
calls: e.calls,
|
|
315
|
-
preconditions: e.preconditions,
|
|
316
|
-
addressOverrides: {
|
|
317
|
-
...Qe,
|
|
318
|
-
...e.addressOverrides
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
return t.console.log("[useTrails] API Commit Response:", b), {
|
|
323
|
-
originIntentAddress: m.toString(),
|
|
324
|
-
destinationIntentAddress: s.toString(),
|
|
325
|
-
response: b
|
|
439
|
+
t.console.log("[useTrails] Committing intent to API...");
|
|
440
|
+
const Oe = await _e.mutateAsync(e);
|
|
441
|
+
return t.console.log("[useTrails] API Commit Response:", Oe), {
|
|
442
|
+
originIntentAddress: w.toString(),
|
|
443
|
+
destinationIntentAddress: y.toString(),
|
|
444
|
+
response: Oe
|
|
326
445
|
};
|
|
327
446
|
} catch (n) {
|
|
328
447
|
throw console.error("[useTrails] Error during commit intent mutation:", n), n;
|
|
@@ -335,95 +454,88 @@ function st(K) {
|
|
|
335
454
|
), t.console.log(
|
|
336
455
|
"[useTrails] Setting committedOriginIntentAddress:",
|
|
337
456
|
e.originIntentAddress
|
|
338
|
-
),
|
|
457
|
+
), B(e.originIntentAddress), N(e.destinationIntentAddress);
|
|
339
458
|
},
|
|
340
459
|
onError: (e) => {
|
|
341
|
-
t.console.error("[useTrails] Failed to commit intent config:", e),
|
|
460
|
+
t.console.error("[useTrails] Failed to commit intent config:", e), B(null), N(null);
|
|
342
461
|
}
|
|
343
|
-
}), {
|
|
344
|
-
data:
|
|
345
|
-
isLoading:
|
|
346
|
-
error:
|
|
347
|
-
} =
|
|
348
|
-
queryKey: ["
|
|
462
|
+
}), Z = Qe(), {
|
|
463
|
+
data: Ke,
|
|
464
|
+
isLoading: ze,
|
|
465
|
+
error: Xe
|
|
466
|
+
} = xe({
|
|
467
|
+
queryKey: ["getIntent", h],
|
|
349
468
|
queryFn: async () => {
|
|
350
|
-
if (!
|
|
469
|
+
if (!o || !h)
|
|
351
470
|
throw new Error("API client or committed intent address not available");
|
|
352
471
|
return t.console.log(
|
|
353
472
|
"Fetching intent config for address:",
|
|
354
|
-
|
|
355
|
-
), await
|
|
356
|
-
|
|
357
|
-
});
|
|
473
|
+
h
|
|
474
|
+
), (await o.getIntent({
|
|
475
|
+
intentId: h
|
|
476
|
+
})).intent;
|
|
358
477
|
},
|
|
359
|
-
enabled: !!
|
|
478
|
+
enabled: !!h && !!o && S.isSuccess,
|
|
360
479
|
staleTime: 1e3 * 60 * 5,
|
|
361
480
|
// 5 minutes
|
|
362
481
|
retry: 1
|
|
363
482
|
});
|
|
364
|
-
async function
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
...e.params,
|
|
368
|
-
addressOverrides: {
|
|
369
|
-
...Qe,
|
|
370
|
-
...e.params.addressOverrides
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
});
|
|
483
|
+
async function Je(e) {
|
|
484
|
+
const { intent: n } = await De(o, e);
|
|
485
|
+
return n;
|
|
374
486
|
}
|
|
375
|
-
const
|
|
487
|
+
const T = Ie({
|
|
376
488
|
mutationFn: async (e) => {
|
|
377
|
-
if (e.
|
|
378
|
-
|
|
379
|
-
|
|
489
|
+
if (e.originChainId === e.destinationChainId && ce(
|
|
490
|
+
te(e.originTokenAddress),
|
|
491
|
+
te(e.destinationTokenAddress)
|
|
380
492
|
))
|
|
381
493
|
throw new Error(
|
|
382
494
|
"The same token cannot be used as both the source and destination token."
|
|
383
495
|
);
|
|
384
|
-
if (!
|
|
496
|
+
if (!i.address)
|
|
385
497
|
throw new Error("Missing selected token or account address");
|
|
386
|
-
|
|
387
|
-
const n = await
|
|
388
|
-
return
|
|
498
|
+
B(null), N(null), ge(null), V(null), P(null), R(null), U(null), p(null), _(null);
|
|
499
|
+
const { intent: n } = await De(o, e);
|
|
500
|
+
return P(n.metaTxns), R(n.calls), U(n.preconditions), V(n.fees), p(n.originIntentAddress), _(n.destinationIntentAddress), se(n), B(null), N(null), ge(null), n;
|
|
389
501
|
},
|
|
390
502
|
onSuccess: (e) => {
|
|
391
|
-
t.console.log("Intent Config Success:", e),
|
|
503
|
+
t.console.log("Intent Config Success:", e), V(e.fees || null), p(e.originIntentAddress), _(e.destinationIntentAddress), e?.calls && e.calls.length > 0 && e.preconditions && e.preconditions.length > 0 && e.metaTxns && e.metaTxns.length > 0 ? (R(e.calls), U(e.preconditions), P(e.metaTxns)) : (t.console.warn("API returned success but no operations found."), R(null), U(null), P(null));
|
|
392
504
|
},
|
|
393
505
|
onError: (e) => {
|
|
394
|
-
console.error("Intent Config Error:", e),
|
|
506
|
+
console.error("Intent Config Error:", e), R(null), U(null), P(null), V(null), p(null), _(null);
|
|
395
507
|
}
|
|
396
508
|
});
|
|
397
|
-
function
|
|
398
|
-
|
|
509
|
+
function Ye(e) {
|
|
510
|
+
T.mutate(e);
|
|
399
511
|
}
|
|
400
|
-
const
|
|
401
|
-
t.console.log("[Trails] Clearing intent state"),
|
|
402
|
-
}, []), D =
|
|
403
|
-
(e, n,
|
|
404
|
-
|
|
512
|
+
const Ze = Le(() => {
|
|
513
|
+
t.console.log("[Trails] Clearing intent state"), R(null), U(null), P(null), V(null), B(null), N(null), ge(null), p(null), _(null), de({}), L(!1), Re({});
|
|
514
|
+
}, []), D = Le(
|
|
515
|
+
(e, n, m, w, y) => {
|
|
516
|
+
H({
|
|
405
517
|
txnHash: e,
|
|
406
518
|
status: n === "success" ? "Success" : n === "reverted" ? "Failed" : n === "sending" ? "Sending..." : "Pending",
|
|
407
|
-
revertReason: n === "reverted" ?
|
|
408
|
-
gasUsed:
|
|
409
|
-
effectiveGasPrice:
|
|
519
|
+
revertReason: n === "reverted" ? y || "Transaction reverted" : void 0,
|
|
520
|
+
gasUsed: m ? Number(m) : void 0,
|
|
521
|
+
effectiveGasPrice: w?.toString()
|
|
410
522
|
});
|
|
411
523
|
},
|
|
412
524
|
[]
|
|
413
|
-
),
|
|
525
|
+
), en = async () => {
|
|
414
526
|
if (t.console.log("Sending origin transaction..."), t.console.log(
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
),
|
|
423
|
-
!
|
|
527
|
+
K,
|
|
528
|
+
s,
|
|
529
|
+
s?.error,
|
|
530
|
+
s?.to,
|
|
531
|
+
s?.data,
|
|
532
|
+
s?.value,
|
|
533
|
+
s?.chainId
|
|
534
|
+
), K || // Prevent duplicate transactions
|
|
535
|
+
!s || s.error || !s.to || s.data === null || s.value === null || s.chainId === null) {
|
|
424
536
|
t.console.error(
|
|
425
537
|
"Origin call parameters not available or invalid:",
|
|
426
|
-
|
|
538
|
+
s
|
|
427
539
|
), D(
|
|
428
540
|
void 0,
|
|
429
541
|
"reverted",
|
|
@@ -433,103 +545,103 @@ function st(K) {
|
|
|
433
545
|
);
|
|
434
546
|
return;
|
|
435
547
|
}
|
|
436
|
-
if (
|
|
437
|
-
|
|
548
|
+
if (i.chainId !== s.chainId) {
|
|
549
|
+
G(!0), D(
|
|
438
550
|
void 0,
|
|
439
551
|
"pending",
|
|
440
552
|
void 0,
|
|
441
553
|
void 0,
|
|
442
|
-
`Switching to chain ${
|
|
554
|
+
`Switching to chain ${s.chainId}...`
|
|
443
555
|
);
|
|
444
|
-
const e =
|
|
445
|
-
chain:
|
|
446
|
-
transport:
|
|
556
|
+
const e = Be({
|
|
557
|
+
chain: be(s.chainId),
|
|
558
|
+
transport: Ne(await i.connector.getProvider())
|
|
447
559
|
// TODO: Add proper type
|
|
448
560
|
});
|
|
449
561
|
try {
|
|
450
|
-
await
|
|
562
|
+
await Fe({
|
|
451
563
|
walletClient: e,
|
|
452
|
-
desiredChainId:
|
|
453
|
-
}),
|
|
564
|
+
desiredChainId: s.chainId
|
|
565
|
+
}), G(!1);
|
|
454
566
|
} catch (n) {
|
|
455
|
-
t.console.error("Chain switch failed:", n), n instanceof Error && n.message.includes("User rejected") &&
|
|
567
|
+
t.console.error("Chain switch failed:", n), n instanceof Error && n.message.includes("User rejected") && x(!1), D(
|
|
456
568
|
void 0,
|
|
457
569
|
"reverted",
|
|
458
570
|
void 0,
|
|
459
571
|
void 0,
|
|
460
572
|
n instanceof Error ? n.message : "Unknown error switching chain"
|
|
461
|
-
),
|
|
573
|
+
), G(!1);
|
|
462
574
|
return;
|
|
463
575
|
}
|
|
464
576
|
}
|
|
465
|
-
if (
|
|
577
|
+
if (K)
|
|
466
578
|
t.console.warn(
|
|
467
579
|
"Transaction already in progress. Skipping duplicate request."
|
|
468
580
|
);
|
|
469
581
|
else {
|
|
470
|
-
if (
|
|
471
|
-
|
|
582
|
+
if (J(!0), ie(void 0), D(void 0, "sending"), !me && !Ce) {
|
|
583
|
+
f(!0);
|
|
472
584
|
return;
|
|
473
585
|
}
|
|
474
|
-
if (
|
|
475
|
-
t.console.error("Gas estimation failed:",
|
|
586
|
+
if (Ce) {
|
|
587
|
+
t.console.error("Gas estimation failed:", Se), D(
|
|
476
588
|
void 0,
|
|
477
589
|
"reverted",
|
|
478
590
|
void 0,
|
|
479
591
|
void 0,
|
|
480
|
-
`Gas estimation failed: ${
|
|
481
|
-
),
|
|
592
|
+
`Gas estimation failed: ${Se?.message}`
|
|
593
|
+
), J(!1);
|
|
482
594
|
return;
|
|
483
595
|
}
|
|
484
|
-
const e =
|
|
485
|
-
|
|
596
|
+
const e = me ? BigInt(Math.floor(Number(me) * 1.2)) : void 0;
|
|
597
|
+
M.sendTransaction(
|
|
486
598
|
{
|
|
487
|
-
to:
|
|
488
|
-
data:
|
|
489
|
-
value:
|
|
490
|
-
chainId:
|
|
599
|
+
to: s.to,
|
|
600
|
+
data: s.data,
|
|
601
|
+
value: s.value,
|
|
602
|
+
chainId: s.chainId,
|
|
491
603
|
gas: e
|
|
492
604
|
},
|
|
493
605
|
{
|
|
494
606
|
onSuccess: (n) => {
|
|
495
|
-
t.console.log("Transaction sent, hash:", n),
|
|
607
|
+
t.console.log("Transaction sent, hash:", n), ie(n), J(!1);
|
|
496
608
|
},
|
|
497
609
|
onError: (n) => {
|
|
498
|
-
t.console.error("Transaction failed:", n), n instanceof Error && (n.message.includes("User rejected") || n.message.includes("user rejected")) &&
|
|
610
|
+
t.console.error("Transaction failed:", n), n instanceof Error && (n.message.includes("User rejected") || n.message.includes("user rejected")) && x(!1), D(
|
|
499
611
|
void 0,
|
|
500
612
|
"reverted",
|
|
501
613
|
void 0,
|
|
502
614
|
void 0,
|
|
503
615
|
n instanceof Error ? n.message : "Unknown error"
|
|
504
|
-
),
|
|
616
|
+
), J(!1);
|
|
505
617
|
}
|
|
506
618
|
}
|
|
507
619
|
);
|
|
508
620
|
}
|
|
509
621
|
};
|
|
510
|
-
|
|
511
|
-
|
|
622
|
+
b(() => {
|
|
623
|
+
Y && (t.console.error("Chain switch error:", Y), D(
|
|
512
624
|
void 0,
|
|
513
625
|
"reverted",
|
|
514
626
|
void 0,
|
|
515
627
|
void 0,
|
|
516
|
-
`Chain switch failed: ${
|
|
517
|
-
),
|
|
518
|
-
}, [
|
|
519
|
-
|
|
520
|
-
}, []),
|
|
521
|
-
|
|
522
|
-
}, [
|
|
523
|
-
if (
|
|
628
|
+
`Chain switch failed: ${Y.message || "Unknown error"}`
|
|
629
|
+
), G(!1));
|
|
630
|
+
}, [Y, D]), b(() => {
|
|
631
|
+
f(!1);
|
|
632
|
+
}, []), b(() => {
|
|
633
|
+
s?.chainId && i.chainId === s.chainId && (t.console.log("No chain switch required"), G(!1));
|
|
634
|
+
}, [i.chainId, s?.chainId]), b(() => {
|
|
635
|
+
if (s?.chainId && i.chainId !== s.chainId) {
|
|
524
636
|
async function e() {
|
|
525
637
|
try {
|
|
526
|
-
const n =
|
|
527
|
-
chain:
|
|
528
|
-
transport:
|
|
638
|
+
const n = s.chainId, m = Be({
|
|
639
|
+
chain: be(n),
|
|
640
|
+
transport: Ne(await i.connector.getProvider())
|
|
529
641
|
// TODO: Add proper type
|
|
530
642
|
});
|
|
531
|
-
await
|
|
532
|
-
walletClient:
|
|
643
|
+
await Fe({
|
|
644
|
+
walletClient: m,
|
|
533
645
|
desiredChainId: n
|
|
534
646
|
});
|
|
535
647
|
} catch (n) {
|
|
@@ -538,365 +650,167 @@ function st(K) {
|
|
|
538
650
|
}
|
|
539
651
|
e().catch(t.console.error);
|
|
540
652
|
}
|
|
541
|
-
}, [
|
|
653
|
+
}, [i, s]);
|
|
542
654
|
const {
|
|
543
|
-
data:
|
|
544
|
-
isLoading:
|
|
545
|
-
isSuccess:
|
|
546
|
-
isError:
|
|
547
|
-
error:
|
|
548
|
-
} =
|
|
549
|
-
hash:
|
|
655
|
+
data: F,
|
|
656
|
+
isLoading: ee,
|
|
657
|
+
isSuccess: we,
|
|
658
|
+
isError: ke,
|
|
659
|
+
error: fe
|
|
660
|
+
} = $n({
|
|
661
|
+
hash: g,
|
|
550
662
|
confirmations: 1,
|
|
551
663
|
query: {
|
|
552
|
-
enabled: !!
|
|
664
|
+
enabled: !!g
|
|
553
665
|
}
|
|
554
666
|
});
|
|
555
|
-
|
|
556
|
-
if (!
|
|
557
|
-
|
|
667
|
+
b(() => {
|
|
668
|
+
if (!g) {
|
|
669
|
+
v?.txnHash && H(null), Ae(null), Object.keys(Q).length > 0 && le({});
|
|
558
670
|
return;
|
|
559
671
|
}
|
|
560
|
-
if (!(
|
|
561
|
-
if (
|
|
562
|
-
|
|
563
|
-
...e?.txnHash ===
|
|
672
|
+
if (!(v?.txnHash === g && (v?.status === "Success" || v?.status === "Failed") && !ee)) {
|
|
673
|
+
if (ee) {
|
|
674
|
+
H((e) => ({
|
|
675
|
+
...e?.txnHash === g ? e : {
|
|
564
676
|
gasUsed: void 0,
|
|
565
677
|
effectiveGasPrice: void 0,
|
|
566
678
|
revertReason: void 0
|
|
567
679
|
},
|
|
568
|
-
txnHash:
|
|
680
|
+
txnHash: g,
|
|
569
681
|
status: "Pending"
|
|
570
682
|
}));
|
|
571
683
|
return;
|
|
572
684
|
}
|
|
573
|
-
if (
|
|
574
|
-
const e =
|
|
575
|
-
|
|
576
|
-
txnHash:
|
|
685
|
+
if (we && F) {
|
|
686
|
+
const e = F.status === "success" ? "Success" : "Failed";
|
|
687
|
+
H({
|
|
688
|
+
txnHash: F.transactionHash,
|
|
577
689
|
status: e,
|
|
578
|
-
gasUsed:
|
|
579
|
-
effectiveGasPrice:
|
|
580
|
-
revertReason:
|
|
581
|
-
}), e === "Success" &&
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
const a = Ce(o.chainId), s = await Ke({
|
|
590
|
-
chain: a,
|
|
591
|
-
transport: ze()
|
|
592
|
-
}).getBlock({
|
|
593
|
-
blockNumber: BigInt(E.blockNumber)
|
|
594
|
-
});
|
|
595
|
-
W(Number(s.timestamp));
|
|
596
|
-
} catch (a) {
|
|
597
|
-
t.console.error(
|
|
598
|
-
"[Trails] Error fetching origin block timestamp:",
|
|
599
|
-
a
|
|
600
|
-
), W(null);
|
|
601
|
-
}
|
|
602
|
-
})() : e !== "Success" && W(null), e === "Success" && u && u.length > 0 && x && !u.some((n) => z[`${n.chainId}-${n.id}`]) && (t.console.log(
|
|
603
|
-
"Origin transaction successful, auto-sending all meta transactions..."
|
|
604
|
-
), se.mutate({ selectedId: null }));
|
|
605
|
-
} else Oe && (g({
|
|
606
|
-
txnHash: I,
|
|
690
|
+
gasUsed: F.gasUsed ? Number(F.gasUsed) : void 0,
|
|
691
|
+
effectiveGasPrice: F.effectiveGasPrice?.toString(),
|
|
692
|
+
revertReason: F.status === "reverted" ? fe?.message || "Transaction reverted by receipt" : void 0
|
|
693
|
+
}), e !== "Success" && Ae(null), e === "Success" && j && j.length > 0 && a && !j.some((n) => Q[`${n.chainId}-${n.id}`]) && (t.console.log(
|
|
694
|
+
"Origin transaction successful, calling executeIntent and auto-sending all meta transactions..."
|
|
695
|
+
), h && g && Z.mutate({
|
|
696
|
+
intentId: h,
|
|
697
|
+
depositTransactionHash: g
|
|
698
|
+
}));
|
|
699
|
+
} else ke && (H({
|
|
700
|
+
txnHash: g,
|
|
607
701
|
status: "Failed",
|
|
608
|
-
revertReason:
|
|
702
|
+
revertReason: fe?.message || "Failed to get receipt",
|
|
609
703
|
gasUsed: void 0,
|
|
610
704
|
effectiveGasPrice: void 0
|
|
611
|
-
}),
|
|
705
|
+
}), Ae(null));
|
|
612
706
|
}
|
|
613
707
|
}, [
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
708
|
+
g,
|
|
709
|
+
ee,
|
|
710
|
+
we,
|
|
711
|
+
ke,
|
|
712
|
+
F,
|
|
713
|
+
fe,
|
|
714
|
+
j,
|
|
715
|
+
Q,
|
|
716
|
+
a,
|
|
717
|
+
v?.status,
|
|
718
|
+
v?.txnHash,
|
|
719
|
+
h,
|
|
720
|
+
Z
|
|
721
|
+
]), b(() => {
|
|
722
|
+
a && S.isSuccess && s?.chainId && i.chainId === s.chainId && !s.error && s.to && s.data !== null && s.value !== null && !M.isPending && !ee && !g && !ue && !v && !X && (t.console.log("Auto-executing transaction: All conditions met."), L(!0), H({
|
|
628
723
|
status: "Sending..."
|
|
629
|
-
}),
|
|
724
|
+
}), M.sendTransaction(
|
|
630
725
|
{
|
|
631
|
-
to:
|
|
632
|
-
data:
|
|
633
|
-
value:
|
|
634
|
-
chainId:
|
|
726
|
+
to: s.to,
|
|
727
|
+
data: s.data,
|
|
728
|
+
value: s.value,
|
|
729
|
+
chainId: s.chainId
|
|
635
730
|
},
|
|
636
731
|
{
|
|
637
732
|
onSuccess: (n) => {
|
|
638
|
-
t.console.log("Auto-executed transaction sent, hash:", n),
|
|
733
|
+
t.console.log("Auto-executed transaction sent, hash:", n), ie(n);
|
|
639
734
|
},
|
|
640
735
|
onError: (n) => {
|
|
641
|
-
t.console.error("Auto-executed transaction failed:", n), n instanceof Error && (n.message.includes("User rejected") || n.message.includes("user rejected")) &&
|
|
736
|
+
t.console.error("Auto-executed transaction failed:", n), n instanceof Error && (n.message.includes("User rejected") || n.message.includes("user rejected")) && x(!1), H({
|
|
642
737
|
status: "Failed",
|
|
643
738
|
revertReason: n instanceof Error ? n.message : "Unknown error"
|
|
644
|
-
}),
|
|
739
|
+
}), L(!1);
|
|
645
740
|
}
|
|
646
741
|
}
|
|
647
742
|
));
|
|
648
743
|
}, [
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
]),
|
|
661
|
-
|
|
662
|
-
mainSignerAddress: c.address,
|
|
663
|
-
calls: A,
|
|
664
|
-
preconditions: C,
|
|
665
|
-
quoteProvider: h.quoteProvider,
|
|
666
|
-
addressOverrides: f.variables?.params.addressOverrides
|
|
667
|
-
}));
|
|
744
|
+
a,
|
|
745
|
+
S.isSuccess,
|
|
746
|
+
s,
|
|
747
|
+
i.chainId,
|
|
748
|
+
M.isPending,
|
|
749
|
+
ee,
|
|
750
|
+
g,
|
|
751
|
+
ue,
|
|
752
|
+
v,
|
|
753
|
+
X,
|
|
754
|
+
M
|
|
755
|
+
]), b(() => {
|
|
756
|
+
a && W && k && A && i.address && $ && !S.isPending && !S.isSuccess && (t.console.log("Auto-committing intent configuration..."), q && S.mutate(q));
|
|
668
757
|
}, [
|
|
669
|
-
|
|
758
|
+
a,
|
|
759
|
+
q,
|
|
760
|
+
W,
|
|
761
|
+
k,
|
|
670
762
|
A,
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
L,
|
|
675
|
-
w,
|
|
676
|
-
f.variables
|
|
763
|
+
i.address,
|
|
764
|
+
$,
|
|
765
|
+
S
|
|
677
766
|
]);
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
hasIntentCallsPayloads: !!A,
|
|
683
|
-
hasIntentPreconditions: !!C,
|
|
684
|
-
hasMetaTxns: !!u,
|
|
685
|
-
hasAccountAddress: !!c.address,
|
|
686
|
-
quoteProvider: h?.quoteProvider
|
|
687
|
-
}), !A || !C || !u || !c.address)
|
|
688
|
-
throw new Error("Missing required data for meta-transaction");
|
|
689
|
-
if (!h?.quoteProvider)
|
|
690
|
-
throw new Error("quoteProvider is required");
|
|
691
|
-
const n = _e(
|
|
692
|
-
c.address,
|
|
693
|
-
A
|
|
694
|
-
), a = e ? [u.find((s) => s.id === e)] : u;
|
|
695
|
-
if (t.console.log("[trails-sdk] Selected transactions to send", {
|
|
696
|
-
selectedId: e,
|
|
697
|
-
totalMetaTxns: u.length,
|
|
698
|
-
txnsToSendCount: a.filter((s) => s).length,
|
|
699
|
-
txnsToSend: a.filter((s) => s).map((s) => ({
|
|
700
|
-
id: s?.id,
|
|
701
|
-
chainId: s?.chainId,
|
|
702
|
-
walletAddress: s?.walletAddress,
|
|
703
|
-
contract: s?.contract
|
|
704
|
-
}))
|
|
705
|
-
}), !a || e && !a[0])
|
|
706
|
-
throw new Error("Meta transaction not found");
|
|
707
|
-
const m = [];
|
|
708
|
-
for (const s of a) {
|
|
709
|
-
if (!s) continue;
|
|
710
|
-
const l = `${s.chainId}-${s.id}`, v = z[l], p = Date.now();
|
|
711
|
-
if (t.console.log(
|
|
712
|
-
`[trails-sdk] Processing meta transaction ${l}`,
|
|
713
|
-
{
|
|
714
|
-
metaTxnId: s.id,
|
|
715
|
-
chainId: s.chainId,
|
|
716
|
-
walletAddress: s.walletAddress,
|
|
717
|
-
contract: s.contract,
|
|
718
|
-
intentAddress: n
|
|
719
|
-
}
|
|
720
|
-
), v && p - v < Je) {
|
|
721
|
-
const i = Math.ceil(
|
|
722
|
-
(Je - (p - v)) / 1e3
|
|
723
|
-
);
|
|
724
|
-
t.console.log(
|
|
725
|
-
`[trails-sdk] Meta transaction for ${l} was sent recently. Wait ${i}s before retry`,
|
|
726
|
-
{
|
|
727
|
-
lastSentTime: v,
|
|
728
|
-
now: p,
|
|
729
|
-
timeLeft: i
|
|
730
|
-
}
|
|
731
|
-
);
|
|
732
|
-
continue;
|
|
733
|
-
}
|
|
734
|
-
try {
|
|
735
|
-
const i = parseInt(s.chainId, 10);
|
|
736
|
-
if (Number.isNaN(i) || i <= 0)
|
|
737
|
-
throw t.console.error(
|
|
738
|
-
"[trails-sdk] Invalid chainId for meta transaction",
|
|
739
|
-
{
|
|
740
|
-
chainId: i,
|
|
741
|
-
operationKey: l,
|
|
742
|
-
metaTxn: s
|
|
743
|
-
}
|
|
744
|
-
), new Error(`Invalid chainId for meta transaction: ${i}`);
|
|
745
|
-
const y = Pe(i);
|
|
746
|
-
if (!y)
|
|
747
|
-
throw t.console.error("[trails-sdk] No relayer found for chainId", {
|
|
748
|
-
chainId: i,
|
|
749
|
-
operationKey: l,
|
|
750
|
-
availableRelayers: Array.from(sn.keys())
|
|
751
|
-
}), new Error(`No relayer found for chainId: ${i}`);
|
|
752
|
-
const b = C.filter(
|
|
753
|
-
(oe) => oe.chainId && parseInt(oe.chainId, 10) === i
|
|
754
|
-
);
|
|
755
|
-
t.console.log(
|
|
756
|
-
`[trails-sdk] Relaying meta transaction ${l} to intent ${n} via relayer`,
|
|
757
|
-
{
|
|
758
|
-
chainId: i,
|
|
759
|
-
operationKey: l,
|
|
760
|
-
intentAddress: n,
|
|
761
|
-
relayer: !!y,
|
|
762
|
-
preconditionsCount: b.length
|
|
763
|
-
}
|
|
764
|
-
);
|
|
765
|
-
const { opHash: ge } = await y.sendMetaTxn(
|
|
766
|
-
s.walletAddress,
|
|
767
|
-
s.contract,
|
|
768
|
-
s.input,
|
|
769
|
-
Number(s.chainId),
|
|
770
|
-
void 0,
|
|
771
|
-
b
|
|
772
|
-
);
|
|
773
|
-
t.console.log(
|
|
774
|
-
`[trails-sdk] Successfully sent meta transaction ${l}`,
|
|
775
|
-
{
|
|
776
|
-
operationKey: l,
|
|
777
|
-
opHash: ge,
|
|
778
|
-
chainId: i
|
|
779
|
-
}
|
|
780
|
-
);
|
|
781
|
-
const Te = !1;
|
|
782
|
-
m.push({
|
|
783
|
-
operationKey: l,
|
|
784
|
-
opHash: ge,
|
|
785
|
-
success: !0
|
|
786
|
-
});
|
|
787
|
-
} catch (i) {
|
|
788
|
-
const y = i instanceof Error ? i.message : "Unknown error";
|
|
789
|
-
t.console.error(
|
|
790
|
-
`[trails-sdk] Failed to send meta transaction ${l}`,
|
|
791
|
-
{
|
|
792
|
-
operationKey: l,
|
|
793
|
-
error: y,
|
|
794
|
-
chainId: s.chainId,
|
|
795
|
-
metaTxnId: s.id,
|
|
796
|
-
walletAddress: s.walletAddress,
|
|
797
|
-
contract: s.contract
|
|
798
|
-
}
|
|
799
|
-
), m.push({
|
|
800
|
-
operationKey: l,
|
|
801
|
-
error: y,
|
|
802
|
-
success: !1
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
return m;
|
|
807
|
-
},
|
|
808
|
-
onSuccess: (e) => {
|
|
809
|
-
t.console.log(
|
|
810
|
-
"[trails-sdk] sendMetaTxn mutation completed successfully",
|
|
811
|
-
{
|
|
812
|
-
totalResults: e.length,
|
|
813
|
-
successfulResults: e.filter((n) => n.success).length,
|
|
814
|
-
failedResults: e.filter((n) => !n.success).length,
|
|
815
|
-
results: e.map((n) => ({
|
|
816
|
-
operationKey: n.operationKey,
|
|
817
|
-
success: n.success,
|
|
818
|
-
opHash: n.opHash || null,
|
|
819
|
-
error: n.error || null
|
|
820
|
-
}))
|
|
821
|
-
}
|
|
822
|
-
), e.forEach(({ operationKey: n, opHash: a, success: m }) => {
|
|
823
|
-
m && a ? (ie((s) => ({
|
|
824
|
-
...s,
|
|
825
|
-
[n]: Date.now()
|
|
826
|
-
})), he((s) => ({
|
|
827
|
-
...s,
|
|
828
|
-
[n]: a
|
|
829
|
-
}))) : t.console.warn(
|
|
830
|
-
`[trails-sdk] Not updating state for failed meta transaction ${n}`,
|
|
831
|
-
{
|
|
832
|
-
operationKey: n,
|
|
833
|
-
error: e.find((s) => s.operationKey === n)?.error
|
|
834
|
-
}
|
|
835
|
-
);
|
|
836
|
-
});
|
|
837
|
-
},
|
|
838
|
-
onError: (e) => {
|
|
839
|
-
t.console.error("[trails-sdk] Error in meta-transaction process", {
|
|
840
|
-
error: e instanceof Error ? e.message : String(e),
|
|
841
|
-
errorType: e instanceof Error ? e.constructor.name : typeof e,
|
|
842
|
-
stack: e instanceof Error ? e.stack : void 0
|
|
843
|
-
});
|
|
844
|
-
},
|
|
845
|
-
retry: 5,
|
|
846
|
-
// Allow up to 2 retries
|
|
847
|
-
retryDelay: (e) => Math.min(1e3 * 2 ** e, 3e4)
|
|
848
|
-
// Exponential backoff
|
|
849
|
-
}), [de, un] = d(null), [ue, gn] = d(null);
|
|
850
|
-
F(() => {
|
|
851
|
-
if (!L || !A?.[0]?.chainId || !de || !ue || !C || !c.address) {
|
|
852
|
-
J(null);
|
|
767
|
+
const [ne, nn] = l(null), [re, tn] = l(null);
|
|
768
|
+
b(() => {
|
|
769
|
+
if (!$ || !W?.[0]?.chainId || !ne || !re || !k || !i.address) {
|
|
770
|
+
O(null);
|
|
853
771
|
return;
|
|
854
772
|
}
|
|
855
773
|
try {
|
|
856
|
-
const e =
|
|
857
|
-
if (!e || !
|
|
858
|
-
|
|
774
|
+
const e = $;
|
|
775
|
+
if (!e || !Dn(e)) {
|
|
776
|
+
O(null);
|
|
859
777
|
return;
|
|
860
778
|
}
|
|
861
|
-
let n,
|
|
862
|
-
const
|
|
863
|
-
if (
|
|
864
|
-
const
|
|
865
|
-
(
|
|
866
|
-
)?.
|
|
867
|
-
if (
|
|
868
|
-
throw new Error(
|
|
869
|
-
|
|
870
|
-
);
|
|
871
|
-
m = BigInt(p), n = s;
|
|
779
|
+
let n, m = "0x", w = 0n;
|
|
780
|
+
const y = e;
|
|
781
|
+
if (ne === he || ne === Fn) {
|
|
782
|
+
const E = k.find(
|
|
783
|
+
(C) => (C.type === "transfer-native" || C.type === "native-balance") && C.chainId === re
|
|
784
|
+
)?.minAmount?.toString();
|
|
785
|
+
if (E === void 0)
|
|
786
|
+
throw new Error("Could not find precondition or min amount");
|
|
787
|
+
w = BigInt(E), n = y;
|
|
872
788
|
} else {
|
|
873
|
-
const
|
|
874
|
-
(
|
|
875
|
-
|
|
876
|
-
|
|
789
|
+
const E = k.find(
|
|
790
|
+
(C) => C.type === "erc20-balance" && C.chainId === re && C.tokenAddress && ce(
|
|
791
|
+
te(C.tokenAddress),
|
|
792
|
+
te(ne)
|
|
877
793
|
)
|
|
878
|
-
)?.
|
|
879
|
-
if (
|
|
880
|
-
throw new Error(
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
amount: BigInt(p)
|
|
886
|
-
}), n = de;
|
|
794
|
+
)?.minAmount?.toString();
|
|
795
|
+
if (E === void 0)
|
|
796
|
+
throw new Error("Could not find precondition or min amount");
|
|
797
|
+
m = qn({
|
|
798
|
+
recipient: y,
|
|
799
|
+
amount: BigInt(E)
|
|
800
|
+
}), n = ne;
|
|
887
801
|
}
|
|
888
|
-
|
|
802
|
+
O({
|
|
889
803
|
to: n,
|
|
890
|
-
data:
|
|
891
|
-
value:
|
|
892
|
-
chainId:
|
|
804
|
+
data: m,
|
|
805
|
+
value: w,
|
|
806
|
+
chainId: re,
|
|
893
807
|
error: void 0
|
|
894
808
|
});
|
|
895
809
|
} catch (e) {
|
|
896
810
|
t.console.error(
|
|
897
811
|
"[trails-sdk] Failed to calculate origin call params for UI:",
|
|
898
812
|
e
|
|
899
|
-
),
|
|
813
|
+
), O({
|
|
900
814
|
to: null,
|
|
901
815
|
data: null,
|
|
902
816
|
value: null,
|
|
@@ -905,313 +819,217 @@ function st(K) {
|
|
|
905
819
|
});
|
|
906
820
|
}
|
|
907
821
|
}, [
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
822
|
+
W,
|
|
823
|
+
ne,
|
|
824
|
+
re,
|
|
825
|
+
k,
|
|
826
|
+
i.address,
|
|
827
|
+
$
|
|
914
828
|
]);
|
|
915
|
-
const
|
|
916
|
-
|
|
917
|
-
|
|
829
|
+
const I = Gn(
|
|
830
|
+
h ?? void 0,
|
|
831
|
+
o
|
|
918
832
|
);
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
"[trails-sdk] Running meta-transaction block timestamp effect:",
|
|
927
|
-
{
|
|
928
|
-
metaTxnsLength: u?.length,
|
|
929
|
-
monitorStatusesLength: Object.keys(V).length
|
|
930
|
-
}
|
|
931
|
-
), !u || u.length === 0) {
|
|
932
|
-
t.console.log(
|
|
933
|
-
"[trails-sdk] No meta transactions, clearing timestamps"
|
|
934
|
-
), Re.current.clear(), Object.keys(Ee).length > 0 && le({});
|
|
833
|
+
b(() => {
|
|
834
|
+
if (t.console.log("[trails-sdk] Intent receipt status update:", {
|
|
835
|
+
intentId: h,
|
|
836
|
+
done: I.done,
|
|
837
|
+
hasReceipt: !!I.intentReceipt
|
|
838
|
+
}), !I.intentReceipt) {
|
|
839
|
+
t.console.log("[trails-sdk] No intent receipt yet, waiting...");
|
|
935
840
|
return;
|
|
936
841
|
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
842
|
+
const e = {};
|
|
843
|
+
if (I.intentReceipt.originTransaction) {
|
|
844
|
+
const n = I.intentReceipt.originTransaction, m = `${n.chainId}-${n.metaTxnId}`;
|
|
845
|
+
e[m] = { timestamp: null };
|
|
940
846
|
}
|
|
941
|
-
|
|
942
|
-
const
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
), Re.current.add(a);
|
|
966
|
-
try {
|
|
967
|
-
const l = parseInt(e.chainId, 10);
|
|
968
|
-
if (Number.isNaN(l) || l <= 0)
|
|
969
|
-
throw new Error(
|
|
970
|
-
`Invalid chainId for meta transaction: ${e.chainId}`
|
|
971
|
-
);
|
|
972
|
-
const v = Ce(l), p = Ke({
|
|
973
|
-
chain: v,
|
|
974
|
-
transport: ze()
|
|
975
|
-
}), i = await p.getTransactionReceipt({
|
|
976
|
-
hash: s
|
|
977
|
-
});
|
|
978
|
-
if (i && typeof i.blockNumber == "bigint") {
|
|
979
|
-
const y = await p.getBlock({
|
|
980
|
-
blockNumber: i.blockNumber
|
|
847
|
+
if (I.intentReceipt.destinationTransaction) {
|
|
848
|
+
const n = I.intentReceipt.destinationTransaction, m = `${n.chainId}-${n.metaTxnId}`;
|
|
849
|
+
e[m] = { timestamp: null };
|
|
850
|
+
}
|
|
851
|
+
Re(e);
|
|
852
|
+
}, [
|
|
853
|
+
I.intentReceipt,
|
|
854
|
+
I.done,
|
|
855
|
+
h
|
|
856
|
+
]), b(() => {
|
|
857
|
+
if (I.done && I.intentReceipt && (t.console.log("[trails-sdk] Intent execution completed", {
|
|
858
|
+
intentId: h,
|
|
859
|
+
status: I.intentReceipt.status
|
|
860
|
+
}), I.intentReceipt.originTransaction?.txnHash)) {
|
|
861
|
+
const e = A?.quoteProvider ? String(A.quoteProvider).toLowerCase() : void 0, n = T.variables?.options?.quoteProvider ? String(
|
|
862
|
+
T.variables.options.quoteProvider
|
|
863
|
+
).toLowerCase() : void 0;
|
|
864
|
+
if ((e === "cctp" || n === "cctp") && T.variables)
|
|
865
|
+
try {
|
|
866
|
+
On({
|
|
867
|
+
sourceTxHash: I.intentReceipt.originTransaction.txnHash,
|
|
868
|
+
sourceChainId: T.variables.originChainId,
|
|
869
|
+
destinationChainId: T.variables.destinationChainId,
|
|
870
|
+
trailsClient: o
|
|
981
871
|
});
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
[a]: {
|
|
987
|
-
timestamp: Number(y.timestamp),
|
|
988
|
-
error: void 0
|
|
989
|
-
}
|
|
990
|
-
}));
|
|
991
|
-
try {
|
|
992
|
-
const b = h?.quoteProvider ? String(h.quoteProvider).toLowerCase() : void 0, ge = f.variables?.params.provider ? String(
|
|
993
|
-
f.variables.params.provider
|
|
994
|
-
).toLowerCase() : void 0, Te = b === "cctp" || ge === "cctp", oe = f.variables?.params.originChainId, De = f.variables?.params.destinationChainId;
|
|
995
|
-
t.console.log("[Trails] isCctp", Te), t.console.log("[Trails] providerFromQuote", b), t.console.log("[Trails] providerFromArgs", ge), t.console.log("[Trails] trailsFee", h), t.console.log(
|
|
996
|
-
"[Trails] createIntentMutation.variables",
|
|
997
|
-
f.variables
|
|
998
|
-
), t.console.log(
|
|
999
|
-
"[Trails] createIntentMutation.variables.params.provider",
|
|
1000
|
-
f.variables?.params.provider
|
|
1001
|
-
), t.console.log(
|
|
1002
|
-
"[Trails] createIntentMutation.variables.params.originChainId",
|
|
1003
|
-
f.variables?.params.originChainId
|
|
1004
|
-
), t.console.log(
|
|
1005
|
-
"[Trails] createIntentMutation.variables.params.destinationChainId",
|
|
1006
|
-
f.variables?.params.destinationChainId
|
|
1007
|
-
), t.console.log(
|
|
1008
|
-
"[Trails] lastQueuedCctpSourceTxHash",
|
|
1009
|
-
Ue.current
|
|
1010
|
-
), t.console.log("[Trails] transactionHash", s), t.console.log(
|
|
1011
|
-
"[Trails] originChainIdForCctp",
|
|
1012
|
-
oe
|
|
1013
|
-
), t.console.log(
|
|
1014
|
-
"[Trails] destinationChainIdForCctp",
|
|
1015
|
-
De
|
|
1016
|
-
), Te && T && s && typeof oe == "number" && typeof De == "number" && Ue.current !== s && n === 0 && (Ue.current = s, await jn({
|
|
1017
|
-
trailsClient: T,
|
|
1018
|
-
sourceTxHash: s,
|
|
1019
|
-
sourceChainId: oe,
|
|
1020
|
-
destinationChainId: De
|
|
1021
|
-
}));
|
|
1022
|
-
} catch (b) {
|
|
1023
|
-
t.console.error(
|
|
1024
|
-
`[trails-sdk] Queue CCTP on meta-tx error (${a}):`,
|
|
1025
|
-
b
|
|
1026
|
-
);
|
|
1027
|
-
}
|
|
1028
|
-
} else
|
|
1029
|
-
t.console.warn(
|
|
1030
|
-
`[trails-sdk] MetaTxn ${a}: No block number in receipt`
|
|
1031
|
-
), le((y) => ({
|
|
1032
|
-
...y,
|
|
1033
|
-
[a]: {
|
|
1034
|
-
timestamp: null,
|
|
1035
|
-
error: "Block number not found in receipt"
|
|
1036
|
-
}
|
|
1037
|
-
}));
|
|
1038
|
-
} catch (l) {
|
|
1039
|
-
t.console.error(
|
|
1040
|
-
`[trails-sdk] MetaTxn ${a}: Error:`,
|
|
1041
|
-
l
|
|
1042
|
-
), le((v) => ({
|
|
1043
|
-
...v,
|
|
1044
|
-
[a]: {
|
|
1045
|
-
timestamp: null,
|
|
1046
|
-
error: l.message || "Failed to fetch receipt/timestamp"
|
|
1047
|
-
}
|
|
1048
|
-
}));
|
|
1049
|
-
}
|
|
1050
|
-
});
|
|
872
|
+
} catch (w) {
|
|
873
|
+
t.console.error("[Trails] queueCCTPTransfer error", w);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
1051
876
|
}, [
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
Ee,
|
|
877
|
+
I.done,
|
|
878
|
+
I.intentReceipt,
|
|
1055
879
|
h,
|
|
1056
|
-
|
|
1057
|
-
T
|
|
880
|
+
A,
|
|
881
|
+
T.variables,
|
|
882
|
+
o
|
|
1058
883
|
]);
|
|
1059
|
-
const
|
|
1060
|
-
|
|
884
|
+
const sn = (e) => {
|
|
885
|
+
x(e);
|
|
1061
886
|
};
|
|
1062
|
-
function
|
|
1063
|
-
|
|
1064
|
-
...e,
|
|
1065
|
-
destinationSalt: Date.now().toString()
|
|
1066
|
-
});
|
|
887
|
+
function on(e) {
|
|
888
|
+
T.mutate(e);
|
|
1067
889
|
}
|
|
1068
|
-
function
|
|
1069
|
-
t.console.log("[trails-sdk]
|
|
890
|
+
function rn(e) {
|
|
891
|
+
t.console.log("[trails-sdk] commitIntent", e), S.mutate(e);
|
|
1070
892
|
}
|
|
1071
|
-
function
|
|
893
|
+
function an(e) {
|
|
1072
894
|
if (!e) {
|
|
1073
|
-
|
|
895
|
+
O(null);
|
|
1074
896
|
return;
|
|
1075
897
|
}
|
|
1076
|
-
const { originChainId: n, tokenAddress:
|
|
1077
|
-
|
|
898
|
+
const { originChainId: n, tokenAddress: m } = e;
|
|
899
|
+
tn(n), nn(m);
|
|
1078
900
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
901
|
+
const { chainId: cn } = i, Ue = s?.chainId, ln = T.isPending, dn = T.isSuccess, un = T.error, gn = T.variables, mn = S.isPending, fn = S.isSuccess, In = S.error, hn = S.variables, pn = Z.isPending, vn = Z.isSuccess, Tn = Z.error;
|
|
902
|
+
function An(e) {
|
|
903
|
+
Z.mutate(e);
|
|
1081
904
|
}
|
|
1082
|
-
const { chainId: vn } = c, Le = o?.chainId, Tn = f.isPending, Cn = f.isSuccess, Sn = f.error, yn = f.variables, An = w.isPending, wn = w.isSuccess, bn = w.error, kn = w.variables, En = se.isPending, Pn = se.isSuccess, xn = se.error, Mn = se.variables;
|
|
1083
905
|
return {
|
|
1084
|
-
trailsClient:
|
|
1085
|
-
metaTxns:
|
|
1086
|
-
intentCallsPayloads:
|
|
1087
|
-
intentPreconditions:
|
|
1088
|
-
trailsFee:
|
|
1089
|
-
txnHash:
|
|
1090
|
-
committedOriginIntentAddress:
|
|
1091
|
-
committedDestinationIntentAddress:
|
|
1092
|
-
verificationStatus:
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
906
|
+
trailsClient: o,
|
|
907
|
+
metaTxns: j,
|
|
908
|
+
intentCallsPayloads: W,
|
|
909
|
+
intentPreconditions: k,
|
|
910
|
+
trailsFee: A,
|
|
911
|
+
txnHash: g,
|
|
912
|
+
committedOriginIntentAddress: h,
|
|
913
|
+
committedDestinationIntentAddress: ve,
|
|
914
|
+
verificationStatus: Ve,
|
|
915
|
+
estimatedGas: me,
|
|
916
|
+
isEstimateError: Ce,
|
|
917
|
+
estimateError: Se,
|
|
918
|
+
calculateIntentAddress: Mn,
|
|
919
|
+
calculateOriginAndDestinationIntentAddresses: He,
|
|
920
|
+
committedIntentConfig: Ke,
|
|
921
|
+
isLoadingCommittedConfig: ze,
|
|
922
|
+
committedConfigError: Xe,
|
|
923
|
+
commitIntent: rn,
|
|
924
|
+
commitIntentPending: mn,
|
|
925
|
+
commitIntentSuccess: fn,
|
|
926
|
+
commitIntentError: In,
|
|
927
|
+
commitIntentArgs: hn,
|
|
928
|
+
executeIntent: An,
|
|
929
|
+
executeIntentPending: pn,
|
|
930
|
+
executeIntentSuccess: vn,
|
|
931
|
+
executeIntentError: Tn,
|
|
932
|
+
getIntent: Je,
|
|
933
|
+
operationHashes: oe,
|
|
934
|
+
callIntentCallsPayload: Ye,
|
|
935
|
+
sendOriginTransaction: en,
|
|
936
|
+
switchChain: c,
|
|
937
|
+
isSwitchingChain: Te,
|
|
938
|
+
switchChainError: Y,
|
|
939
|
+
isTransactionInProgress: K,
|
|
940
|
+
isChainSwitchRequired: cn !== Ue && !!Ue,
|
|
941
|
+
sendTransaction: M.sendTransaction,
|
|
942
|
+
isSendingTransaction: M.isPending,
|
|
943
|
+
originCallStatus: v,
|
|
1119
944
|
updateOriginCallStatus: D,
|
|
1120
|
-
isEstimatingGas:
|
|
1121
|
-
isAutoExecute:
|
|
1122
|
-
updateAutoExecute:
|
|
1123
|
-
receipt:
|
|
1124
|
-
isWaitingForReceipt:
|
|
1125
|
-
receiptIsSuccess:
|
|
1126
|
-
receiptIsError:
|
|
1127
|
-
receiptError:
|
|
1128
|
-
hasAutoExecuted:
|
|
1129
|
-
originCallSuccess:
|
|
1130
|
-
sentMetaTxns:
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
updateOriginCallParams: pn,
|
|
1145
|
-
originBlockTimestamp: ce,
|
|
1146
|
-
metaTxnBlockTimestamps: Ee,
|
|
1147
|
-
originIntentAddress: L,
|
|
1148
|
-
destinationIntentAddress: Se
|
|
945
|
+
isEstimatingGas: d,
|
|
946
|
+
isAutoExecute: a,
|
|
947
|
+
updateAutoExecute: sn,
|
|
948
|
+
receipt: F,
|
|
949
|
+
isWaitingForReceipt: ee,
|
|
950
|
+
receiptIsSuccess: we,
|
|
951
|
+
receiptIsError: ke,
|
|
952
|
+
receiptError: fe,
|
|
953
|
+
hasAutoExecuted: X,
|
|
954
|
+
originCallSuccess: M.isSuccess,
|
|
955
|
+
sentMetaTxns: Q,
|
|
956
|
+
clearIntent: Ze,
|
|
957
|
+
intentReceiptStatus: I,
|
|
958
|
+
createIntent: on,
|
|
959
|
+
createIntentPending: ln,
|
|
960
|
+
createIntentSuccess: dn,
|
|
961
|
+
createIntentError: un,
|
|
962
|
+
createIntentArgs: gn,
|
|
963
|
+
originCallParams: s,
|
|
964
|
+
updateOriginCallParams: an,
|
|
965
|
+
originBlockTimestamp: je,
|
|
966
|
+
metaTxnBlockTimestamps: We,
|
|
967
|
+
originIntentAddress: $,
|
|
968
|
+
destinationIntentAddress: Pe
|
|
1149
969
|
};
|
|
1150
970
|
}
|
|
1151
971
|
export {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
Ut as getWalletConnectProjectId,
|
|
972
|
+
Yn as InsufficientBalanceError,
|
|
973
|
+
Zn as TRAILS_ROUTER_PLACEHOLDER_AMOUNT,
|
|
974
|
+
xn as TradeType,
|
|
975
|
+
et as TrailsClient,
|
|
976
|
+
nt as TrailsWidget,
|
|
977
|
+
tt as UserRejectionError,
|
|
978
|
+
Mn as calculateIntentAddress,
|
|
979
|
+
He as calculateOriginAndDestinationIntentAddresses,
|
|
980
|
+
st as commitIntent,
|
|
981
|
+
it as createModalController,
|
|
982
|
+
ot as declareSequenceEnv,
|
|
983
|
+
rt as getAccountTotalBalanceUsd,
|
|
984
|
+
at as getAccountTransactionHistory,
|
|
985
|
+
ct as getAllChains,
|
|
986
|
+
be as getChainInfo,
|
|
987
|
+
lt as getDebug,
|
|
988
|
+
qn as getERC20TransferData,
|
|
989
|
+
dt as getHasSufficientBalanceToken,
|
|
990
|
+
ut as getHasSufficientBalanceUsd,
|
|
991
|
+
gt as getIndexerGatewayClient,
|
|
992
|
+
De as getIntent,
|
|
993
|
+
mt as getIntentTransactionHistory,
|
|
994
|
+
ft as getIsUserRejectionError,
|
|
995
|
+
It as getMinLogLevel,
|
|
996
|
+
ht as getSequenceEnv,
|
|
997
|
+
pt as getSequenceIndexerUrl,
|
|
998
|
+
vt as getSequenceNodeGatewayUrl,
|
|
999
|
+
Tt as getSequenceProjectAccessKey,
|
|
1000
|
+
At as getSlippageTolerance,
|
|
1001
|
+
Ct as getSupportedChains,
|
|
1002
|
+
St as getSupportedTokens,
|
|
1003
|
+
wt as getTrailsApiUrl,
|
|
1004
|
+
kt as getTrailsClient,
|
|
1005
|
+
yt as getTxTimeDiff,
|
|
1006
|
+
Et as getWalletConnectProjectId,
|
|
1188
1007
|
t as logger,
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
Ze as useTrailsClient
|
|
1008
|
+
bt as pollIntentReceipt,
|
|
1009
|
+
Pn as prepareSend,
|
|
1010
|
+
xt as sendOriginTransaction,
|
|
1011
|
+
Pt as setDebug,
|
|
1012
|
+
Rt as setSequenceEnv,
|
|
1013
|
+
Ut as setSequenceIndexerUrl,
|
|
1014
|
+
qt as setSequenceNodeGatewayUrl,
|
|
1015
|
+
Ot as setSequenceProjectAccessKey,
|
|
1016
|
+
Mt as setSlippageTolerance,
|
|
1017
|
+
Ht as setTrailsApiUrl,
|
|
1018
|
+
Dt as setWalletConnectProjectId,
|
|
1019
|
+
Ft as useAccountTotalBalanceUsd,
|
|
1020
|
+
Lt as useAccountTransactionHistory,
|
|
1021
|
+
Ge as useCommitIntent,
|
|
1022
|
+
Qe as useExecuteIntent,
|
|
1023
|
+
Bt as useHasSufficientBalanceToken,
|
|
1024
|
+
Nt as useHasSufficientBalanceUsd,
|
|
1025
|
+
kn as useIndexerGatewayClient,
|
|
1026
|
+
Gn as useIntentReceiptMonitor,
|
|
1027
|
+
$t as useIntentTransactionHistory,
|
|
1028
|
+
Kn as useQuote,
|
|
1029
|
+
Gt as useSupportedChains,
|
|
1030
|
+
yn as useSupportedTokens,
|
|
1031
|
+
Qt as useTokenBalances,
|
|
1032
|
+
jt as useTokenList,
|
|
1033
|
+
zn as useTrails,
|
|
1034
|
+
pe as useTrailsClient
|
|
1217
1035
|
};
|