0xtrails 0.13.0 → 0.13.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 (307) hide show
  1. package/dist/{ccip-Cg9-lJ6K.js → ccip-CT_An6eM.js} +39 -39
  2. package/dist/chains.d.ts +4 -3
  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/customTokens.d.ts.map +1 -1
  7. package/dist/error.d.ts +1 -0
  8. package/dist/error.d.ts.map +1 -1
  9. package/dist/gasless.d.ts +1 -2
  10. package/dist/gasless.d.ts.map +1 -1
  11. package/dist/{index-DEojZg7b.js → index-RfqL5Foz.js} +56672 -43550
  12. package/dist/index.d.ts +5 -2
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +385 -333
  15. package/dist/intents.d.ts +8 -2
  16. package/dist/intents.d.ts.map +1 -1
  17. package/dist/keyMachineClient.d.ts +9 -0
  18. package/dist/keyMachineClient.d.ts.map +1 -0
  19. package/dist/keymachine/index.d.ts +14 -0
  20. package/dist/keymachine/index.d.ts.map +1 -0
  21. package/dist/keymachine/key-machine.gen.d.ts +461 -0
  22. package/dist/keymachine/key-machine.gen.d.ts.map +1 -0
  23. package/dist/onramp/MeshConnectFlow.d.ts +18 -0
  24. package/dist/onramp/MeshConnectFlow.d.ts.map +1 -0
  25. package/dist/onramp/MeshConnectIframe.d.ts +13 -0
  26. package/dist/onramp/MeshConnectIframe.d.ts.map +1 -0
  27. package/dist/onramp/SendFromExchangeButton.d.ts +16 -0
  28. package/dist/onramp/SendFromExchangeButton.d.ts.map +1 -0
  29. package/dist/onramp/TrailsOnRampProvider.d.ts +31 -0
  30. package/dist/onramp/TrailsOnRampProvider.d.ts.map +1 -0
  31. package/dist/onramp/index.d.ts +13 -0
  32. package/dist/onramp/index.d.ts.map +1 -0
  33. package/dist/onramp/meshconnect.d.ts +30 -0
  34. package/dist/onramp/meshconnect.d.ts.map +1 -0
  35. package/dist/onramp/trailsOnramp.d.ts +24 -0
  36. package/dist/onramp/trailsOnramp.d.ts.map +1 -0
  37. package/dist/onramp-client/index.d.ts +3 -3
  38. package/dist/onramp-client/index.d.ts.map +1 -1
  39. package/dist/paymasterSend.d.ts.map +1 -1
  40. package/dist/prepareSend.d.ts.map +1 -1
  41. package/dist/query/balance.fetchers.d.ts +31 -2
  42. package/dist/query/balance.fetchers.d.ts.map +1 -1
  43. package/dist/query/balance.hooks.d.ts +21 -2
  44. package/dist/query/balance.hooks.d.ts.map +1 -1
  45. package/dist/query/balance.queries.d.ts +18 -1
  46. package/dist/query/balance.queries.d.ts.map +1 -1
  47. package/dist/query/chains.queries.d.ts.map +1 -1
  48. package/dist/query/meld.fetchers.d.ts +1 -1
  49. package/dist/query/meld.fetchers.d.ts.map +1 -1
  50. package/dist/query/meld.hooks.d.ts +3 -3
  51. package/dist/query/meld.hooks.d.ts.map +1 -1
  52. package/dist/query/meld.queries.d.ts +1 -1
  53. package/dist/query/meld.queries.d.ts.map +1 -1
  54. package/dist/query/price.fetchers.d.ts +15 -0
  55. package/dist/query/price.fetchers.d.ts.map +1 -0
  56. package/dist/query/price.hooks.d.ts +352 -0
  57. package/dist/query/price.hooks.d.ts.map +1 -0
  58. package/dist/query/price.queries.d.ts +34 -0
  59. package/dist/query/price.queries.d.ts.map +1 -0
  60. package/dist/query/tokenList.queries.d.ts +54 -0
  61. package/dist/query/tokenList.queries.d.ts.map +1 -0
  62. package/dist/recover.d.ts +6 -4
  63. package/dist/recover.d.ts.map +1 -1
  64. package/dist/tokens.d.ts +13 -0
  65. package/dist/tokens.d.ts.map +1 -1
  66. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +2 -2
  67. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
  68. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +2 -2
  69. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
  70. package/dist/transactionIntent/deposits/standardDeposit.d.ts +1 -1
  71. package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
  72. package/dist/transactionIntent/handlers/intentHandler.d.ts.map +1 -1
  73. package/dist/transactionIntent/helpers/transactionStateHelpers.d.ts.map +1 -1
  74. package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
  75. package/dist/transactionIntent/types.d.ts +1 -1
  76. package/dist/transactionIntent/types.d.ts.map +1 -1
  77. package/dist/transactions.d.ts +4 -0
  78. package/dist/transactions.d.ts.map +1 -1
  79. package/dist/umd/trails.min.js +291 -202
  80. package/dist/utils/format.d.ts +7 -0
  81. package/dist/utils/format.d.ts.map +1 -1
  82. package/dist/walletUtils.d.ts +2 -1
  83. package/dist/walletUtils.d.ts.map +1 -1
  84. package/dist/wallets.d.ts +13 -54
  85. package/dist/wallets.d.ts.map +1 -1
  86. package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
  87. package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
  88. package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
  89. package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
  90. package/dist/widget/components/DirectTransfer.d.ts +1 -1
  91. package/dist/widget/components/DirectTransfer.d.ts.map +1 -1
  92. package/dist/widget/components/EarnPools.d.ts.map +1 -1
  93. package/dist/widget/components/ExecutionStatusBadge.d.ts.map +1 -1
  94. package/dist/widget/components/Fund.d.ts.map +1 -1
  95. package/dist/widget/components/FundMethods.d.ts.map +1 -1
  96. package/dist/widget/components/HighPriceImpactBlock.d.ts +7 -0
  97. package/dist/widget/components/HighPriceImpactBlock.d.ts.map +1 -0
  98. package/dist/widget/components/MeldHistory.d.ts.map +1 -1
  99. package/dist/widget/components/MeshExchangeSelection.d.ts +11 -0
  100. package/dist/widget/components/MeshExchangeSelection.d.ts.map +1 -0
  101. package/dist/widget/components/OnrampHistoryRow.d.ts +1 -1
  102. package/dist/widget/components/OnrampHistoryRow.d.ts.map +1 -1
  103. package/dist/widget/components/OnrampProviderConfirmation.d.ts.map +1 -1
  104. package/dist/widget/components/Pay.d.ts.map +1 -1
  105. package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
  106. package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
  107. package/dist/widget/components/QRCodeWalletSelect.d.ts +1 -1
  108. package/dist/widget/components/QRCodeWalletSelect.d.ts.map +1 -1
  109. package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
  110. package/dist/widget/components/Receipt.d.ts.map +1 -1
  111. package/dist/widget/components/Recipients.d.ts.map +1 -1
  112. package/dist/widget/components/RefundWarning.d.ts.map +1 -1
  113. package/dist/widget/components/TokenSelector.d.ts.map +1 -1
  114. package/dist/widget/components/TransactionDetails.d.ts.map +1 -1
  115. package/dist/widget/components/TransactionHistoryItem.d.ts +2 -0
  116. package/dist/widget/components/TransactionHistoryItem.d.ts.map +1 -1
  117. package/dist/widget/components/TransferPendingVertical.d.ts +1 -0
  118. package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
  119. package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
  120. package/dist/widget/components/WalletConnect.d.ts.map +1 -1
  121. package/dist/widget/components/WalletImage.d.ts.map +1 -1
  122. package/dist/widget/components/WalletList.d.ts.map +1 -1
  123. package/dist/widget/components/Withdraw.d.ts.map +1 -1
  124. package/dist/widget/css/compiled.css +1 -1
  125. package/dist/widget/hooks/useAddressWalletIcon.d.ts.map +1 -1
  126. package/dist/widget/hooks/useCombinedHistory.d.ts +6 -5
  127. package/dist/widget/hooks/useCombinedHistory.d.ts.map +1 -1
  128. package/dist/widget/hooks/useCustomTokenSearch.d.ts +6 -1
  129. package/dist/widget/hooks/useCustomTokenSearch.d.ts.map +1 -1
  130. package/dist/widget/hooks/useDefaultDestinationToken.d.ts.map +1 -1
  131. package/dist/widget/hooks/useDefaultOriginToken.d.ts.map +1 -1
  132. package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts +1 -1
  133. package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts.map +1 -1
  134. package/dist/widget/hooks/useGetIntent.d.ts +3 -2
  135. package/dist/widget/hooks/useGetIntent.d.ts.map +1 -1
  136. package/dist/widget/hooks/useIntentReceiptBalances.d.ts +1 -1
  137. package/dist/widget/hooks/useIntentReceiptBalances.d.ts.map +1 -1
  138. package/dist/widget/hooks/useIntentTransactionHistory.d.ts +3 -2
  139. package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
  140. package/dist/widget/hooks/useMeldTransactionHistory.d.ts +1 -1
  141. package/dist/widget/hooks/useMeldTransactionHistory.d.ts.map +1 -1
  142. package/dist/widget/hooks/useMeldTransactionStatus.d.ts +1 -1
  143. package/dist/widget/hooks/useMeldTransactionStatus.d.ts.map +1 -1
  144. package/dist/widget/hooks/useOnRampQuote.d.ts +1 -1
  145. package/dist/widget/hooks/useOnRampQuote.d.ts.map +1 -1
  146. package/dist/widget/hooks/useOnRampTransactionStatus.d.ts +1 -1
  147. package/dist/widget/hooks/useOnRampTransactionStatus.d.ts.map +1 -1
  148. package/dist/widget/hooks/useQuote.d.ts +2 -2
  149. package/dist/widget/hooks/useQuote.d.ts.map +1 -1
  150. package/dist/widget/hooks/useSelectedFundMethod.d.ts +7 -0
  151. package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -1
  152. package/dist/widget/hooks/useSendForm.d.ts +0 -1
  153. package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
  154. package/dist/widget/hooks/useTokenList.d.ts +7 -1
  155. package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
  156. package/dist/widget/hooks/useViewManager.d.ts +1 -1
  157. package/dist/widget/hooks/useViewManager.d.ts.map +1 -1
  158. package/dist/widget/index.js +1 -1
  159. package/dist/widget/providers/TrailsProvider.d.ts +2 -0
  160. package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
  161. package/dist/widget/utils/createWagmiConfig.d.ts +2 -2
  162. package/dist/widget/utils/createWagmiConfig.d.ts.map +1 -1
  163. package/dist/widget/utils/fundMethodSwitchState.d.ts +1 -0
  164. package/dist/widget/utils/fundMethodSwitchState.d.ts.map +1 -1
  165. package/dist/widget/utils/historyFilters.d.ts +13 -0
  166. package/dist/widget/utils/historyFilters.d.ts.map +1 -0
  167. package/dist/widget/utils/meldProviderUtils.d.ts +1 -1
  168. package/dist/widget/utils/meldProviderUtils.d.ts.map +1 -1
  169. package/dist/widget/utils/meshSupportedTokens.d.ts +4 -0
  170. package/dist/widget/utils/meshSupportedTokens.d.ts.map +1 -0
  171. package/dist/widget/utils/onrampConfig.d.ts +11 -0
  172. package/dist/widget/utils/onrampConfig.d.ts.map +1 -0
  173. package/dist/widget/utils/statusLabel.d.ts +2 -0
  174. package/dist/widget/utils/statusLabel.d.ts.map +1 -0
  175. package/dist/widget/utils/trailsOnrampConfig.d.ts +18 -0
  176. package/dist/widget/utils/trailsOnrampConfig.d.ts.map +1 -0
  177. package/dist/widget/widget.d.ts +24 -8
  178. package/dist/widget/widget.d.ts.map +1 -1
  179. package/package.json +9 -7
  180. package/src/chains.ts +26 -9
  181. package/src/constants.ts +2 -0
  182. package/src/customTokens.ts +22 -7
  183. package/src/error.ts +7 -0
  184. package/src/gasless.ts +5 -2
  185. package/src/index.ts +8 -5
  186. package/src/intents.ts +56 -60
  187. package/src/keyMachineClient.ts +29 -0
  188. package/src/keymachine/index.ts +175 -0
  189. package/src/keymachine/key-machine.gen.ts +993 -0
  190. package/src/onramp/MeshConnectFlow.tsx +86 -0
  191. package/src/onramp/MeshConnectIframe.tsx +661 -0
  192. package/src/onramp/SendFromExchangeButton.tsx +81 -0
  193. package/src/onramp/TrailsOnRampProvider.tsx +59 -0
  194. package/src/onramp/index.ts +31 -0
  195. package/src/onramp/meshconnect.ts +277 -0
  196. package/src/onramp/trailsOnramp.tsx +130 -0
  197. package/src/onramp-client/index.ts +4 -6
  198. package/src/paymasterSend.ts +0 -5
  199. package/src/prepareSend.ts +45 -44
  200. package/src/query/balance.fetchers.ts +172 -17
  201. package/src/query/balance.hooks.ts +69 -6
  202. package/src/query/balance.queries.ts +63 -0
  203. package/src/query/chains.queries.ts +1 -6
  204. package/src/query/meld.fetchers.ts +1 -1
  205. package/src/query/meld.hooks.ts +1 -1
  206. package/src/query/meld.queries.ts +1 -1
  207. package/src/query/price.fetchers.ts +53 -0
  208. package/src/query/price.hooks.ts +46 -0
  209. package/src/query/price.queries.ts +364 -0
  210. package/src/query/tokenList.queries.ts +118 -0
  211. package/src/recover.ts +89 -26
  212. package/src/tokens.ts +108 -26
  213. package/src/transactionIntent/deposits/depositOrchestrator.ts +11 -11
  214. package/src/transactionIntent/deposits/gaslessDeposit.ts +38 -39
  215. package/src/transactionIntent/deposits/standardDeposit.ts +5 -30
  216. package/src/transactionIntent/handlers/intentHandler.ts +29 -12
  217. package/src/transactionIntent/helpers/transactionStateHelpers.ts +5 -2
  218. package/src/transactionIntent/quote/normalizeQuote.ts +11 -5
  219. package/src/transactionIntent/types.ts +1 -1
  220. package/src/transactions.ts +5 -1
  221. package/src/utils/format.ts +85 -1
  222. package/src/walletUtils.ts +2 -1
  223. package/src/wallets.ts +184 -380
  224. package/src/widget/compiled.css +1 -1
  225. package/src/widget/components/AccountIntentTransactionHistory.tsx +134 -109
  226. package/src/widget/components/ClassicSwap.tsx +26 -24
  227. package/src/widget/components/ConnectWallet.tsx +4 -2
  228. package/src/widget/components/ConnectedWallets.tsx +2 -5
  229. package/src/widget/components/DirectTransfer.tsx +5 -2
  230. package/src/widget/components/EarnPools.tsx +1 -2
  231. package/src/widget/components/ExecutionStatusBadge.tsx +10 -4
  232. package/src/widget/components/Fund.tsx +169 -110
  233. package/src/widget/components/FundMethods.tsx +5 -9
  234. package/src/widget/components/HighPriceImpactBlock.tsx +44 -0
  235. package/src/widget/components/MeldHistory.tsx +4 -28
  236. package/src/widget/components/MeshExchangeSelection.tsx +218 -0
  237. package/src/widget/components/OnrampHistoryRow.tsx +3 -27
  238. package/src/widget/components/OnrampProviderConfirmation.tsx +0 -25
  239. package/src/widget/components/Pay.tsx +20 -36
  240. package/src/widget/components/PoolDeposit.tsx +14 -24
  241. package/src/widget/components/PoolWithdraw.tsx +1 -63
  242. package/src/widget/components/QRCodeWalletSelect.tsx +5 -2
  243. package/src/widget/components/QuoteDetails.tsx +113 -106
  244. package/src/widget/components/Receipt.tsx +0 -11
  245. package/src/widget/components/Recipients.tsx +2 -1
  246. package/src/widget/components/RefundWarning.tsx +5 -10
  247. package/src/widget/components/ThemeProvider.tsx +4 -4
  248. package/src/widget/components/TokenSelector.tsx +85 -16
  249. package/src/widget/components/TransactionDetails.tsx +46 -0
  250. package/src/widget/components/TransactionHistoryItem.tsx +14 -23
  251. package/src/widget/components/TransferPendingVertical.tsx +17 -11
  252. package/src/widget/components/WaasFeeOptions.tsx +4 -42
  253. package/src/widget/components/WalletConnect.tsx +2 -5
  254. package/src/widget/components/WalletImage.tsx +6 -18
  255. package/src/widget/components/WalletList.tsx +1 -1
  256. package/src/widget/components/Withdraw.tsx +22 -23
  257. package/src/widget/hooks/useAddressWalletIcon.ts +2 -1
  258. package/src/widget/hooks/useAmountUsd.ts +1 -1
  259. package/src/widget/hooks/useCombinedHistory.ts +37 -93
  260. package/src/widget/hooks/useCustomTokenSearch.tsx +63 -33
  261. package/src/widget/hooks/useDefaultDestinationToken.tsx +2 -5
  262. package/src/widget/hooks/useDefaultOriginToken.tsx +2 -5
  263. package/src/widget/hooks/useFiatOnRampCurrencies.ts +1 -1
  264. package/src/widget/hooks/useGetIntent.ts +5 -4
  265. package/src/widget/hooks/useIntentReceiptBalances.ts +3 -3
  266. package/src/widget/hooks/useIntentTransactionHistory.ts +24 -47
  267. package/src/widget/hooks/useMeldTransactionHistory.ts +4 -2
  268. package/src/widget/hooks/useMeldTransactionStatus.ts +13 -11
  269. package/src/widget/hooks/useOnRampQuote.ts +3 -3
  270. package/src/widget/hooks/useOnRampTransactionStatus.ts +8 -6
  271. package/src/widget/hooks/useQuote.ts +56 -48
  272. package/src/widget/hooks/useSelectedFundMethod.tsx +14 -1
  273. package/src/widget/hooks/useSendForm.ts +52 -31
  274. package/src/widget/hooks/useTokenList.ts +209 -140
  275. package/src/widget/hooks/useTrailsSendTransaction.ts +1 -1
  276. package/src/widget/hooks/useViewManager.tsx +1 -0
  277. package/src/widget/providers/TrailsProvider.tsx +5 -0
  278. package/src/widget/styles.ts +1 -1
  279. package/src/widget/utils/createWagmiConfig.ts +7 -2
  280. package/src/widget/utils/fundMethodSwitchState.ts +2 -0
  281. package/src/widget/utils/historyFilters.ts +157 -0
  282. package/src/widget/utils/meldProviderUtils.ts +8 -2
  283. package/src/widget/utils/meshSupportedTokens.ts +28 -0
  284. package/src/widget/utils/onrampConfig.ts +15 -0
  285. package/src/widget/utils/statusLabel.ts +3 -0
  286. package/src/widget/utils/trailsOnrampConfig.ts +39 -0
  287. package/src/widget/widget.tsx +235 -185
  288. package/dist/onramp-client/trails-onramp.gen.d.ts +0 -570
  289. package/dist/onramp-client/trails-onramp.gen.d.ts.map +0 -1
  290. package/dist/prices.d.ts +0 -34
  291. package/dist/prices.d.ts.map +0 -1
  292. package/dist/useGasEstimation.d.ts +0 -34
  293. package/dist/useGasEstimation.d.ts.map +0 -1
  294. package/dist/widget/hooks/useCustomTokenFetch.d.ts +0 -19
  295. package/dist/widget/hooks/useCustomTokenFetch.d.ts.map +0 -1
  296. package/dist/widget/hooks/useTokenWithFreshBalance.d.ts +0 -18
  297. package/dist/widget/hooks/useTokenWithFreshBalance.d.ts.map +0 -1
  298. package/src/onramp-client/trails-onramp.gen.ts +0 -1320
  299. package/src/prices.ts +0 -528
  300. package/src/useGasEstimation.ts +0 -147
  301. package/src/widget/assets/Binance_Icon_Logo.svg +0 -14
  302. package/src/widget/assets/Bitfinex_Icon_Logo.svg +0 -5
  303. package/src/widget/assets/Coinbase_Icon_Logo.svg +0 -1
  304. package/src/widget/assets/WalletConnect-logo-blue-bg.svg +0 -11
  305. package/src/widget/assets/sequence-logo.svg +0 -15
  306. package/src/widget/hooks/useCustomTokenFetch.tsx +0 -74
  307. package/src/widget/hooks/useTokenWithFreshBalance.ts +0 -246
package/src/recover.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Payload as WalletPayload } from "@0xsequence/wallet-primitives"
2
2
  import {
3
+ type Config,
3
4
  Constants,
4
5
  Erc6492,
5
6
  Payload,
@@ -21,7 +22,11 @@ import { attemptSwitchChain } from "./chainSwitch.js"
21
22
  import { SEQUENCE_V3_CONTRACT_ADDRESSES } from "./constants.js"
22
23
  import { decodeGuestModuleEvents } from "./decoders.js"
23
24
  import { splitSignature } from "./gasless.js"
24
- import { abortIntent, getIntentConfigurationFromCalls } from "./intents.js"
25
+ import {
26
+ abortIntent,
27
+ getIntentConfigurationFromAddress,
28
+ getIntentConfigurationFromCalls,
29
+ } from "./intents.js"
25
30
  import { logger } from "./logger.js"
26
31
  import { type TrailsClient, useTrailsClient } from "./trailsClient.js"
27
32
  import {
@@ -39,6 +44,28 @@ import { getERC20TransferData } from "./utils.js"
39
44
  import { useGetIntent } from "./widget/hooks/useGetIntent.js"
40
45
 
41
46
  import { normalizeAddress } from "./utils/address.js"
47
+ import {
48
+ type KeyMachineClient,
49
+ useKeyMachineClient,
50
+ } from "./keyMachineClient.js"
51
+
52
+ function getIntentProtocol(
53
+ intent: Intent | null | undefined,
54
+ ): IntentProtocolVersion {
55
+ const rawIntentProtocol = (
56
+ intent as { intentProtocol?: string; intentProtocolVersion?: string }
57
+ )?.intentProtocol
58
+ const rawIntentProtocolVersion = (
59
+ intent as { intentProtocol?: string; intentProtocolVersion?: string }
60
+ )?.intentProtocolVersion
61
+ const rawVersion = rawIntentProtocol ?? rawIntentProtocolVersion
62
+
63
+ if (rawVersion === "v1.5" || rawVersion === "v1_5") {
64
+ return IntentProtocolVersion.v1_5
65
+ }
66
+
67
+ return IntentProtocolVersion.v1
68
+ }
42
69
  /**
43
70
  * Checks if an address is deployed by checking for bytecode
44
71
  * @param address - The address to check
@@ -132,8 +159,9 @@ export async function signPayload(
132
159
 
133
160
  export interface BuildRefundTransactionWithSignatureParams {
134
161
  trailsClient: TrailsClient
162
+ keyMachineClient: KeyMachineClient
135
163
  intentId: string
136
- intentProtocolVersion: IntentProtocolVersion
164
+ intentProtocol: IntentProtocolVersion
137
165
  mainSigner: Address.Address
138
166
  checkpoint: number
139
167
  calls: Array<IntentCalls>
@@ -152,8 +180,9 @@ export async function buildRefundTransactionWithSignature(
152
180
  ): Promise<{ to: `0x${string}`; data: Hex.Hex }> {
153
181
  const {
154
182
  trailsClient,
183
+ keyMachineClient,
155
184
  intentId,
156
- intentProtocolVersion,
185
+ intentProtocol,
157
186
  mainSigner,
158
187
  checkpoint,
159
188
  calls,
@@ -210,7 +239,7 @@ export async function buildRefundTransactionWithSignature(
210
239
  // In the current version, calls are already pre-filtered in the hook
211
240
  // to contain only the calls for the selected intent address (origin or destination)
212
241
  logger.console.log("[refund] Using pre-filtered calls for configuration:", {
213
- intentProtocolVersion,
242
+ intentProtocol,
214
243
  callsCount: calls.length,
215
244
  chainId,
216
245
  intentAddress,
@@ -222,25 +251,39 @@ export async function buildRefundTransactionWithSignature(
222
251
  throw new Error("Invalid calls provided for intent configuration")
223
252
  }
224
253
 
254
+ let intentConfig: Config.Config
255
+ let imageHash: Hex.Hex
256
+ let resolvedAddress: Address.Address
225
257
  const context = SEQUENCE_V3_CONTRACT_ADDRESSES
226
- const {
227
- config: intentConfig,
228
- imageHash,
229
- address: apiAddress,
230
- } = await getIntentConfigurationFromCalls(
231
- trailsClient,
232
- intentId,
233
- intentProtocolVersion,
234
- mainSigner,
235
- checkpoint,
236
- calls[0]!,
237
- isOriginIntent,
238
- context,
258
+ // Attempt to get the intent configuration from the address
259
+ const configFromAddress = await getIntentConfigurationFromAddress(
260
+ keyMachineClient,
261
+ intentAddress,
239
262
  )
263
+ if (configFromAddress) {
264
+ intentConfig = configFromAddress.config
265
+ imageHash = configFromAddress.imageHash
266
+ resolvedAddress = configFromAddress.address
267
+ } else {
268
+ // Fallback to reconstruction
269
+ const configFromCalls = await getIntentConfigurationFromCalls(
270
+ trailsClient,
271
+ intentId,
272
+ intentProtocol,
273
+ mainSigner,
274
+ checkpoint,
275
+ calls[0]!,
276
+ isOriginIntent,
277
+ context,
278
+ )
279
+ intentConfig = configFromCalls.config
280
+ imageHash = configFromCalls.imageHash
281
+ resolvedAddress = configFromCalls.address
282
+ }
240
283
 
241
284
  logger.console.log("[refund] Image hash:", imageHash)
242
285
 
243
- if (!Address.isEqual(apiAddress, intentAddress)) {
286
+ if (!Address.isEqual(resolvedAddress, intentAddress)) {
244
287
  throw new Error(
245
288
  "API address does not match intent address. Probably config is wrong",
246
289
  )
@@ -813,6 +856,7 @@ function buildCallsForSelectedAddress(
813
856
  */
814
857
  async function buildRecoverTxFromSignature(params: {
815
858
  trailsClient: TrailsClient
859
+ keyMachineClient: KeyMachineClient
816
860
  intentData: Intent
817
861
  mainSigner: Address.Address
818
862
  selected: SelectedIntentAddress
@@ -827,6 +871,7 @@ async function buildRecoverTxFromSignature(params: {
827
871
  }> {
828
872
  const {
829
873
  trailsClient,
874
+ keyMachineClient,
830
875
  intentData,
831
876
  mainSigner,
832
877
  selected,
@@ -846,14 +891,14 @@ async function buildRecoverTxFromSignature(params: {
846
891
  throw new Error("Chain ID not found for selected intent address")
847
892
  }
848
893
 
849
- const intentProtocolVersion =
850
- intentData.intentProtocolVersion ?? IntentProtocolVersion.v1
894
+ const intentProtocol = getIntentProtocol(intentData)
851
895
  const checkpoint = Number(intentData.salt)
852
896
 
853
897
  const result = await buildRefundTransactionWithSignature({
854
898
  trailsClient,
899
+ keyMachineClient,
855
900
  intentId: intentData.intentId,
856
- intentProtocolVersion,
901
+ intentProtocol,
857
902
  checkpoint,
858
903
  mainSigner,
859
904
  calls,
@@ -987,7 +1032,7 @@ export interface UseIntentRecoverReturn {
987
1032
  }>
988
1033
  }
989
1034
 
990
- export interface UseIntentRecoverWithSignatureParams {
1035
+ export interface UseIntentRecoverWithAddressParams {
991
1036
  intentId: string | undefined
992
1037
  /** Signer for the recovery tx and default refund receiver */
993
1038
  walletAddress: `0x${string}` | undefined
@@ -995,7 +1040,7 @@ export interface UseIntentRecoverWithSignatureParams {
995
1040
  refundToAddress?: `0x${string}`
996
1041
  }
997
1042
 
998
- export interface UseIntentRecoverWithSignatureReturn {
1043
+ export interface UseIntentRecoverWithAddressReturn {
999
1044
  intent: Intent | null
1000
1045
  isLoadingIntent: boolean
1001
1046
  isLoadingBalances: boolean
@@ -1205,7 +1250,7 @@ export function useIntentRecoverWithAddress({
1205
1250
  intentId,
1206
1251
  walletAddress,
1207
1252
  refundToAddress,
1208
- }: UseIntentRecoverWithSignatureParams): UseIntentRecoverWithSignatureReturn {
1253
+ }: UseIntentRecoverWithAddressParams): UseIntentRecoverWithAddressReturn {
1209
1254
  const {
1210
1255
  intent: intentData,
1211
1256
  isLoading: isLoadingIntent,
@@ -1217,7 +1262,7 @@ export function useIntentRecoverWithAddress({
1217
1262
  })
1218
1263
 
1219
1264
  const trailsClient = useTrailsClient()
1220
-
1265
+ const keyMachineClient = useKeyMachineClient()
1221
1266
  const originIntentAddressForBalances = intentData?.originIntentAddress
1222
1267
  ? Address.from(intentData.originIntentAddress)
1223
1268
  : null
@@ -1354,6 +1399,7 @@ export function useIntentRecoverWithAddress({
1354
1399
  }
1355
1400
  return buildRecoverTxFromSignature({
1356
1401
  trailsClient,
1402
+ keyMachineClient,
1357
1403
  intentData,
1358
1404
  mainSigner: Address.from(walletAddress),
1359
1405
  selected: selectedIntentAddress,
@@ -1368,6 +1414,7 @@ export function useIntentRecoverWithAddress({
1368
1414
  selectedIntentAddress,
1369
1415
  effectiveRefundAddress,
1370
1416
  trailsClient,
1417
+ keyMachineClient,
1371
1418
  ],
1372
1419
  )
1373
1420
 
@@ -1416,6 +1463,7 @@ export function useIntentRecoverWithBalances({
1416
1463
  refundToAddress,
1417
1464
  }: UseIntentRecoverWithBalancesParams): UseIntentRecoverWithBalancesReturn {
1418
1465
  const trailsClient = useTrailsClient()
1466
+ const keyMachineClient = useKeyMachineClient()
1419
1467
 
1420
1468
  const originTokenBalancesData = intentData?.originIntentAddress
1421
1469
  ? balancesByIntentAddress[normalizeAddress(intentData.originIntentAddress)]
@@ -1563,7 +1611,20 @@ export function useIntentRecoverWithBalances({
1563
1611
  throw new Error("No intent address selected for recovery")
1564
1612
  }
1565
1613
 
1566
- if (!intentData.intentProtocolVersion) {
1614
+ const rawIntentProtocol = (
1615
+ intentData as {
1616
+ intentProtocol?: string
1617
+ intentProtocolVersion?: string
1618
+ }
1619
+ ).intentProtocol
1620
+ const rawIntentProtocolVersion = (
1621
+ intentData as {
1622
+ intentProtocol?: string
1623
+ intentProtocolVersion?: string
1624
+ }
1625
+ ).intentProtocolVersion
1626
+
1627
+ if (!rawIntentProtocol && !rawIntentProtocolVersion) {
1567
1628
  logger.console.log(
1568
1629
  "[recover] Intent configuration version not found, using V1",
1569
1630
  )
@@ -1571,6 +1632,7 @@ export function useIntentRecoverWithBalances({
1571
1632
 
1572
1633
  return buildRecoverTxFromSignature({
1573
1634
  trailsClient,
1635
+ keyMachineClient,
1574
1636
  intentData,
1575
1637
  mainSigner: Address.from(walletClient.account.address),
1576
1638
  selected: selectedIntentAddress,
@@ -1585,6 +1647,7 @@ export function useIntentRecoverWithBalances({
1585
1647
  selectedIntentAddress,
1586
1648
  effectiveRefundAddress,
1587
1649
  trailsClient,
1650
+ keyMachineClient,
1588
1651
  ],
1589
1652
  )
1590
1653
 
package/src/tokens.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { useQuery } from "@tanstack/react-query"
1
+ import {
2
+ useQuery,
3
+ useQueryClient,
4
+ type QueryClient,
5
+ } from "@tanstack/react-query"
2
6
  import { DAY_MS, retryDelay } from "./utils/time.js"
3
7
  import { queryPersister } from "./query/persister.js"
4
8
  import { erc20Abi, zeroAddress } from "viem"
5
- import {
6
- getChainInfo,
7
- getChainRpcClient,
8
- getSupportedSequenceChains,
9
- } from "./chains.js"
9
+ import { getChainInfo, getChainRpcClient } from "./chains.js"
10
10
  import {
11
11
  arbitrum,
12
12
  base,
@@ -46,6 +46,9 @@ import { getTrailsClient } from "./trailsClient.js"
46
46
  import { formatBalanceFields, formatPriceFields } from "./utils/format.js"
47
47
  import { PROD_SEQUENCE_METADATA_URL } from "./constants.js"
48
48
  import { SequenceMetadata } from "@0xsequence/metadata"
49
+ import { chainQueries } from "./query/chains.queries.js"
50
+ import { tokenListQueries } from "./query/tokenList.queries.js"
51
+ import { queryClient as defaultQueryClient } from "./query/client.js"
49
52
 
50
53
  // ApiTokenInfo type from trails-api (internal use only)
51
54
  interface ApiTokenInfo {
@@ -417,12 +420,16 @@ export function getCachedTokenImageUrl(
417
420
  export async function getSupportedTokens(config: {
418
421
  trailsApiKey: string
419
422
  trailsApiUrl: string
423
+ queryClient?: QueryClient
420
424
  }): Promise<Token[]> {
421
- const sequenceChains = await getSupportedSequenceChains({
422
- trailsApiUrl: config.trailsApiUrl,
423
- trailsApiKey: config.trailsApiKey,
424
- })
425
- const chainIds = sequenceChains.map((chain) => chain.id)
425
+ const effectiveQueryClient = config.queryClient ?? defaultQueryClient
426
+ const chains = await effectiveQueryClient.ensureQueryData(
427
+ chainQueries.supported({
428
+ trailsApiUrl: config.trailsApiUrl,
429
+ trailsApiKey: config.trailsApiKey,
430
+ }),
431
+ )
432
+ const chainIds = chains.map((chain) => chain.id)
426
433
 
427
434
  // Get trails client using provided config
428
435
  const trailsClient = getTrailsClient({
@@ -444,11 +451,23 @@ export async function getSupportedTokens(config: {
444
451
  // When filtering by a single chain, use limit of 100, otherwise use 30 per chain
445
452
  // Type assertion needed because TrailsClient extends TrailsApi which has these methods
446
453
  const limit = chainIds.length === 1 ? 100 : 30
447
- const tokenListResponse = await trailsClient.getTokenList({
448
- chainIds,
449
- includeAllListed: true,
450
- limit, // Limit per chain - 100 for single chain, 30 for multiple chains
451
- })
454
+ const tokenListResponse =
455
+ chainIds.length > 0
456
+ ? await effectiveQueryClient.ensureQueryData(
457
+ tokenListQueries.catalog(
458
+ trailsClient,
459
+ {
460
+ trailsApiUrl: config.trailsApiUrl,
461
+ trailsApiKey: config.trailsApiKey,
462
+ },
463
+ {
464
+ chainIds,
465
+ includeAllListed: true,
466
+ limit,
467
+ },
468
+ ),
469
+ )
470
+ : { tokens: [] }
452
471
 
453
472
  // The API already handles sorting (featured first, then alphabetically) and deduplication
454
473
  // Map ApiTokenInfo from API to Token format using conversion helper
@@ -551,24 +570,22 @@ export function useSupportedTokens({
551
570
  } {
552
571
  const { customTokens } = useCustomTokens()
553
572
  const trailsConfig = useTrails()
573
+ const queryClient = useQueryClient()
554
574
  const { data: supportedTokens = EMPTY_TOKENS, isLoading: isLoadingTokens } =
555
575
  useQuery({
556
- queryKey: [
557
- "supportedTokens",
558
- trailsConfig.trailsApiUrl,
559
- trailsConfig.trailsApiKey,
560
- ],
576
+ queryKey: ["supportedTokens"],
561
577
  queryFn: async () => {
562
578
  return getSupportedTokens({
563
579
  trailsApiKey: trailsConfig.trailsApiKey,
564
580
  trailsApiUrl: trailsConfig.trailsApiUrl,
581
+ queryClient,
565
582
  })
566
583
  },
567
584
  staleTime: DAY_MS,
568
585
  gcTime: DAY_MS,
569
- refetchOnMount: false, // Don't refetch when cached data exists (persistence-friendly)
570
- refetchOnWindowFocus: false, // Don't refetch when window regains focus
571
- refetchOnReconnect: false, // Don't refetch on network reconnect
586
+ refetchOnMount: false,
587
+ refetchOnWindowFocus: false,
588
+ refetchOnReconnect: false,
572
589
  enabled: !disabled,
573
590
  persister: queryPersister.persisterFn,
574
591
  })
@@ -670,6 +687,7 @@ export async function getTokenInfo(
670
687
  trailsApiKey: string
671
688
  trailsApiUrl: string
672
689
  sequenceMetadataUrl: string
690
+ queryClient?: QueryClient
673
691
  },
674
692
  ): Promise<Token | null> {
675
693
  const normalizedAddress = normalizeAddress(contractAddress)
@@ -717,7 +735,11 @@ export async function getTokenInfo(
717
735
  }
718
736
 
719
737
  // Look in supported tokens
720
- const tokens = await getSupportedTokens(config)
738
+ const tokens = await getSupportedTokens({
739
+ trailsApiKey: config.trailsApiKey,
740
+ trailsApiUrl: config.trailsApiUrl,
741
+ queryClient: config.queryClient,
742
+ })
721
743
  const token = tokens.find(
722
744
  (t) =>
723
745
  t.chainId === chainId &&
@@ -855,6 +877,60 @@ export async function getTokenInfo(
855
877
  }
856
878
  }
857
879
 
880
+ /**
881
+ * Search for a token by contract address across all chains using the
882
+ * Sequence Metadata findContractInfo endpoint. Returns one Token per
883
+ * chain where the contract is deployed with valid ERC-20 metadata.
884
+ */
885
+ export async function searchTokenByAddress(
886
+ contractAddress: string,
887
+ config: {
888
+ sequenceMetadataUrl: string
889
+ trailsApiKey: string
890
+ },
891
+ ): Promise<Token[]> {
892
+ const normalizedAddress = normalizeAddress(contractAddress)
893
+
894
+ const metadataClient = new SequenceMetadata(
895
+ config.sequenceMetadataUrl,
896
+ config.trailsApiKey,
897
+ )
898
+
899
+ const { contractInfoList } = await metadataClient.findContractInfo({
900
+ contractAddress: normalizedAddress,
901
+ })
902
+
903
+ return (contractInfoList || [])
904
+ .filter(
905
+ (info) =>
906
+ info.deployed === true && info.decimals != null && info.decimals > 0,
907
+ )
908
+ .map((info): Token => {
909
+ const addr = normalizeAddress(info.address)
910
+ const chainInfo = getChainInfo(info.chainId)
911
+ const token: Token = {
912
+ tokenId: `${info.symbol}-${chainInfo?.name || `chain-${info.chainId}`}`,
913
+ symbol: info.symbol,
914
+ name: info.name,
915
+ decimals: info.decimals!,
916
+ chainId: info.chainId,
917
+ contractAddress: addr,
918
+ chainName: chainInfo?.name || `Chain ${info.chainId}`,
919
+ imageUrl:
920
+ info.logoURI ||
921
+ getTokenImageUrl({
922
+ chainId: info.chainId,
923
+ contractAddress: addr,
924
+ symbol: info.symbol,
925
+ }),
926
+ isCustomToken: true,
927
+ }
928
+
929
+ setTokenInfoCache(`${info.chainId}:${addr}`, token)
930
+ return token
931
+ })
932
+ }
933
+
858
934
  // Mapping of hyphenated symbols to their canonical token symbols.
859
935
  // The Sequence API returns BNB-USD, but we want to use USDT instead.
860
936
  const HYPHENATED_SYMBOL_MAP: Record<string, string> = {
@@ -864,7 +940,11 @@ const HYPHENATED_SYMBOL_MAP: Record<string, string> = {
864
940
  export async function getTokenAddress(
865
941
  chainId: number,
866
942
  tokenSymbol: string,
867
- config: { trailsApiKey: string; trailsApiUrl: string },
943
+ config: {
944
+ trailsApiKey: string
945
+ trailsApiUrl: string
946
+ queryClient?: QueryClient
947
+ },
868
948
  ) {
869
949
  const chainInfo = getChainInfo(chainId)
870
950
  // Normalize token symbol: trim whitespace and convert to uppercase for comparison
@@ -915,6 +995,7 @@ export function useTokenAddress({
915
995
  tokenSymbol,
916
996
  }: UseTokenAddressProps) {
917
997
  const trailsConfig = useTrails()
998
+ const queryClient = useQueryClient()
918
999
  const { data: tokenAddress } = useQuery({
919
1000
  queryKey: ["tokenAddress", chainId, tokenSymbol],
920
1001
  queryFn: () =>
@@ -922,6 +1003,7 @@ export function useTokenAddress({
922
1003
  ? getTokenAddress(chainId, tokenSymbol, {
923
1004
  trailsApiKey: trailsConfig.trailsApiKey,
924
1005
  trailsApiUrl: trailsConfig.trailsApiUrl,
1006
+ queryClient,
925
1007
  })
926
1008
  : null,
927
1009
  enabled: !!chainId && !!tokenSymbol,
@@ -9,11 +9,11 @@ import type { FeeOption, TrailsApi } from "@0xtrails/api"
9
9
  import type { TransactionState } from "../../transactions.js"
10
10
  import type { CheckoutOnHandlers } from "../../widget/hooks/useCheckout.js"
11
11
  import type { FundMethod } from "../types.js"
12
- import type {
13
- DepositSignature,
14
- GasFeeOptions,
15
- ExecuteIntentResponse,
16
- TrailsContracts,
12
+ import {
13
+ type DepositSignature,
14
+ type GasFeeOptions,
15
+ type ExecuteIntentResponse,
16
+ type TrailsContracts,
17
17
  IntentProtocolVersion,
18
18
  } from "@0xtrails/api"
19
19
  import type { QueryClient } from "@tanstack/react-query"
@@ -59,7 +59,7 @@ export async function attemptUserDepositTx({
59
59
  sequenceProjectAccessKey,
60
60
  sequenceIndexerUrl,
61
61
  depositTransaction,
62
- intentProtocolVersion,
62
+ intentProtocol,
63
63
  }: {
64
64
  queryClient?: QueryClient
65
65
  originTokenAddress: string
@@ -106,7 +106,7 @@ export async function attemptUserDepositTx({
106
106
  value?: string | bigint
107
107
  chainId: number
108
108
  }
109
- intentProtocolVersion: IntentProtocolVersion
109
+ intentProtocol: IntentProtocolVersion
110
110
  }): Promise<TransactionReceipt | null> {
111
111
  let depositUserTxnReceipt: TransactionReceipt | null = null
112
112
  const originChainId = chain.id
@@ -119,7 +119,7 @@ export async function attemptUserDepositTx({
119
119
  logger.console.log(
120
120
  "[trails-sdk] [intent-protocol] attemptUserDepositTx called",
121
121
  {
122
- intentProtocolVersion,
122
+ intentProtocol,
123
123
  fundMethod,
124
124
  intentId,
125
125
  hasPaymasterUrl: !!paymasterUrl,
@@ -162,12 +162,12 @@ export async function attemptUserDepositTx({
162
162
  logger.console.log(
163
163
  "[trails-sdk] [intent-protocol] [gasless-flow] Entering gasless deposit flow",
164
164
  {
165
- intentProtocolVersion,
165
+ intentProtocol,
166
166
  doGasless,
167
167
  hasPaymasterUrl: !!paymasterUrl,
168
168
  paymasterUrl,
169
169
  gaslessFlowDifference:
170
- intentProtocolVersion === "v1"
170
+ intentProtocol === IntentProtocolVersion.v1
171
171
  ? "v1: requires intent signature + nonce + infinite permit"
172
172
  : "v1.5: simplified (permit only if needed)",
173
173
  },
@@ -192,7 +192,7 @@ export async function attemptUserDepositTx({
192
192
  onTransactionStateChange,
193
193
  transactionStates,
194
194
  executeIntentFn,
195
- intentProtocolVersion,
195
+ intentProtocol,
196
196
  })
197
197
  // Gasless deposit submitted to backend, monitoring happens separately
198
198
  depositUserTxnReceipt = null
@@ -1,12 +1,12 @@
1
1
  import type { Account, Chain, WalletClient } from "viem"
2
2
  import { maxUint256 } from "viem"
3
- import type {
4
- TrailsApi,
5
- GasFeeOptions,
6
- FeeOption,
7
- DepositSignature,
8
- ExecuteIntentResponse,
9
- TrailsContracts,
3
+ import {
4
+ type TrailsApi,
5
+ type GasFeeOptions,
6
+ type FeeOption,
7
+ type DepositSignature,
8
+ type ExecuteIntentResponse,
9
+ type TrailsContracts,
10
10
  IntentProtocolVersion,
11
11
  } from "@0xtrails/api"
12
12
  import type { CheckoutOnHandlers } from "../../widget/hooks/useCheckout.js"
@@ -53,7 +53,7 @@ export async function attemptGaslessDeposit({
53
53
  onTransactionStateChange,
54
54
  transactionStates,
55
55
  executeIntentFn,
56
- intentProtocolVersion,
56
+ intentProtocol,
57
57
  }: {
58
58
  paymasterUrl?: string
59
59
  depositTokenAddress: string
@@ -77,7 +77,7 @@ export async function attemptGaslessDeposit({
77
77
  depositTransactionHash?: string
78
78
  depositSignature?: DepositSignature
79
79
  }) => Promise<ExecuteIntentResponse>
80
- intentProtocolVersion: IntentProtocolVersion
80
+ intentProtocol: IntentProtocolVersion
81
81
  }): Promise<void> {
82
82
  const originChainId = chain.id
83
83
 
@@ -304,42 +304,43 @@ export async function attemptGaslessDeposit({
304
304
  }
305
305
  }
306
306
 
307
+ const isV1 = intentProtocol === IntentProtocolVersion.v1
308
+
307
309
  logger.console.log(
308
310
  "[trails-sdk] [intent-protocol] [gasless-flow] Checking approval requirements",
309
311
  {
310
- intentProtocolVersion,
311
- isV1: intentProtocolVersion === "v1",
312
- checkingEntrypointApproval: intentProtocolVersion === "v1",
312
+ intentProtocol,
313
+ isV1,
314
+ checkingEntrypointApproval: isV1,
313
315
  },
314
316
  )
315
317
 
316
- const needsApproval =
317
- intentProtocolVersion === "v1"
318
- ? await getNeedsIntentEntrypointApproval({
319
- client: publicClient,
320
- token: depositTokenAddress as `0x${string}`,
321
- account: account.address,
322
- entrypoint:
323
- TRAILS_CONTRACTS.trailsIntentEntrypointAddress as `0x${string}`,
324
- amount: requiredAmount, // Check if we have enough allowance for this specific transaction
325
- })
326
- : false
318
+ const needsApproval = isV1
319
+ ? await getNeedsIntentEntrypointApproval({
320
+ client: publicClient,
321
+ token: depositTokenAddress as `0x${string}`,
322
+ account: account.address,
323
+ entrypoint:
324
+ TRAILS_CONTRACTS.trailsIntentEntrypointAddress as `0x${string}`,
325
+ amount: requiredAmount, // Check if we have enough allowance for this specific transaction
326
+ })
327
+ : false
327
328
 
328
329
  logger.console.log(
329
330
  "[trails-sdk] [intent-protocol] [gasless-flow] Approval check result",
330
331
  {
331
- intentProtocolVersion,
332
+ intentProtocol,
332
333
  needsApproval,
333
- reason:
334
- intentProtocolVersion === "v1"
335
- ? "v1: checked entrypoint approval"
336
- : "v1.5: skipped entrypoint approval (not needed)",
334
+ reason: isV1
335
+ ? "v1: checked entrypoint approval"
336
+ : "v1.5: skipped entrypoint approval (not needed)",
337
337
  },
338
338
  )
339
339
 
340
340
  const depositTokenIsNative = isNativeToken(depositTokenAddressLower)
341
341
  const shouldAttachPermit =
342
- !depositTokenIsNative && (intentProtocolVersion !== "v1" || needsApproval)
342
+ !depositTokenIsNative &&
343
+ (intentProtocol !== IntentProtocolVersion.v1 || needsApproval)
343
344
 
344
345
  logger.console.log(
345
346
  "[trails-sdk] [gasless-flow] Checking permit requirements",
@@ -352,7 +353,7 @@ export async function attemptGaslessDeposit({
352
353
  chainID: originChainId,
353
354
  deadline,
354
355
  needsApproval,
355
- intentProtocolVersion,
356
+ intentProtocol,
356
357
  shouldAttachPermit,
357
358
  },
358
359
  )
@@ -369,7 +370,7 @@ export async function attemptGaslessDeposit({
369
370
  )
370
371
 
371
372
  let spender: `0x${string}`
372
- if (intentProtocolVersion === "v1") {
373
+ if (isV1) {
373
374
  // Use infinite approval (maxUint256) to entrypoint
374
375
  permitAmount = maxUint256
375
376
  spender =
@@ -415,7 +416,6 @@ export async function attemptGaslessDeposit({
415
416
  let permitSig: Awaited<ReturnType<typeof getPermitSignature>> | undefined
416
417
  try {
417
418
  permitSig = await getPermitSignature({
418
- publicClient,
419
419
  walletClient,
420
420
  signer: account.address,
421
421
  spender,
@@ -449,16 +449,15 @@ export async function attemptGaslessDeposit({
449
449
  logger.console.log(
450
450
  "[trails-sdk] [intent-protocol] [gasless-flow] Intent signature check",
451
451
  {
452
- intentProtocolVersion,
453
- requiresIntentSignature: intentProtocolVersion === "v1",
454
- reason:
455
- intentProtocolVersion === "v1"
456
- ? "v1: requires EIP-712 intent signature + nonce"
457
- : "v1.5: no intent signature needed (backend manages)",
452
+ intentProtocol,
453
+ requiresIntentSignature: isV1,
454
+ reason: isV1
455
+ ? "v1: requires EIP-712 intent signature + nonce"
456
+ : "v1.5: no intent signature needed (backend manages)",
458
457
  },
459
458
  )
460
459
 
461
- if (intentProtocolVersion === "v1") {
460
+ if (isV1) {
462
461
  // Intent signature is only needed for v1
463
462
  logger.console.log(
464
463
  "[trails-sdk] [intent-protocol] [gasless-flow] v1: Starting intent signature flow",