0xtrails 0.1.13 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/dist/aave.d.ts.map +1 -1
  2. package/dist/analytics.d.ts +11 -2
  3. package/dist/analytics.d.ts.map +1 -1
  4. package/dist/apiClient.d.ts +1 -1
  5. package/dist/apiClient.d.ts.map +1 -1
  6. package/dist/{proxyCaller.d.ts → balanceInjector.d.ts} +5 -4
  7. package/dist/balanceInjector.d.ts.map +1 -0
  8. package/dist/{ccip-D3gTQONK.js → ccip-D6ToCrWc.js} +12 -12
  9. package/dist/cctp.d.ts.map +1 -1
  10. package/dist/cctpqueue.d.ts +3 -3
  11. package/dist/cctpqueue.d.ts.map +1 -1
  12. package/dist/chains.d.ts.map +1 -1
  13. package/dist/config.d.ts +17 -3
  14. package/dist/config.d.ts.map +1 -1
  15. package/dist/constants.d.ts +5 -4
  16. package/dist/constants.d.ts.map +1 -1
  17. package/dist/contractUtils.d.ts +2 -0
  18. package/dist/contractUtils.d.ts.map +1 -1
  19. package/dist/customChains.d.ts +24 -0
  20. package/dist/customChains.d.ts.map +1 -0
  21. package/dist/{index-CnUM7lKf.js → index-BqgeTLL8.js} +34072 -30146
  22. package/dist/index.d.ts +5 -3
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +411 -400
  25. package/dist/intentEntrypoint.d.ts +96 -0
  26. package/dist/intentEntrypoint.d.ts.map +1 -0
  27. package/dist/intents.d.ts +5 -3
  28. package/dist/intents.d.ts.map +1 -1
  29. package/dist/metaTxnMonitor.d.ts.map +1 -1
  30. package/dist/morpho.d.ts.map +1 -1
  31. package/dist/pools.d.ts +3 -1
  32. package/dist/pools.d.ts.map +1 -1
  33. package/dist/prepareSend.d.ts +8 -2
  34. package/dist/prepareSend.d.ts.map +1 -1
  35. package/dist/prices.d.ts +1 -1
  36. package/dist/prices.d.ts.map +1 -1
  37. package/dist/relaySdk.d.ts.map +1 -1
  38. package/dist/relayer.d.ts.map +1 -1
  39. package/dist/toast.d.ts +9 -0
  40. package/dist/toast.d.ts.map +1 -0
  41. package/dist/tokenBalances.d.ts +6 -2
  42. package/dist/tokenBalances.d.ts.map +1 -1
  43. package/dist/tokens.d.ts.map +1 -1
  44. package/dist/trails.d.ts +6 -5
  45. package/dist/trails.d.ts.map +1 -1
  46. package/dist/trailsClient.d.ts +12 -0
  47. package/dist/trailsClient.d.ts.map +1 -0
  48. package/dist/transactions.d.ts +8 -0
  49. package/dist/transactions.d.ts.map +1 -1
  50. package/dist/wallets.d.ts.map +1 -1
  51. package/dist/widget/components/AccountActionsDropdown.d.ts.map +1 -1
  52. package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
  53. package/dist/widget/components/AccountSettings.d.ts +7 -0
  54. package/dist/widget/components/AccountSettings.d.ts.map +1 -0
  55. package/dist/widget/components/ChainList.d.ts +0 -1
  56. package/dist/widget/components/ChainList.d.ts.map +1 -1
  57. package/dist/widget/components/ClassicSwap.d.ts +46 -0
  58. package/dist/widget/components/ClassicSwap.d.ts.map +1 -0
  59. package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
  60. package/dist/widget/components/ConnectedWallets.d.ts +9 -0
  61. package/dist/widget/components/ConnectedWallets.d.ts.map +1 -0
  62. package/dist/widget/components/DebugMenu.d.ts.map +1 -1
  63. package/dist/widget/components/DebugScreensList.d.ts.map +1 -1
  64. package/dist/widget/components/DebugToast.d.ts +3 -0
  65. package/dist/widget/components/DebugToast.d.ts.map +1 -0
  66. package/dist/widget/components/Earn.d.ts.map +1 -1
  67. package/dist/widget/components/EarnPools.d.ts.map +1 -1
  68. package/dist/widget/components/Fund.d.ts +44 -0
  69. package/dist/widget/components/Fund.d.ts.map +1 -0
  70. package/dist/widget/components/Identicon.d.ts +9 -0
  71. package/dist/widget/components/Identicon.d.ts.map +1 -0
  72. package/dist/widget/components/Pay.d.ts +46 -0
  73. package/dist/widget/components/Pay.d.ts.map +1 -0
  74. package/dist/widget/components/Receive.d.ts.map +1 -1
  75. package/dist/widget/components/RecentTokens.d.ts.map +1 -1
  76. package/dist/widget/components/Recipients.d.ts +9 -0
  77. package/dist/widget/components/Recipients.d.ts.map +1 -0
  78. package/dist/widget/components/RefundWarning.d.ts +9 -0
  79. package/dist/widget/components/RefundWarning.d.ts.map +1 -0
  80. package/dist/widget/components/SimpleSwap.d.ts.map +1 -1
  81. package/dist/widget/components/Swap.d.ts.map +1 -1
  82. package/dist/widget/components/SwapSettings.d.ts +1 -5
  83. package/dist/widget/components/SwapSettings.d.ts.map +1 -1
  84. package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
  85. package/dist/widget/components/ThemeSyncer.d.ts +6 -0
  86. package/dist/widget/components/ThemeSyncer.d.ts.map +1 -0
  87. package/dist/widget/components/Toast.d.ts +24 -0
  88. package/dist/widget/components/Toast.d.ts.map +1 -0
  89. package/dist/widget/components/TokenList.d.ts.map +1 -1
  90. package/dist/widget/components/TransactionDetails.d.ts.map +1 -1
  91. package/dist/widget/components/TruncatedAddress.d.ts +2 -0
  92. package/dist/widget/components/TruncatedAddress.d.ts.map +1 -1
  93. package/dist/widget/components/UserPreferences.d.ts +7 -0
  94. package/dist/widget/components/UserPreferences.d.ts.map +1 -0
  95. package/dist/widget/hooks/useBalanceVisible.d.ts +1 -0
  96. package/dist/widget/hooks/useBalanceVisible.d.ts.map +1 -1
  97. package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
  98. package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
  99. package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
  100. package/dist/widget/hooks/useDebugScreens.d.ts +1 -1
  101. package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
  102. package/dist/widget/hooks/useDefaultTokenSelection.d.ts +54 -0
  103. package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -0
  104. package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
  105. package/dist/widget/hooks/usePayMessage.d.ts +34 -0
  106. package/dist/widget/hooks/usePayMessage.d.ts.map +1 -0
  107. package/dist/widget/hooks/useRecipients.d.ts +17 -0
  108. package/dist/widget/hooks/useRecipients.d.ts.map +1 -0
  109. package/dist/widget/hooks/useSelectedRecipient.d.ts +12 -0
  110. package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -0
  111. package/dist/widget/hooks/useSendForm.d.ts +2 -0
  112. package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
  113. package/dist/widget/hooks/useSwapAmount.d.ts +13 -0
  114. package/dist/widget/hooks/useSwapAmount.d.ts.map +1 -0
  115. package/dist/widget/hooks/useSwapSettings.d.ts +16 -0
  116. package/dist/widget/hooks/useSwapSettings.d.ts.map +1 -0
  117. package/dist/widget/hooks/useTargetAmount.d.ts +5 -0
  118. package/dist/widget/hooks/useTargetAmount.d.ts.map +1 -0
  119. package/dist/widget/hooks/useTheme.d.ts +14 -0
  120. package/dist/widget/hooks/useTheme.d.ts.map +1 -0
  121. package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
  122. package/dist/widget/index.js +2 -2
  123. package/dist/widget/widget.d.ts +9 -0
  124. package/dist/widget/widget.d.ts.map +1 -1
  125. package/package.json +29 -28
  126. package/src/aave.ts +6 -1
  127. package/src/analytics.ts +103 -53
  128. package/src/apiClient.ts +1 -1
  129. package/src/{proxyCaller.ts → balanceInjector.ts} +22 -17
  130. package/src/cctp.ts +6 -2
  131. package/src/cctpqueue.ts +7 -7
  132. package/src/chains.ts +8 -0
  133. package/src/config.ts +40 -9
  134. package/src/constants.ts +11 -8
  135. package/src/contractUtils.ts +33 -2
  136. package/src/customChains.ts +24 -0
  137. package/src/index.ts +11 -1
  138. package/src/intentEntrypoint.ts +253 -0
  139. package/src/intents.ts +87 -54
  140. package/src/metaTxnMonitor.ts +1 -0
  141. package/src/morpho.ts +13 -2
  142. package/src/pools.ts +68 -86
  143. package/src/prepareSend.ts +437 -207
  144. package/src/prices.ts +51 -7
  145. package/src/relaySdk.ts +6 -4
  146. package/src/relayer.ts +2 -0
  147. package/src/toast.ts +110 -0
  148. package/src/tokenBalances.ts +112 -20
  149. package/src/tokens.ts +70 -7
  150. package/src/trails.ts +80 -77
  151. package/src/trailsClient.ts +45 -0
  152. package/src/transactions.ts +27 -35
  153. package/src/umd.tsx +1 -1
  154. package/src/wallets.ts +2 -1
  155. package/src/widget/assets/sequence-logo.svg +15 -0
  156. package/src/widget/compiled.css +2 -2
  157. package/src/widget/components/AccountActionsDropdown.tsx +18 -159
  158. package/src/widget/components/AccountIntentTransactionHistory.tsx +346 -63
  159. package/src/widget/components/AccountSettings.tsx +96 -0
  160. package/src/widget/components/ChainFilterDropdown.tsx +1 -1
  161. package/src/widget/components/ChainList.tsx +10 -20
  162. package/src/widget/components/ClassicSwap.tsx +923 -0
  163. package/src/widget/components/ConfigDisplay.tsx +8 -5
  164. package/src/widget/components/ConnectedWallets.tsx +260 -0
  165. package/src/widget/components/DebugMenu.tsx +2 -0
  166. package/src/widget/components/DebugScreensList.tsx +3 -0
  167. package/src/widget/components/DebugToast.tsx +63 -0
  168. package/src/widget/components/Earn.tsx +108 -116
  169. package/src/widget/components/EarnPools.tsx +2 -4
  170. package/src/widget/components/EarnPoolsFilters.tsx +6 -6
  171. package/src/widget/components/Fund.tsx +1245 -0
  172. package/src/widget/components/FundMethods.tsx +1 -1
  173. package/src/widget/components/FundSendForm.tsx +1 -1
  174. package/src/widget/components/Identicon.tsx +158 -0
  175. package/src/widget/components/Pay.tsx +1088 -0
  176. package/src/widget/components/PaySendForm.tsx +1 -1
  177. package/src/widget/components/QuoteDetails.tsx +1 -1
  178. package/src/widget/components/Receipt.tsx +1 -1
  179. package/src/widget/components/Receive.tsx +4 -2
  180. package/src/widget/components/RecentTokens.tsx +2 -1
  181. package/src/widget/components/Recipients.tsx +448 -0
  182. package/src/widget/components/RefundWarning.tsx +61 -0
  183. package/src/widget/components/ScreenHeader.tsx +1 -1
  184. package/src/widget/components/SimpleSwap.tsx +74 -58
  185. package/src/widget/components/Swap.tsx +35 -853
  186. package/src/widget/components/SwapSettings.tsx +5 -11
  187. package/src/widget/components/ThemeProvider.tsx +32 -0
  188. package/src/widget/components/ThemeSyncer.tsx +47 -0
  189. package/src/widget/components/Toast.tsx +315 -0
  190. package/src/widget/components/TokenList.tsx +2 -34
  191. package/src/widget/components/TokenSelector.tsx +3 -3
  192. package/src/widget/components/TransactionDetails.tsx +153 -13
  193. package/src/widget/components/TruncatedAddress.tsx +5 -1
  194. package/src/widget/components/UserPreferences.tsx +156 -0
  195. package/src/widget/components/WalletList.tsx +1 -1
  196. package/src/widget/hooks/useBalanceVisible.tsx +40 -2
  197. package/src/widget/hooks/useCheckout.ts +13 -0
  198. package/src/widget/hooks/useCurrentScreen.tsx +3 -0
  199. package/src/widget/hooks/useDebugScreens.ts +12 -2
  200. package/src/widget/hooks/useDefaultTokenSelection.tsx +475 -0
  201. package/src/widget/hooks/useIntentTransactionHistory.ts +212 -0
  202. package/src/widget/hooks/usePayMessage.tsx +370 -0
  203. package/src/widget/hooks/useRecipients.ts +168 -0
  204. package/src/widget/hooks/useSelectedRecipient.tsx +48 -0
  205. package/src/widget/hooks/useSendForm.ts +179 -26
  206. package/src/widget/hooks/useSwapAmount.tsx +50 -0
  207. package/src/widget/hooks/useSwapSettings.tsx +100 -0
  208. package/src/widget/hooks/useTargetAmount.ts +23 -0
  209. package/src/widget/hooks/useTheme.tsx +80 -0
  210. package/src/widget/hooks/useTokenList.ts +20 -11
  211. package/src/widget/index.css +45 -21
  212. package/src/widget/widget.tsx +164 -68
  213. package/dist/address.d.ts +0 -2
  214. package/dist/address.d.ts.map +0 -1
  215. package/dist/proxyCaller.d.ts.map +0 -1
  216. package/src/address.ts +0 -6
package/dist/index.js CHANGED
@@ -1,53 +1,55 @@
1
- import { u as Pn, a as xn, l as t, c as Pe, f as Mn, b as L, T as xe, d as Me, e as Re, g as Oe, i as Rn, j as On, k as ce, q as Nn, m as qn, n as Ne } from "./index-CnUM7lKf.js";
2
- import { P as Jn, z as Xn, ab as Zn, v as et, aa as nt, U as tt, o as st, E as it, B as ot, a8 as rt, F as at, G as ct, s as lt, A as dt, S as ut, a9 as gt, Q as ft, W as ht, Y as mt, X as It, a1 as vt, V as pt, a6 as Tt, p as St, L as At, O as Ct, a4 as wt, x as yt, R as kt, w as bt, a7 as Et, _ as Pt, a2 as xt, $ as Mt, a0 as Rt, Z as Ot, a5 as Nt, a3 as qt, H as $t, C as Ft, I as Dt, J as Ht, t as Ut, D as Lt, y as Bt, r as Gt, M as jt, K as _t, N as Wt } from "./index-CnUM7lKf.js";
3
- import { useMutation as Ae, useQuery as $n } from "@tanstack/react-query";
4
- import { useState as c, useCallback as qe, useEffect as b, useMemo as Fn, useRef as $e } from "react";
5
- import { isAddressEqual as ee, zeroAddress as Fe, isAddress as Dn, createPublicClient as De, http as He, createWalletClient as Ue, custom as Le } from "viem";
6
- import { useSwitchChain as Hn, useSendTransaction as Un, useEstimateGas as Ln, useWaitForTransactionReceipt as Bn } from "wagmi";
7
- const Be = 1e4;
8
- function Kn(Ge) {
1
+ import { u as bn, a as En, l as t, c as Pe, f as Pn, b as B, S as xe, d as Me, e as xn, h as Mn, i as ce, q as On, j as qn, k as Oe } from "./index-BqgeTLL8.js";
2
+ import { O as zn, T as Yn, ad as Jn, af as Xn, v as Zn, ae as et, U as nt, m as tt, D as st, A as it, r as at, aa as ot, E as rt, F as ct, s as lt, z as dt, R as ut, ab as gt, P as mt, W as ft, Z as ht, Y as It, a3 as pt, V as vt, a8 as Tt, o as Ct, K as St, X as At, ac as yt, N as wt, a6 as kt, x as bt, Q as Et, w as Pt, a9 as xt, $ as Mt, a4 as Ot, a1 as qt, a2 as Rt, _ as $t, a7 as Nt, a0 as Ft, a5 as Ht, n as Ut, G as Dt, B as Bt, H as jt, I as Gt, t as Lt, C as _t, y as Wt, p as Qt, L as Vt, J as Kt, M as zt } from "./index-BqgeTLL8.js";
3
+ import { useMutation as Se, useQuery as Rn } from "@tanstack/react-query";
4
+ import { useState as c, useCallback as qe, useEffect as b, useMemo as $n, useRef as Re } from "react";
5
+ import { isAddressEqual as ee, zeroAddress as $e, isAddress as Nn, createPublicClient as Ne, http as Fe, createWalletClient as He, custom as Ue } from "viem";
6
+ import { useSwitchChain as Fn, useSendTransaction as Hn, useEstimateGas as Un, useWaitForTransactionReceipt as Dn } from "wagmi";
7
+ const De = 1e4;
8
+ function Qn(Be) {
9
9
  const {
10
10
  account: d,
11
11
  disableAutoExecute: je = !1,
12
- env: _e,
13
- sequenceProjectAccessKey: We
14
- } = Ge, A = Pn({ projectAccessKey: We }), [x, ne] = c(!je), [le, de] = c(!1), [B, Ce] = c(
12
+ env: Ge,
13
+ sequenceProjectAccessKey: Le
14
+ } = Be, S = bn({
15
+ projectAccessKey: Le
16
+ }), [x, ne] = c(!je), [le, de] = c(!1), [j, Ae] = c(
15
17
  {}
16
- ), [u, R] = c(null), [w, O] = c(null), [p, N] = c(null), [C, G] = c(null), [T, ue] = c(), [q, j] = c(null), [
17
- Ve,
18
+ ), [u, O] = c(null), [y, q] = c(null), [v, R] = c(null), [A, G] = c(null), [T, ue] = c(), [$, L] = c(null), [
19
+ _e,
18
20
  _
19
- ] = c(null), [$, W] = c(
21
+ ] = c(null), [N, W] = c(
20
22
  null
21
- ), [Qe, V] = c(null), [i, Q] = c(null), [Ke, we] = c({}), [te, se] = c(!1), [ye, K] = c(!1), {
22
- switchChain: Ye,
23
- isPending: ze,
24
- error: Y
25
- } = Hn(), E = Un(), [Je, ke] = c(!1), [y, M] = c(null), [Xe, F] = c(null), [ge, z] = c({}), [Ze, ie] = c(null), { getRelayer: fe, relayers: en } = xn({
26
- env: _e
23
+ ), [We, Q] = c(null), [i, V] = c(null), [Qe, ye] = c({}), [te, se] = c(!1), [we, K] = c(!1), {
24
+ switchChain: Ve,
25
+ isPending: Ke,
26
+ error: z
27
+ } = Fn(), E = Hn(), [ze, ke] = c(!1), [w, M] = c(null), [Ye, F] = c(null), [ge, Y] = c({}), [Je, ie] = c(null), { getRelayer: me, relayers: Xe } = En({
28
+ env: Ge
27
29
  }), {
28
- data: oe,
29
- isError: he,
30
- error: me
31
- } = Ln(
30
+ data: ae,
31
+ isError: fe,
32
+ error: he
33
+ } = Un(
32
34
  i?.to && i?.chainId && !i.error ? {
33
35
  to: i.to || void 0,
34
36
  data: i.data || void 0,
35
37
  value: i.value || void 0,
36
38
  chainId: i.chainId || void 0
37
39
  } : void 0
38
- ), I = Ae({
40
+ ), I = Se({
39
41
  mutationFn: async (e) => {
40
42
  if (t.console.log(
41
43
  "[useTrails] commitIntentConfigMutation started with args:",
42
44
  e
43
- ), !A)
45
+ ), !S)
44
46
  throw t.console.error("[useTrails] API client not available"), new Error("API client not available");
45
47
  if (!e.quoteProvider)
46
48
  throw t.console.error("[useTrails] quoteProvider is required"), new Error("quoteProvider is required");
47
49
  try {
48
50
  t.console.log("[useTrails] Calculating intent address..."), t.console.log("[useTrails] Main signer:", e.mainSignerAddress), t.console.log("[useTrails] Calls:", e.calls);
49
- const n = g.variables?.originChainId, o = g.variables?.destinationChainId;
50
- if (!n || !o)
51
+ const n = g.variables?.params.originChainId, a = g.variables?.params.destinationChainId;
52
+ if (!n || !a)
51
53
  throw t.console.error(
52
54
  "[useTrails] Could not determine origin/destination chain IDs for verification."
53
55
  ), new Error(
@@ -57,64 +59,64 @@ function Kn(Ge) {
57
59
  e.mainSignerAddress,
58
60
  e.calls
59
61
  ), {
60
- originAddress: a,
61
- destinationAddress: f
62
- } = Mn(
62
+ originAddress: r,
63
+ destinationAddress: m
64
+ } = Pn(
63
65
  e.preconditions,
64
66
  n,
65
- o
67
+ a
66
68
  );
67
69
  t.console.log("[useTrails] Verification addresses:", {
68
70
  calculatedOrigin: l.toString(),
69
71
  calculatedDestination: s.toString(),
70
- preconditionOrigin: a,
71
- preconditionDestination: f
72
+ preconditionOrigin: r,
73
+ preconditionDestination: m
72
74
  });
73
- const h = !!a && ee(
74
- L(a),
75
+ const f = !!r && ee(
76
+ B(r),
75
77
  l
76
78
  );
77
- t.console.log("[useTrails] Origin verified:", h);
78
- const r = f && ee(
79
- L(f),
79
+ t.console.log("[useTrails] Origin verified:", f);
80
+ const o = m && ee(
81
+ B(m),
80
82
  s
81
- ) || !f && n === o && ee(s, Fe);
83
+ ) || !m && n === a && ee(s, $e);
82
84
  t.console.log(
83
85
  "[useTrails] Destination verified:",
84
- r
86
+ o
85
87
  );
86
- const m = h && r;
88
+ const h = f && o;
87
89
  if (ie({
88
- success: m,
89
- receivedOriginAddress: a,
90
- receivedDestinationAddress: f,
90
+ success: h,
91
+ receivedOriginAddress: r,
92
+ receivedDestinationAddress: m,
91
93
  calculatedOriginAddress: l.toString(),
92
94
  calculatedDestinationAddress: s.toString()
93
- }), !m)
95
+ }), !h)
94
96
  throw t.console.error("[useTrails] Address verification failed.", {
95
- isOriginVerified: h,
96
- isDestinationVerified: r
97
+ isOriginVerified: f,
98
+ isDestinationVerified: o
97
99
  }), new Error(
98
- `Address verification failed. Origin verified: ${h}, Destination verified: ${r}`
100
+ `Address verification failed. Origin verified: ${f}, Destination verified: ${o}`
99
101
  );
100
102
  t.console.log("[useTrails] Committing intent config to API...");
101
- const v = await A.commitIntentConfig({
102
- originIntentAddress: l.toString(),
103
- destinationIntentAddress: s.toString(),
104
- mainSigner: e.mainSignerAddress,
105
- calls: e.calls,
106
- preconditions: e.preconditions,
107
- addressOverrides: {
108
- trailsLiFiSapientSignerAddress: Re,
109
- trailsRelaySapientSignerAddress: Me,
110
- trailsCCTPV2SapientSignerAddress: xe,
111
- ...e.addressOverrides
103
+ const p = await S.commitIntentConfig({
104
+ params: {
105
+ originIntentAddress: l.toString(),
106
+ destinationIntentAddress: s.toString(),
107
+ mainSigner: e.mainSignerAddress,
108
+ calls: e.calls,
109
+ preconditions: e.preconditions,
110
+ addressOverrides: {
111
+ ...xe,
112
+ ...e.addressOverrides
113
+ }
112
114
  }
113
115
  });
114
- return t.console.log("[useTrails] API Commit Response:", v), {
116
+ return t.console.log("[useTrails] API Commit Response:", p), {
115
117
  originIntentAddress: l.toString(),
116
118
  destinationIntentAddress: s.toString(),
117
- response: v
119
+ response: p
118
120
  };
119
121
  } catch (n) {
120
122
  throw console.error("[useTrails] Error during commit intent mutation:", n), n;
@@ -127,77 +129,77 @@ function Kn(Ge) {
127
129
  ), t.console.log(
128
130
  "[useTrails] Setting committedOriginIntentAddress:",
129
131
  e.originIntentAddress
130
- ), j(e.originIntentAddress), _(e.destinationIntentAddress);
132
+ ), L(e.originIntentAddress), _(e.destinationIntentAddress);
131
133
  },
132
134
  onError: (e) => {
133
- t.console.error("[useTrails] Failed to commit intent config:", e), j(null), _(null);
135
+ t.console.error("[useTrails] Failed to commit intent config:", e), L(null), _(null);
134
136
  }
135
137
  }), {
136
- data: nn,
137
- isLoading: tn,
138
- error: sn
139
- } = $n({
140
- queryKey: ["getIntentConfig", q],
138
+ data: Ze,
139
+ isLoading: en,
140
+ error: nn
141
+ } = Rn({
142
+ queryKey: ["getIntentConfig", $],
141
143
  queryFn: async () => {
142
- if (!A || !q)
144
+ if (!S || !$)
143
145
  throw new Error("API client or committed intent address not available");
144
146
  return t.console.log(
145
147
  "Fetching intent config for address:",
146
- q
147
- ), await A.getIntentConfig({
148
- intentAddress: q
148
+ $
149
+ ), await S.getIntentConfig({
150
+ intentAddress: $
149
151
  });
150
152
  },
151
- enabled: !!q && !!A && I.isSuccess,
153
+ enabled: !!$ && !!S && I.isSuccess,
152
154
  staleTime: 1e3 * 60 * 5,
153
155
  // 5 minutes
154
156
  retry: 1
155
157
  });
156
158
  async function be(e) {
157
- return qn(A, {
158
- ...e,
159
- addressOverrides: {
160
- trailsLiFiSapientSignerAddress: Re,
161
- trailsRelaySapientSignerAddress: Me,
162
- trailsCCTPV2SapientSignerAddress: xe,
163
- ...e.addressOverrides
159
+ return qn(S, {
160
+ params: {
161
+ ...e.params,
162
+ addressOverrides: {
163
+ ...xe,
164
+ ...e.params.addressOverrides
165
+ }
164
166
  }
165
167
  });
166
168
  }
167
- const g = Ae({
169
+ const g = Se({
168
170
  mutationFn: async (e) => {
169
- if (e.originChainId === e.destinationChainId && ee(
170
- L(e.originTokenAddress),
171
- L(e.destinationTokenAddress)
171
+ if (e.params.originChainId === e.params.destinationChainId && ee(
172
+ B(e.params.originTokenAddress),
173
+ B(e.params.destinationTokenAddress)
172
174
  ))
173
175
  throw new Error(
174
176
  "The same token cannot be used as both the source and destination token."
175
177
  );
176
178
  if (!d.address)
177
179
  throw new Error("Missing selected token or account address");
178
- j(null), _(null), ie(null), G(null), R(null), O(null), N(null), W(null), V(null);
180
+ L(null), _(null), ie(null), G(null), O(null), q(null), R(null), W(null), Q(null);
179
181
  const n = await be(e);
180
- return R(n.metaTxns), O(n.calls), N(n.preconditions), G(n.trailsFee), W(n.originIntentAddress), V(n.destinationIntentAddress), j(null), _(null), ie(null), n;
182
+ return O(n.payloads.metaTxns), q(n.payloads.calls), R(n.payloads.preconditions), G(n.payloads.trailsFee), W(n.payloads.originIntentAddress), Q(n.payloads.destinationIntentAddress), L(null), _(null), ie(null), n;
181
183
  },
182
184
  onSuccess: (e) => {
183
- t.console.log("Intent Config Success:", e), G(e.trailsFee || null), W(e.originIntentAddress), V(e.destinationIntentAddress), e?.calls && e.calls.length > 0 && e.preconditions && e.preconditions.length > 0 && e.metaTxns && e.metaTxns.length > 0 ? (O(e.calls), N(e.preconditions), R(e.metaTxns)) : (t.console.warn("API returned success but no operations found."), O(null), N(null), R(null));
185
+ t.console.log("Intent Config Success:", e), G(e.payloads.trailsFee || null), W(e.payloads.originIntentAddress), Q(e.payloads.destinationIntentAddress), e.payloads?.calls && e.payloads.calls.length > 0 && e.payloads.preconditions && e.payloads.preconditions.length > 0 && e.payloads.metaTxns && e.payloads.metaTxns.length > 0 ? (q(e.payloads.calls), R(e.payloads.preconditions), O(e.payloads.metaTxns)) : (t.console.warn("API returned success but no operations found."), q(null), R(null), O(null));
184
186
  },
185
187
  onError: (e) => {
186
- console.error("Intent Config Error:", e), O(null), N(null), R(null), G(null), W(null), V(null);
188
+ console.error("Intent Config Error:", e), q(null), R(null), O(null), G(null), W(null), Q(null);
187
189
  }
188
190
  });
189
- function on(e) {
191
+ function tn(e) {
190
192
  g.mutate(e);
191
193
  }
192
- const rn = qe(() => {
193
- t.console.log("[Trails] Clearing intent state"), O(null), N(null), R(null), G(null), j(null), _(null), ie(null), W(null), V(null), we({}), de(!1), z({});
194
+ const sn = qe(() => {
195
+ t.console.log("[Trails] Clearing intent state"), q(null), R(null), O(null), G(null), L(null), _(null), ie(null), W(null), Q(null), ye({}), de(!1), Y({});
194
196
  }, []), k = qe(
195
- (e, n, o, l, s) => {
197
+ (e, n, a, l, s) => {
196
198
  M({
197
199
  txnHash: e,
198
200
  status: n === "success" ? "Success" : n === "reverted" ? "Failed" : n === "sending" ? "Sending..." : "Pending",
199
201
  revertReason: n === "reverted" ? s || "Transaction reverted" : void 0,
200
- gasUsed: o ? Number(o) : void 0,
202
+ gasUsed: a ? Number(a) : void 0,
201
203
  effectiveGasPrice: l?.toString()
202
204
  });
203
205
  },
@@ -233,13 +235,13 @@ function Kn(Ge) {
233
235
  void 0,
234
236
  `Switching to chain ${i.chainId}...`
235
237
  );
236
- const e = Ue({
238
+ const e = He({
237
239
  chain: ce(i.chainId),
238
- transport: Le(await d.connector.getProvider())
240
+ transport: Ue(await d.connector.getProvider())
239
241
  // TODO: Add proper type
240
242
  });
241
243
  try {
242
- await Ne({
244
+ await Oe({
243
245
  walletClient: e,
244
246
  desiredChainId: i.chainId
245
247
  }), K(!1);
@@ -259,21 +261,21 @@ function Kn(Ge) {
259
261
  "Transaction already in progress. Skipping duplicate request."
260
262
  );
261
263
  else {
262
- if (se(!0), ue(void 0), k(void 0, "sending"), !oe && !he) {
264
+ if (se(!0), ue(void 0), k(void 0, "sending"), !ae && !fe) {
263
265
  ke(!0);
264
266
  return;
265
267
  }
266
- if (he) {
267
- t.console.error("Gas estimation failed:", me), k(
268
+ if (fe) {
269
+ t.console.error("Gas estimation failed:", he), k(
268
270
  void 0,
269
271
  "reverted",
270
272
  void 0,
271
273
  void 0,
272
- `Gas estimation failed: ${me?.message}`
274
+ `Gas estimation failed: ${he?.message}`
273
275
  ), se(!1);
274
276
  return;
275
277
  }
276
- const e = oe ? BigInt(Math.floor(Number(oe) * 1.2)) : void 0;
278
+ const e = ae ? BigInt(Math.floor(Number(ae) * 1.2)) : void 0;
277
279
  E.sendTransaction(
278
280
  {
279
281
  to: i.to,
@@ -300,14 +302,14 @@ function Kn(Ge) {
300
302
  }
301
303
  };
302
304
  b(() => {
303
- Y && (t.console.error("Chain switch error:", Y), k(
305
+ z && (t.console.error("Chain switch error:", z), k(
304
306
  void 0,
305
307
  "reverted",
306
308
  void 0,
307
309
  void 0,
308
- `Chain switch failed: ${Y.message || "Unknown error"}`
310
+ `Chain switch failed: ${z.message || "Unknown error"}`
309
311
  ), K(!1));
310
- }, [Y, k]), b(() => {
312
+ }, [z, k]), b(() => {
311
313
  ke(!1);
312
314
  }, []), b(() => {
313
315
  i?.chainId && d.chainId === i.chainId && (t.console.log("No chain switch required"), K(!1));
@@ -315,13 +317,13 @@ function Kn(Ge) {
315
317
  if (i?.chainId && d.chainId !== i.chainId) {
316
318
  async function e() {
317
319
  try {
318
- const n = i.chainId, o = Ue({
320
+ const n = i.chainId, a = He({
319
321
  chain: ce(n),
320
- transport: Le(await d.connector.getProvider())
322
+ transport: Ue(await d.connector.getProvider())
321
323
  // TODO: Add proper type
322
324
  });
323
- await Ne({
324
- walletClient: o,
325
+ await Oe({
326
+ walletClient: a,
325
327
  desiredChainId: n
326
328
  });
327
329
  } catch (n) {
@@ -332,12 +334,12 @@ function Kn(Ge) {
332
334
  }
333
335
  }, [d, i]);
334
336
  const {
335
- data: S,
336
- isLoading: D,
337
+ data: C,
338
+ isLoading: H,
337
339
  isSuccess: Ie,
338
- isError: ve,
339
- error: re
340
- } = Bn({
340
+ isError: pe,
341
+ error: oe
342
+ } = Dn({
341
343
  hash: T,
342
344
  confirmations: 1,
343
345
  query: {
@@ -346,11 +348,11 @@ function Kn(Ge) {
346
348
  });
347
349
  b(() => {
348
350
  if (!T) {
349
- y?.txnHash && M(null), F(null), Object.keys(B).length > 0 && Ce({});
351
+ w?.txnHash && M(null), F(null), Object.keys(j).length > 0 && Ae({});
350
352
  return;
351
353
  }
352
- if (!(y?.txnHash === T && (y?.status === "Success" || y?.status === "Failed") && !D)) {
353
- if (D) {
354
+ if (!(w?.txnHash === T && (w?.status === "Success" || w?.status === "Failed") && !H)) {
355
+ if (H) {
354
356
  M((e) => ({
355
357
  ...e?.txnHash === T ? e : {
356
358
  gasUsed: void 0,
@@ -362,15 +364,15 @@ function Kn(Ge) {
362
364
  }));
363
365
  return;
364
366
  }
365
- if (Ie && S) {
366
- const e = S.status === "success" ? "Success" : "Failed";
367
+ if (Ie && C) {
368
+ const e = C.status === "success" ? "Success" : "Failed";
367
369
  M({
368
- txnHash: S.transactionHash,
370
+ txnHash: C.transactionHash,
369
371
  status: e,
370
- gasUsed: S.gasUsed ? Number(S.gasUsed) : void 0,
371
- effectiveGasPrice: S.effectiveGasPrice?.toString(),
372
- revertReason: S.status === "reverted" ? re?.message || "Transaction reverted by receipt" : void 0
373
- }), e === "Success" && S.blockNumber ? (async () => {
372
+ gasUsed: C.gasUsed ? Number(C.gasUsed) : void 0,
373
+ effectiveGasPrice: C.effectiveGasPrice?.toString(),
374
+ revertReason: C.status === "reverted" ? oe?.message || "Transaction reverted by receipt" : void 0
375
+ }), e === "Success" && C.blockNumber ? (async () => {
374
376
  try {
375
377
  if (!i?.chainId) {
376
378
  t.console.error(
@@ -378,45 +380,45 @@ function Kn(Ge) {
378
380
  ), F(null);
379
381
  return;
380
382
  }
381
- const o = ce(i.chainId), s = await De({
382
- chain: o,
383
- transport: He()
383
+ const a = ce(i.chainId), s = await Ne({
384
+ chain: a,
385
+ transport: Fe()
384
386
  }).getBlock({
385
- blockNumber: BigInt(S.blockNumber)
387
+ blockNumber: BigInt(C.blockNumber)
386
388
  });
387
389
  F(Number(s.timestamp));
388
- } catch (o) {
390
+ } catch (a) {
389
391
  t.console.error(
390
392
  "[Trails] Error fetching origin block timestamp:",
391
- o
393
+ a
392
394
  ), F(null);
393
395
  }
394
- })() : e !== "Success" && F(null), e === "Success" && u && u.length > 0 && x && !u.some((n) => B[`${n.chainId}-${n.id}`]) && (t.console.log(
396
+ })() : e !== "Success" && F(null), e === "Success" && u && u.length > 0 && x && !u.some((n) => j[`${n.chainId}-${n.id}`]) && (t.console.log(
395
397
  "Origin transaction successful, auto-sending all meta transactions..."
396
- ), H.mutate({ selectedId: null }));
397
- } else ve && (M({
398
+ ), U.mutate({ selectedId: null }));
399
+ } else pe && (M({
398
400
  txnHash: T,
399
401
  status: "Failed",
400
- revertReason: re?.message || "Failed to get receipt",
402
+ revertReason: oe?.message || "Failed to get receipt",
401
403
  gasUsed: void 0,
402
404
  effectiveGasPrice: void 0
403
405
  }), F(null));
404
406
  }
405
407
  }, [
406
408
  T,
407
- D,
409
+ H,
408
410
  Ie,
409
- ve,
410
- S,
411
- re,
411
+ pe,
412
+ C,
413
+ oe,
412
414
  u,
413
- B,
415
+ j,
414
416
  x,
415
417
  i?.chainId,
416
- y?.status,
417
- y?.txnHash
418
+ w?.status,
419
+ w?.txnHash
418
420
  ]), b(() => {
419
- x && I.isSuccess && i?.chainId && d.chainId === i.chainId && !i.error && i.to && i.data !== null && i.value !== null && !E.isPending && !D && !T && !ye && !y && !le && (t.console.log("Auto-executing transaction: All conditions met."), de(!0), M({
421
+ x && I.isSuccess && i?.chainId && d.chainId === i.chainId && !i.error && i.to && i.data !== null && i.value !== null && !E.isPending && !H && !T && !we && !w && !le && (t.console.log("Auto-executing transaction: All conditions met."), de(!0), M({
420
422
  status: "Sending..."
421
423
  }), E.sendTransaction(
422
424
  {
@@ -443,65 +445,65 @@ function Kn(Ge) {
443
445
  i,
444
446
  d.chainId,
445
447
  E.isPending,
446
- D,
448
+ H,
447
449
  T,
448
- ye,
449
- y,
450
+ we,
451
+ w,
450
452
  le,
451
453
  E
452
454
  ]), b(() => {
453
- x && w && p && C && d.address && $ && !I.isPending && !I.isSuccess && (t.console.log("Auto-committing intent configuration..."), I.mutate({
455
+ x && y && v && A && d.address && N && !I.isPending && !I.isSuccess && (t.console.log("Auto-committing intent configuration..."), I.mutate({
454
456
  mainSignerAddress: d.address,
455
- calls: w,
456
- preconditions: p,
457
- quoteProvider: C.quoteProvider,
458
- addressOverrides: g.variables?.addressOverrides
457
+ calls: y,
458
+ preconditions: v,
459
+ quoteProvider: A.quoteProvider,
460
+ addressOverrides: g.variables?.params.addressOverrides
459
461
  }));
460
462
  }, [
461
463
  x,
462
- w,
463
- p,
464
- C,
464
+ y,
465
+ v,
466
+ A,
465
467
  d.address,
466
- $,
468
+ N,
467
469
  I,
468
470
  g.variables
469
471
  ]);
470
- const H = Ae({
472
+ const U = Se({
471
473
  mutationFn: async ({ selectedId: e }) => {
472
474
  if (t.console.log("[trails-sdk] Starting sendMetaTxn mutation", {
473
475
  selectedId: e,
474
- hasIntentCallsPayloads: !!w,
475
- hasIntentPreconditions: !!p,
476
+ hasIntentCallsPayloads: !!y,
477
+ hasIntentPreconditions: !!v,
476
478
  hasMetaTxns: !!u,
477
479
  hasAccountAddress: !!d.address,
478
- quoteProvider: C?.quoteProvider
479
- }), !w || !p || !u || !d.address)
480
+ quoteProvider: A?.quoteProvider
481
+ }), !y || !v || !u || !d.address)
480
482
  throw new Error("Missing required data for meta-transaction");
481
- if (!C?.quoteProvider)
483
+ if (!A?.quoteProvider)
482
484
  throw new Error("quoteProvider is required");
483
- const n = Oe(
485
+ const n = Me(
484
486
  d.address,
485
- w
486
- ), o = e ? [u.find((s) => s.id === e)] : u;
487
+ y
488
+ ), a = e ? [u.find((s) => s.id === e)] : u;
487
489
  if (t.console.log("[trails-sdk] Selected transactions to send", {
488
490
  selectedId: e,
489
491
  totalMetaTxns: u.length,
490
- txnsToSendCount: o.filter((s) => s).length,
491
- txnsToSend: o.filter((s) => s).map((s) => ({
492
+ txnsToSendCount: a.filter((s) => s).length,
493
+ txnsToSend: a.filter((s) => s).map((s) => ({
492
494
  id: s?.id,
493
495
  chainId: s?.chainId,
494
496
  walletAddress: s?.walletAddress,
495
497
  contract: s?.contract
496
498
  }))
497
- }), !o || e && !o[0])
499
+ }), !a || e && !a[0])
498
500
  throw new Error("Meta transaction not found");
499
501
  const l = [];
500
- for (const s of o) {
502
+ for (const s of a) {
501
503
  if (!s) continue;
502
- const a = `${s.chainId}-${s.id}`, f = B[a], h = Date.now();
504
+ const r = `${s.chainId}-${s.id}`, m = j[r], f = Date.now();
503
505
  if (t.console.log(
504
- `[trails-sdk] Processing meta transaction ${a}`,
506
+ `[trails-sdk] Processing meta transaction ${r}`,
505
507
  {
506
508
  metaTxnId: s.id,
507
509
  chainId: s.chainId,
@@ -509,88 +511,88 @@ function Kn(Ge) {
509
511
  contract: s.contract,
510
512
  intentAddress: n
511
513
  }
512
- ), f && h - f < Be) {
513
- const r = Math.ceil(
514
- (Be - (h - f)) / 1e3
514
+ ), m && f - m < De) {
515
+ const o = Math.ceil(
516
+ (De - (f - m)) / 1e3
515
517
  );
516
518
  t.console.log(
517
- `[trails-sdk] Meta transaction for ${a} was sent recently. Wait ${r}s before retry`,
519
+ `[trails-sdk] Meta transaction for ${r} was sent recently. Wait ${o}s before retry`,
518
520
  {
519
- lastSentTime: f,
520
- now: h,
521
- timeLeft: r
521
+ lastSentTime: m,
522
+ now: f,
523
+ timeLeft: o
522
524
  }
523
525
  );
524
526
  continue;
525
527
  }
526
528
  try {
527
- const r = parseInt(s.chainId, 10);
528
- if (Number.isNaN(r) || r <= 0)
529
+ const o = parseInt(s.chainId, 10);
530
+ if (Number.isNaN(o) || o <= 0)
529
531
  throw t.console.error(
530
532
  "[trails-sdk] Invalid chainId for meta transaction",
531
533
  {
532
- chainId: r,
533
- operationKey: a,
534
+ chainId: o,
535
+ operationKey: r,
534
536
  metaTxn: s
535
537
  }
536
- ), new Error(`Invalid chainId for meta transaction: ${r}`);
537
- const m = fe(r);
538
- if (!m)
538
+ ), new Error(`Invalid chainId for meta transaction: ${o}`);
539
+ const h = me(o);
540
+ if (!h)
539
541
  throw t.console.error("[trails-sdk] No relayer found for chainId", {
540
- chainId: r,
541
- operationKey: a,
542
- availableRelayers: Array.from(en.keys())
543
- }), new Error(`No relayer found for chainId: ${r}`);
544
- const v = p.filter(
545
- (U) => U.chainId && parseInt(U.chainId, 10) === r
542
+ chainId: o,
543
+ operationKey: r,
544
+ availableRelayers: Array.from(Xe.keys())
545
+ }), new Error(`No relayer found for chainId: ${o}`);
546
+ const p = v.filter(
547
+ (D) => D.chainId && parseInt(D.chainId, 10) === o
546
548
  );
547
549
  t.console.log(
548
- `[trails-sdk] Relaying meta transaction ${a} to intent ${n} via relayer`,
550
+ `[trails-sdk] Relaying meta transaction ${r} to intent ${n} via relayer`,
549
551
  {
550
- chainId: r,
551
- operationKey: a,
552
+ chainId: o,
553
+ operationKey: r,
552
554
  intentAddress: n,
553
- relayer: !!m,
554
- preconditionsCount: v.length
555
+ relayer: !!h,
556
+ preconditionsCount: p.length
555
557
  }
556
558
  );
557
- const { opHash: Z } = await m.sendMetaTxn(
559
+ const { opHash: Z } = await h.sendMetaTxn(
558
560
  s.walletAddress,
559
561
  s.contract,
560
562
  s.input,
561
563
  Number(s.chainId),
562
564
  void 0,
563
- v
565
+ p
564
566
  );
565
567
  t.console.log(
566
- `[trails-sdk] Successfully sent meta transaction ${a}`,
568
+ `[trails-sdk] Successfully sent meta transaction ${r}`,
567
569
  {
568
- operationKey: a,
570
+ operationKey: r,
569
571
  opHash: Z,
570
- chainId: r
572
+ chainId: o
571
573
  }
572
574
  );
573
- const ae = !1;
575
+ const re = !1;
574
576
  l.push({
575
- operationKey: a,
577
+ operationKey: r,
576
578
  opHash: Z,
577
579
  success: !0
578
580
  });
579
- } catch (r) {
580
- const m = r instanceof Error ? r.message : "Unknown error";
581
+ } catch (o) {
582
+ const h = o instanceof Error ? o.message : "Unknown error";
581
583
  t.console.error(
582
- `[trails-sdk] Failed to send meta transaction ${a}`,
584
+ `[trails-sdk] Failed to send meta transaction ${r}`,
583
585
  {
584
- operationKey: a,
585
- error: m,
586
+ operationKey: r,
587
+ error: h,
586
588
  chainId: s.chainId,
587
589
  metaTxnId: s.id,
588
590
  walletAddress: s.walletAddress,
589
591
  contract: s.contract
590
592
  }
591
593
  ), l.push({
592
- operationKey: a,
593
- error: m,
594
+ operationKey: r,
595
+ error: h,
594
596
  success: !1
595
597
  });
596
598
  }
@@ -611,13 +613,13 @@ function Kn(Ge) {
611
613
  error: n.error || null
612
614
  }))
613
615
  }
614
- ), e.forEach(({ operationKey: n, opHash: o, success: l }) => {
615
- l && o ? (Ce((s) => ({
616
+ ), e.forEach(({ operationKey: n, opHash: a, success: l }) => {
617
+ l && a ? (Ae((s) => ({
616
618
  ...s,
617
619
  [n]: Date.now()
618
- })), we((s) => ({
620
+ })), ye((s) => ({
619
621
  ...s,
620
- [n]: o
622
+ [n]: a
621
623
  }))) : t.console.warn(
622
624
  `[trails-sdk] Not updating state for failed meta transaction ${n}`,
623
625
  {
@@ -638,48 +640,48 @@ function Kn(Ge) {
638
640
  // Allow up to 2 retries
639
641
  retryDelay: (e) => Math.min(1e3 * 2 ** e, 3e4)
640
642
  // Exponential backoff
641
- }), [J, cn] = c(null), [X, ln] = c(null);
643
+ }), [J, on] = c(null), [X, rn] = c(null);
642
644
  b(() => {
643
- if (!$ || !w?.[0]?.chainId || !J || !X || !p || !d.address) {
644
- Q(null);
645
+ if (!N || !y?.[0]?.chainId || !J || !X || !v || !d.address) {
646
+ V(null);
645
647
  return;
646
648
  }
647
649
  try {
648
- const e = $;
649
- if (!e || !Dn(e)) {
650
- Q(null);
650
+ const e = N;
651
+ if (!e || !Nn(e)) {
652
+ V(null);
651
653
  return;
652
654
  }
653
- let n, o = "0x", l = 0n;
655
+ let n, a = "0x", l = 0n;
654
656
  const s = e;
655
- if (J === Fe) {
656
- const f = p.find(
657
- (r) => (r.type === "transfer-native" || r.type === "native-balance") && r.chainId === X.toString()
658
- ), h = f?.data?.minAmount?.toString() ?? f?.data?.min?.toString();
659
- if (h === void 0)
657
+ if (J === $e) {
658
+ const m = v.find(
659
+ (o) => (o.type === "transfer-native" || o.type === "native-balance") && o.chainId === X.toString()
660
+ ), f = m?.data?.minAmount?.toString() ?? m?.data?.min?.toString();
661
+ if (f === void 0)
660
662
  throw new Error(
661
663
  "Could not find native precondition (transfer-native or native-balance) or min amount"
662
664
  );
663
- l = BigInt(h), n = s;
665
+ l = BigInt(f), n = s;
664
666
  } else {
665
- const h = p.find(
666
- (r) => r.type === "erc20-balance" && r.chainId === X.toString() && r.data?.token && ee(
667
- L(r.data.token),
668
- L(J)
667
+ const f = v.find(
668
+ (o) => o.type === "erc20-balance" && o.chainId === X.toString() && o.data?.token && ee(
669
+ B(o.data.token),
670
+ B(J)
669
671
  )
670
672
  )?.data?.min?.toString();
671
- if (h === void 0)
673
+ if (f === void 0)
672
674
  throw new Error(
673
675
  "Could not find ERC20 balance precondition or min amount"
674
676
  );
675
- o = Rn({
677
+ a = xn({
676
678
  recipient: s,
677
- amount: BigInt(h)
679
+ amount: BigInt(f)
678
680
  }), n = J;
679
681
  }
680
- Q({
682
+ V({
681
683
  to: n,
682
- data: o,
684
+ data: a,
683
685
  value: l,
684
686
  chainId: X,
685
687
  error: void 0
@@ -688,7 +690,7 @@ function Kn(Ge) {
688
690
  t.console.error(
689
691
  "[trails-sdk] Failed to calculate origin call params for UI:",
690
692
  e
691
- ), Q({
693
+ ), V({
692
694
  to: null,
693
695
  data: null,
694
696
  value: null,
@@ -697,22 +699,22 @@ function Kn(Ge) {
697
699
  });
698
700
  }
699
701
  }, [
700
- w,
702
+ y,
701
703
  J,
702
704
  X,
703
- p,
705
+ v,
704
706
  d.address,
705
- $
707
+ N
706
708
  ]);
707
- const P = On(
709
+ const P = Mn(
708
710
  u,
709
- fe
711
+ me
710
712
  );
711
- Fn(() => !u || Object.keys(P).length === 0 ? "no_statuses" : u.map((n) => `${n.chainId}-${n.id}`).sort().map((n) => {
712
- const o = P[n];
713
- return `${n}:${o ? o.status : "loading"}`;
713
+ $n(() => !u || Object.keys(P).length === 0 ? "no_statuses" : u.map((n) => `${n.chainId}-${n.id}`).sort().map((n) => {
714
+ const a = P[n];
715
+ return `${n}:${a ? a.status : "loading"}`;
714
716
  }).join(","), [u, P]);
715
- const pe = $e(/* @__PURE__ */ new Set()), Te = $e(null);
717
+ const ve = Re(/* @__PURE__ */ new Set()), Te = Re(null);
716
718
  b(() => {
717
719
  if (t.console.log(
718
720
  "[trails-sdk] Running meta-transaction block timestamp effect:",
@@ -723,7 +725,7 @@ function Kn(Ge) {
723
725
  ), !u || u.length === 0) {
724
726
  t.console.log(
725
727
  "[trails-sdk] No meta transactions, clearing timestamps"
726
- ), pe.current.clear(), Object.keys(ge).length > 0 && z({});
728
+ ), ve.current.clear(), Object.keys(ge).length > 0 && Y({});
727
729
  return;
728
730
  }
729
731
  if (!Object.keys(P).length) {
@@ -731,109 +733,111 @@ function Kn(Ge) {
731
733
  return;
732
734
  }
733
735
  u.forEach(async (e, n) => {
734
- const o = `${e.chainId}-${e.id}`;
735
- if (pe.current.has(o)) {
736
+ const a = `${e.chainId}-${e.id}`;
737
+ if (ve.current.has(a)) {
736
738
  t.console.log(
737
- `[trails-sdk] MetaTxn ${o}: Already processed, skipping`
739
+ `[trails-sdk] MetaTxn ${a}: Already processed, skipping`
738
740
  );
739
741
  return;
740
742
  }
741
- const l = P[o];
743
+ const l = P[a];
742
744
  if (!l || l.status !== "confirmed") {
743
745
  t.console.log(
744
- `[trails-sdk] MetaTxn ${o}: Status not confirmed, skipping`
746
+ `[trails-sdk] MetaTxn ${a}: Status not confirmed, skipping`
745
747
  );
746
748
  return;
747
749
  }
748
750
  const s = l.transactionHash;
749
751
  if (!s) {
750
752
  t.console.log(
751
- `[trails-sdk] MetaTxn ${o}: No transaction hash, skipping`
753
+ `[trails-sdk] MetaTxn ${a}: No transaction hash, skipping`
752
754
  );
753
755
  return;
754
756
  }
755
757
  t.console.log(
756
- `[trails-sdk] MetaTxn ${o}: Processing transaction ${s}`
757
- ), pe.current.add(o);
758
+ `[trails-sdk] MetaTxn ${a}: Processing transaction ${s}`
759
+ ), ve.current.add(a);
758
760
  try {
759
- const a = parseInt(e.chainId, 10);
760
- if (Number.isNaN(a) || a <= 0)
761
+ const r = parseInt(e.chainId, 10);
762
+ if (Number.isNaN(r) || r <= 0)
761
763
  throw new Error(
762
764
  `Invalid chainId for meta transaction: ${e.chainId}`
763
765
  );
764
- const f = ce(a), h = De({
765
- chain: f,
766
- transport: He()
767
- }), r = await h.getTransactionReceipt({
766
+ const m = ce(r), f = Ne({
767
+ chain: m,
768
+ transport: Fe()
769
+ }), o = await f.getTransactionReceipt({
768
770
  hash: s
769
771
  });
770
- if (r && typeof r.blockNumber == "bigint") {
771
- const m = await h.getBlock({
772
- blockNumber: r.blockNumber
772
+ if (o && typeof o.blockNumber == "bigint") {
773
+ const h = await f.getBlock({
774
+ blockNumber: o.blockNumber
773
775
  });
774
776
  t.console.log(
775
- `[trails-sdk] MetaTxn ${o}: Got block timestamp ${m.timestamp}`
776
- ), z((v) => ({
777
- ...v,
778
- [o]: {
779
- timestamp: Number(m.timestamp),
777
+ `[trails-sdk] MetaTxn ${a}: Got block timestamp ${h.timestamp}`
778
+ ), Y((p) => ({
779
+ ...p,
780
+ [a]: {
781
+ timestamp: Number(h.timestamp),
780
782
  error: void 0
781
783
  }
782
784
  }));
783
785
  try {
784
- const v = C?.quoteProvider ? String(C.quoteProvider).toLowerCase() : void 0, Z = g.variables?.provider ? String(g.variables.provider).toLowerCase() : void 0, ae = v === "cctp" || Z === "cctp", U = g.variables?.originChainId, Se = g.variables?.destinationChainId;
785
- t.console.log("[Trails] isCctp", ae), t.console.log("[Trails] providerFromQuote", v), t.console.log("[Trails] providerFromArgs", Z), t.console.log("[Trails] trailsFee", C), t.console.log(
786
+ const p = A?.quoteProvider ? String(A.quoteProvider).toLowerCase() : void 0, Z = g.variables?.params.provider ? String(
787
+ g.variables.params.provider
788
+ ).toLowerCase() : void 0, re = p === "cctp" || Z === "cctp", D = g.variables?.params.originChainId, Ce = g.variables?.params.destinationChainId;
789
+ t.console.log("[Trails] isCctp", re), t.console.log("[Trails] providerFromQuote", p), t.console.log("[Trails] providerFromArgs", Z), t.console.log("[Trails] trailsFee", A), t.console.log(
786
790
  "[Trails] createIntentMutation.variables",
787
791
  g.variables
788
792
  ), t.console.log(
789
- "[Trails] createIntentMutation.variables.provider",
790
- g.variables?.provider
793
+ "[Trails] createIntentMutation.variables.params.provider",
794
+ g.variables?.params.provider
791
795
  ), t.console.log(
792
- "[Trails] createIntentMutation.variables.originChainId",
793
- g.variables?.originChainId
796
+ "[Trails] createIntentMutation.variables.params.originChainId",
797
+ g.variables?.params.originChainId
794
798
  ), t.console.log(
795
- "[Trails] createIntentMutation.variables.destinationChainId",
796
- g.variables?.destinationChainId
799
+ "[Trails] createIntentMutation.variables.params.destinationChainId",
800
+ g.variables?.params.destinationChainId
797
801
  ), t.console.log(
798
802
  "[Trails] lastQueuedCctpSourceTxHash",
799
803
  Te.current
800
804
  ), t.console.log("[Trails] transactionHash", s), t.console.log(
801
805
  "[Trails] originChainIdForCctp",
802
- U
806
+ D
803
807
  ), t.console.log(
804
808
  "[Trails] destinationChainIdForCctp",
805
- Se
806
- ), ae && A && s && typeof U == "number" && typeof Se == "number" && Te.current !== s && n === 0 && (Te.current = s, await Nn({
807
- apiClient: A,
809
+ Ce
810
+ ), re && S && s && typeof D == "number" && typeof Ce == "number" && Te.current !== s && n === 0 && (Te.current = s, await On({
811
+ trailsClient: S,
808
812
  sourceTxHash: s,
809
- sourceChainId: U,
810
- destinationChainId: Se
813
+ sourceChainId: D,
814
+ destinationChainId: Ce
811
815
  }));
812
- } catch (v) {
816
+ } catch (p) {
813
817
  t.console.error(
814
- `[trails-sdk] Queue CCTP on meta-tx error (${o}):`,
815
- v
818
+ `[trails-sdk] Queue CCTP on meta-tx error (${a}):`,
819
+ p
816
820
  );
817
821
  }
818
822
  } else
819
823
  t.console.warn(
820
- `[trails-sdk] MetaTxn ${o}: No block number in receipt`
821
- ), z((m) => ({
822
- ...m,
823
- [o]: {
824
+ `[trails-sdk] MetaTxn ${a}: No block number in receipt`
825
+ ), Y((h) => ({
826
+ ...h,
827
+ [a]: {
824
828
  timestamp: null,
825
829
  error: "Block number not found in receipt"
826
830
  }
827
831
  }));
828
- } catch (a) {
832
+ } catch (r) {
829
833
  t.console.error(
830
- `[trails-sdk] MetaTxn ${o}: Error:`,
831
- a
832
- ), z((f) => ({
833
- ...f,
834
- [o]: {
834
+ `[trails-sdk] MetaTxn ${a}: Error:`,
835
+ r
836
+ ), Y((m) => ({
837
+ ...m,
838
+ [a]: {
835
839
  timestamp: null,
836
- error: a.message || "Failed to fetch receipt/timestamp"
840
+ error: r.message || "Failed to fetch receipt/timestamp"
837
841
  }
838
842
  }));
839
843
  }
@@ -842,159 +846,166 @@ function Kn(Ge) {
842
846
  u,
843
847
  P,
844
848
  ge,
845
- C,
849
+ A,
846
850
  g.variables,
847
- A
851
+ S
848
852
  ]);
849
- const dn = (e) => {
853
+ const cn = (e) => {
850
854
  ne(e);
851
855
  };
852
- function un(e) {
856
+ function ln(e) {
853
857
  g.mutate({
854
858
  ...e,
855
859
  destinationSalt: Date.now().toString()
856
860
  });
857
861
  }
858
- function gn(e) {
862
+ function dn(e) {
859
863
  t.console.log("[trails-sdk] commitIntentConfig", e), I.mutate(e);
860
864
  }
861
- function fn(e) {
865
+ function un(e) {
862
866
  if (!e) {
863
- Q(null);
867
+ V(null);
864
868
  return;
865
869
  }
866
- const { originChainId: n, tokenAddress: o } = e;
867
- ln(n), cn(o);
870
+ const { originChainId: n, tokenAddress: a } = e;
871
+ rn(n), on(a);
868
872
  }
869
- function hn(e) {
870
- H.mutate({ selectedId: e });
873
+ function gn(e) {
874
+ U.mutate({ selectedId: e });
871
875
  }
872
- const { chainId: mn } = d, Ee = i?.chainId, In = g.isPending, vn = g.isSuccess, pn = g.error, Tn = g.variables, Sn = I.isPending, An = I.isSuccess, Cn = I.error, wn = I.variables, yn = H.isPending, kn = H.isSuccess, bn = H.error, En = H.variables;
876
+ const { chainId: mn } = d, Ee = i?.chainId, fn = g.isPending, hn = g.isSuccess, In = g.error, pn = g.variables, vn = I.isPending, Tn = I.isSuccess, Cn = I.error, Sn = I.variables, An = U.isPending, yn = U.isSuccess, wn = U.error, kn = U.variables;
873
877
  return {
874
- apiClient: A,
878
+ trailsClient: S,
875
879
  metaTxns: u,
876
- intentCallsPayloads: w,
877
- intentPreconditions: p,
878
- trailsFee: C,
880
+ intentCallsPayloads: y,
881
+ intentPreconditions: v,
882
+ trailsFee: A,
879
883
  txnHash: T,
880
- committedOriginIntentAddress: q,
881
- committedDestinationIntentAddress: Ve,
882
- verificationStatus: Ze,
883
- getRelayer: fe,
884
- estimatedGas: oe,
885
- isEstimateError: he,
886
- estimateError: me,
887
- calculateIntentAddress: Oe,
884
+ committedOriginIntentAddress: $,
885
+ committedDestinationIntentAddress: _e,
886
+ verificationStatus: Je,
887
+ getRelayer: me,
888
+ estimatedGas: ae,
889
+ isEstimateError: fe,
890
+ estimateError: he,
891
+ calculateIntentAddress: Me,
888
892
  calculateOriginAndDestinationIntentAddresses: Pe,
889
- committedIntentConfig: nn,
890
- isLoadingCommittedConfig: tn,
891
- committedConfigError: sn,
892
- commitIntentConfig: gn,
893
- commitIntentConfigPending: Sn,
894
- commitIntentConfigSuccess: An,
893
+ committedIntentConfig: Ze,
894
+ isLoadingCommittedConfig: en,
895
+ committedConfigError: nn,
896
+ commitIntentConfig: dn,
897
+ commitIntentConfigPending: vn,
898
+ commitIntentConfigSuccess: Tn,
895
899
  commitIntentConfigError: Cn,
896
- commitIntentConfigArgs: wn,
900
+ commitIntentConfigArgs: Sn,
897
901
  getIntentCallsPayloads: be,
898
- operationHashes: Ke,
899
- callIntentCallsPayload: on,
902
+ operationHashes: Qe,
903
+ callIntentCallsPayload: tn,
900
904
  sendOriginTransaction: an,
901
- switchChain: Ye,
902
- isSwitchingChain: ze,
903
- switchChainError: Y,
905
+ switchChain: Ve,
906
+ isSwitchingChain: Ke,
907
+ switchChainError: z,
904
908
  isTransactionInProgress: te,
905
909
  isChainSwitchRequired: mn !== Ee && !!Ee,
906
910
  sendTransaction: E.sendTransaction,
907
911
  isSendingTransaction: E.isPending,
908
- originCallStatus: y,
912
+ originCallStatus: w,
909
913
  updateOriginCallStatus: k,
910
- isEstimatingGas: Je,
914
+ isEstimatingGas: ze,
911
915
  isAutoExecute: x,
912
- updateAutoExecute: dn,
913
- receipt: S,
914
- isWaitingForReceipt: D,
916
+ updateAutoExecute: cn,
917
+ receipt: C,
918
+ isWaitingForReceipt: H,
915
919
  receiptIsSuccess: Ie,
916
- receiptIsError: ve,
917
- receiptError: re,
920
+ receiptIsError: pe,
921
+ receiptError: oe,
918
922
  hasAutoExecuted: le,
919
923
  originCallSuccess: E.isSuccess,
920
- sentMetaTxns: B,
921
- sendMetaTxn: hn,
922
- sendMetaTxnPending: yn,
923
- sendMetaTxnSuccess: kn,
924
- sendMetaTxnError: bn,
925
- sendMetaTxnArgs: En,
926
- clearIntent: rn,
924
+ sentMetaTxns: j,
925
+ sendMetaTxn: gn,
926
+ sendMetaTxnPending: An,
927
+ sendMetaTxnSuccess: yn,
928
+ sendMetaTxnError: wn,
929
+ sendMetaTxnArgs: kn,
930
+ clearIntent: sn,
927
931
  metaTxnMonitorStatuses: P,
928
- createIntent: un,
929
- createIntentPending: In,
930
- createIntentSuccess: vn,
931
- createIntentError: pn,
932
- createIntentArgs: Tn,
932
+ createIntent: ln,
933
+ createIntentPending: fn,
934
+ createIntentSuccess: hn,
935
+ createIntentError: In,
936
+ createIntentArgs: pn,
933
937
  originCallParams: i,
934
- updateOriginCallParams: fn,
935
- originBlockTimestamp: Xe,
938
+ updateOriginCallParams: un,
939
+ originBlockTimestamp: Ye,
936
940
  metaTxnBlockTimestamps: ge,
937
- originIntentAddress: $,
938
- destinationIntentAddress: Qe
941
+ originIntentAddress: N,
942
+ destinationIntentAddress: We
939
943
  };
940
944
  }
941
945
  export {
942
- Jn as TRAILS_CONTRACT_PLACEHOLDER_AMOUNT,
943
- Xn as TradeType,
944
- Zn as TrailsWidget,
945
- Oe as calculateIntentAddress,
946
+ zn as TRAILS_CONTRACT_PLACEHOLDER_AMOUNT,
947
+ Yn as TradeType,
948
+ Jn as TrailsClient,
949
+ Xn as TrailsWidget,
950
+ Me as calculateIntentAddress,
946
951
  Pe as calculateOriginAndDestinationIntentAddresses,
947
- et as commitIntentConfig,
948
- nt as createModalController,
949
- tt as declareSequenceEnv,
950
- st as getAPIClient,
951
- it as getAccountTotalBalanceUsd,
952
- ot as getAccountTransactionHistory,
953
- rt as getDebug,
954
- Rn as getERC20TransferData,
955
- at as getHasSufficientBalanceToken,
952
+ Zn as commitIntentConfig,
953
+ et as createModalController,
954
+ nt as declareSequenceEnv,
955
+ tt as getAPIClient,
956
+ st as getAccountTotalBalanceUsd,
957
+ it as getAccountTransactionHistory,
958
+ at as getAllChains,
959
+ ce as getChainInfo,
960
+ ot as getDebug,
961
+ xn as getERC20TransferData,
962
+ rt as getHasSufficientBalanceToken,
956
963
  ct as getHasSufficientBalanceUsd,
957
964
  lt as getIndexerGatewayClient,
958
965
  qn as getIntentCallsPayloads,
959
966
  dt as getIntentTransactionHistory,
960
967
  ut as getMetaTxnReceipt,
961
968
  gt as getMinLogLevel,
962
- ft as getRelayer,
963
- ht as getSequenceApiUrl,
964
- mt as getSequenceEnv,
969
+ mt as getRelayer,
970
+ ft as getSequenceApiUrl,
971
+ ht as getSequenceEnv,
965
972
  It as getSequenceIndexerUrl,
966
- vt as getSequenceNodeGatewayUrl,
967
- pt as getSequenceProjectAccessKey,
973
+ pt as getSequenceNodeGatewayUrl,
974
+ vt as getSequenceProjectAccessKey,
968
975
  Tt as getSlippageTolerance,
969
- St as getSupportedChains,
970
- At as getSupportedTokens,
971
- Ct as getTxTimeDiff,
972
- wt as getWalletConnectProjectId,
976
+ Ct as getSupportedChains,
977
+ St as getSupportedTokens,
978
+ At as getTrailsApiUrl,
979
+ yt as getTrailsClient,
980
+ wt as getTxTimeDiff,
981
+ kt as getWalletConnectProjectId,
973
982
  t as logger,
974
- yt as prepareSend,
975
- kt as relayerSendMetaTx,
976
- bt as sendOriginTransaction,
977
- Et as setDebug,
978
- Pt as setSequenceApiUrl,
979
- xt as setSequenceEnv,
980
- Mt as setSequenceIndexerUrl,
983
+ bt as prepareSend,
984
+ Et as relayerSendMetaTx,
985
+ Pt as sendOriginTransaction,
986
+ xt as setDebug,
987
+ Mt as setSequenceApiUrl,
988
+ Ot as setSequenceEnv,
989
+ qt as setSequenceIndexerUrl,
981
990
  Rt as setSequenceNodeGatewayUrl,
982
- Ot as setSequenceProjectAccessKey,
991
+ $t as setSequenceProjectAccessKey,
983
992
  Nt as setSlippageTolerance,
984
- qt as setWalletConnectProjectId,
985
- Pn as useAPIClient,
986
- $t as useAccountTotalBalanceUsd,
987
- Ft as useAccountTransactionHistory,
988
- Dt as useHasSufficientBalanceToken,
989
- Ht as useHasSufficientBalanceUsd,
990
- Ut as useIndexerGatewayClient,
991
- Lt as useIntentTransactionHistory,
992
- On as useMetaTxnsMonitor,
993
- Bt as useQuote,
994
- xn as useRelayers,
995
- Gt as useSupportedChains,
996
- jt as useSupportedTokens,
997
- _t as useTokenBalances,
998
- Wt as useTokenList,
999
- Kn as useTrails
993
+ Ft as setTrailsApiUrl,
994
+ Ht as setWalletConnectProjectId,
995
+ Ut as useAPIClient,
996
+ Dt as useAccountTotalBalanceUsd,
997
+ Bt as useAccountTransactionHistory,
998
+ jt as useHasSufficientBalanceToken,
999
+ Gt as useHasSufficientBalanceUsd,
1000
+ Lt as useIndexerGatewayClient,
1001
+ _t as useIntentTransactionHistory,
1002
+ Mn as useMetaTxnsMonitor,
1003
+ Wt as useQuote,
1004
+ En as useRelayers,
1005
+ Qt as useSupportedChains,
1006
+ Vt as useSupportedTokens,
1007
+ Kt as useTokenBalances,
1008
+ zt as useTokenList,
1009
+ Qn as useTrails,
1010
+ bn as useTrailsClient
1000
1011
  };