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