0xtrails 0.3.0 → 0.4.1

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