0xtrails 0.13.1 → 0.14.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 (804) hide show
  1. package/dist/abis/trailsHydrate.d.ts +5 -42
  2. package/dist/abis/trailsHydrate.d.ts.map +1 -1
  3. package/dist/abis/trailsRouter.d.ts +1 -1
  4. package/dist/abis/trailsRouter.d.ts.map +1 -1
  5. package/dist/{widget/analytics → analytics/hooks}/useWidgetAnalytics.d.ts +2 -4
  6. package/dist/analytics/hooks/useWidgetAnalytics.d.ts.map +1 -0
  7. package/dist/analytics.d.ts.map +1 -1
  8. package/dist/chainSwitch.d.ts.map +1 -1
  9. package/dist/chains-C1NhDLF_.js +4 -0
  10. package/dist/chains-CcoarGia.js +658 -0
  11. package/dist/chains.d.ts +0 -1
  12. package/dist/chains.d.ts.map +1 -1
  13. package/dist/committedIntentStore.d.ts +5 -0
  14. package/dist/committedIntentStore.d.ts.map +1 -0
  15. package/dist/config.d.ts +2 -0
  16. package/dist/config.d.ts.map +1 -1
  17. package/dist/constants.d.ts +3 -1
  18. package/dist/constants.d.ts.map +1 -1
  19. package/dist/customTokens.d.ts.map +1 -1
  20. package/dist/error.d.ts +73 -4
  21. package/dist/error.d.ts.map +1 -1
  22. package/dist/hooks/useAddressWalletIcon.d.ts.map +1 -0
  23. package/dist/hooks/useAmountUsd.d.ts.map +1 -0
  24. package/dist/hooks/useBalanceVisible.d.ts.map +1 -0
  25. package/dist/hooks/useChainFilter.d.ts.map +1 -0
  26. package/dist/{widget/hooks → hooks}/useCheckout.d.ts +15 -15
  27. package/dist/hooks/useCheckout.d.ts.map +1 -0
  28. package/dist/hooks/useClickTracking.d.ts.map +1 -0
  29. package/dist/{widget/hooks → hooks}/useCombinedHistory.d.ts +3 -2
  30. package/dist/hooks/useCombinedHistory.d.ts.map +1 -0
  31. package/dist/hooks/useConnector.d.ts.map +1 -0
  32. package/dist/{widget/hooks → hooks}/useCustomTokenSearch.d.ts +7 -2
  33. package/dist/hooks/useCustomTokenSearch.d.ts.map +1 -0
  34. package/dist/hooks/useDebounce.d.ts.map +1 -0
  35. package/dist/{widget/hooks → hooks}/useDebugScreens.d.ts +2 -2
  36. package/dist/hooks/useDebugScreens.d.ts.map +1 -0
  37. package/dist/{widget/hooks → hooks}/useDefaultDestinationToken.d.ts +1 -1
  38. package/dist/hooks/useDefaultDestinationToken.d.ts.map +1 -0
  39. package/dist/{widget/hooks → hooks}/useDefaultOriginToken.d.ts +1 -1
  40. package/dist/hooks/useDefaultOriginToken.d.ts.map +1 -0
  41. package/dist/hooks/useDepositMonitor.d.ts.map +1 -0
  42. package/dist/{widget/hooks → hooks}/useDestinationSelectedToken.d.ts +2 -2
  43. package/dist/hooks/useDestinationSelectedToken.d.ts.map +1 -0
  44. package/dist/hooks/useDisplayCurrencyPreference.d.ts.map +1 -0
  45. package/dist/{widget/hooks → hooks}/useEarnPool.d.ts +1 -1
  46. package/dist/hooks/useEarnPool.d.ts.map +1 -0
  47. package/dist/hooks/useEffectiveFundBalance.d.ts +28 -0
  48. package/dist/hooks/useEffectiveFundBalance.d.ts.map +1 -0
  49. package/dist/hooks/useExecutingIntentsCount.d.ts.map +1 -0
  50. package/dist/{widget/hooks → hooks}/useExternalFundingReceiptSync.d.ts +1 -1
  51. package/dist/hooks/useExternalFundingReceiptSync.d.ts.map +1 -0
  52. package/dist/{widget/hooks → hooks}/useFiatOnRampCurrencies.d.ts +2 -2
  53. package/dist/hooks/useFiatOnRampCurrencies.d.ts.map +1 -0
  54. package/dist/hooks/useFiatSelectedCurrency.d.ts.map +1 -0
  55. package/dist/hooks/useGetIntent.d.ts.map +1 -0
  56. package/dist/{widget/hooks → hooks}/useIntentReceiptBalances.d.ts +1 -1
  57. package/dist/hooks/useIntentReceiptBalances.d.ts.map +1 -0
  58. package/dist/{widget/hooks → hooks}/useIntentTransactionHistory.d.ts +2 -1
  59. package/dist/hooks/useIntentTransactionHistory.d.ts.map +1 -0
  60. package/dist/hooks/useIsMobile.d.ts.map +1 -0
  61. package/dist/hooks/useIsSequenceWallet.d.ts.map +1 -0
  62. package/dist/hooks/useLocalePreference.d.ts.map +1 -0
  63. package/dist/hooks/useMeldTransactionHistory.d.ts.map +1 -0
  64. package/dist/hooks/useMeldTransactionStatus.d.ts.map +1 -0
  65. package/dist/hooks/useOnRampCountryDefaults.d.ts.map +1 -0
  66. package/dist/{widget/hooks → hooks}/useOnRampPaymentMethods.d.ts +2 -2
  67. package/dist/hooks/useOnRampPaymentMethods.d.ts.map +1 -0
  68. package/dist/{widget/hooks → hooks}/useOnRampProviderWidget.d.ts +1 -1
  69. package/dist/hooks/useOnRampProviderWidget.d.ts.map +1 -0
  70. package/dist/{widget/hooks → hooks}/useOnRampQuote.d.ts +3 -3
  71. package/dist/hooks/useOnRampQuote.d.ts.map +1 -0
  72. package/dist/{widget/hooks → hooks}/useOnRampTransactionStatus.d.ts +1 -1
  73. package/dist/hooks/useOnRampTransactionStatus.d.ts.map +1 -0
  74. package/dist/{widget/hooks → hooks}/useOriginSelectedToken.d.ts +1 -1
  75. package/dist/hooks/useOriginSelectedToken.d.ts.map +1 -0
  76. package/dist/hooks/usePayMessage.d.ts.map +1 -0
  77. package/dist/hooks/usePriceImpactWarning.d.ts.map +1 -0
  78. package/dist/hooks/useQuote.d.ts +439 -0
  79. package/dist/hooks/useQuote.d.ts.map +1 -0
  80. package/dist/{widget/hooks → hooks}/useRecentTokens.d.ts +1 -1
  81. package/dist/hooks/useRecentTokens.d.ts.map +1 -0
  82. package/dist/hooks/useRecipients.d.ts.map +1 -0
  83. package/dist/hooks/useSelectedFeeOption.d.ts.map +1 -0
  84. package/dist/{widget/hooks → hooks}/useSelectedFundMethod.d.ts +18 -1
  85. package/dist/hooks/useSelectedFundMethod.d.ts.map +1 -0
  86. package/dist/hooks/useSelectedRecipient.d.ts.map +1 -0
  87. package/dist/{widget/hooks → hooks}/useSendForm.d.ts +6 -11
  88. package/dist/hooks/useSendForm.d.ts.map +1 -0
  89. package/dist/hooks/useSwapAmount.d.ts.map +1 -0
  90. package/dist/{widget/hooks → hooks}/useSwapState.d.ts +1 -1
  91. package/dist/hooks/useSwapState.d.ts.map +1 -0
  92. package/dist/hooks/useTargetAmount.d.ts.map +1 -0
  93. package/dist/hooks/useTheme.d.ts.map +1 -0
  94. package/dist/{widget/hooks → hooks}/useTokenList.d.ts +9 -3
  95. package/dist/hooks/useTokenList.d.ts.map +1 -0
  96. package/dist/{widget/hooks → hooks}/useTrailsSendTransaction.d.ts +1 -1
  97. package/dist/hooks/useTrailsSendTransaction.d.ts.map +1 -0
  98. package/dist/{widget/hooks → hooks}/useViewManager.d.ts +1 -1
  99. package/dist/hooks/useViewManager.d.ts.map +1 -0
  100. package/dist/hooks/useWalletConnectUri.d.ts +19 -0
  101. package/dist/hooks/useWalletConnectUri.d.ts.map +1 -0
  102. package/dist/hooks/useWalletConnectionContext.d.ts.map +1 -0
  103. package/dist/{widget/hooks → hooks}/useWidgetProps.d.ts +1 -1
  104. package/dist/hooks/useWidgetProps.d.ts.map +1 -0
  105. package/dist/hydrate/builder.d.ts +131 -0
  106. package/dist/hydrate/builder.d.ts.map +1 -0
  107. package/dist/hydrate/constants.d.ts +13 -0
  108. package/dist/hydrate/constants.d.ts.map +1 -0
  109. package/dist/hydrate/encodeExecute.d.ts +73 -0
  110. package/dist/hydrate/encodeExecute.d.ts.map +1 -0
  111. package/dist/hydrate/index.d.ts +6 -0
  112. package/dist/hydrate/index.d.ts.map +1 -0
  113. package/dist/hydrate/index.js +11 -0
  114. package/dist/hydrate/payload.d.ts +38 -0
  115. package/dist/hydrate/payload.d.ts.map +1 -0
  116. package/dist/hydrate/selectors.d.ts +28 -0
  117. package/dist/hydrate/selectors.d.ts.map +1 -0
  118. package/dist/hydrate/types.d.ts +19 -0
  119. package/dist/hydrate/types.d.ts.map +1 -0
  120. package/dist/hydrate/utils.d.ts +8 -0
  121. package/dist/hydrate/utils.d.ts.map +1 -0
  122. package/dist/hydrate-Cr9eaeDK.js +654 -0
  123. package/dist/index.d.ts +20 -13
  124. package/dist/index.d.ts.map +1 -1
  125. package/dist/index.js +156 -610
  126. package/dist/intentConfigStore.d.ts +8 -0
  127. package/dist/intentConfigStore.d.ts.map +1 -0
  128. package/dist/intentProtocolApi.d.ts +11 -0
  129. package/dist/intentProtocolApi.d.ts.map +1 -0
  130. package/dist/intentProtocolEncoding.d.ts +25 -0
  131. package/dist/intentProtocolEncoding.d.ts.map +1 -0
  132. package/dist/intentProtocolResolver.d.ts +28 -0
  133. package/dist/intentProtocolResolver.d.ts.map +1 -0
  134. package/dist/intentReceiptPoller.d.ts.map +1 -1
  135. package/dist/intentValidation.d.ts +5 -0
  136. package/dist/intentValidation.d.ts.map +1 -0
  137. package/dist/intents.d.ts +8 -2
  138. package/dist/intents.d.ts.map +1 -1
  139. package/dist/keyMachineClient.d.ts +9 -0
  140. package/dist/keyMachineClient.d.ts.map +1 -0
  141. package/dist/keymachine/index.d.ts +34 -0
  142. package/dist/keymachine/index.d.ts.map +1 -0
  143. package/dist/keymachine/key-machine.gen.d.ts +461 -0
  144. package/dist/keymachine/key-machine.gen.d.ts.map +1 -0
  145. package/dist/mutations.d.ts.map +1 -1
  146. package/dist/offlineRecovery.d.ts +24 -0
  147. package/dist/offlineRecovery.d.ts.map +1 -0
  148. package/dist/onramp/MeshConnectFlow.d.ts +27 -0
  149. package/dist/onramp/MeshConnectFlow.d.ts.map +1 -0
  150. package/dist/onramp/MeshConnectIframe.d.ts +22 -0
  151. package/dist/onramp/MeshConnectIframe.d.ts.map +1 -0
  152. package/dist/onramp/SendFromExchangeButton.d.ts +16 -0
  153. package/dist/onramp/SendFromExchangeButton.d.ts.map +1 -0
  154. package/dist/onramp/TrailsOnRampProvider.d.ts +31 -0
  155. package/dist/onramp/TrailsOnRampProvider.d.ts.map +1 -0
  156. package/dist/onramp/index.d.ts +13 -0
  157. package/dist/onramp/index.d.ts.map +1 -0
  158. package/dist/onramp/mesh/components/MeshExchangeConfirmation.d.ts +10 -0
  159. package/dist/onramp/mesh/components/MeshExchangeConfirmation.d.ts.map +1 -0
  160. package/dist/onramp/mesh/components/MeshExchangeIcon.d.ts +13 -0
  161. package/dist/onramp/mesh/components/MeshExchangeIcon.d.ts.map +1 -0
  162. package/dist/onramp/mesh/components/MeshExchangeSelection.d.ts +12 -0
  163. package/dist/onramp/mesh/components/MeshExchangeSelection.d.ts.map +1 -0
  164. package/dist/onramp/mesh/components/MeshSessionOptions.d.ts +15 -0
  165. package/dist/onramp/mesh/components/MeshSessionOptions.d.ts.map +1 -0
  166. package/dist/onramp/mesh/hooks/useMeshAccessTokens.d.ts +9 -0
  167. package/dist/onramp/mesh/hooks/useMeshAccessTokens.d.ts.map +1 -0
  168. package/dist/onramp/mesh/hooks/useMeshFundingSelection.d.ts +11 -0
  169. package/dist/onramp/mesh/hooks/useMeshFundingSelection.d.ts.map +1 -0
  170. package/dist/onramp/mesh/hooks/useMeshOnrampFlow.d.ts +71 -0
  171. package/dist/onramp/mesh/hooks/useMeshOnrampFlow.d.ts.map +1 -0
  172. package/dist/onramp/mesh/hooks/useMeshOnrampSessionState.d.ts +32 -0
  173. package/dist/onramp/mesh/hooks/useMeshOnrampSessionState.d.ts.map +1 -0
  174. package/dist/onramp/mesh/hooks/useMeshSelectedTokenBalance.d.ts +19 -0
  175. package/dist/onramp/mesh/hooks/useMeshSelectedTokenBalance.d.ts.map +1 -0
  176. package/dist/onramp/mesh/hooks/useMeshSessionAccountBalance.d.ts +15 -0
  177. package/dist/onramp/mesh/hooks/useMeshSessionAccountBalance.d.ts.map +1 -0
  178. package/dist/onramp/mesh/hooks/useMeshSessionStorage.d.ts +7 -0
  179. package/dist/onramp/mesh/hooks/useMeshSessionStorage.d.ts.map +1 -0
  180. package/dist/onramp/meshSessionStorage.d.ts +13 -0
  181. package/dist/onramp/meshSessionStorage.d.ts.map +1 -0
  182. package/dist/onramp/meshconnect.d.ts +32 -0
  183. package/dist/onramp/meshconnect.d.ts.map +1 -0
  184. package/dist/onramp/trailsOnramp.d.ts +32 -0
  185. package/dist/onramp/trailsOnramp.d.ts.map +1 -0
  186. package/dist/onramp-client/index.d.ts +3 -3
  187. package/dist/onramp-client/index.d.ts.map +1 -1
  188. package/dist/onrampClient.d.ts.map +1 -1
  189. package/dist/prepareSend.d.ts +3 -2
  190. package/dist/prepareSend.d.ts.map +1 -1
  191. package/dist/query/balance.fetchers.d.ts +27 -0
  192. package/dist/query/balance.fetchers.d.ts.map +1 -1
  193. package/dist/query/balance.hooks.d.ts +19 -0
  194. package/dist/query/balance.hooks.d.ts.map +1 -1
  195. package/dist/query/balance.queries.d.ts +18 -1
  196. package/dist/query/balance.queries.d.ts.map +1 -1
  197. package/dist/query/chains.queries.d.ts.map +1 -1
  198. package/dist/query/intentProtocol.queries.d.ts +32 -0
  199. package/dist/query/intentProtocol.queries.d.ts.map +1 -0
  200. package/dist/query/meld.fetchers.d.ts +1 -1
  201. package/dist/query/meld.fetchers.d.ts.map +1 -1
  202. package/dist/query/meld.hooks.d.ts +3 -3
  203. package/dist/query/meld.hooks.d.ts.map +1 -1
  204. package/dist/query/meld.queries.d.ts +1 -1
  205. package/dist/query/meld.queries.d.ts.map +1 -1
  206. package/dist/query/tokenList.queries.d.ts +54 -0
  207. package/dist/query/tokenList.queries.d.ts.map +1 -0
  208. package/dist/recover.d.ts +71 -23
  209. package/dist/recover.d.ts.map +1 -1
  210. package/dist/src-4HYDQv2T.js +48798 -0
  211. package/dist/tokens.d.ts +13 -0
  212. package/dist/tokens.d.ts.map +1 -1
  213. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +3 -4
  214. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
  215. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +3 -4
  216. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
  217. package/dist/transactionIntent/deposits/standardDeposit.d.ts +2 -5
  218. package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
  219. package/dist/transactionIntent/handlers/intentHandler.d.ts +4 -4
  220. package/dist/transactionIntent/handlers/intentHandler.d.ts.map +1 -1
  221. package/dist/transactionIntent/helpers/transactionStateHelpers.d.ts.map +1 -1
  222. package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
  223. package/dist/transactionIntent/quote/quoteHelpers.d.ts +2 -2
  224. package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -1
  225. package/dist/transactionIntent/types.d.ts +4 -4
  226. package/dist/transactionIntent/types.d.ts.map +1 -1
  227. package/dist/transactions.d.ts +4 -0
  228. package/dist/transactions.d.ts.map +1 -1
  229. package/dist/umd/trails.min.js +1371 -322
  230. package/dist/utils/localStorageGc.d.ts +22 -0
  231. package/dist/utils/localStorageGc.d.ts.map +1 -0
  232. package/dist/walletUtils.d.ts +2 -1
  233. package/dist/walletUtils.d.ts.map +1 -1
  234. package/dist/wallets.d.ts +13 -54
  235. package/dist/wallets.d.ts.map +1 -1
  236. package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
  237. package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
  238. package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
  239. package/dist/widget/components/ConnectedWallets.d.ts +1 -1
  240. package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
  241. package/dist/widget/components/DirectTransfer.d.ts +1 -1
  242. package/dist/widget/components/DirectTransfer.d.ts.map +1 -1
  243. package/dist/widget/components/Earn.d.ts +2 -6
  244. package/dist/widget/components/Earn.d.ts.map +1 -1
  245. package/dist/widget/components/FeeOption.d.ts +1 -1
  246. package/dist/widget/components/FeeOption.d.ts.map +1 -1
  247. package/dist/widget/components/FeeOptions.d.ts +1 -1
  248. package/dist/widget/components/FeeOptions.d.ts.map +1 -1
  249. package/dist/widget/components/FiatSelector.d.ts +1 -1
  250. package/dist/widget/components/FiatSelector.d.ts.map +1 -1
  251. package/dist/widget/components/FiatSelectorButton.d.ts +1 -1
  252. package/dist/widget/components/FiatSelectorButton.d.ts.map +1 -1
  253. package/dist/widget/components/Fund.d.ts +1 -1
  254. package/dist/widget/components/Fund.d.ts.map +1 -1
  255. package/dist/widget/components/FundMethods.d.ts.map +1 -1
  256. package/dist/widget/components/FundingMethodSelectorButton.d.ts +1 -1
  257. package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -1
  258. package/dist/widget/components/MeldHistory.d.ts +1 -1
  259. package/dist/widget/components/MeldHistory.d.ts.map +1 -1
  260. package/dist/widget/components/MeldTransactionStatus.d.ts +1 -1
  261. package/dist/widget/components/MeldTransactionStatus.d.ts.map +1 -1
  262. package/dist/widget/components/MeshExchangeAccountHeader.d.ts +9 -0
  263. package/dist/widget/components/MeshExchangeAccountHeader.d.ts.map +1 -0
  264. package/dist/widget/components/OnrampHistoryRow.d.ts +2 -2
  265. package/dist/widget/components/OnrampHistoryRow.d.ts.map +1 -1
  266. package/dist/widget/components/OnrampProviderConfirmation.d.ts +1 -1
  267. package/dist/widget/components/OnrampProviderConfirmation.d.ts.map +1 -1
  268. package/dist/widget/components/Pay.d.ts.map +1 -1
  269. package/dist/widget/components/PoolDeposit.d.ts +2 -6
  270. package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
  271. package/dist/widget/components/PoolWithdraw.d.ts +2 -2
  272. package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
  273. package/dist/widget/components/PulsatingButton.d.ts +9 -0
  274. package/dist/widget/components/PulsatingButton.d.ts.map +1 -0
  275. package/dist/widget/components/QRCodeWalletSelect.d.ts +1 -1
  276. package/dist/widget/components/QRCodeWalletSelect.d.ts.map +1 -1
  277. package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
  278. package/dist/widget/components/Receipt.d.ts +1 -1
  279. package/dist/widget/components/Receipt.d.ts.map +1 -1
  280. package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -1
  281. package/dist/widget/components/Recipients.d.ts.map +1 -1
  282. package/dist/widget/components/RefundWarning.d.ts.map +1 -1
  283. package/dist/widget/components/Swap.d.ts +2 -6
  284. package/dist/widget/components/Swap.d.ts.map +1 -1
  285. package/dist/widget/components/TokenList.d.ts +1 -0
  286. package/dist/widget/components/TokenList.d.ts.map +1 -1
  287. package/dist/widget/components/TokenSelector.d.ts +1 -2
  288. package/dist/widget/components/TokenSelector.d.ts.map +1 -1
  289. package/dist/widget/components/TransactionDetails.d.ts +1 -0
  290. package/dist/widget/components/TransactionDetails.d.ts.map +1 -1
  291. package/dist/widget/components/TransactionHistoryItem.d.ts +1 -0
  292. package/dist/widget/components/TransactionHistoryItem.d.ts.map +1 -1
  293. package/dist/widget/components/TransferPendingVertical.d.ts +2 -1
  294. package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
  295. package/dist/widget/components/WalletAccountHeader.d.ts +7 -0
  296. package/dist/widget/components/WalletAccountHeader.d.ts.map +1 -0
  297. package/dist/widget/components/WalletConfirmation.d.ts +2 -1
  298. package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
  299. package/dist/widget/components/WalletConnect.d.ts.map +1 -1
  300. package/dist/widget/components/WalletList.d.ts.map +1 -1
  301. package/dist/widget/components/WidgetProviders.d.ts.map +1 -1
  302. package/dist/widget/components/Withdraw.d.ts.map +1 -1
  303. package/dist/widget/index.d.ts +13 -0
  304. package/dist/widget/index.d.ts.map +1 -1
  305. package/dist/widget/index.js +16 -8
  306. package/dist/widget/modes/EarnWidget.d.ts +83 -0
  307. package/dist/widget/modes/EarnWidget.d.ts.map +1 -0
  308. package/dist/widget/modes/FundWidget.d.ts +103 -0
  309. package/dist/widget/modes/FundWidget.d.ts.map +1 -0
  310. package/dist/widget/modes/PayWidget.d.ts +86 -0
  311. package/dist/widget/modes/PayWidget.d.ts.map +1 -0
  312. package/dist/widget/modes/SwapWidget.d.ts +82 -0
  313. package/dist/widget/modes/SwapWidget.d.ts.map +1 -0
  314. package/dist/widget/modes/WithdrawWidget.d.ts +71 -0
  315. package/dist/widget/modes/WithdrawWidget.d.ts.map +1 -0
  316. package/dist/widget/providers/TrailsProvider.d.ts +5 -0
  317. package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
  318. package/dist/widget/shared/mapSharedProps.d.ts +9 -0
  319. package/dist/widget/shared/mapSharedProps.d.ts.map +1 -0
  320. package/dist/widget/shared/methodMap.d.ts +18 -0
  321. package/dist/widget/shared/methodMap.d.ts.map +1 -0
  322. package/dist/widget/shared/resolution.d.ts +22 -0
  323. package/dist/widget/shared/resolution.d.ts.map +1 -0
  324. package/dist/widget/shared/resolvePaymentSource.d.ts +34 -0
  325. package/dist/widget/shared/resolvePaymentSource.d.ts.map +1 -0
  326. package/dist/widget/shared/types.d.ts +94 -0
  327. package/dist/widget/shared/types.d.ts.map +1 -0
  328. package/dist/widget/types/commonProps.d.ts +3 -7
  329. package/dist/widget/types/commonProps.d.ts.map +1 -1
  330. package/dist/widget/utils/createWagmiConfig.d.ts +2 -2
  331. package/dist/widget/utils/createWagmiConfig.d.ts.map +1 -1
  332. package/dist/widget/utils/fundMethodSwitchState.d.ts +2 -0
  333. package/dist/widget/utils/fundMethodSwitchState.d.ts.map +1 -1
  334. package/dist/widget/utils/meldProviderUtils.d.ts +1 -1
  335. package/dist/widget/utils/meldProviderUtils.d.ts.map +1 -1
  336. package/dist/widget/utils/meshSupportedTokens.d.ts +4 -0
  337. package/dist/widget/utils/meshSupportedTokens.d.ts.map +1 -0
  338. package/dist/widget/utils/onrampConfig.d.ts +11 -0
  339. package/dist/widget/utils/onrampConfig.d.ts.map +1 -0
  340. package/dist/widget/utils/trailsOnrampConfig.d.ts +18 -0
  341. package/dist/widget/utils/trailsOnrampConfig.d.ts.map +1 -0
  342. package/dist/widget/utils/viewManagerGuards.d.ts +1 -1
  343. package/dist/widget/utils/viewManagerGuards.d.ts.map +1 -1
  344. package/dist/widget/widget.d.ts +45 -24
  345. package/dist/widget/widget.d.ts.map +1 -1
  346. package/package.json +20 -24
  347. package/dist/buffer.d.ts +0 -3
  348. package/dist/buffer.d.ts.map +0 -1
  349. package/dist/ccip-DStzFCYT.js +0 -230
  350. package/dist/index-HY9_ppit.js +0 -101240
  351. package/dist/onramp-client/trails-onramp.gen.d.ts +0 -570
  352. package/dist/onramp-client/trails-onramp.gen.d.ts.map +0 -1
  353. package/dist/paymasterSend.d.ts +0 -90
  354. package/dist/paymasterSend.d.ts.map +0 -1
  355. package/dist/sendUserOp.d.ts +0 -122
  356. package/dist/sendUserOp.d.ts.map +0 -1
  357. package/dist/toSimpleSmartAccount.d.ts +0 -95
  358. package/dist/toSimpleSmartAccount.d.ts.map +0 -1
  359. package/dist/transactionIntent/utils/erc20Approval.d.ts +0 -34
  360. package/dist/transactionIntent/utils/erc20Approval.d.ts.map +0 -1
  361. package/dist/utils/allowance.d.ts +0 -19
  362. package/dist/utils/allowance.d.ts.map +0 -1
  363. package/dist/widget/analytics/useWidgetAnalytics.d.ts.map +0 -1
  364. package/dist/widget/components/FeeBreakdown.d.ts +0 -9
  365. package/dist/widget/components/FeeBreakdown.d.ts.map +0 -1
  366. package/dist/widget/components/HideBalances.d.ts +0 -4
  367. package/dist/widget/components/HideBalances.d.ts.map +0 -1
  368. package/dist/widget/components/OnrampDeposit.d.ts +0 -10
  369. package/dist/widget/components/OnrampDeposit.d.ts.map +0 -1
  370. package/dist/widget/components/SwapSettings.d.ts +0 -4
  371. package/dist/widget/components/SwapSettings.d.ts.map +0 -1
  372. package/dist/widget/components/TruncatedAddress.d.ts +0 -12
  373. package/dist/widget/components/TruncatedAddress.d.ts.map +0 -1
  374. package/dist/widget/components/WalletImage.d.ts +0 -8
  375. package/dist/widget/components/WalletImage.d.ts.map +0 -1
  376. package/dist/widget/css/compiled.css +0 -26
  377. package/dist/widget/css/index.css +0 -686
  378. package/dist/widget/hooks/useAddressWalletIcon.d.ts.map +0 -1
  379. package/dist/widget/hooks/useAmountUsd.d.ts.map +0 -1
  380. package/dist/widget/hooks/useBalanceVisible.d.ts.map +0 -1
  381. package/dist/widget/hooks/useChainFilter.d.ts.map +0 -1
  382. package/dist/widget/hooks/useCheckout.d.ts.map +0 -1
  383. package/dist/widget/hooks/useClickTracking.d.ts.map +0 -1
  384. package/dist/widget/hooks/useCombinedHistory.d.ts.map +0 -1
  385. package/dist/widget/hooks/useConnector.d.ts.map +0 -1
  386. package/dist/widget/hooks/useCustomTokenFetch.d.ts +0 -19
  387. package/dist/widget/hooks/useCustomTokenFetch.d.ts.map +0 -1
  388. package/dist/widget/hooks/useCustomTokenSearch.d.ts.map +0 -1
  389. package/dist/widget/hooks/useDebounce.d.ts.map +0 -1
  390. package/dist/widget/hooks/useDebugScreens.d.ts.map +0 -1
  391. package/dist/widget/hooks/useDefaultDestinationToken.d.ts.map +0 -1
  392. package/dist/widget/hooks/useDefaultOriginToken.d.ts.map +0 -1
  393. package/dist/widget/hooks/useDepositMonitor.d.ts.map +0 -1
  394. package/dist/widget/hooks/useDestinationSelectedToken.d.ts.map +0 -1
  395. package/dist/widget/hooks/useDisplayCurrencyPreference.d.ts.map +0 -1
  396. package/dist/widget/hooks/useEarnPool.d.ts.map +0 -1
  397. package/dist/widget/hooks/useExecutingIntentsCount.d.ts.map +0 -1
  398. package/dist/widget/hooks/useExternalFundingReceiptSync.d.ts.map +0 -1
  399. package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts.map +0 -1
  400. package/dist/widget/hooks/useFiatSelectedCurrency.d.ts.map +0 -1
  401. package/dist/widget/hooks/useGetIntent.d.ts.map +0 -1
  402. package/dist/widget/hooks/useIntentReceiptBalances.d.ts.map +0 -1
  403. package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +0 -1
  404. package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts +0 -7
  405. package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts.map +0 -1
  406. package/dist/widget/hooks/useIsMobile.d.ts.map +0 -1
  407. package/dist/widget/hooks/useIsSequenceWallet.d.ts.map +0 -1
  408. package/dist/widget/hooks/useLocalePreference.d.ts.map +0 -1
  409. package/dist/widget/hooks/useMeldTransactionHistory.d.ts.map +0 -1
  410. package/dist/widget/hooks/useMeldTransactionStatus.d.ts.map +0 -1
  411. package/dist/widget/hooks/useOnRampCountryDefaults.d.ts.map +0 -1
  412. package/dist/widget/hooks/useOnRampPaymentMethods.d.ts.map +0 -1
  413. package/dist/widget/hooks/useOnRampProviderWidget.d.ts.map +0 -1
  414. package/dist/widget/hooks/useOnRampQuote.d.ts.map +0 -1
  415. package/dist/widget/hooks/useOnRampTransactionStatus.d.ts.map +0 -1
  416. package/dist/widget/hooks/useOriginSelectedToken.d.ts.map +0 -1
  417. package/dist/widget/hooks/usePayMessage.d.ts.map +0 -1
  418. package/dist/widget/hooks/usePriceImpactWarning.d.ts.map +0 -1
  419. package/dist/widget/hooks/useQuote.d.ts +0 -378
  420. package/dist/widget/hooks/useQuote.d.ts.map +0 -1
  421. package/dist/widget/hooks/useRecentTokens.d.ts.map +0 -1
  422. package/dist/widget/hooks/useRecipients.d.ts.map +0 -1
  423. package/dist/widget/hooks/useScreenTracking.d.ts +0 -2
  424. package/dist/widget/hooks/useScreenTracking.d.ts.map +0 -1
  425. package/dist/widget/hooks/useSelectedFeeOption.d.ts.map +0 -1
  426. package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +0 -1
  427. package/dist/widget/hooks/useSelectedRecipient.d.ts.map +0 -1
  428. package/dist/widget/hooks/useSendForm.d.ts.map +0 -1
  429. package/dist/widget/hooks/useSwapAmount.d.ts.map +0 -1
  430. package/dist/widget/hooks/useSwapState.d.ts.map +0 -1
  431. package/dist/widget/hooks/useTargetAmount.d.ts.map +0 -1
  432. package/dist/widget/hooks/useTheme.d.ts.map +0 -1
  433. package/dist/widget/hooks/useTokenList.d.ts.map +0 -1
  434. package/dist/widget/hooks/useTokenWithFreshBalance.d.ts +0 -18
  435. package/dist/widget/hooks/useTokenWithFreshBalance.d.ts.map +0 -1
  436. package/dist/widget/hooks/useTrailsSendTransaction.d.ts.map +0 -1
  437. package/dist/widget/hooks/useViewManager.d.ts.map +0 -1
  438. package/dist/widget/hooks/useWalletConnectUri.d.ts +0 -11
  439. package/dist/widget/hooks/useWalletConnectUri.d.ts.map +0 -1
  440. package/dist/widget/hooks/useWalletConnectionContext.d.ts.map +0 -1
  441. package/dist/widget/hooks/useWidgetProps.d.ts.map +0 -1
  442. package/dist/widget/types.d.ts +0 -44
  443. package/dist/widget/types.d.ts.map +0 -1
  444. package/dist/widget/utils/historyUtils.d.ts +0 -18
  445. package/dist/widget/utils/historyUtils.d.ts.map +0 -1
  446. package/src/abi.ts +0 -38
  447. package/src/abis/erc20.ts +0 -60
  448. package/src/abis/trailsHydrate.ts +0 -185
  449. package/src/abis/trailsRouter.ts +0 -121
  450. package/src/abis/trailsSweep.ts +0 -32
  451. package/src/abortController.ts +0 -35
  452. package/src/analytics.ts +0 -2029
  453. package/src/buffer.ts +0 -10
  454. package/src/chainSwitch.ts +0 -95
  455. package/src/chains.ts +0 -565
  456. package/src/config.ts +0 -118
  457. package/src/constants.ts +0 -237
  458. package/src/contractUtils.ts +0 -46
  459. package/src/cssUtils.ts +0 -5
  460. package/src/customChains.ts +0 -24
  461. package/src/customTokens.ts +0 -147
  462. package/src/decoders.ts +0 -365
  463. package/src/ens.ts +0 -74
  464. package/src/error.ts +0 -268
  465. package/src/estimate.ts +0 -480
  466. package/src/explorer.ts +0 -38
  467. package/src/fees.ts +0 -362
  468. package/src/gasless.ts +0 -638
  469. package/src/index.ts +0 -204
  470. package/src/indexerClient.ts +0 -118
  471. package/src/intentReceiptMonitor.ts +0 -99
  472. package/src/intentReceiptPoller.ts +0 -327
  473. package/src/intents.ts +0 -1125
  474. package/src/localeUtils.ts +0 -244
  475. package/src/logger/index.ts +0 -95
  476. package/src/logger/useSyncLoggerDebug.ts +0 -11
  477. package/src/logger.ts +0 -1
  478. package/src/meld/components/MeldCountriesList.tsx +0 -237
  479. package/src/meld/components/MeldFundMethods.tsx +0 -265
  480. package/src/meld/components/MeldProvidersList.tsx +0 -187
  481. package/src/meld/components/MeldTokensList.tsx +0 -321
  482. package/src/meld/components/SimpleHeader.tsx +0 -35
  483. package/src/meld/utils/meld.ts +0 -77
  484. package/src/mutations.ts +0 -166
  485. package/src/onramp-client/index.ts +0 -54
  486. package/src/onramp-client/trails-onramp.gen.ts +0 -1320
  487. package/src/onrampClient.ts +0 -46
  488. package/src/paymasterSend.ts +0 -521
  489. package/src/placeholder.ts +0 -92
  490. package/src/poolUtils.ts +0 -222
  491. package/src/pools.ts +0 -120
  492. package/src/prepareSend.ts +0 -552
  493. package/src/query/balance.fetchers.ts +0 -623
  494. package/src/query/balance.hooks.ts +0 -298
  495. package/src/query/balance.queries.ts +0 -244
  496. package/src/query/chains.hooks.ts +0 -45
  497. package/src/query/chains.queries.ts +0 -22
  498. package/src/query/client.ts +0 -20
  499. package/src/query/fiat.fetchers.ts +0 -33
  500. package/src/query/fiat.hooks.ts +0 -71
  501. package/src/query/fiat.queries.ts +0 -67
  502. package/src/query/geo.fetchers.ts +0 -100
  503. package/src/query/geo.hooks.ts +0 -16
  504. package/src/query/geo.queries.ts +0 -36
  505. package/src/query/helpers.ts +0 -81
  506. package/src/query/meld.fetchers.ts +0 -97
  507. package/src/query/meld.hooks.ts +0 -18
  508. package/src/query/meld.queries.ts +0 -184
  509. package/src/query/persister.ts +0 -11
  510. package/src/query/price.fetchers.ts +0 -53
  511. package/src/query/price.hooks.ts +0 -46
  512. package/src/query/price.queries.ts +0 -364
  513. package/src/queryParams.ts +0 -100
  514. package/src/recover.ts +0 -1665
  515. package/src/sendUserOp.ts +0 -512
  516. package/src/theme.ts +0 -2
  517. package/src/toSimpleSmartAccount.ts +0 -567
  518. package/src/toast.ts +0 -110
  519. package/src/tokens.ts +0 -1780
  520. package/src/trailsClient.ts +0 -40
  521. package/src/transactionIntent/constants.ts +0 -15
  522. package/src/transactionIntent/deposits/depositOrchestrator.ts +0 -243
  523. package/src/transactionIntent/deposits/gaslessDeposit.ts +0 -705
  524. package/src/transactionIntent/deposits/index.ts +0 -3
  525. package/src/transactionIntent/deposits/standardDeposit.ts +0 -594
  526. package/src/transactionIntent/execution/index.ts +0 -1
  527. package/src/transactionIntent/execution/transactionState.ts +0 -38
  528. package/src/transactionIntent/handlers/index.ts +0 -1
  529. package/src/transactionIntent/handlers/intentHandler.ts +0 -1596
  530. package/src/transactionIntent/helpers/index.ts +0 -1
  531. package/src/transactionIntent/helpers/transactionStateHelpers.ts +0 -437
  532. package/src/transactionIntent/index.ts +0 -10
  533. package/src/transactionIntent/quote/feeExtractors.ts +0 -61
  534. package/src/transactionIntent/quote/index.ts +0 -3
  535. package/src/transactionIntent/quote/normalizeQuote.ts +0 -553
  536. package/src/transactionIntent/quote/quoteHelpers.ts +0 -117
  537. package/src/transactionIntent/types.ts +0 -241
  538. package/src/transactionIntent/utils/balanceChecker.ts +0 -103
  539. package/src/transactionIntent/utils/erc20Approval.ts +0 -171
  540. package/src/transactionIntent/utils/index.ts +0 -2
  541. package/src/transactionIntent/utils/resilientDepositTracker.ts +0 -171
  542. package/src/transactionIntent/utils/testnetHelpers.ts +0 -5
  543. package/src/transactionIntent/validators.ts +0 -27
  544. package/src/transactions.ts +0 -426
  545. package/src/types.d.ts +0 -16
  546. package/src/umd.tsx +0 -33
  547. package/src/utils/address.ts +0 -78
  548. package/src/utils/allowance.ts +0 -47
  549. package/src/utils/fiat.ts +0 -32
  550. package/src/utils/format.ts +0 -625
  551. package/src/utils/passthrough.ts +0 -93
  552. package/src/utils/time.ts +0 -118
  553. package/src/utils/validation.ts +0 -104
  554. package/src/utils.ts +0 -112
  555. package/src/version.ts +0 -8
  556. package/src/vite-env.d.ts +0 -4
  557. package/src/walletUtils.ts +0 -292
  558. package/src/wallets.ts +0 -740
  559. package/src/widget/analytics/useWidgetAnalytics.ts +0 -56
  560. package/src/widget/assets/Binance_Icon_Logo.svg +0 -14
  561. package/src/widget/assets/Bitfinex_Icon_Logo.svg +0 -5
  562. package/src/widget/assets/Coinbase_Icon_Logo.svg +0 -1
  563. package/src/widget/assets/Exchange-icon-black.svg +0 -5
  564. package/src/widget/assets/MetaMask-icon-fox-with-margins.svg +0 -31
  565. package/src/widget/assets/MetaMask-icon-fox.svg +0 -26
  566. package/src/widget/assets/MetaMask-logo-black.svg +0 -3
  567. package/src/widget/assets/MetaMask-logo-white.svg +0 -16
  568. package/src/widget/assets/Trails-logo-black.svg +0 -13
  569. package/src/widget/assets/Trails-logo-white.svg +0 -13
  570. package/src/widget/assets/WalletChange-black.svg +0 -5
  571. package/src/widget/assets/WalletConnect-logo-black.svg +0 -14
  572. package/src/widget/assets/WalletConnect-logo-blue-bg.svg +0 -11
  573. package/src/widget/assets/WalletConnect-logo-blue.svg +0 -14
  574. package/src/widget/assets/WalletConnect-logo-white.svg +0 -14
  575. package/src/widget/assets/WalletConnect-logo.svg +0 -40
  576. package/src/widget/assets/aave.svg +0 -14
  577. package/src/widget/assets/morpho.svg +0 -14
  578. package/src/widget/assets/sequence-logo.svg +0 -15
  579. package/src/widget/compiled.css +0 -26
  580. package/src/widget/components/AccountActionsDropdown.tsx +0 -31
  581. package/src/widget/components/AccountIntentTransactionHistory.tsx +0 -756
  582. package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +0 -34
  583. package/src/widget/components/AccountSettings.tsx +0 -168
  584. package/src/widget/components/AddressOrEnsName.tsx +0 -24
  585. package/src/widget/components/AddressWalletIcon.tsx +0 -49
  586. package/src/widget/components/AllChainsIcon.tsx +0 -54
  587. package/src/widget/components/ChainFilterDropdown.tsx +0 -220
  588. package/src/widget/components/ChainImage.tsx +0 -40
  589. package/src/widget/components/ChainList.tsx +0 -158
  590. package/src/widget/components/ClassicSwap.tsx +0 -1744
  591. package/src/widget/components/ConfigDisplay.tsx +0 -158
  592. package/src/widget/components/ConnectWallet.tsx +0 -564
  593. package/src/widget/components/ConnectedWallets.tsx +0 -417
  594. package/src/widget/components/CopyButton.tsx +0 -108
  595. package/src/widget/components/CountryFilterDropdown.tsx +0 -179
  596. package/src/widget/components/DebugMenu.tsx +0 -50
  597. package/src/widget/components/DebugScreensList.tsx +0 -70
  598. package/src/widget/components/DebugToast.tsx +0 -63
  599. package/src/widget/components/DepositTracker.tsx +0 -326
  600. package/src/widget/components/DirectTransfer.tsx +0 -302
  601. package/src/widget/components/Disconnect.tsx +0 -68
  602. package/src/widget/components/DynamicInputStyles.tsx +0 -121
  603. package/src/widget/components/DynamicSizeInputField.tsx +0 -245
  604. package/src/widget/components/ENSAvatar.tsx +0 -33
  605. package/src/widget/components/Earn.tsx +0 -160
  606. package/src/widget/components/EarnPools.tsx +0 -417
  607. package/src/widget/components/EarnPoolsFilters.tsx +0 -165
  608. package/src/widget/components/ErrorAnimationIcon.tsx +0 -130
  609. package/src/widget/components/ErrorDisplay.tsx +0 -152
  610. package/src/widget/components/ExecutingIntentsBadge.tsx +0 -24
  611. package/src/widget/components/ExecutionStatusBadge.tsx +0 -53
  612. package/src/widget/components/FeeBreakdown.tsx +0 -155
  613. package/src/widget/components/FeeOption.tsx +0 -170
  614. package/src/widget/components/FeeOptions.tsx +0 -247
  615. package/src/widget/components/FiatSelector.tsx +0 -308
  616. package/src/widget/components/FiatSelectorButton.tsx +0 -68
  617. package/src/widget/components/Footer.tsx +0 -67
  618. package/src/widget/components/Fund.tsx +0 -2331
  619. package/src/widget/components/FundMethods.tsx +0 -427
  620. package/src/widget/components/FundWalletSelection.tsx +0 -60
  621. package/src/widget/components/FundingMethodSelectorButton.tsx +0 -106
  622. package/src/widget/components/GreenCheckAnimation.tsx +0 -119
  623. package/src/widget/components/HideBalances.tsx +0 -24
  624. package/src/widget/components/HighPriceImpactBlock.tsx +0 -44
  625. package/src/widget/components/HookModalContent.tsx +0 -377
  626. package/src/widget/components/Identicon.tsx +0 -228
  627. package/src/widget/components/LoadingSpinner.tsx +0 -9
  628. package/src/widget/components/MeldForm.tsx +0 -780
  629. package/src/widget/components/MeldHistory.tsx +0 -433
  630. package/src/widget/components/MeldStepsFlow.tsx +0 -1651
  631. package/src/widget/components/MeldTransactionStatus.tsx +0 -255
  632. package/src/widget/components/Modal.tsx +0 -86
  633. package/src/widget/components/OFTProgressBar.tsx +0 -89
  634. package/src/widget/components/OnRampProviderSelector.tsx +0 -263
  635. package/src/widget/components/OnrampDeposit.tsx +0 -122
  636. package/src/widget/components/OnrampErrorScreen.tsx +0 -163
  637. package/src/widget/components/OnrampHistoryRow.tsx +0 -321
  638. package/src/widget/components/OnrampPaymentMethods.tsx +0 -81
  639. package/src/widget/components/OnrampProviderConfirmation.tsx +0 -1060
  640. package/src/widget/components/OriginSelectionAmount.tsx +0 -144
  641. package/src/widget/components/OriginTransferInformation.tsx +0 -59
  642. package/src/widget/components/Pay.tsx +0 -1181
  643. package/src/widget/components/PaymentMethods.tsx +0 -198
  644. package/src/widget/components/PercentageMaxButtons.tsx +0 -112
  645. package/src/widget/components/PoolDeposit.tsx +0 -651
  646. package/src/widget/components/PoolWithdraw.tsx +0 -761
  647. package/src/widget/components/PriceImpactWarning.tsx +0 -87
  648. package/src/widget/components/QRCodeOptions.tsx +0 -65
  649. package/src/widget/components/QRCodeWalletSelect.tsx +0 -77
  650. package/src/widget/components/QrCode.tsx +0 -216
  651. package/src/widget/components/QuoteDetails.tsx +0 -1266
  652. package/src/widget/components/Receipt.tsx +0 -673
  653. package/src/widget/components/ReceiptRecoverableFunds.tsx +0 -135
  654. package/src/widget/components/RecentTokens.tsx +0 -66
  655. package/src/widget/components/RecipientSelectorButton.tsx +0 -50
  656. package/src/widget/components/Recipients.tsx +0 -412
  657. package/src/widget/components/RefundWarning.tsx +0 -66
  658. package/src/widget/components/RequiredPropsError.tsx +0 -33
  659. package/src/widget/components/ScreenHeader.tsx +0 -123
  660. package/src/widget/components/SearchInputField.tsx +0 -99
  661. package/src/widget/components/SessionTimeoutScreen.tsx +0 -103
  662. package/src/widget/components/ShadowPortal.tsx +0 -99
  663. package/src/widget/components/ShadowRootContext.tsx +0 -17
  664. package/src/widget/components/SimpleRecipientInputScreen.tsx +0 -91
  665. package/src/widget/components/SlippageToleranceSettings.tsx +0 -279
  666. package/src/widget/components/Swap.tsx +0 -50
  667. package/src/widget/components/SwapDisplay.tsx +0 -68
  668. package/src/widget/components/SwapSettings.tsx +0 -52
  669. package/src/widget/components/ThemeProvider.tsx +0 -115
  670. package/src/widget/components/ThemeSyncer.tsx +0 -47
  671. package/src/widget/components/Toast.tsx +0 -336
  672. package/src/widget/components/TokenDisplayNonSelectable.tsx +0 -40
  673. package/src/widget/components/TokenImage.tsx +0 -156
  674. package/src/widget/components/TokenList.tsx +0 -107
  675. package/src/widget/components/TokenSelector.tsx +0 -738
  676. package/src/widget/components/TokenSelectorButton.tsx +0 -123
  677. package/src/widget/components/TokenSkeleton.tsx +0 -53
  678. package/src/widget/components/Tooltip.tsx +0 -64
  679. package/src/widget/components/TrailsHookModal.tsx +0 -107
  680. package/src/widget/components/TransactionDetails.tsx +0 -488
  681. package/src/widget/components/TransactionHistoryItem.tsx +0 -767
  682. package/src/widget/components/TransferPendingVertical.tsx +0 -583
  683. package/src/widget/components/TruncatedAddress.tsx +0 -68
  684. package/src/widget/components/TruncatedTransactionHash.tsx +0 -74
  685. package/src/widget/components/UserPreferences.tsx +0 -570
  686. package/src/widget/components/WaasFeeOptions.tsx +0 -588
  687. package/src/widget/components/WalletConfirmation.tsx +0 -220
  688. package/src/widget/components/WalletConnect.tsx +0 -351
  689. package/src/widget/components/WalletConnectionPending.tsx +0 -178
  690. package/src/widget/components/WalletImage.tsx +0 -64
  691. package/src/widget/components/WalletList.tsx +0 -125
  692. package/src/widget/components/WidgetProviders.tsx +0 -82
  693. package/src/widget/components/Withdraw.tsx +0 -1088
  694. package/src/widget/components/YellowWarningAnimation.tsx +0 -146
  695. package/src/widget/hooks/useAddressWalletIcon.ts +0 -54
  696. package/src/widget/hooks/useAmountUsd.ts +0 -44
  697. package/src/widget/hooks/useBalanceVisible.tsx +0 -95
  698. package/src/widget/hooks/useChainFilter.tsx +0 -56
  699. package/src/widget/hooks/useCheckout.ts +0 -361
  700. package/src/widget/hooks/useClickTracking.ts +0 -74
  701. package/src/widget/hooks/useCombinedHistory.ts +0 -420
  702. package/src/widget/hooks/useConnector.tsx +0 -24
  703. package/src/widget/hooks/useCustomTokenFetch.tsx +0 -74
  704. package/src/widget/hooks/useCustomTokenSearch.tsx +0 -339
  705. package/src/widget/hooks/useDebounce.ts +0 -25
  706. package/src/widget/hooks/useDebugScreens.ts +0 -600
  707. package/src/widget/hooks/useDefaultDestinationToken.tsx +0 -182
  708. package/src/widget/hooks/useDefaultOriginToken.tsx +0 -410
  709. package/src/widget/hooks/useDepositMonitor.ts +0 -118
  710. package/src/widget/hooks/useDestinationSelectedToken.tsx +0 -310
  711. package/src/widget/hooks/useDisplayCurrencyPreference.tsx +0 -145
  712. package/src/widget/hooks/useEarnPool.tsx +0 -36
  713. package/src/widget/hooks/useExecutingIntentsCount.ts +0 -78
  714. package/src/widget/hooks/useExternalFundingReceiptSync.ts +0 -79
  715. package/src/widget/hooks/useFiatOnRampCurrencies.ts +0 -46
  716. package/src/widget/hooks/useFiatSelectedCurrency.tsx +0 -123
  717. package/src/widget/hooks/useGetIntent.ts +0 -54
  718. package/src/widget/hooks/useIntentReceiptBalances.ts +0 -141
  719. package/src/widget/hooks/useIntentTransactionHistory.ts +0 -785
  720. package/src/widget/hooks/useIsConnectedWalletSmartContract.ts +0 -43
  721. package/src/widget/hooks/useIsMobile.tsx +0 -50
  722. package/src/widget/hooks/useIsSequenceWallet.ts +0 -17
  723. package/src/widget/hooks/useLocalePreference.tsx +0 -187
  724. package/src/widget/hooks/useMeldTransactionHistory.ts +0 -184
  725. package/src/widget/hooks/useMeldTransactionStatus.ts +0 -707
  726. package/src/widget/hooks/useOnRampCountryDefaults.ts +0 -57
  727. package/src/widget/hooks/useOnRampPaymentMethods.ts +0 -72
  728. package/src/widget/hooks/useOnRampProviderWidget.ts +0 -184
  729. package/src/widget/hooks/useOnRampQuote.ts +0 -340
  730. package/src/widget/hooks/useOnRampTransactionStatus.ts +0 -196
  731. package/src/widget/hooks/useOriginSelectedToken.tsx +0 -253
  732. package/src/widget/hooks/usePayMessage.tsx +0 -496
  733. package/src/widget/hooks/usePriceImpactWarning.ts +0 -17
  734. package/src/widget/hooks/useQuote.ts +0 -1233
  735. package/src/widget/hooks/useRecentTokens.ts +0 -159
  736. package/src/widget/hooks/useRecipients.ts +0 -167
  737. package/src/widget/hooks/useScreenTracking.ts +0 -14
  738. package/src/widget/hooks/useSelectedFeeOption.tsx +0 -323
  739. package/src/widget/hooks/useSelectedFundMethod.tsx +0 -80
  740. package/src/widget/hooks/useSelectedRecipient.tsx +0 -75
  741. package/src/widget/hooks/useSendForm.ts +0 -1373
  742. package/src/widget/hooks/useSwapAmount.tsx +0 -50
  743. package/src/widget/hooks/useSwapState.tsx +0 -121
  744. package/src/widget/hooks/useTargetAmount.ts +0 -26
  745. package/src/widget/hooks/useTheme.tsx +0 -80
  746. package/src/widget/hooks/useTokenList.ts +0 -1099
  747. package/src/widget/hooks/useTokenWithFreshBalance.ts +0 -246
  748. package/src/widget/hooks/useTrailsSendTransaction.ts +0 -987
  749. package/src/widget/hooks/useViewManager.tsx +0 -505
  750. package/src/widget/hooks/useWalletConnectUri.tsx +0 -307
  751. package/src/widget/hooks/useWalletConnectionContext.tsx +0 -128
  752. package/src/widget/hooks/useWidgetProps.tsx +0 -33
  753. package/src/widget/index.css +0 -686
  754. package/src/widget/index.tsx +0 -28
  755. package/src/widget/providers/TrailsModalProvider.tsx +0 -238
  756. package/src/widget/providers/TrailsProvider.tsx +0 -150
  757. package/src/widget/providers/UserActivityProvider.tsx +0 -78
  758. package/src/widget/providers/WidgetProviderTree.tsx +0 -90
  759. package/src/widget/styles.ts +0 -26
  760. package/src/widget/types/analytics.ts +0 -22
  761. package/src/widget/types/commonProps.ts +0 -56
  762. package/src/widget/types/svg.d.ts +0 -8
  763. package/src/widget/types.ts +0 -51
  764. package/src/widget/utils/countryUtils.ts +0 -89
  765. package/src/widget/utils/createWagmiConfig.ts +0 -38
  766. package/src/widget/utils/forexRateStore.ts +0 -120
  767. package/src/widget/utils/fundMethodSwitchState.ts +0 -25
  768. package/src/widget/utils/historyFilters.ts +0 -157
  769. package/src/widget/utils/historyUtils.ts +0 -101
  770. package/src/widget/utils/localeStore.ts +0 -68
  771. package/src/widget/utils/meldProviderUtils.ts +0 -20
  772. package/src/widget/utils/statusLabel.ts +0 -3
  773. package/src/widget/utils/tokens.ts +0 -138
  774. package/src/widget/utils/transactionFailure.ts +0 -52
  775. package/src/widget/utils/viewManagerGuards.ts +0 -49
  776. package/src/widget/utils/windowUtils.ts +0 -138
  777. package/src/widget/widget.tsx +0 -3334
  778. /package/dist/{widget/hooks → hooks}/useAddressWalletIcon.d.ts +0 -0
  779. /package/dist/{widget/hooks → hooks}/useAmountUsd.d.ts +0 -0
  780. /package/dist/{widget/hooks → hooks}/useBalanceVisible.d.ts +0 -0
  781. /package/dist/{widget/hooks → hooks}/useChainFilter.d.ts +0 -0
  782. /package/dist/{widget/hooks → hooks}/useClickTracking.d.ts +0 -0
  783. /package/dist/{widget/hooks → hooks}/useConnector.d.ts +0 -0
  784. /package/dist/{widget/hooks → hooks}/useDebounce.d.ts +0 -0
  785. /package/dist/{widget/hooks → hooks}/useDepositMonitor.d.ts +0 -0
  786. /package/dist/{widget/hooks → hooks}/useDisplayCurrencyPreference.d.ts +0 -0
  787. /package/dist/{widget/hooks → hooks}/useExecutingIntentsCount.d.ts +0 -0
  788. /package/dist/{widget/hooks → hooks}/useFiatSelectedCurrency.d.ts +0 -0
  789. /package/dist/{widget/hooks → hooks}/useGetIntent.d.ts +0 -0
  790. /package/dist/{widget/hooks → hooks}/useIsMobile.d.ts +0 -0
  791. /package/dist/{widget/hooks → hooks}/useIsSequenceWallet.d.ts +0 -0
  792. /package/dist/{widget/hooks → hooks}/useLocalePreference.d.ts +0 -0
  793. /package/dist/{widget/hooks → hooks}/useMeldTransactionHistory.d.ts +0 -0
  794. /package/dist/{widget/hooks → hooks}/useMeldTransactionStatus.d.ts +0 -0
  795. /package/dist/{widget/hooks → hooks}/useOnRampCountryDefaults.d.ts +0 -0
  796. /package/dist/{widget/hooks → hooks}/usePayMessage.d.ts +0 -0
  797. /package/dist/{widget/hooks → hooks}/usePriceImpactWarning.d.ts +0 -0
  798. /package/dist/{widget/hooks → hooks}/useRecipients.d.ts +0 -0
  799. /package/dist/{widget/hooks → hooks}/useSelectedFeeOption.d.ts +0 -0
  800. /package/dist/{widget/hooks → hooks}/useSelectedRecipient.d.ts +0 -0
  801. /package/dist/{widget/hooks → hooks}/useSwapAmount.d.ts +0 -0
  802. /package/dist/{widget/hooks → hooks}/useTargetAmount.d.ts +0 -0
  803. /package/dist/{widget/hooks → hooks}/useTheme.d.ts +0 -0
  804. /package/dist/{widget/hooks → hooks}/useWalletConnectionContext.d.ts +0 -0
package/src/recover.ts DELETED
@@ -1,1665 +0,0 @@
1
- import type { Payload as WalletPayload } from "@0xsequence/wallet-primitives"
2
- import {
3
- Constants,
4
- Erc6492,
5
- Payload,
6
- Signature,
7
- } from "@0xsequence/wallet-primitives"
8
- import { isPositiveBigInt } from "./utils/validation.js"
9
- import {
10
- IntentProtocolVersion,
11
- type Intent,
12
- type IntentCalls,
13
- type TransactionCall,
14
- } from "@0xtrails/api"
15
- import { AbiFunction, Address, Bytes, type Hex } from "ox"
16
- import { useCallback, useMemo } from "react"
17
- import type { Chain, TransactionReceipt, WalletClient } from "viem"
18
- import { zeroAddress } from "viem"
19
- import { getChainInfo, getChainRpcClient } from "./chains.js"
20
- import { attemptSwitchChain } from "./chainSwitch.js"
21
- import { SEQUENCE_V3_CONTRACT_ADDRESSES } from "./constants.js"
22
- import { decodeGuestModuleEvents } from "./decoders.js"
23
- import { splitSignature } from "./gasless.js"
24
- import { abortIntent, getIntentConfigurationFromCalls } from "./intents.js"
25
- import { logger } from "./logger.js"
26
- import { type TrailsClient, useTrailsClient } from "./trailsClient.js"
27
- import {
28
- useTokenBalancesForMultipleAccounts,
29
- WIDGET_REFRESH_INTERVAL,
30
- } from "./query/balance.hooks.js"
31
- import type { FlatTokenBalancesData } from "./query/balance.fetchers.js"
32
- import type { Token } from "./tokens.js"
33
- import {
34
- checkProviderHealth,
35
- sendWalletTransaction,
36
- signWithTimeout,
37
- } from "./walletUtils.js"
38
- import { getERC20TransferData } from "./utils.js"
39
- import { useGetIntent } from "./widget/hooks/useGetIntent.js"
40
-
41
- import { normalizeAddress } from "./utils/address.js"
42
- /**
43
- * Checks if an address is deployed by checking for bytecode
44
- * @param address - The address to check
45
- * @param chainId - The chain ID where the address exists
46
- * @returns Promise resolving to true if the address has bytecode, false otherwise
47
- */
48
- export async function isAddressDeployed(
49
- address: Address.Address,
50
- chainId: number,
51
- ): Promise<boolean> {
52
- const publicClient = getChainRpcClient(chainId)
53
- const code = await publicClient.getCode({ address })
54
- const isDeployed = code !== undefined && code !== "0x"
55
- logger.console.log("[refund] Address deployment check:", {
56
- address,
57
- chainId,
58
- codeLength: code?.length ?? 0,
59
- isDeployed,
60
- })
61
- return isDeployed
62
- }
63
-
64
- /**
65
- * Generates a random space value for Sequence wallet payloads.
66
- * Space must be in the range [0, 2^160) (20 bytes).
67
- */
68
- function generateRandomSpace(): bigint {
69
- const bytes = new Uint8Array(20) // 20 bytes = 160 bits
70
- crypto.getRandomValues(bytes)
71
- // Convert bytes to BigInt, ensuring it's within [0, 2^160)
72
- return BigInt(
73
- `0x${Array.from(bytes)
74
- .map((b) => b.toString(16).padStart(2, "0"))
75
- .join("")}`,
76
- )
77
- }
78
-
79
- /**
80
- * Creates a refund payload with random space
81
- * @param refundCall - The refund call to include in the payload
82
- * @param nonce - The nonce value to use
83
- * @returns The created payload
84
- */
85
- function createRefundPayload(
86
- refundCall: Payload.Call,
87
- nonce: bigint,
88
- ): Payload.Calls {
89
- const refundSpace = generateRandomSpace()
90
- return {
91
- type: "call",
92
- calls: [refundCall],
93
- space: refundSpace,
94
- nonce,
95
- }
96
- }
97
-
98
- /**
99
- * Signs the payload hash for a refund transaction
100
- */
101
- export async function signPayload(
102
- walletClient: WalletClient,
103
- intentAddress: Address.Address,
104
- chainId: number,
105
- payload: Payload.Calls,
106
- ): Promise<string> {
107
- if (!walletClient.account) {
108
- throw new Error("Wallet client account is required for signing")
109
- }
110
-
111
- // Check provider health before signing
112
- await checkProviderHealth(walletClient)
113
-
114
- const typedData = Payload.toTyped(
115
- Address.from(intentAddress),
116
- chainId,
117
- payload,
118
- )
119
-
120
- // Sign with timeout to prevent hanging
121
- const signature = await signWithTimeout(
122
- walletClient.signTypedData({
123
- account: walletClient.account,
124
- ...typedData,
125
- }),
126
- "Payload signature",
127
- )
128
-
129
- logger.console.log("[refund] Signature received:", signature)
130
- return signature
131
- }
132
-
133
- export interface BuildRefundTransactionWithSignatureParams {
134
- trailsClient: TrailsClient
135
- intentId: string
136
- intentProtocolVersion: IntentProtocolVersion
137
- mainSigner: Address.Address
138
- checkpoint: number
139
- calls: Array<IntentCalls>
140
- payload: Payload.Calls // The payload that was signed
141
- chainId: number
142
- intentAddress: Address.Address
143
- signature: string // Hex string signature
144
- isOriginIntent: boolean // Whether this is the origin intent address (vs destination)
145
- }
146
-
147
- /**
148
- * Builds a refund transaction using a pre-signed hash
149
- */
150
- export async function buildRefundTransactionWithSignature(
151
- params: BuildRefundTransactionWithSignatureParams,
152
- ): Promise<{ to: `0x${string}`; data: Hex.Hex }> {
153
- const {
154
- trailsClient,
155
- intentId,
156
- intentProtocolVersion,
157
- mainSigner,
158
- checkpoint,
159
- calls,
160
- payload,
161
- chainId,
162
- intentAddress,
163
- signature,
164
- isOriginIntent,
165
- } = params
166
-
167
- // Validate refund call "to" address is not zeroAddress
168
- const refundCall = payload.calls[0]
169
- if (!refundCall) {
170
- throw new Error("Refund call not found in payload")
171
- }
172
- if (!refundCall.to || Address.isEqual(refundCall.to, zeroAddress)) {
173
- throw new Error("Refund call 'to' address cannot be zero address")
174
- }
175
-
176
- logger.console.log(
177
- "[refund] buildRefundTransactionWithSignature called with params:",
178
- {
179
- mainSigner,
180
- callsCount: calls.length,
181
- calls: calls.map((c) => ({
182
- chainId: c.chainId,
183
- space: c.space?.toString(),
184
- nonce: c.nonce?.toString(),
185
- callsCount: c.calls?.length,
186
- calls: c.calls.map((c) => ({
187
- to: c.to,
188
- value: c.value?.toString(),
189
- data: c.data,
190
- gasLimit: c.gasLimit?.toString(),
191
- delegateCall: c.delegateCall,
192
- onlyFallback: c.onlyFallback,
193
- behaviorOnError: c.behaviorOnError,
194
- })),
195
- })),
196
- refundCall: {
197
- to: refundCall.to,
198
- value: refundCall.value.toString(),
199
- data: refundCall.data,
200
- gasLimit: refundCall.gasLimit.toString(),
201
- },
202
- chainId,
203
- intentAddress,
204
- signatureLength: signature.length,
205
- space: payload.space.toString(),
206
- nonce: payload.nonce.toString(),
207
- },
208
- )
209
-
210
- // In the current version, calls are already pre-filtered in the hook
211
- // to contain only the calls for the selected intent address (origin or destination)
212
- logger.console.log("[refund] Using pre-filtered calls for configuration:", {
213
- intentProtocolVersion,
214
- callsCount: calls.length,
215
- chainId,
216
- intentAddress,
217
- isOriginIntent,
218
- callChainIds: calls.map((c) => c.chainId),
219
- })
220
-
221
- if (calls.length !== 1) {
222
- throw new Error("Invalid calls provided for intent configuration")
223
- }
224
-
225
- 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,
239
- )
240
-
241
- logger.console.log("[refund] Image hash:", imageHash)
242
-
243
- if (!Address.isEqual(apiAddress, intentAddress)) {
244
- throw new Error(
245
- "API address does not match intent address. Probably config is wrong",
246
- )
247
- }
248
-
249
- // Use the payload that was passed in (already contains space, nonce, and refundCall)
250
- logger.console.log("[refund] Payload created:", {
251
- type: payload.type,
252
- callsCount: payload.calls.length,
253
- space: payload.space.toString(),
254
- nonce: payload.nonce.toString(),
255
- calls: payload.calls.map((c) => ({
256
- to: c.to,
257
- value: c.value.toString(),
258
- data: c.data,
259
- gasLimit: c.gasLimit.toString(),
260
- })),
261
- })
262
-
263
- const encodedPayload = Bytes.toHex(Payload.encode(payload))
264
- logger.console.log("[refund] Encoded payload:", encodedPayload)
265
-
266
- const toSignatureLeaf = async (
267
- signer: Address.Address,
268
- signature: `0x${string}`,
269
- ): Promise<
270
- Signature.SignatureOfSignerLeaf | Signature.SignatureOfSapientSignerLeaf
271
- > => {
272
- const signerIsContract = await isAddressDeployed(signer, chainId)
273
- if (signerIsContract) {
274
- return {
275
- address: signer,
276
- type: "erc1271",
277
- data: signature as `0x${string}`,
278
- }
279
- } else {
280
- const { r, s, v } = splitSignature(signature)
281
- const yParity = v - 27 // Convert v to yParity (0 or 1)
282
- logger.console.log("[refund] Signature parsed:", { r, s, v, yParity })
283
- const rBigInt = BigInt(r)
284
- const sBigInt = BigInt(s)
285
- return {
286
- type: "hash",
287
- r: rBigInt,
288
- s: sBigInt,
289
- yParity,
290
- }
291
- }
292
- }
293
- const signerSignatureLeaf = await toSignatureLeaf(
294
- mainSigner,
295
- signature as `0x${string}`,
296
- )
297
- const topology = Signature.fillLeaves(intentConfig.topology, (leaf) =>
298
- Address.isEqual(leaf.address, mainSigner) ? signerSignatureLeaf : undefined,
299
- )
300
- logger.console.log("[refund] Topology filled with signature leaves")
301
-
302
- const filledConfig = {
303
- noChainId: false,
304
- configuration: { ...intentConfig, topology },
305
- }
306
- const encodedSignature = Signature.encodeSignature(filledConfig, true, true)
307
- logger.console.log(
308
- "[refund] Signature encoded:",
309
- Bytes.toHex(encodedSignature),
310
- )
311
-
312
- // Check if intent address has bytecode deployed
313
- const intentAddressDeployed = await isAddressDeployed(intentAddress, chainId)
314
-
315
- const executeData = AbiFunction.encodeData(Constants.EXECUTE, [
316
- encodedPayload,
317
- Bytes.toHex(encodedSignature),
318
- ])
319
- logger.console.log("[refund] Execute data encoded:", executeData)
320
-
321
- // Validate intent address is not zeroAddress
322
- if (!intentAddress || Address.isEqual(intentAddress, zeroAddress)) {
323
- throw new Error("Intent address cannot be zero address")
324
- }
325
-
326
- if (intentAddressDeployed) {
327
- logger.console.log(
328
- "[refund] Intent address is deployed, returning direct transaction:",
329
- {
330
- to: intentAddress,
331
- data: executeData,
332
- },
333
- )
334
- return { to: intentAddress, data: executeData }
335
- } else {
336
- logger.console.log(
337
- "[refund] Intent address not deployed, using ERC-6492 deploy",
338
- )
339
- const deploy = Erc6492.deploy(imageHash, context)
340
- logger.console.log("[refund] ERC-6492 deploy created:", {
341
- to: deploy.to,
342
- dataLength: deploy.data.length,
343
- deployToHex: deploy.to,
344
- imageHashUsed: imageHash,
345
- factoryAddress: context.factory,
346
- guestModuleAddress: context.guestModule,
347
- })
348
-
349
- // Validate deploy.to and intentAddress are not zeroAddress
350
- if (!deploy.to || Address.isEqual(deploy.to, zeroAddress)) {
351
- throw new Error("Deploy 'to' address cannot be zero address")
352
- }
353
-
354
- const deployPayload = {
355
- type: "call" as const,
356
- space: 0n,
357
- nonce: 0n,
358
- calls: [
359
- {
360
- to: deploy.to,
361
- value: 0n,
362
- data: deploy.data,
363
- gasLimit: 0n,
364
- delegateCall: false,
365
- onlyFallback: false,
366
- behaviorOnError: "revert" as const,
367
- },
368
- {
369
- to: intentAddress,
370
- value: 0n,
371
- data: executeData,
372
- gasLimit: 0n,
373
- delegateCall: false,
374
- onlyFallback: false,
375
- behaviorOnError: "revert" as const,
376
- },
377
- ],
378
- }
379
- logger.console.log("[refund] Deploy payload created:", {
380
- callsCount: deployPayload.calls.length,
381
- calls: deployPayload.calls.map((c) => ({
382
- to: c.to,
383
- value: c.value.toString(),
384
- dataLength: c.data.length,
385
- gasLimit: c.gasLimit.toString(),
386
- })),
387
- })
388
-
389
- const encodedDeployPayload = Bytes.toHex(Payload.encode(deployPayload))
390
- logger.console.log("[refund] Encoded deploy payload:", {
391
- fullPayload: encodedDeployPayload,
392
- payloadLength: encodedDeployPayload.length,
393
- payloadPreview: `${encodedDeployPayload.slice(0, 100)}...`,
394
- executeDataLength: executeData.length,
395
- executeDataPreview: `${executeData.slice(0, 100)}...`,
396
- })
397
-
398
- const result = {
399
- to: context.guestModule as `0x${string}`,
400
- data: encodedDeployPayload,
401
- }
402
-
403
- // Validate final transaction "to" address is not zeroAddress
404
- if (!result.to || Address.isEqual(result.to, zeroAddress)) {
405
- throw new Error("Transaction 'to' address cannot be zero address")
406
- }
407
-
408
- logger.console.log("[refund] Returning ERC-6492 transaction:", {
409
- to: result.to,
410
- dataLength: result.data.length,
411
- })
412
-
413
- return result
414
- }
415
- }
416
-
417
- /**
418
- * Determines the refund call based on token balances at the intent address
419
- * Uses Token type which has symbol, name, decimals, chainId directly (no contractInfo)
420
- */
421
- export function determineRefundCall(
422
- tokenBalancesData:
423
- | {
424
- tokens?: Array<{
425
- balance?: string
426
- contractAddress?: string
427
- decimals?: number
428
- chainId?: number
429
- isNativeToken?: boolean
430
- }>
431
- }
432
- | undefined,
433
- refundToAddress: `0x${string}`,
434
- ): WalletPayload.Call {
435
- // Validate refund address is not zeroAddress
436
- if (!refundToAddress || Address.isEqual(refundToAddress, zeroAddress)) {
437
- throw new Error("Refund address cannot be zero address")
438
- }
439
- // Find the token with the highest balance
440
- let highestBalanceToken: {
441
- type: "native" | "erc20"
442
- balance: bigint
443
- tokenAddress?: string
444
- decimals?: number
445
- chainId?: number
446
- } | null = null
447
-
448
- // Check all tokens (both native and ERC20)
449
- if (tokenBalancesData?.tokens) {
450
- for (const token of tokenBalancesData.tokens) {
451
- const balance = BigInt(token.balance || "0")
452
- if (balance > 0n) {
453
- if (!highestBalanceToken || balance > highestBalanceToken.balance) {
454
- highestBalanceToken = {
455
- type: token.isNativeToken ? "native" : "erc20",
456
- balance,
457
- tokenAddress: token.contractAddress,
458
- decimals: token.decimals,
459
- chainId: token.chainId,
460
- }
461
- }
462
- }
463
- }
464
- }
465
-
466
- if (!highestBalanceToken) {
467
- logger.console.log(
468
- "[refund] No tokens found at intent address, creating empty refund call",
469
- )
470
- return {
471
- to: refundToAddress,
472
- value: 0n,
473
- data: "0x" as `0x${string}`,
474
- gasLimit: 0n,
475
- delegateCall: false,
476
- onlyFallback: false,
477
- behaviorOnError: "revert",
478
- }
479
- } else if (highestBalanceToken.type === "native") {
480
- logger.console.log("[refund] Creating native token refund call:", {
481
- to: refundToAddress,
482
- value: highestBalanceToken.balance.toString(),
483
- balance: highestBalanceToken.balance.toString(),
484
- chainId: highestBalanceToken.chainId,
485
- })
486
- return {
487
- to: refundToAddress,
488
- value: highestBalanceToken.balance,
489
- data: "0x" as `0x${string}`,
490
- gasLimit: 0n,
491
- delegateCall: false,
492
- onlyFallback: false,
493
- behaviorOnError: "revert",
494
- }
495
- } else {
496
- // ERC20 token refund
497
- // For recovery operations, we still encode client-side
498
- const transferData = getERC20TransferData(
499
- refundToAddress,
500
- highestBalanceToken.balance,
501
- )
502
- logger.console.log("[refund] Creating ERC20 token refund call:", {
503
- to: highestBalanceToken.tokenAddress,
504
- value: "0",
505
- data: transferData,
506
- balance: highestBalanceToken.balance.toString(),
507
- decimals: highestBalanceToken.decimals,
508
- chainId: highestBalanceToken.chainId,
509
- recipient: refundToAddress,
510
- })
511
- // Validate token address is not zeroAddress
512
- if (
513
- !highestBalanceToken.tokenAddress ||
514
- Address.isEqual(
515
- Address.from(highestBalanceToken.tokenAddress),
516
- zeroAddress,
517
- )
518
- ) {
519
- throw new Error("ERC20 token address cannot be zero address")
520
- }
521
-
522
- return {
523
- to: Address.from(highestBalanceToken.tokenAddress),
524
- value: 0n,
525
- data: transferData as `0x${string}`,
526
- gasLimit: 0n,
527
- delegateCall: false,
528
- onlyFallback: false,
529
- behaviorOnError: "revert",
530
- }
531
- }
532
- }
533
-
534
- // ─── Shared helper types and functions (used by multiple hooks) ───
535
-
536
- interface SelectedIntentAddress {
537
- address: Address.Address
538
- chainId: number
539
- intentAddress: Address.Address
540
- tokenBalancesData: FlatTokenBalancesData | undefined
541
- isOrigin: boolean
542
- }
543
-
544
- function findHighestTokenUsdBalance(
545
- tokenBalancesData: FlatTokenBalancesData | undefined,
546
- ): number {
547
- if (!tokenBalancesData?.tokens) return 0
548
- let highest = 0
549
- for (const token of tokenBalancesData.tokens) {
550
- const balanceUsd = token.balanceUsd || 0
551
- if (balanceUsd > highest) highest = balanceUsd
552
- }
553
- return highest
554
- }
555
-
556
- function findHighestRawTokenBalance(
557
- tokenBalancesData: FlatTokenBalancesData | undefined,
558
- ): bigint {
559
- if (!tokenBalancesData?.tokens) return 0n
560
- let highest = 0n
561
- for (const token of tokenBalancesData.tokens) {
562
- const balance = BigInt(token.balance || "0")
563
- if (balance > highest) highest = balance
564
- }
565
- return highest
566
- }
567
-
568
- function selectIntentAddress(
569
- intentData: Intent,
570
- originBalances: FlatTokenBalancesData | undefined,
571
- destBalances: FlatTokenBalancesData | undefined,
572
- originAddr: Address.Address | null,
573
- destAddr: Address.Address | null,
574
- ): SelectedIntentAddress | null {
575
- const originHighestTokenUsd = findHighestTokenUsdBalance(originBalances)
576
- const destinationHighestTokenUsd = findHighestTokenUsdBalance(destBalances)
577
- const originHighestRawBalance = findHighestRawTokenBalance(originBalances)
578
- const destinationHighestRawBalance = findHighestRawTokenBalance(destBalances)
579
-
580
- let useDestination = false
581
- if (destAddr) {
582
- if (originHighestTokenUsd > 0 && destinationHighestTokenUsd > 0) {
583
- useDestination = destinationHighestTokenUsd > originHighestTokenUsd
584
- } else if (destinationHighestTokenUsd > 0 && originHighestTokenUsd === 0) {
585
- useDestination = true
586
- } else if (originHighestTokenUsd > 0 && destinationHighestTokenUsd === 0) {
587
- useDestination = false
588
- } else {
589
- useDestination = destinationHighestRawBalance > originHighestRawBalance
590
- }
591
- }
592
-
593
- const makeOriginResult = (): SelectedIntentAddress | null => {
594
- if (!intentData.originIntentAddress || !originAddr) return null
595
- return {
596
- address: originAddr,
597
- chainId: Number(intentData.originChainId || 0),
598
- intentAddress: Address.from(intentData.originIntentAddress),
599
- tokenBalancesData: originBalances,
600
- isOrigin: true,
601
- }
602
- }
603
-
604
- if (useDestination) {
605
- const chainId = intentData.destinationChainId
606
- if (!chainId || !intentData.destinationIntentAddress || !destAddr) {
607
- return makeOriginResult()
608
- }
609
- return {
610
- address: destAddr,
611
- chainId: Number(chainId),
612
- intentAddress: Address.from(intentData.destinationIntentAddress),
613
- tokenBalancesData: destBalances,
614
- isOrigin: false,
615
- }
616
- }
617
-
618
- return makeOriginResult()
619
- }
620
-
621
- function checkAnyIntentBalance(
622
- originBalances: FlatTokenBalancesData | undefined,
623
- destBalances: FlatTokenBalancesData | undefined,
624
- ): boolean {
625
- const hasBalance = (data: { tokens?: Token[] } | undefined): boolean => {
626
- if (!data?.tokens) return false
627
- for (const token of data.tokens) {
628
- if (isPositiveBigInt(token.balance || "0")) return true
629
- }
630
- return false
631
- }
632
- return hasBalance(originBalances) || hasBalance(destBalances)
633
- }
634
-
635
- function findRecoverToken(
636
- selected: SelectedIntentAddress | null,
637
- ): Token | null {
638
- if (!selected?.tokenBalancesData?.tokens) return null
639
- let highestBalanceToken: Token | null = null
640
- let highestBalance = 0n
641
- for (const token of selected.tokenBalancesData.tokens) {
642
- const balance = BigInt(token.balance || "0")
643
- if (balance > 0n && balance > highestBalance) {
644
- highestBalance = balance
645
- highestBalanceToken = token
646
- }
647
- }
648
- return highestBalanceToken
649
- }
650
-
651
- function mapTransactionCalls(intentData: Intent): IntentCalls[] {
652
- const allCalls: IntentCalls[] = []
653
- if (intentData.originCalls) {
654
- allCalls.push({
655
- chainId: intentData.originCalls.chainId,
656
- space: intentData.originCalls.space,
657
- nonce: intentData.originCalls.nonce,
658
- calls: intentData.originCalls.calls.map((call: TransactionCall) => ({
659
- to: call.to,
660
- value: call.value,
661
- data: call.data,
662
- gasLimit: call.gasLimit,
663
- delegateCall: call.delegateCall,
664
- onlyFallback: call.onlyFallback,
665
- behaviorOnError: call.behaviorOnError,
666
- })),
667
- })
668
- }
669
- if (
670
- intentData.destinationCalls &&
671
- intentData.destinationCalls.chainId !== intentData.originCalls?.chainId
672
- ) {
673
- allCalls.push({
674
- chainId: intentData.destinationCalls.chainId,
675
- space: intentData.destinationCalls.space,
676
- nonce: intentData.destinationCalls.nonce,
677
- calls: intentData.destinationCalls.calls.map((call: TransactionCall) => ({
678
- to: call.to,
679
- value: call.value,
680
- data: call.data,
681
- gasLimit: call.gasLimit,
682
- delegateCall: call.delegateCall,
683
- onlyFallback: call.onlyFallback,
684
- behaviorOnError: call.behaviorOnError,
685
- })),
686
- })
687
- }
688
- return allCalls
689
- }
690
-
691
- function filterCallsByChainId(
692
- allCalls: IntentCalls[],
693
- targetChainId: number,
694
- ): IntentCalls[] {
695
- return allCalls.filter((call) => {
696
- const callChainId =
697
- typeof call.chainId === "bigint"
698
- ? call.chainId
699
- : BigInt(String(call.chainId))
700
- return callChainId === BigInt(targetChainId)
701
- })
702
- }
703
-
704
- function validateRefundAddress(
705
- address: `0x${string}` | null,
706
- ): asserts address is `0x${string}` {
707
- if (!address) {
708
- throw new Error(
709
- "Refund address is required. Provide refundToAddress or connect a wallet with a valid address",
710
- )
711
- }
712
- if (Address.isEqual(address, zeroAddress)) {
713
- throw new Error("Refund address cannot be zero address")
714
- }
715
- }
716
-
717
- async function getRecoverStatusFromChain(params: {
718
- txHash: `0x${string}`
719
- chainId: number
720
- }): Promise<{ status: "success" | "fail" | "pending" }> {
721
- const { txHash, chainId } = params
722
- const publicClient = getChainRpcClient(chainId)
723
- try {
724
- const transaction = await publicClient.getTransaction({ hash: txHash })
725
- if (transaction) {
726
- try {
727
- const receipt = await publicClient.getTransactionReceipt({
728
- hash: txHash,
729
- })
730
- if (receipt.status === "reverted") return { status: "fail" }
731
- const guestModuleEvents = decodeGuestModuleEvents(receipt)
732
- if (guestModuleEvents.some((e) => e.type === "CallFailed"))
733
- return { status: "fail" }
734
- return { status: "success" }
735
- } catch {
736
- return { status: "pending" }
737
- }
738
- }
739
- } catch {
740
- try {
741
- const receipt = await publicClient.getTransactionReceipt({
742
- hash: txHash,
743
- })
744
- if (receipt.status === "reverted") return { status: "fail" }
745
- const guestModuleEvents = decodeGuestModuleEvents(receipt)
746
- if (guestModuleEvents.some((e) => e.type === "CallFailed"))
747
- return { status: "fail" }
748
- return { status: "success" }
749
- } catch {
750
- return { status: "pending" }
751
- }
752
- }
753
- return { status: "pending" }
754
- }
755
-
756
- function buildSelectedRecoveryTarget(selected: SelectedIntentAddress | null) {
757
- if (!selected) return null
758
- const chainInfo = getChainInfo(selected.chainId)
759
- return {
760
- address: selected.address,
761
- chainId: selected.chainId,
762
- chainName: chainInfo?.name || `Chain ${selected.chainId}`,
763
- isOrigin: selected.isOrigin,
764
- tokenBalancesData: selected.tokenBalancesData,
765
- }
766
- }
767
-
768
- /**
769
- * Builds the calls array for a specific intent address (origin or destination).
770
- * Used by getRecoverTx in multiple hooks.
771
- */
772
- function buildCallsForSelectedAddress(
773
- intentData: Intent,
774
- selected: SelectedIntentAddress,
775
- ): IntentCalls[] {
776
- const calls: IntentCalls[] = []
777
- if (selected.isOrigin && intentData.originCalls) {
778
- calls.push({
779
- chainId: intentData.originCalls.chainId,
780
- space: intentData.originCalls.space,
781
- nonce: intentData.originCalls.nonce,
782
- calls: intentData.originCalls.calls.map((call: TransactionCall) => ({
783
- to: call.to,
784
- value: call.value,
785
- data: call.data,
786
- gasLimit: call.gasLimit,
787
- delegateCall: call.delegateCall,
788
- onlyFallback: call.onlyFallback,
789
- behaviorOnError: call.behaviorOnError,
790
- })),
791
- })
792
- } else if (!selected.isOrigin && intentData.destinationCalls) {
793
- calls.push({
794
- chainId: intentData.destinationCalls.chainId,
795
- space: intentData.destinationCalls.space,
796
- nonce: intentData.destinationCalls.nonce,
797
- calls: intentData.destinationCalls.calls.map((call: TransactionCall) => ({
798
- to: call.to,
799
- value: call.value,
800
- data: call.data,
801
- gasLimit: call.gasLimit,
802
- delegateCall: call.delegateCall,
803
- onlyFallback: call.onlyFallback,
804
- behaviorOnError: call.behaviorOnError,
805
- })),
806
- })
807
- }
808
- return calls
809
- }
810
-
811
- /**
812
- * Builds a recover transaction from signature + payload using shared logic.
813
- */
814
- async function buildRecoverTxFromSignature(params: {
815
- trailsClient: TrailsClient
816
- intentData: Intent
817
- mainSigner: Address.Address
818
- selected: SelectedIntentAddress
819
- effectiveRefundAddress: `0x${string}`
820
- signature: string
821
- payload: Payload.Calls
822
- }): Promise<{
823
- to: `0x${string}`
824
- data: `0x${string}`
825
- chainId: number
826
- chain: Chain
827
- }> {
828
- const {
829
- trailsClient,
830
- intentData,
831
- mainSigner,
832
- selected,
833
- effectiveRefundAddress,
834
- signature,
835
- payload,
836
- } = params
837
- validateRefundAddress(effectiveRefundAddress)
838
-
839
- const calls = buildCallsForSelectedAddress(intentData, selected)
840
- if (calls.length === 0) {
841
- throw new Error("No calls found for the selected intent address")
842
- }
843
-
844
- const chainId = selected.chainId
845
- if (!chainId) {
846
- throw new Error("Chain ID not found for selected intent address")
847
- }
848
-
849
- const intentProtocolVersion =
850
- intentData.intentProtocolVersion ?? IntentProtocolVersion.v1
851
- const checkpoint = Number(intentData.salt)
852
-
853
- const result = await buildRefundTransactionWithSignature({
854
- trailsClient,
855
- intentId: intentData.intentId,
856
- intentProtocolVersion,
857
- checkpoint,
858
- mainSigner,
859
- calls,
860
- payload,
861
- chainId: Number(chainId),
862
- intentAddress: selected.intentAddress,
863
- signature,
864
- isOriginIntent: selected.isOrigin,
865
- })
866
-
867
- if (!result.to || Address.isEqual(result.to, zeroAddress)) {
868
- throw new Error("Refund transaction 'to' address cannot be zero address")
869
- }
870
-
871
- const chainInfo = getChainInfo(Number(chainId))
872
- if (!chainInfo) {
873
- throw new Error(`Chain info not found for chain ID: ${chainId}`)
874
- }
875
-
876
- return {
877
- to: result.to,
878
- data: result.data,
879
- chainId: Number(chainId),
880
- chain: chainInfo as Chain,
881
- }
882
- }
883
-
884
- // ─── End shared helpers ───
885
-
886
- export interface UseIntentRecoverParams {
887
- intentId: string | undefined
888
- walletClient: WalletClient | undefined
889
- refundToAddress?: `0x${string}`
890
- }
891
-
892
- export interface UseIntentRecoverWithBalancesParams {
893
- intent: Intent | null
894
- balancesByIntentAddress: {
895
- [account: string]: {
896
- tokenBalancesData: FlatTokenBalancesData | undefined
897
- isLoading: boolean
898
- error: Error | null
899
- }
900
- }
901
- walletClient: WalletClient | undefined
902
- refundToAddress?: `0x${string}`
903
- }
904
-
905
- /**
906
- * Optimized return type for useIntentRecoverWithBalances
907
- */
908
- export interface UseIntentRecoverWithBalancesReturn {
909
- intent: Intent | null
910
- hasIntentBalance: boolean
911
- recoverToken: Token | null
912
- selectedRecoveryTarget: {
913
- address: Address.Address
914
- chainId: number
915
- chainName: string
916
- isOrigin: boolean
917
- tokenBalancesData: FlatTokenBalancesData | undefined
918
- } | null
919
- refetchIntent: () => void
920
- signPayload: () => Promise<{
921
- signature: string
922
- payload: Payload.Calls
923
- refundCall: Payload.Call
924
- }>
925
- getRecoverTx: (params: {
926
- signedHash: string
927
- payload: Payload.Calls
928
- }) => Promise<{
929
- to: `0x${string}`
930
- data: `0x${string}`
931
- chainId: number
932
- chain: Chain
933
- }>
934
- recover: () => Promise<{
935
- txHash: `0x${string}`
936
- }>
937
- getRecoverStatus: (params: {
938
- txHash: `0x${string}`
939
- chainId: number
940
- }) => Promise<{
941
- status: "success" | "fail" | "pending"
942
- }>
943
- }
944
-
945
- export interface UseIntentRecoverReturn {
946
- intent: Intent | null
947
- isLoadingIntent: boolean
948
- isLoadingBalances: boolean
949
- intentError: Error | null
950
- balancesError: Error | null
951
- hasIntentBalance: boolean
952
- /** Token that will be recovered (the one with highest balance) */
953
- recoverToken: Token | null
954
- /** Information about which intent address will be recovered from */
955
- selectedRecoveryTarget: {
956
- address: Address.Address
957
- chainId: number
958
- chainName: string
959
- isOrigin: boolean
960
- tokenBalancesData: FlatTokenBalancesData | undefined
961
- } | null
962
- refetchIntent: () => void
963
- signPayload: () => Promise<{
964
- signature: string
965
- payload: Payload.Calls
966
- refundCall: Payload.Call
967
- }>
968
- getRecoverTx: (params: {
969
- signedHash: string
970
- payload: Payload.Calls
971
- }) => Promise<{
972
- to: `0x${string}`
973
- data: `0x${string}`
974
- chainId: number
975
- chain: Chain
976
- }>
977
- recover: () => Promise<{
978
- txHash: `0x${string}`
979
- receipt: TransactionReceipt
980
- chainId: number
981
- }>
982
- getRecoverStatus: (params: {
983
- txHash: `0x${string}`
984
- chainId: number
985
- }) => Promise<{
986
- status: "success" | "fail" | "pending"
987
- }>
988
- }
989
-
990
- export interface UseIntentRecoverWithAddressParams {
991
- intentId: string | undefined
992
- /** Signer for the recovery tx and default refund receiver */
993
- walletAddress: `0x${string}` | undefined
994
- /** Optional. If set, refund is sent here instead of walletAddress (signer stays walletAddress). */
995
- refundToAddress?: `0x${string}`
996
- }
997
-
998
- export interface UseIntentRecoverWithAddressReturn {
999
- intent: Intent | null
1000
- isLoadingIntent: boolean
1001
- isLoadingBalances: boolean
1002
- intentError: Error | null
1003
- balancesError: Error | null
1004
- hasIntentBalance: boolean
1005
- recoverToken: Token | null
1006
- selectedRecoveryTarget: {
1007
- address: Address.Address
1008
- chainId: number
1009
- chainName: string
1010
- isOrigin: boolean
1011
- tokenBalancesData: FlatTokenBalancesData | undefined
1012
- } | null
1013
- refetchIntent: () => void
1014
- /** Returns payload and EIP-712 typed data for the app to sign (e.g. with embedded wallet). */
1015
- getDataToSign: () => Promise<{
1016
- payload: Payload.Calls
1017
- refundCall: Payload.Call
1018
- chainId: number
1019
- typedData: ReturnType<typeof Payload.toTyped>
1020
- }>
1021
- getRecoverTx: (params: {
1022
- signature: string
1023
- payload: Payload.Calls
1024
- }) => Promise<{
1025
- to: `0x${string}`
1026
- data: `0x${string}`
1027
- chainId: number
1028
- chain: Chain
1029
- }>
1030
- getRecoverStatus: (params: {
1031
- txHash: `0x${string}`
1032
- chainId: number
1033
- }) => Promise<{
1034
- status: "success" | "fail" | "pending"
1035
- }>
1036
- }
1037
-
1038
- /**
1039
- * Hook for building and signing recover transactions.
1040
- * Wraps useIntentRecoverWithAddress and adds walletClient-based signing + sending.
1041
- * @example
1042
- * ```tsx
1043
- * const { signPayload, getRecoverTx, recover } = useIntentRecover({
1044
- * intentId: "0x...",
1045
- * walletClient: walletClient,
1046
- * })
1047
- *
1048
- * // Option 1: Manual flow
1049
- * const signedHash = await signPayload()
1050
- * const recoverTx = await getRecoverTx({ signedHash })
1051
- * await walletClient.sendTransaction(recoverTx)
1052
- *
1053
- * // Option 2: Automatic flow (recommended)
1054
- * const { txHash, receipt, chainId } = await recover()
1055
- * const status = await getRecoverStatus({ txHash, chainId })
1056
- * ```
1057
- */
1058
- export function useIntentRecover({
1059
- intentId,
1060
- walletClient,
1061
- refundToAddress,
1062
- }: UseIntentRecoverParams): UseIntentRecoverReturn {
1063
- const trailsClient = useTrailsClient()
1064
- const walletAddress = walletClient?.account?.address as
1065
- | `0x${string}`
1066
- | undefined
1067
-
1068
- const inner = useIntentRecoverWithAddress({
1069
- intentId,
1070
- walletAddress,
1071
- refundToAddress: refundToAddress || walletAddress,
1072
- })
1073
-
1074
- const signPayload = useCallback(async (): Promise<{
1075
- signature: string
1076
- payload: Payload.Calls
1077
- refundCall: Payload.Call
1078
- }> => {
1079
- if (!walletClient || !walletClient.account) {
1080
- throw new Error("Intent data and wallet client with account required")
1081
- }
1082
-
1083
- await checkProviderHealth(walletClient)
1084
-
1085
- const { payload, refundCall, chainId, typedData } =
1086
- await inner.getDataToSign()
1087
-
1088
- await attemptSwitchChain({
1089
- walletClient,
1090
- desiredChainId: Number(chainId),
1091
- })
1092
-
1093
- await checkProviderHealth(walletClient)
1094
-
1095
- const signature = await signWithTimeout(
1096
- walletClient.signTypedData({
1097
- account: walletClient.account,
1098
- ...typedData,
1099
- }),
1100
- "Recovery signature",
1101
- )
1102
-
1103
- return { signature, payload, refundCall }
1104
- }, [walletClient, inner])
1105
-
1106
- const getRecoverTx = useCallback(
1107
- async (params: {
1108
- signedHash: string
1109
- payload: Payload.Calls
1110
- }): Promise<{
1111
- to: `0x${string}`
1112
- data: `0x${string}`
1113
- chainId: number
1114
- chain: Chain
1115
- }> =>
1116
- inner.getRecoverTx({
1117
- signature: params.signedHash,
1118
- payload: params.payload,
1119
- }),
1120
- [inner],
1121
- )
1122
-
1123
- const recover = useCallback(async (): Promise<{
1124
- txHash: `0x${string}`
1125
- receipt: TransactionReceipt
1126
- chainId: number
1127
- }> => {
1128
- if (!walletClient || !walletClient.account) {
1129
- throw new Error("Intent data and wallet client with account required")
1130
- }
1131
-
1132
- const { signature, payload } = await signPayload()
1133
-
1134
- const recoverTx = await getRecoverTx({
1135
- signedHash: signature,
1136
- payload,
1137
- })
1138
-
1139
- await attemptSwitchChain({
1140
- walletClient,
1141
- desiredChainId: recoverTx.chainId,
1142
- })
1143
-
1144
- const txHash = await sendWalletTransaction(walletClient, {
1145
- account: walletClient.account,
1146
- to: recoverTx.to,
1147
- data: recoverTx.data,
1148
- chain: recoverTx.chain,
1149
- })
1150
-
1151
- const publicClient = getChainRpcClient(recoverTx.chainId)
1152
- const receipt = await publicClient.waitForTransactionReceipt({
1153
- hash: txHash as `0x${string}`,
1154
- })
1155
-
1156
- if (intentId && trailsClient) {
1157
- try {
1158
- await abortIntent(trailsClient, intentId, recoverTx.chainId, txHash)
1159
- } catch (error) {
1160
- logger.console.error(
1161
- "[recover] Failed to abort intent after recovery:",
1162
- {
1163
- error: error instanceof Error ? error.message : String(error),
1164
- intentId,
1165
- chainId: recoverTx.chainId,
1166
- txHash,
1167
- },
1168
- )
1169
- }
1170
- }
1171
-
1172
- return {
1173
- txHash: txHash as `0x${string}`,
1174
- receipt,
1175
- chainId: recoverTx.chainId,
1176
- }
1177
- }, [signPayload, getRecoverTx, walletClient, intentId, trailsClient])
1178
-
1179
- return {
1180
- ...inner,
1181
- signPayload,
1182
- getRecoverTx,
1183
- recover,
1184
- }
1185
- }
1186
-
1187
- /**
1188
- * Recovery hook for apps that handle signing externally (e.g. embedded wallets)
1189
- * Use getDataToSign to get EIP-712 data, sign with walletAddress, then getRecoverTx(signature, payload).
1190
- * Refund goes to refundToAddress if provided, otherwise to walletAddress.
1191
- * @example
1192
- * ```tsx
1193
- * const { getDataToSign, getRecoverTx } = useIntentRecoverWithAddress({
1194
- * intentId: "0x...",
1195
- * walletAddress: "0x...",
1196
- * refundToAddress: "0x...", // optional, allows for different refund address than signer
1197
- * })
1198
- * const { payload, typedData, chainId } = await getDataToSign()
1199
- * const signature = await myCustomWallet.signTypedData({ account: walletAddress, ...typedData })
1200
- * const recoverTx = await getRecoverTx({ signature, payload })
1201
- * const hash = await myCustomWallet.sendTransaction({ to: recoverTx.to, data: recoverTx.data, chain: recoverTx.chain })
1202
- * ```
1203
- */
1204
- export function useIntentRecoverWithAddress({
1205
- intentId,
1206
- walletAddress,
1207
- refundToAddress,
1208
- }: UseIntentRecoverWithAddressParams): UseIntentRecoverWithAddressReturn {
1209
- const {
1210
- intent: intentData,
1211
- isLoading: isLoadingIntent,
1212
- error: intentError,
1213
- refetch: refetchIntent,
1214
- } = useGetIntent({
1215
- intentId,
1216
- enabled: !!intentId,
1217
- })
1218
-
1219
- const trailsClient = useTrailsClient()
1220
-
1221
- const originIntentAddressForBalances = intentData?.originIntentAddress
1222
- ? Address.from(intentData.originIntentAddress)
1223
- : null
1224
- const destinationIntentAddressForBalances =
1225
- intentData?.destinationIntentAddress
1226
- ? Address.from(intentData.destinationIntentAddress)
1227
- : null
1228
-
1229
- const {
1230
- balancesByAccount: balancesByIntentAddress,
1231
- isLoading: isLoadingBalances,
1232
- error: balanceError,
1233
- } = useTokenBalancesForMultipleAccounts(
1234
- [originIntentAddressForBalances, destinationIntentAddressForBalances],
1235
- {
1236
- refetchInterval: WIDGET_REFRESH_INTERVAL,
1237
- },
1238
- )
1239
-
1240
- const originTokenBalancesData = originIntentAddressForBalances
1241
- ? balancesByIntentAddress[normalizeAddress(originIntentAddressForBalances)]
1242
- ?.tokenBalancesData
1243
- : undefined
1244
- const destinationTokenBalancesData = destinationIntentAddressForBalances
1245
- ? balancesByIntentAddress[
1246
- normalizeAddress(destinationIntentAddressForBalances)
1247
- ]?.tokenBalancesData
1248
- : undefined
1249
- const balancesError = balanceError
1250
-
1251
- const selectedIntentAddress = useMemo<SelectedIntentAddress | null>(
1252
- () =>
1253
- intentData
1254
- ? selectIntentAddress(
1255
- intentData,
1256
- originTokenBalancesData,
1257
- destinationTokenBalancesData,
1258
- originIntentAddressForBalances,
1259
- destinationIntentAddressForBalances,
1260
- )
1261
- : null,
1262
- [
1263
- intentData,
1264
- originTokenBalancesData,
1265
- destinationTokenBalancesData,
1266
- originIntentAddressForBalances,
1267
- destinationIntentAddressForBalances,
1268
- ],
1269
- )
1270
-
1271
- const hasIntentBalance = useMemo<boolean>(
1272
- () =>
1273
- checkAnyIntentBalance(
1274
- originTokenBalancesData,
1275
- destinationTokenBalancesData,
1276
- ),
1277
- [originTokenBalancesData, destinationTokenBalancesData],
1278
- )
1279
-
1280
- const recoverToken = useMemo<Token | null>(
1281
- () => findRecoverToken(selectedIntentAddress),
1282
- [selectedIntentAddress],
1283
- )
1284
-
1285
- const effectiveRefundAddress = useMemo<`0x${string}` | null>(() => {
1286
- const address = refundToAddress ?? walletAddress
1287
- if (!address || Address.isEqual(address, zeroAddress)) return null
1288
- return address
1289
- }, [refundToAddress, walletAddress])
1290
-
1291
- const getDataToSign = useCallback(async (): Promise<{
1292
- payload: Payload.Calls
1293
- refundCall: Payload.Call
1294
- chainId: number
1295
- typedData: ReturnType<typeof Payload.toTyped>
1296
- }> => {
1297
- if (!intentData) {
1298
- throw new Error("Intent data required")
1299
- }
1300
- if (!effectiveRefundAddress) {
1301
- throw new Error(
1302
- "Refund address required. Provide refundToAddress or walletAddress",
1303
- )
1304
- }
1305
- if (Address.isEqual(effectiveRefundAddress, zeroAddress)) {
1306
- throw new Error("Refund address cannot be zero address")
1307
- }
1308
- if (!selectedIntentAddress) {
1309
- throw new Error("No intent address selected for recovery")
1310
- }
1311
- const allCalls = mapTransactionCalls(intentData)
1312
- const calls = filterCallsByChainId(allCalls, selectedIntentAddress.chainId)
1313
- if (calls.length === 0) {
1314
- throw new Error("No calls found for the selected intent address")
1315
- }
1316
- const refundCall = determineRefundCall(
1317
- selectedIntentAddress.tokenBalancesData,
1318
- effectiveRefundAddress,
1319
- )
1320
- const chainId = selectedIntentAddress.chainId
1321
- if (!chainId) {
1322
- throw new Error("Chain ID not found for selected intent address")
1323
- }
1324
- const payload = createRefundPayload(
1325
- refundCall,
1326
- BigInt(calls[0]?.nonce ?? 0),
1327
- )
1328
- const typedData = Payload.toTyped(
1329
- selectedIntentAddress.intentAddress,
1330
- chainId,
1331
- payload,
1332
- )
1333
- return { payload, refundCall, chainId, typedData }
1334
- }, [intentData, selectedIntentAddress, effectiveRefundAddress])
1335
-
1336
- const getRecoverTx = useCallback(
1337
- async (params: {
1338
- signature: string
1339
- payload: Payload.Calls
1340
- }): Promise<{
1341
- to: `0x${string}`
1342
- data: `0x${string}`
1343
- chainId: number
1344
- chain: Chain
1345
- }> => {
1346
- if (!intentData) {
1347
- throw new Error("Intent data required")
1348
- }
1349
- if (!walletAddress) {
1350
- throw new Error("walletAddress is required")
1351
- }
1352
- if (!selectedIntentAddress) {
1353
- throw new Error("No intent address selected for recovery")
1354
- }
1355
- return buildRecoverTxFromSignature({
1356
- trailsClient,
1357
- intentData,
1358
- mainSigner: Address.from(walletAddress),
1359
- selected: selectedIntentAddress,
1360
- effectiveRefundAddress: effectiveRefundAddress!,
1361
- signature: params.signature,
1362
- payload: params.payload,
1363
- })
1364
- },
1365
- [
1366
- intentData,
1367
- walletAddress,
1368
- selectedIntentAddress,
1369
- effectiveRefundAddress,
1370
- trailsClient,
1371
- ],
1372
- )
1373
-
1374
- const getRecoverStatus = useCallback(
1375
- (params: { txHash: `0x${string}`; chainId: number }) =>
1376
- getRecoverStatusFromChain(params),
1377
- [],
1378
- )
1379
-
1380
- const selectedRecoveryTarget = useMemo(
1381
- () => buildSelectedRecoveryTarget(selectedIntentAddress),
1382
- [selectedIntentAddress],
1383
- )
1384
-
1385
- return {
1386
- intent: intentData,
1387
- isLoadingIntent,
1388
- isLoadingBalances,
1389
- intentError: intentError as Error | null,
1390
- balancesError: balancesError as Error | null,
1391
- hasIntentBalance,
1392
- recoverToken,
1393
- selectedRecoveryTarget,
1394
- refetchIntent,
1395
- getDataToSign,
1396
- getRecoverTx,
1397
- getRecoverStatus,
1398
- }
1399
- }
1400
-
1401
- /**
1402
- * Optimized hook for building and signing recover transactions with pre-fetched data
1403
- * @example
1404
- * ```tsx
1405
- * const { hasIntentBalance, recoverToken, recover } = useIntentRecoverWithBalances({
1406
- * intent: intentData,
1407
- * balancesByIntentAddress: balancesMap,
1408
- * walletClient: walletClient,
1409
- * })
1410
- * ```
1411
- */
1412
- export function useIntentRecoverWithBalances({
1413
- intent: intentData,
1414
- balancesByIntentAddress,
1415
- walletClient,
1416
- refundToAddress,
1417
- }: UseIntentRecoverWithBalancesParams): UseIntentRecoverWithBalancesReturn {
1418
- const trailsClient = useTrailsClient()
1419
-
1420
- const originTokenBalancesData = intentData?.originIntentAddress
1421
- ? balancesByIntentAddress[normalizeAddress(intentData.originIntentAddress)]
1422
- ?.tokenBalancesData
1423
- : undefined
1424
-
1425
- const destinationTokenBalancesData = intentData?.destinationIntentAddress
1426
- ? balancesByIntentAddress[
1427
- normalizeAddress(intentData.destinationIntentAddress)
1428
- ]?.tokenBalancesData
1429
- : undefined
1430
-
1431
- const originIntentAddressForBalances = intentData?.originIntentAddress
1432
- ? Address.from(intentData.originIntentAddress)
1433
- : null
1434
-
1435
- const destinationIntentAddressForBalances =
1436
- intentData?.destinationIntentAddress
1437
- ? Address.from(intentData.destinationIntentAddress)
1438
- : null
1439
-
1440
- const selectedIntentAddress = useMemo<SelectedIntentAddress | null>(
1441
- () =>
1442
- intentData
1443
- ? selectIntentAddress(
1444
- intentData,
1445
- originTokenBalancesData,
1446
- destinationTokenBalancesData,
1447
- originIntentAddressForBalances,
1448
- destinationIntentAddressForBalances,
1449
- )
1450
- : null,
1451
- [
1452
- intentData,
1453
- originTokenBalancesData,
1454
- destinationTokenBalancesData,
1455
- originIntentAddressForBalances,
1456
- destinationIntentAddressForBalances,
1457
- ],
1458
- )
1459
-
1460
- const hasIntentBalance = useMemo<boolean>(
1461
- () =>
1462
- checkAnyIntentBalance(
1463
- originTokenBalancesData,
1464
- destinationTokenBalancesData,
1465
- ),
1466
- [originTokenBalancesData, destinationTokenBalancesData],
1467
- )
1468
-
1469
- const recoverToken = useMemo<Token | null>(
1470
- () => findRecoverToken(selectedIntentAddress),
1471
- [selectedIntentAddress],
1472
- )
1473
-
1474
- // Get refund address
1475
- const effectiveRefundAddress = useMemo<`0x${string}` | null>(() => {
1476
- const address =
1477
- refundToAddress || (walletClient?.account?.address as `0x${string}`)
1478
- if (!address || Address.isEqual(address, zeroAddress)) {
1479
- return null
1480
- }
1481
- return address
1482
- }, [refundToAddress, walletClient?.account?.address])
1483
-
1484
- const signPayloadCallback = useCallback(async (): Promise<{
1485
- signature: string
1486
- payload: Payload.Calls
1487
- refundCall: Payload.Call
1488
- }> => {
1489
- if (!intentData || !walletClient || !walletClient.account) {
1490
- throw new Error("Intent data and wallet client with account required")
1491
- }
1492
-
1493
- await checkProviderHealth(walletClient)
1494
- validateRefundAddress(effectiveRefundAddress)
1495
-
1496
- if (!selectedIntentAddress) {
1497
- throw new Error("No intent address selected for recovery")
1498
- }
1499
-
1500
- const allCalls = mapTransactionCalls(intentData)
1501
- const calls = filterCallsByChainId(allCalls, selectedIntentAddress.chainId)
1502
-
1503
- if (calls.length === 0) {
1504
- throw new Error("No calls found for the selected intent address")
1505
- }
1506
-
1507
- const refundCall = determineRefundCall(
1508
- selectedIntentAddress.tokenBalancesData,
1509
- effectiveRefundAddress,
1510
- )
1511
-
1512
- const chainId = selectedIntentAddress.chainId
1513
- if (!chainId) {
1514
- throw new Error("Chain ID not found for selected intent address")
1515
- }
1516
-
1517
- await attemptSwitchChain({
1518
- walletClient,
1519
- desiredChainId: Number(chainId),
1520
- })
1521
-
1522
- const intentAddress = selectedIntentAddress.intentAddress
1523
- const payload = createRefundPayload(
1524
- refundCall,
1525
- BigInt(calls[0]?.nonce ?? 0),
1526
- )
1527
-
1528
- await checkProviderHealth(walletClient)
1529
-
1530
- const typedData = Payload.toTyped(intentAddress, chainId, payload)
1531
-
1532
- const signature = await signWithTimeout(
1533
- walletClient.signTypedData({
1534
- account: walletClient.account,
1535
- ...typedData,
1536
- }),
1537
- "Recovery signature",
1538
- )
1539
-
1540
- return {
1541
- signature,
1542
- payload,
1543
- refundCall,
1544
- }
1545
- }, [intentData, walletClient, selectedIntentAddress, effectiveRefundAddress])
1546
-
1547
- const signPayload = signPayloadCallback
1548
-
1549
- const getRecoverTx = useCallback(
1550
- async (params: {
1551
- signedHash: string
1552
- payload: Payload.Calls
1553
- }): Promise<{
1554
- to: `0x${string}`
1555
- data: `0x${string}`
1556
- chainId: number
1557
- chain: Chain
1558
- }> => {
1559
- if (!intentData || !walletClient?.account) {
1560
- throw new Error("Intent data and wallet client with account required")
1561
- }
1562
- if (!selectedIntentAddress) {
1563
- throw new Error("No intent address selected for recovery")
1564
- }
1565
-
1566
- if (!intentData.intentProtocolVersion) {
1567
- logger.console.log(
1568
- "[recover] Intent configuration version not found, using V1",
1569
- )
1570
- }
1571
-
1572
- return buildRecoverTxFromSignature({
1573
- trailsClient,
1574
- intentData,
1575
- mainSigner: Address.from(walletClient.account.address),
1576
- selected: selectedIntentAddress,
1577
- effectiveRefundAddress: effectiveRefundAddress!,
1578
- signature: params.signedHash,
1579
- payload: params.payload,
1580
- })
1581
- },
1582
- [
1583
- intentData,
1584
- walletClient,
1585
- selectedIntentAddress,
1586
- effectiveRefundAddress,
1587
- trailsClient,
1588
- ],
1589
- )
1590
-
1591
- const recover = useCallback(async (): Promise<{
1592
- txHash: `0x${string}`
1593
- }> => {
1594
- if (!walletClient || !walletClient.account) {
1595
- throw new Error("Wallet client with account is required for recovery")
1596
- }
1597
- if (!intentData) {
1598
- throw new Error("Intent data is required for recovery")
1599
- }
1600
-
1601
- const { signature, payload } = await signPayload()
1602
- const recoverTx = await getRecoverTx({
1603
- signedHash: signature,
1604
- payload,
1605
- })
1606
-
1607
- await attemptSwitchChain({
1608
- walletClient,
1609
- desiredChainId: Number(recoverTx.chainId),
1610
- })
1611
-
1612
- const txHash = await sendWalletTransaction(walletClient, {
1613
- account: walletClient.account,
1614
- to: recoverTx.to,
1615
- data: recoverTx.data,
1616
- chain: recoverTx.chain,
1617
- })
1618
-
1619
- const publicClient = getChainRpcClient(recoverTx.chainId)
1620
- await publicClient.waitForTransactionReceipt({
1621
- hash: txHash,
1622
- })
1623
-
1624
- if (intentData.intentId && trailsClient) {
1625
- try {
1626
- await abortIntent(
1627
- trailsClient,
1628
- intentData.intentId,
1629
- recoverTx.chainId,
1630
- txHash,
1631
- )
1632
- } catch (error) {
1633
- logger.console.warn(
1634
- "[recover] Failed to abort intent after recovery (non-fatal):",
1635
- error,
1636
- )
1637
- }
1638
- }
1639
-
1640
- return { txHash }
1641
- }, [walletClient, intentData, signPayload, getRecoverTx, trailsClient])
1642
-
1643
- const getRecoverStatus = useCallback(
1644
- (params: { txHash: `0x${string}`; chainId: number }) =>
1645
- getRecoverStatusFromChain(params),
1646
- [],
1647
- )
1648
-
1649
- const selectedRecoveryTarget = useMemo(
1650
- () => buildSelectedRecoveryTarget(selectedIntentAddress),
1651
- [selectedIntentAddress],
1652
- )
1653
-
1654
- return {
1655
- intent: intentData,
1656
- hasIntentBalance,
1657
- recoverToken,
1658
- selectedRecoveryTarget,
1659
- refetchIntent: () => {}, // No-op since intent is passed in
1660
- signPayload,
1661
- getRecoverTx,
1662
- recover,
1663
- getRecoverStatus,
1664
- }
1665
- }