0xtrails 0.3.0 → 0.4.0

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