0xtrails 0.4.1 → 0.4.2

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