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