0xtrails 0.6.0 → 0.6.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 (88) hide show
  1. package/dist/{ccip-Dw5AN7oU.js → ccip-CZfykYU7.js} +4 -4
  2. package/dist/chains.d.ts +9 -2
  3. package/dist/chains.d.ts.map +1 -1
  4. package/dist/constants.d.ts +1 -0
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/contractUtils.d.ts +2 -1
  7. package/dist/contractUtils.d.ts.map +1 -1
  8. package/dist/{index-BtVUTbEZ.js → index-S9pphnT9.js} +29732 -36767
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +300 -242
  12. package/dist/prepareSend.d.ts.map +1 -1
  13. package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -1
  14. package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -1
  15. package/dist/transactionIntent/types.d.ts +3 -1
  16. package/dist/transactionIntent/types.d.ts.map +1 -1
  17. package/dist/widget/components/ChainImage.d.ts.map +1 -1
  18. package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
  19. package/dist/widget/components/DepositTracker.d.ts +12 -0
  20. package/dist/widget/components/DepositTracker.d.ts.map +1 -0
  21. package/dist/widget/components/Disconnect.d.ts.map +1 -1
  22. package/dist/widget/components/FeeBreakdown.d.ts.map +1 -1
  23. package/dist/widget/components/QRCodeDeposit.d.ts.map +1 -1
  24. package/dist/widget/components/QRCodeOptions.d.ts +9 -0
  25. package/dist/widget/components/QRCodeOptions.d.ts.map +1 -0
  26. package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
  27. package/dist/widget/components/Receipt.d.ts.map +1 -1
  28. package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
  29. package/dist/widget/components/Toast.d.ts.map +1 -1
  30. package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
  31. package/dist/widget/components/WalletConnectionPending.d.ts.map +1 -1
  32. package/dist/widget/css/compiled.css +1 -1
  33. package/dist/widget/css/index.css +103 -38
  34. package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
  35. package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
  36. package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
  37. package/dist/widget/hooks/useDebugScreens.d.ts +1 -1
  38. package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
  39. package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
  40. package/dist/widget/hooks/useQuote.d.ts.map +1 -1
  41. package/dist/widget/hooks/useSelectedFeeOption.d.ts.map +1 -1
  42. package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
  43. package/dist/widget/index.js +1 -1
  44. package/dist/widget/widget.d.ts.map +1 -1
  45. package/package.json +6 -9
  46. package/src/chains.ts +37 -4
  47. package/src/constants.ts +1 -0
  48. package/src/contractUtils.ts +8 -7
  49. package/src/estimate.ts +2 -2
  50. package/src/index.ts +2 -0
  51. package/src/intents.ts +2 -2
  52. package/src/paymasterSend.ts +2 -2
  53. package/src/prepareSend.ts +34 -3
  54. package/src/sendUserOp.ts +2 -2
  55. package/src/tokens.ts +2 -2
  56. package/src/transactionIntent/deposits/gaslessDeposit.ts +2 -2
  57. package/src/transactionIntent/handlers/crossChain.ts +51 -2
  58. package/src/transactionIntent/handlers/sameChainSameToken.ts +52 -2
  59. package/src/transactionIntent/quote/normalizeQuote.ts +2 -2
  60. package/src/transactionIntent/types.ts +9 -1
  61. package/src/widget/compiled.css +1 -1
  62. package/src/widget/components/ChainImage.tsx +10 -7
  63. package/src/widget/components/ChainList.tsx +1 -1
  64. package/src/widget/components/ClassicSwap.tsx +8 -4
  65. package/src/widget/components/ConnectedWallets.tsx +1 -1
  66. package/src/widget/components/DepositTracker.tsx +298 -0
  67. package/src/widget/components/Disconnect.tsx +24 -3
  68. package/src/widget/components/FeeBreakdown.tsx +3 -3
  69. package/src/widget/components/QRCodeDeposit.tsx +29 -19
  70. package/src/widget/components/QRCodeOptions.tsx +65 -0
  71. package/src/widget/components/QuoteDetails.tsx +694 -803
  72. package/src/widget/components/Receipt.tsx +76 -40
  73. package/src/widget/components/ThemeProvider.tsx +7 -12
  74. package/src/widget/components/Toast.tsx +3 -2
  75. package/src/widget/components/TokenSelector.tsx +1 -1
  76. package/src/widget/components/Tooltip.tsx +1 -1
  77. package/src/widget/components/TransferPendingVertical.tsx +11 -2
  78. package/src/widget/components/WalletConnectionPending.tsx +28 -5
  79. package/src/widget/hooks/useCheckout.ts +10 -2
  80. package/src/widget/hooks/useCurrentScreen.tsx +1 -0
  81. package/src/widget/hooks/useDebugScreens.ts +1 -0
  82. package/src/widget/hooks/useIntentTransactionHistory.ts +114 -143
  83. package/src/widget/hooks/useQuote.ts +92 -6
  84. package/src/widget/hooks/useSelectedFeeOption.tsx +86 -29
  85. package/src/widget/hooks/useSendForm.ts +43 -7
  86. package/src/widget/index.css +103 -38
  87. package/src/widget/widget.tsx +48 -5
  88. package/dist/0xtrails.css +0 -1
package/dist/index.js CHANGED
@@ -1,36 +1,36 @@
1
- import { l as r, u as T, t as oe, a as re, b as ae, I as ie, g as h, c as ce, d as le, e as ue, f as de, h as ge, T as me, p as pe, i as N, j as fe, k as S } from "./index-BtVUTbEZ.js";
2
- import { m as qe, Q as Oe, _ as Le, X as Me, a0 as Ne, U as He, v as Be, w as Pe, x as Fe, $ as Qe, E as _e, B as Je, r as $e, W as Ge, V as Ke, R as je, F as We, G as ze, n as Ve, Y as Xe, s as Ye, S as Ze, o as et, M as tt, Z as nt, P as st, A as ot, y as rt, z as at, H as it, C as ct, O as lt, J as ut, K as dt, D as gt, q as mt, L as pt, N as ft } from "./index-BtVUTbEZ.js";
3
- import { useQuery as P, useMutation as F } from "@tanstack/react-query";
4
- import { useIndexerGatewayClient as Ee } from "@0xsequence/hooks";
5
- import { useIndexerGatewayClient as Ct } from "@0xsequence/hooks";
6
- import { useRef as Ce } from "react";
7
- import { zeroAddress as H } from "viem";
8
- const B = 150, ve = (i, e) => {
9
- const t = P({
10
- queryKey: ["waitIntentReceipt", i],
1
+ import { l as r, u as v, t as le, a as ue, b as de, I as ge, g as A, c as me, d as Q, e as pe, f as fe, h as $, i as Ce, T as Ee, p as ye, j as _, k as he, m as w } from "./index-S9pphnT9.js";
2
+ import { n as He, S as Be, a0 as Fe, Z as Qe, a2 as $e, U as _e, x as Je, y as Ge, z as Ke, a1 as je, G as We, D as ze, s as Ve, w as Xe, Y as Ye, X as Ze, V as et, H as tt, J as nt, o as ot, _ as st, v as rt, W as it, q as at, O as ct, $ as lt, R as ut, C as dt, A as gt, B as mt, K as pt, E as ft, Q as Ct, L as Et, M as yt, F as ht, r as kt, N as St, P as bt } from "./index-S9pphnT9.js";
3
+ import { useQuery as G, useMutation as K } from "@tanstack/react-query";
4
+ import { useIndexerGatewayClient as ke } from "@0xsequence/hooks";
5
+ import { useIndexerGatewayClient as Tt } from "@0xsequence/hooks";
6
+ import { useRef as Se } from "react";
7
+ import { zeroAddress as T, erc20Abi as be } from "viem";
8
+ const J = 150, Oe = (c, e) => {
9
+ const t = G({
10
+ queryKey: ["waitIntentReceipt", c],
11
11
  queryFn: async () => {
12
- if (!i)
12
+ if (!c)
13
13
  throw new Error("Intent ID is required for monitoring");
14
14
  r.console.log(
15
- `[trails-sdk] 🔍 Monitoring intent receipt for ${i}`
15
+ `[trails-sdk] 🔍 Monitoring intent receipt for ${c}`
16
16
  );
17
- const n = await e.waitIntentReceipt({
18
- intentId: i
17
+ const o = await e.waitIntentReceipt({
18
+ intentId: c
19
19
  });
20
20
  return r.console.log(
21
- `[trails-sdk] 📊 Intent ${i} status: ${n.intentReceipt.status}, done: ${n.done}`
22
- ), n;
21
+ `[trails-sdk] 📊 Intent ${c} status: ${o.intentReceipt.status}, done: ${o.done}`
22
+ ), o;
23
23
  },
24
- enabled: !!i,
24
+ enabled: !!c,
25
25
  refetchIntervalInBackground: !0,
26
- refetchInterval: (n) => {
27
- const s = n.state.data;
26
+ refetchInterval: (o) => {
27
+ const s = o.state.data;
28
28
  return s && s.done ? (r.console.log(
29
- `[trails-sdk] ✅ Intent monitoring complete for ${i}`
30
- ), !1) : B;
29
+ `[trails-sdk] ✅ Intent monitoring complete for ${c}`
30
+ ), !1) : J;
31
31
  },
32
- retry: (n, s) => n >= 30 ? (r.console.error(
33
- `[trails-sdk] ❌ Giving up on intent ${i} after 30 failed API attempts:`,
32
+ retry: (o, s) => o >= 30 ? (r.console.error(
33
+ `[trails-sdk] ❌ Giving up on intent ${c} after 30 failed API attempts:`,
34
34
  s
35
35
  ), !1) : !0
36
36
  });
@@ -42,76 +42,76 @@ const B = 150, ve = (i, e) => {
42
42
  error: t.error
43
43
  };
44
44
  };
45
- function ke() {
46
- const i = T();
47
- return F({
45
+ function we() {
46
+ const c = v();
47
+ return K({
48
48
  mutationFn: async (e) => {
49
49
  r.console.log("[trails-sdk] useCommitIntent: Starting commit", {
50
50
  intentId: e.intentId,
51
51
  originIntentAddress: e.originIntentAddress
52
52
  });
53
- const t = e.quoteRequest.originChainId.toString(), n = e.quoteRequest.destinationChainId.toString();
53
+ const t = e.quoteRequest.originChainId.toString(), o = e.quoteRequest.destinationChainId.toString();
54
54
  try {
55
- oe({
55
+ le({
56
56
  intentAddress: e.originIntentAddress,
57
57
  userAddress: e.ownerAddress,
58
58
  originChainId: t ? Number(t) : void 0,
59
- destinationChainId: n ? Number(n) : void 0
59
+ destinationChainId: o ? Number(o) : void 0
60
60
  });
61
- const s = await i.commitIntent({ intent: e });
61
+ const s = await c.commitIntent({ intent: e });
62
62
  return r.console.log("[trails-sdk] useCommitIntent: Commit successful", {
63
63
  intentId: e.intentId,
64
64
  response: s
65
- }), re({
65
+ }), ue({
66
66
  intentAddress: e.originIntentAddress,
67
67
  userAddress: e.ownerAddress,
68
68
  originChainId: t ? Number(t) : void 0,
69
- destinationChainId: n ? Number(n) : void 0
69
+ destinationChainId: o ? Number(o) : void 0
70
70
  }), s;
71
71
  } catch (s) {
72
- throw ae({
73
- error: h(s),
72
+ throw de({
73
+ error: A(s),
74
74
  userAddress: e.ownerAddress,
75
75
  intentAddress: e.originIntentAddress,
76
76
  originChainId: t ? Number(t) : void 0,
77
- destinationChainId: n ? Number(n) : void 0
77
+ destinationChainId: o ? Number(o) : void 0
78
78
  }), s;
79
79
  }
80
80
  }
81
81
  });
82
82
  }
83
- function ye() {
84
- const i = T();
85
- return F({
83
+ function Te() {
84
+ const c = v();
85
+ return K({
86
86
  mutationFn: async ({
87
87
  intentId: e,
88
88
  depositTransactionHash: t,
89
- depositSignature: n
89
+ depositSignature: o
90
90
  }) => {
91
91
  if (r.console.log("[trails-sdk] useExecuteIntent: Starting execution", {
92
92
  intentId: e,
93
93
  depositTransactionHash: t,
94
- hasDepositSignature: !!n
95
- }), !t && !n)
94
+ hasDepositSignature: !!o
95
+ }), !t && !o)
96
96
  throw new Error(
97
97
  "[trails-sdk] Either depositTransactionHash or depositSignature must be provided"
98
98
  );
99
99
  let s;
100
100
  try {
101
- s = await i.executeIntent({
101
+ s = await c.executeIntent({
102
102
  intentId: e,
103
103
  depositTransactionHash: t,
104
- depositSignature: n
104
+ depositSignature: o
105
105
  });
106
- } catch (c) {
106
+ } catch (l) {
107
107
  if (r.console.error(
108
108
  "[trails-sdk] useExecuteIntent: Error executing intent",
109
109
  {
110
110
  intentId: e,
111
- error: c,
112
- errorJSON: JSON.stringify(c, null, 2)
111
+ error: l,
112
+ errorJSON: JSON.stringify(l, null, 2)
113
113
  }
114
- ), c instanceof Error && c?.message?.includes("status=SUCCEEDED") || c instanceof Error && c?.cause?.message?.includes("status=SUCCEEDED") || c instanceof Error && JSON.stringify(c).includes("status=SUCCEEDED") || c instanceof ie && c?.cause?.toString().includes("status=SUCCEEDED") || JSON.stringify(c).includes("status=SUCCEEDED"))
114
+ ), l instanceof Error && l?.message?.includes("status=SUCCEEDED") || l instanceof Error && l?.cause?.message?.includes("status=SUCCEEDED") || l instanceof Error && JSON.stringify(l).includes("status=SUCCEEDED") || l instanceof ge && l?.cause?.toString().includes("status=SUCCEEDED") || JSON.stringify(l).includes("status=SUCCEEDED"))
115
115
  return r.console.error(
116
116
  "[trails-sdk] useExecuteIntent: Intent already succeeded, treating as success",
117
117
  { intentId: e }
@@ -123,10 +123,10 @@ function ye() {
123
123
  "[trails-sdk] useExecuteIntent did not throw IntentStatusError and is not a SUCCEEDED intent",
124
124
  {
125
125
  intentId: e,
126
- error: c,
127
- errorJSON: JSON.stringify(c, null, 2)
126
+ error: l,
127
+ errorJSON: JSON.stringify(l, null, 2)
128
128
  }
129
- ), c;
129
+ ), l;
130
130
  }
131
131
  return r.console.log(
132
132
  "[trails-sdk] useExecuteIntent: Execution successful",
@@ -138,212 +138,268 @@ function ye() {
138
138
  }
139
139
  });
140
140
  }
141
- function De({
142
- walletClient: i,
141
+ function Ne({
142
+ walletClient: c,
143
143
  fromTokenAddress: e,
144
144
  fromChainId: t,
145
- toTokenAddress: n,
145
+ toTokenAddress: o,
146
146
  toChainId: s,
147
- swapAmount: c,
147
+ swapAmount: l,
148
148
  tradeType: I,
149
- toRecipient: m,
150
- toCalldata: A,
151
- slippageTolerance: b,
152
- onStatusUpdate: Q,
153
- checkoutOnHandlers: _,
154
- quoteProvider: w,
155
- paymasterUrl: J,
156
- selectedFeeOption: U,
157
- nodeGatewayEnv: v,
158
- abortSignal: D,
159
- apiKey: $
149
+ toRecipient: p,
150
+ toCalldata: U,
151
+ slippageTolerance: D,
152
+ onStatusUpdate: j,
153
+ checkoutOnHandlers: W,
154
+ quoteProvider: R,
155
+ paymasterUrl: z,
156
+ selectedFeeOption: x,
157
+ nodeGatewayEnv: q,
158
+ abortSignal: L,
159
+ apiKey: V
160
160
  } = {}) {
161
- v && (globalThis.__testNodeGatewayEnv = v);
162
- const d = Ce(new AbortController()), G = D ? (() => {
161
+ q && (globalThis.__testNodeGatewayEnv = q);
162
+ const g = Se(new AbortController()), X = L ? (() => {
163
163
  const u = new AbortController();
164
- return D.addEventListener("abort", () => {
165
- u.abort(), d.current?.abort();
166
- }), d.current?.signal.addEventListener("abort", () => {
164
+ return L.addEventListener("abort", () => {
165
+ u.abort(), g.current?.abort();
166
+ }), g.current?.signal.addEventListener("abort", () => {
167
167
  u.abort();
168
168
  }), u.signal;
169
- })() : d.current.signal, { trailsApiKey: R, trailsApiUrl: K, sequenceIndexerUrl: j } = ce(), W = R, g = T({
170
- apiKey: R,
171
- hostname: K
172
- }), E = Ee(), { supportedTokens: p } = le(), z = ke(), V = ye(), { data: x, isLoading: X, error: q, refetch: Y } = P({
169
+ })() : g.current.signal, { trailsApiKey: O, trailsApiUrl: Y, sequenceIndexerUrl: Z } = me(), ee = O, m = v({
170
+ apiKey: O,
171
+ hostname: Y
172
+ }), S = ke(), N = Q(t ?? void 0), P = Q(s ?? void 0), { supportedTokens: f } = pe(), te = we(), ne = Te(), { data: M, isLoading: oe, error: H, refetch: se } = G({
173
173
  queryKey: [
174
174
  "prepareSend",
175
175
  e,
176
176
  t,
177
- n,
177
+ o,
178
178
  s,
179
- c?.toString(),
180
- m,
181
- A,
179
+ l?.toString(),
180
+ p,
181
+ U,
182
182
  I,
183
- b,
184
- w,
185
- $
183
+ D,
184
+ R,
185
+ V
186
186
  ],
187
187
  queryFn: async () => {
188
188
  try {
189
- if (d.current.signal.aborted && (r.console.log(
189
+ if (g.current.signal.aborted && (r.console.log(
190
190
  "[trails-sdk] Resetting aborted controller for new query"
191
- ), d.current = new AbortController()), !i || !g || !e || !n || !c || !m || !t || !s || !E)
191
+ ), g.current = new AbortController()), !c || !m || !e || !o || !l || !p || !t || !s || !S)
192
192
  return null;
193
193
  let u = [];
194
194
  try {
195
- u = (await ue({
196
- account: i.account.address,
197
- indexerGatewayClient: E,
198
- trailsClient: g
195
+ u = (await fe({
196
+ account: c.account.address,
197
+ indexerGatewayClient: S,
198
+ trailsClient: m
199
199
  })).balances;
200
- } catch (a) {
201
- const l = h(a), f = l.includes("Cross-Origin") || l.includes("CORS") || l.includes("Same Origin Policy"), se = l.includes("fetch failed") || l.includes("network");
202
- if (f || se)
200
+ } catch (n) {
201
+ const a = A(n), d = a.includes("Cross-Origin") || a.includes("CORS") || a.includes("Same Origin Policy"), k = a.includes("fetch failed") || a.includes("network");
202
+ if (d || k)
203
203
  r.console.warn(
204
204
  "[trails-sdk] [useQuote] Network or CORS error fetching balances, proceeding with quote using zero balance:",
205
205
  {
206
- error: l,
207
- account: i.account.address
206
+ error: a,
207
+ account: c.account.address
208
208
  }
209
209
  ), u = [];
210
210
  else
211
- throw a;
211
+ throw n;
212
212
  }
213
- const Z = u.find(
214
- (a) => a.chainId === t && (a.contractAddress?.toLowerCase() === e.toLowerCase() || !a.contractAddress && e === H)
213
+ const re = u.find(
214
+ (n) => n.chainId === t && (n.contractAddress?.toLowerCase() === e.toLowerCase() || !n.contractAddress && e === T)
215
215
  )?.balance ?? "0";
216
- let C = 0;
216
+ let b = 0;
217
217
  try {
218
- const l = de(t)?.nativeCurrency?.symbol ?? "";
219
- l && (C = (await ge(g, {
220
- tokenSymbol: l,
221
- tokenAddress: H,
218
+ const a = $(t)?.nativeCurrency?.symbol ?? "";
219
+ a && (b = (await Ce(m, {
220
+ tokenSymbol: a,
221
+ tokenAddress: T,
222
222
  chainId: t
223
223
  }))?.priceUsd ?? 0, r.console.log(
224
224
  "[trails-sdk] [useQuote] Origin native token price:",
225
225
  {
226
226
  chainId: t,
227
- symbol: l,
228
- priceUsd: C
227
+ symbol: a,
228
+ priceUsd: b
229
229
  }
230
230
  ));
231
- } catch (a) {
231
+ } catch (n) {
232
232
  r.console.error(
233
233
  "[trails-sdk] [useQuote] Error getting origin native token price:",
234
- a
234
+ n
235
235
  );
236
236
  }
237
- const k = p?.find(
238
- (a) => a.contractAddress?.toLowerCase() === e?.toLowerCase() && a.chainId === t
239
- ), y = p?.find(
240
- (a) => a.contractAddress?.toLowerCase() === n?.toLowerCase() && a.chainId === s
241
- ), O = k?.decimals;
242
- if (!O)
237
+ const B = async (n, a) => {
238
+ try {
239
+ const d = a === t ? N : a === s ? P : null;
240
+ if (!d)
241
+ return r.console.warn(
242
+ `[trails-sdk] No RPC client available for chain ${a}`
243
+ ), null;
244
+ if (n.toLowerCase() === T.toLowerCase())
245
+ return $(a)?.nativeCurrency.decimals ?? 18;
246
+ const k = await d.readContract({
247
+ address: n,
248
+ abi: be,
249
+ functionName: "decimals"
250
+ });
251
+ return r.console.log(
252
+ `[trails-sdk] Fetched decimals on-chain for token ${n} on chain ${a}: ${k}`
253
+ ), k;
254
+ } catch (d) {
255
+ return r.console.error(
256
+ `[trails-sdk] Error fetching decimals on-chain for token ${n} on chain ${a}:`,
257
+ d
258
+ ), null;
259
+ }
260
+ }, C = f?.find(
261
+ (n) => n.contractAddress?.toLowerCase() === e?.toLowerCase() && n.chainId === t
262
+ ), E = f?.find(
263
+ (n) => n.contractAddress?.toLowerCase() === o?.toLowerCase() && n.chainId === s
264
+ );
265
+ let y = C?.decimals;
266
+ if (!y && e && t) {
267
+ r.console.warn(
268
+ "[trails-sdk] [useQuote] Source token decimals not found in token list, fetching on-chain:",
269
+ {
270
+ originToken: C,
271
+ fromTokenAddress: e,
272
+ fromChainId: t
273
+ }
274
+ );
275
+ const n = await B(
276
+ e,
277
+ t
278
+ );
279
+ n !== null && (y = n);
280
+ }
281
+ if (!y)
243
282
  throw r.console.error(
244
- "[trails-sdk] [useQuote] Missing source token decimals:",
283
+ "[trails-sdk] [useQuote] Source token decimals not found:",
245
284
  {
246
- originToken: k,
285
+ originToken: C,
247
286
  fromTokenAddress: e,
248
287
  fromChainId: t
249
288
  }
250
289
  ), new Error("Source token decimals not found");
251
- const L = y?.decimals;
252
- if (!L)
290
+ let h = E?.decimals;
291
+ if (!h && o && s) {
292
+ r.console.warn(
293
+ "[trails-sdk] Destination token decimals not found in token list, fetching on-chain:",
294
+ {
295
+ destinationToken: E,
296
+ toTokenAddress: o,
297
+ toChainId: s
298
+ }
299
+ );
300
+ const n = await B(
301
+ o,
302
+ s
303
+ );
304
+ n !== null && (h = n);
305
+ }
306
+ if (!h)
253
307
  throw r.console.error(
254
- "[trails-sdk] Missing destination token decimals:",
308
+ "[trails-sdk] Destination token decimals not found:",
255
309
  {
256
- destinationToken: y,
257
- toTokenAddress: n,
310
+ destinationToken: E,
311
+ toTokenAddress: o,
258
312
  toChainId: s
259
313
  }
260
314
  ), new Error("Destination token decimals not found");
261
- const ee = y?.symbol ?? "", te = k?.symbol ?? "", M = {
262
- account: i.account,
315
+ const ie = E?.symbol ?? "", ae = C?.symbol ?? "", F = {
316
+ account: c.account,
263
317
  originTokenAddress: e,
264
318
  originChainId: t,
265
- originTokenBalance: Z,
319
+ originTokenBalance: re,
266
320
  destinationChainId: s,
267
- recipient: m,
268
- destinationTokenAddress: n,
269
- swapAmount: c.toString(),
270
- tradeType: I ?? me.EXACT_OUTPUT,
271
- originTokenSymbol: te,
272
- destinationTokenSymbol: ee,
273
- destinationCalldata: A,
274
- client: i,
275
- trailsClient: g,
276
- sourceTokenDecimals: O,
277
- destinationTokenDecimals: L,
321
+ recipient: p,
322
+ destinationTokenAddress: o,
323
+ swapAmount: l.toString(),
324
+ tradeType: I ?? Ee.EXACT_OUTPUT,
325
+ originTokenSymbol: ae,
326
+ destinationTokenSymbol: ie,
327
+ destinationCalldata: U,
328
+ client: c,
329
+ trailsClient: m,
330
+ sourceTokenDecimals: y,
331
+ destinationTokenDecimals: h,
278
332
  fee: "0",
279
333
  dryMode: !1,
280
- onTransactionStateChange: Q ?? (() => {
334
+ onTransactionStateChange: j ?? (() => {
281
335
  }),
282
- slippageTolerance: b?.toString(),
283
- quoteProvider: w,
284
- paymasterUrl: J,
285
- selectedFeeOption: U ?? null,
286
- abortSignal: G,
287
- originNativeTokenPriceUsd: C,
288
- commitIntentFn: z.mutateAsync,
289
- executeIntentFn: V.mutateAsync,
290
- checkoutOnHandlers: _,
291
- sequenceIndexerUrl: j,
292
- sequenceProjectAccessKey: W
336
+ slippageTolerance: D?.toString(),
337
+ quoteProvider: R,
338
+ paymasterUrl: z,
339
+ selectedFeeOption: x ?? null,
340
+ abortSignal: X,
341
+ originNativeTokenPriceUsd: b,
342
+ commitIntentFn: te.mutateAsync,
343
+ executeIntentFn: ne.mutateAsync,
344
+ checkoutOnHandlers: W,
345
+ sequenceIndexerUrl: Z,
346
+ sequenceProjectAccessKey: ee,
347
+ originPublicClient: N ?? void 0,
348
+ destinationPublicClient: P ?? void 0
293
349
  };
294
- r.console.log("[trails-sdk] options", M);
295
- const { quote: o, send: ne } = await pe(M);
350
+ r.console.log("[trails-sdk] options", F);
351
+ const { quote: i, send: ce } = await ye(F);
296
352
  return {
297
353
  quote: {
298
- fromAmount: o.originAmount,
299
- toAmount: o.destinationAmount,
300
- fromAmountMin: o.originAmountMin,
301
- toAmountMin: o.destinationAmountMin,
302
- originToken: o.originToken,
303
- destinationToken: o.destinationToken,
304
- originChain: o.originChain,
305
- destinationChain: o.destinationChain,
306
- fees: o.fees,
307
- priceImpact: o.priceImpact,
308
- completionEstimateSeconds: o.completionEstimateSeconds,
309
- slippageTolerance: o.slippageTolerance,
310
- transactionStates: o.transactionStates,
311
- originTokenRate: o.originTokenRate,
312
- destinationTokenRate: o.destinationTokenRate,
313
- quoteProvider: o.quoteProvider,
314
- fromAmountUsdDisplay: o.originAmountUsdDisplay ?? void 0,
315
- toAmountUsdDisplay: o.destinationAmountUsdDisplay ?? void 0,
316
- gasCostUsd: o.gasCostUsd ?? void 0,
317
- gasCostUsdDisplay: o.gasCostUsdDisplay ?? void 0,
318
- gasCost: o.gasCost ?? void 0,
319
- gasCostFormatted: o.gasCostFormatted ?? void 0
354
+ fromAmount: i.originAmount,
355
+ toAmount: i.destinationAmount,
356
+ fromAmountMin: i.originAmountMin,
357
+ toAmountMin: i.destinationAmountMin,
358
+ originToken: i.originToken,
359
+ destinationToken: i.destinationToken,
360
+ originChain: i.originChain,
361
+ destinationChain: i.destinationChain,
362
+ fees: i.fees,
363
+ priceImpact: i.priceImpact,
364
+ completionEstimateSeconds: i.completionEstimateSeconds,
365
+ slippageTolerance: i.slippageTolerance,
366
+ transactionStates: i.transactionStates,
367
+ originTokenRate: i.originTokenRate,
368
+ destinationTokenRate: i.destinationTokenRate,
369
+ quoteProvider: i.quoteProvider,
370
+ fromAmountUsdDisplay: i.originAmountUsdDisplay ?? void 0,
371
+ toAmountUsdDisplay: i.destinationAmountUsdDisplay ?? void 0,
372
+ gasCostUsd: i.gasCostUsd ?? void 0,
373
+ gasCostUsdDisplay: i.gasCostUsdDisplay ?? void 0,
374
+ gasCost: i.gasCost ?? void 0,
375
+ gasCostFormatted: i.gasCostFormatted ?? void 0
320
376
  },
321
377
  swap: async () => {
322
378
  const {
323
- depositUserTxnReceipt: a,
324
- destinationIntentTransaction: l,
325
- totalCompletionSeconds: f
326
- } = await ne({
327
- selectedFeeOption: U ?? null
379
+ depositUserTxnReceipt: n,
380
+ destinationIntentTransaction: a,
381
+ totalCompletionSeconds: d
382
+ } = await ce({
383
+ selectedFeeOption: x ?? null
328
384
  });
329
385
  return {
330
386
  originTransaction: {
331
- transactionHash: a?.transactionHash,
332
- explorerUrl: N({
333
- txHash: a?.transactionHash,
387
+ transactionHash: n?.transactionHash,
388
+ explorerUrl: _({
389
+ txHash: n?.transactionHash,
334
390
  chainId: t
335
391
  }),
336
- receipt: a
392
+ receipt: n
337
393
  },
338
394
  destinationTransaction: {
339
- transactionHash: l?.txnHash,
340
- explorerUrl: N({
341
- txHash: l?.txnHash,
395
+ transactionHash: a?.txnHash,
396
+ explorerUrl: _({
397
+ txHash: a?.txnHash,
342
398
  chainId: s
343
399
  }),
344
- receipt: l
400
+ receipt: a
345
401
  },
346
- totalCompletionSeconds: f
402
+ totalCompletionSeconds: d
347
403
  };
348
404
  }
349
405
  };
@@ -351,12 +407,12 @@ function De({
351
407
  throw r.console.error(
352
408
  "[trails-sdk] [useQuote] Error getting quote:",
353
409
  u
354
- ), h(u);
410
+ ), A(u);
355
411
  }
356
412
  },
357
413
  // Prevent unnecessary refetching
358
- enabled: !!(i && g && e && n && c && m && t && s && E && // !isLoadingTokens &&
359
- p && p.length > 0),
414
+ enabled: !!(c && m && e && o && l && p && t && s && S && // !isLoadingTokens &&
415
+ f && f.length > 0),
360
416
  staleTime: 30 * 1e3,
361
417
  // Consider data fresh for 30 seconds
362
418
  refetchOnWindowFocus: !1,
@@ -371,72 +427,74 @@ function De({
371
427
  // Refetch when network reconnects
372
428
  });
373
429
  return {
374
- quote: x?.quote || null,
375
- swap: x?.swap || null,
376
- isLoadingQuote: X,
377
- quoteError: q,
378
- quoteErrorPrettified: fe(q),
379
- refetchQuote: () => Y(),
430
+ quote: M?.quote || null,
431
+ swap: M?.swap || null,
432
+ isLoadingQuote: oe,
433
+ quoteError: H,
434
+ quoteErrorPrettified: he(H),
435
+ refetchQuote: () => se(),
380
436
  abort: () => {
381
437
  r.console.log("[trails-sdk] useQuote abort() called"), r.console.log(
382
438
  "[trails-sdk] Active operations before abort:",
383
- S.getAll()
384
- ), d.current.abort(), S.abortAll(), r.console.log(
439
+ w.getAll()
440
+ ), g.current.abort(), w.abortAll(), r.console.log(
385
441
  "[trails-sdk] Abort completed, active operations:",
386
- S.getAll()
442
+ w.getAll()
387
443
  );
388
444
  }
389
445
  };
390
446
  }
391
447
  export {
392
- qe as InsufficientBalanceError,
393
- Oe as TRAILS_ROUTER_PLACEHOLDER_AMOUNT,
394
- me as TradeType,
395
- Le as TrailsClient,
396
- Me as TrailsProvider,
397
- Ne as TrailsWidget,
398
- He as UserRejectionError,
399
- Be as calculateIntentAddress,
400
- Pe as calculateOriginAndDestinationIntentAddresses,
401
- Fe as commitIntent,
402
- Qe as createModalController,
403
- _e as getAccountTotalBalanceUsd,
404
- Je as getAccountTransactionHistory,
405
- $e as getAllChains,
406
- de as getChainInfo,
407
- Ge as getCommitHash,
408
- Ke as getDebug,
409
- je as getERC20TransferData,
410
- We as getHasSufficientBalanceToken,
411
- ze as getHasSufficientBalanceUsd,
412
- Ve as getIsUserRejectionError,
413
- Xe as getMinLogLevel,
414
- Ye as getRpcUrl,
415
- Ze as getSlippageTolerance,
416
- et as getSupportedChains,
417
- tt as getSupportedTokens,
418
- nt as getTrailsClient,
419
- st as getTxTimeDiff,
448
+ He as InsufficientBalanceError,
449
+ Be as TRAILS_ROUTER_PLACEHOLDER_AMOUNT,
450
+ Ee as TradeType,
451
+ Fe as TrailsClient,
452
+ Qe as TrailsProvider,
453
+ $e as TrailsWidget,
454
+ _e as UserRejectionError,
455
+ Je as calculateIntentAddress,
456
+ Ge as calculateOriginAndDestinationIntentAddresses,
457
+ Ke as commitIntent,
458
+ je as createModalController,
459
+ We as getAccountTotalBalanceUsd,
460
+ ze as getAccountTransactionHistory,
461
+ Ve as getAllChains,
462
+ $ as getChainInfo,
463
+ Xe as getChainRpcClient,
464
+ Ye as getCommitHash,
465
+ Ze as getDebug,
466
+ et as getERC20TransferData,
467
+ tt as getHasSufficientBalanceToken,
468
+ nt as getHasSufficientBalanceUsd,
469
+ ot as getIsUserRejectionError,
470
+ st as getMinLogLevel,
471
+ rt as getRpcUrl,
472
+ it as getSlippageTolerance,
473
+ at as getSupportedChains,
474
+ ct as getSupportedTokens,
475
+ lt as getTrailsClient,
476
+ ut as getTxTimeDiff,
420
477
  r as logger,
421
- ot as pollIntentReceipt,
422
- pe as prepareSend,
423
- rt as quoteIntent,
424
- at as sendOriginTransaction,
425
- it as useAccountTotalBalanceUsd,
426
- ct as useAccountTransactionHistory,
427
- ke as useCommitIntent,
428
- ye as useExecuteIntent,
429
- lt as useGetTokenImageUrl,
430
- ut as useHasSufficientBalanceToken,
431
- dt as useHasSufficientBalanceUsd,
432
- Ct as useIndexerGatewayClient,
433
- ve as useIntentReceiptMonitor,
434
- gt as useIntentTransactionHistory,
435
- De as useQuote,
436
- mt as useSupportedChains,
437
- le as useSupportedTokens,
438
- pt as useTokenBalances,
439
- ft as useTokenList,
440
- ce as useTrails,
441
- T as useTrailsClient
478
+ dt as pollIntentReceipt,
479
+ ye as prepareSend,
480
+ gt as quoteIntent,
481
+ mt as sendOriginTransaction,
482
+ pt as useAccountTotalBalanceUsd,
483
+ ft as useAccountTransactionHistory,
484
+ Q as useChainRpcClient,
485
+ we as useCommitIntent,
486
+ Te as useExecuteIntent,
487
+ Ct as useGetTokenImageUrl,
488
+ Et as useHasSufficientBalanceToken,
489
+ yt as useHasSufficientBalanceUsd,
490
+ Tt as useIndexerGatewayClient,
491
+ Oe as useIntentReceiptMonitor,
492
+ ht as useIntentTransactionHistory,
493
+ Ne as useQuote,
494
+ kt as useSupportedChains,
495
+ pe as useSupportedTokens,
496
+ St as useTokenBalances,
497
+ bt as useTokenList,
498
+ me as useTrails,
499
+ v as useTrailsClient
442
500
  };