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
@@ -1,1596 +0,0 @@
1
- import type {
2
- Account,
3
- Chain,
4
- PublicClient,
5
- WalletClient,
6
- TransactionReceipt,
7
- } from "viem"
8
- import { formatUnits } from "viem"
9
- import {
10
- type FeeOption,
11
- type TrailsApi,
12
- type RouteProvider,
13
- type Intent,
14
- type CommitIntentResponse,
15
- type DepositSignature,
16
- type ExecuteIntentResponse,
17
- type GasFeeOptions,
18
- type DepositTransaction,
19
- type IntentTransaction,
20
- type TrailsContracts,
21
- IntentProtocolVersion,
22
- IntentStatus,
23
- } from "@0xtrails/api"
24
- import type { PrepareSendReturn, SendReturn, FundMethod } from "../types.js"
25
- import {
26
- isExternalFundingMethod,
27
- TradeType,
28
- toApiFundMethod,
29
- } from "../types.js"
30
- import type { QueryClient } from "@tanstack/react-query"
31
- import type { TransactionState } from "../../transactions.js"
32
- import type { CheckoutOnHandlers } from "../../widget/hooks/useCheckout.js"
33
- import { logger } from "../../logger.js"
34
- import { getNormalizedQuoteObject } from "../quote/normalizeQuote.js"
35
- import { getChainInfo, getChainRpcClient } from "../../chains.js"
36
- import { getTransactionStateFromReceipt } from "../execution/transactionState.js"
37
- import { getIntentArgs } from "../quote/quoteHelpers.js"
38
- import {
39
- quoteIntent,
40
- commitIntent,
41
- sendOriginTransaction,
42
- executeIntent as executeIntentRequest,
43
- } from "../../intents.js"
44
- import {
45
- decodeTokenSweeperEvents,
46
- decodeGuestModuleEvents,
47
- } from "../../decoders.js"
48
- import { updatePersistentToast } from "../../toast.js"
49
- import { formatRawAmount, rawAmountToNumber } from "../../utils/format.js"
50
- import { invalidateTokenBalancesCache } from "../../query/balance.queries.js"
51
- import { calcAmountUsdPrice } from "../../utils/format.js"
52
- import { checkAccountBalance } from "../utils/balanceChecker.js"
53
- import { queryClient as defaultQueryClient } from "../../query/client.js"
54
- import {
55
- getFeesFromIntent,
56
- getPriceImpactFromIntent,
57
- getPriceImpactUsdFromIntent,
58
- } from "../quote/feeExtractors.js"
59
- import { attemptUserDepositTx } from "../deposits/depositOrchestrator.js"
60
- import { getTxTimeDiff } from "../../transactions.js"
61
- import { pollIntentReceipt } from "../../intentReceiptPoller.js"
62
- import {
63
- trackPaymentCompleted,
64
- trackPaymentError,
65
- trackTransactionConfirmed,
66
- } from "../../analytics.js"
67
- import { getFullErrorMessage, getIsAlreadyExecutingError } from "../../error.js"
68
- import { getIsCustomCalldata } from "../../contractUtils.js"
69
- import { isNativeToken } from "../../utils/address.js"
70
- import { ensureErc20Approval } from "../utils/erc20Approval.js"
71
- import { HOUR_MS } from "../../utils/time.js"
72
- import { attemptSwitchChain } from "../../chainSwitch.js"
73
- import { getDoGasless } from "../deposits/gaslessDeposit.js"
74
- import {
75
- applyIntentReceiptToTransactionStates,
76
- getNormalizedTransactionStates,
77
- insertRefundTransactionState,
78
- updateTransactionStateWithDecodedEvents,
79
- } from "../helpers/transactionStateHelpers.js"
80
- import { isSameChain, isSameToken } from "../validators.js"
81
- import { isSyntheticTransactionHash } from "../../transactions.js"
82
-
83
- /**
84
- * Parameters for the unified intent handler.
85
- */
86
- export interface IntentHandlerParams {
87
- queryClient?: QueryClient
88
- mainSignerAddress: string
89
- originChainId: number
90
- originTokenAddress: string
91
- originTokenBalance: string
92
- originTokenDecimals: number
93
- originTokenSymbol: string
94
- destinationChainId: number
95
- destinationTokenAddress: string
96
- destinationTokenSymbol: string
97
- destinationTokenDecimals: number
98
- swapAmount: string
99
- recipient: string
100
- destinationApproveAddress?: string
101
- destinationCalldata?: string
102
- walletClient: WalletClient
103
- publicClient: PublicClient
104
- account: Account
105
- chain: Chain
106
- onTransactionStateChange: (transactionStates: TransactionState[]) => void
107
- transactionStates: TransactionState[]
108
- trailsClient: TrailsApi
109
- sourceTokenPriceUsd?: number | null
110
- destinationTokenPriceUsd?: number | null
111
- originNativeTokenPriceUsd?: number | null
112
- slippageTolerance: string | null
113
- tradeType?: TradeType
114
- swapProvider?: RouteProvider | null
115
- bridgeProvider?: RouteProvider | null
116
- swapProviderFallback?: boolean
117
- bridgeProviderFallback?: boolean
118
- fundMethod?: FundMethod
119
- mode?: "pay" | "fund" | "earn" | "swap" | "withdraw"
120
- checkoutOnHandlers?: Partial<CheckoutOnHandlers>
121
- paymasterUrl?: string
122
- selectedFeeOption?: FeeOption | null
123
- walletId?: string
124
- abortSignal?: AbortSignal
125
- commitIntentFn?: (intent: Intent) => Promise<CommitIntentResponse>
126
- executeIntentFn?: (params: {
127
- intentId: string
128
- depositTransactionHash?: string
129
- depositSignature?: DepositSignature
130
- }) => Promise<ExecuteIntentResponse>
131
- sequenceProjectAccessKey?: string
132
- sequenceIndexerUrl?: string
133
- isSmartWallet?: boolean
134
- isSenderContractOnOrigin?: boolean | null
135
- trailsApiKey?: string
136
- trailsApiUrl?: string
137
- sequenceMetadataUrl?: string
138
- refundAddress?: string
139
- }
140
-
141
- function isFeeSelectionPassthroughEligible(params: {
142
- selectedFeeOption: FeeOption | null | undefined
143
- gasFeeOptions: GasFeeOptions | undefined
144
- }): boolean {
145
- const { selectedFeeOption, gasFeeOptions } = params
146
-
147
- // Undefined means no explicit user selection yet: stay conservative and use intent flow.
148
- if (selectedFeeOption === undefined) {
149
- return false
150
- }
151
-
152
- // Null means "native fee selected". This is only passthrough-safe if the native fee option
153
- // advertised by backend is explicitly marked passthrough-eligible.
154
- if (selectedFeeOption === null) {
155
- const nativeFeeOption = gasFeeOptions?.feeOptions?.find((option) =>
156
- isNativeToken(option.tokenAddress),
157
- )
158
- return nativeFeeOption?.isPassthroughEligible === true
159
- }
160
-
161
- return selectedFeeOption.isPassthroughEligible === true
162
- }
163
-
164
- /**
165
- * Execute a passthrough transaction (direct transfer, no intents).
166
- *
167
- * Used when backend marks quote passthrough-eligible and client-side fee gating allows it.
168
- * Handles ERC20 approval if needed for custom calldata scenarios (S4c).
169
- * See SPEC.md for flow decision details.
170
- */
171
- async function executePassthrough(
172
- params: IntentHandlerParams,
173
- depositTransaction: DepositTransaction,
174
- transactionStates: TransactionState[],
175
- options: {
176
- onOriginSend?: () => void
177
- depositTransactionHash?: string
178
- },
179
- ): Promise<SendReturn> {
180
- const {
181
- queryClient: paramQueryClient,
182
- account,
183
- walletClient,
184
- onTransactionStateChange,
185
- originTokenDecimals,
186
- originTokenSymbol,
187
- destinationTokenSymbol,
188
- swapAmount,
189
- destinationCalldata,
190
- sourceTokenPriceUsd,
191
- mode,
192
- fundMethod = "wallet",
193
- checkoutOnHandlers,
194
- walletId,
195
- } = params
196
-
197
- const effectiveQueryClient = paramQueryClient ?? defaultQueryClient
198
-
199
- const { onOriginSend, depositTransactionHash } = options
200
-
201
- const effectiveOriginChain = params.chain
202
- const effectiveOriginChainId = effectiveOriginChain.id
203
- const effectivePublicClient =
204
- params.publicClient ?? getChainRpcClient(effectiveOriginChain.id)
205
-
206
- const depositAmountFormatted = Number(
207
- formatUnits(BigInt(swapAmount), originTokenDecimals),
208
- )
209
- const depositAmountUsd = calcAmountUsdPrice({
210
- amount: depositAmountFormatted,
211
- usdPrice: sourceTokenPriceUsd,
212
- })
213
-
214
- // Update transaction state to pending
215
- if (transactionStates[0]) {
216
- transactionStates[0].state = "pending"
217
- try {
218
- onTransactionStateChange(transactionStates)
219
- } catch (error) {
220
- logger.console.error(
221
- "[trails-sdk] Error calling onTransactionStateChange:",
222
- error,
223
- )
224
- }
225
- }
226
-
227
- // Show persistent toast
228
- updatePersistentToast(
229
- "Payment Started",
230
- "Waiting for wallet confirmation...",
231
- "info",
232
- )
233
-
234
- // Validate chainId before sending
235
- if (depositTransaction.chainId !== effectiveOriginChainId) {
236
- throw new Error(
237
- `Chain ID mismatch: expected ${effectiveOriginChainId}, got ${depositTransaction.chainId}`,
238
- )
239
- }
240
-
241
- // Read ALL fields from passthrough depositTransaction
242
- const { to, data, value, chainId } = depositTransaction
243
-
244
- logger.console.log(
245
- "[trails-sdk] Executing passthrough with depositTransaction:",
246
- {
247
- to,
248
- data,
249
- value,
250
- chainId,
251
- },
252
- )
253
-
254
- // Handle ERC20 approval for passthrough transactions with custom calldata.
255
- // This is needed when the passthrough target contract (e.g., Aave) needs to
256
- // transferFrom the user's tokens.
257
- const originTokenAddress = params.originTokenAddress
258
- const hasCustomCalldata = getIsCustomCalldata(destinationCalldata)
259
- const isErc20Token = !isNativeToken(originTokenAddress)
260
-
261
- if (isErc20Token && hasCustomCalldata) {
262
- await ensureErc20Approval({
263
- tokenAddress: originTokenAddress,
264
- spender: to,
265
- requiredAmount: BigInt(swapAmount),
266
- account,
267
- publicClient: effectivePublicClient,
268
- walletClient,
269
- chain: effectiveOriginChain,
270
- depositAmountUsd,
271
- checkoutOnHandlers,
272
- logPrefix: "[trails-sdk] [passthrough]",
273
- })
274
- }
275
-
276
- let effectiveDepositTransactionHash = depositTransactionHash
277
-
278
- if (!effectiveDepositTransactionHash) {
279
- effectiveDepositTransactionHash = await sendOriginTransaction(
280
- account,
281
- walletClient,
282
- {
283
- to,
284
- data: data as `0x${string}`,
285
- value: BigInt(value),
286
- chain: effectiveOriginChain,
287
- },
288
- {
289
- transactionType: "origin_call",
290
- depositTokenAmountUsd: depositAmountUsd?.toString(),
291
- },
292
- )
293
- }
294
- const finalDepositTransactionHash =
295
- effectiveDepositTransactionHash as `0x${string}`
296
-
297
- if (onOriginSend) {
298
- onOriginSend()
299
- }
300
-
301
- // Wait for transaction receipt
302
- const receipt = await effectivePublicClient.waitForTransactionReceipt({
303
- hash: finalDepositTransactionHash,
304
- onReplaced: (replacement) => {
305
- logger.console.log(
306
- "[trails-sdk] Passthrough deposit transaction replaced",
307
- {
308
- reason: replacement.reason,
309
- replacedHash: replacement.replacedTransaction.hash,
310
- replacementHash: replacement.transaction.hash,
311
- },
312
- )
313
- },
314
- })
315
- logger.console.log("[trails-sdk] Passthrough receipt:", receipt)
316
-
317
- // Track transaction confirmation
318
- trackTransactionConfirmed({
319
- transactionHash: finalDepositTransactionHash,
320
- chainId: effectiveOriginChainId,
321
- userAddress: account.address,
322
- blockNumber: Number(receipt.blockNumber),
323
- originTokenAddress: params.originTokenAddress,
324
- depositTokenAmountUsd: depositAmountUsd,
325
- })
326
-
327
- // Update toast
328
- const chainInfo = getChainInfo(effectiveOriginChainId)
329
- updatePersistentToast(
330
- "Transfer Confirmed",
331
- `Your transaction on ${chainInfo?.name || "chain"} has been confirmed`,
332
- "info",
333
- )
334
-
335
- // Update transaction state to completed with decoded events
336
- const updatedStates = updateTransactionStateWithDecodedEvents(
337
- transactionStates,
338
- transactionStates[0]?.label || "Execute",
339
- receipt,
340
- effectiveOriginChainId,
341
- )
342
- onTransactionStateChange(updatedStates)
343
-
344
- // Track payment completion
345
- if (receipt.status === "success") {
346
- trackPaymentCompleted({
347
- userAddress: account.address,
348
- originTxHash: receipt.transactionHash,
349
- originChainId: effectiveOriginChainId,
350
- mode,
351
- fundMethod,
352
- originTokenAddress: params.originTokenAddress,
353
- originTokenSymbol,
354
- originTokenAmount: swapAmount,
355
- originTokenAmountFormatted: depositAmountFormatted.toString(),
356
- destinationTokenAddress: params.originTokenAddress,
357
- destinationTokenSymbol,
358
- depositTokenAmount: swapAmount,
359
- depositTokenAmountFormatted: depositAmountFormatted.toString(),
360
- depositTokenAmountUsd: depositAmountUsd,
361
- destinationTokenAmount: swapAmount,
362
- destinationTokenAmountFormatted: depositAmountFormatted.toString(),
363
- destinationTokenAmountUsd: depositAmountUsd,
364
- originTokenDecimals,
365
- destinationTokenDecimals: originTokenDecimals,
366
- walletId,
367
- destinationCalldata,
368
- })
369
-
370
- invalidateTokenBalancesCache(undefined, effectiveQueryClient)
371
-
372
- if (checkoutOnHandlers?.triggerCheckoutComplete) {
373
- checkoutOnHandlers.triggerCheckoutComplete("success", account.address)
374
- }
375
- } else {
376
- trackPaymentError({
377
- error: "Transaction failed",
378
- userAddress: account.address,
379
- mode,
380
- fundMethod,
381
- originTokenAddress: params.originTokenAddress,
382
- })
383
-
384
- invalidateTokenBalancesCache(undefined, effectiveQueryClient)
385
-
386
- if (checkoutOnHandlers?.triggerCheckoutError) {
387
- checkoutOnHandlers.triggerCheckoutError("Transaction failed")
388
- }
389
- }
390
-
391
- return {
392
- depositUserTxnReceipt: receipt,
393
- originIntentTransaction: null,
394
- destinationIntentTransaction: null,
395
- }
396
- }
397
-
398
- /**
399
- * Execute an intent flow (commit, deposit, poll).
400
- */
401
- async function executeIntent(
402
- params: IntentHandlerParams,
403
- intent: Intent,
404
- localTransactionStates: TransactionState[],
405
- gasFeeOptions: GasFeeOptions | undefined,
406
- trailsContracts: TrailsContracts,
407
- options: {
408
- onOriginSend?: () => void
409
- selectedFeeOption?: FeeOption | null
410
- depositTransactionHash?: string
411
- skipCommit?: boolean
412
- },
413
- ): Promise<SendReturn> {
414
- const {
415
- queryClient: paramQueryClient,
416
- account,
417
- walletClient,
418
- onTransactionStateChange,
419
- originTokenDecimals,
420
- originTokenSymbol,
421
- destinationTokenSymbol,
422
- swapAmount,
423
- destinationCalldata,
424
- sourceTokenPriceUsd,
425
- destinationTokenPriceUsd,
426
- mode,
427
- fundMethod = "wallet",
428
- checkoutOnHandlers,
429
- walletId,
430
- trailsClient,
431
- paymasterUrl,
432
- abortSignal,
433
- executeIntentFn,
434
- destinationTokenDecimals,
435
- swapProvider,
436
- bridgeProvider,
437
- tradeType,
438
- } = params
439
-
440
- const effectiveQueryClient = paramQueryClient ?? defaultQueryClient
441
-
442
- const {
443
- onOriginSend,
444
- selectedFeeOption: runtimeSelectedFeeOption,
445
- depositTransactionHash,
446
- } = options
447
-
448
- const effectiveSelectedFeeOption = runtimeSelectedFeeOption
449
-
450
- const effectiveOriginChain = params.chain
451
- const effectiveOriginChainId = effectiveOriginChain.id
452
- const effectivePublicClient = getChainRpcClient(effectiveOriginChain.id)
453
- const effectiveOriginTokenAddress = params.originTokenAddress
454
-
455
- const isToSameChain = isSameChain(
456
- params.originChainId,
457
- params.destinationChainId,
458
- )
459
- const isToSameToken = isSameToken(
460
- params.originTokenAddress,
461
- params.destinationTokenAddress,
462
- )
463
- const isSameChainSameToken = isToSameChain && isToSameToken
464
-
465
- // API is source of truth for deposit amount
466
- const depositAmount = intent.depositTransaction.amount.toString()
467
-
468
- const depositAmountFormatted = formatRawAmount(
469
- depositAmount,
470
- originTokenDecimals,
471
- )
472
- const depositAmountNumeric = rawAmountToNumber(
473
- depositAmount,
474
- originTokenDecimals,
475
- )
476
- const depositAmountUsd = calcAmountUsdPrice({
477
- amount: depositAmountNumeric,
478
- usdPrice: sourceTokenPriceUsd,
479
- })
480
-
481
- let depositUserTxnReceipt: TransactionReceipt | null = null
482
- let originIntentTransaction: IntentTransaction | null = null
483
- let destinationIntentTransaction: IntentTransaction | null = null
484
- let hasExecutedIntentEarly = false
485
-
486
- // Create destination public client for cross-chain polling
487
- const destinationPublicClient = getChainRpcClient(params.destinationChainId)
488
-
489
- const shouldUseGaslessFlow =
490
- fundMethod === "wallet" &&
491
- (getDoGasless(
492
- effectiveOriginTokenAddress,
493
- gasFeeOptions,
494
- effectiveSelectedFeeOption,
495
- walletId,
496
- ) ||
497
- Boolean(paymasterUrl))
498
-
499
- // Signal executeIntent immediately after commit for all funding flows.
500
- if (intent.intentId && !shouldUseGaslessFlow) {
501
- try {
502
- if (executeIntentFn) {
503
- await executeIntentFn({
504
- intentId: intent.intentId,
505
- })
506
- } else {
507
- await executeIntentRequest(trailsClient, intent.intentId, undefined)
508
- }
509
- hasExecutedIntentEarly = true
510
- logger.console.log(
511
- "[trails-sdk] executeIntent called immediately after commit",
512
- {
513
- intentId: intent.intentId,
514
- fundMethod,
515
- depositTransactionHash,
516
- },
517
- )
518
- } catch (executeError: unknown) {
519
- if (getIsAlreadyExecutingError(executeError)) {
520
- hasExecutedIntentEarly = true
521
- logger.console.log(
522
- "[trails-sdk] Intent already executing after early executeIntent call",
523
- )
524
- } else {
525
- throw executeError
526
- }
527
- }
528
- } else if (intent.intentId && shouldUseGaslessFlow) {
529
- logger.console.log(
530
- "[trails-sdk] Skipping early executeIntent for gasless flow, waiting for deposit signature",
531
- {
532
- intentId: intent.intentId,
533
- fundMethod,
534
- hasPaymasterUrl: Boolean(paymasterUrl),
535
- hasSelectedFeeOption: effectiveSelectedFeeOption !== undefined,
536
- },
537
- )
538
- }
539
-
540
- // External funding flows without a client-provided deposit hash should return
541
- // immediately after commit/early execute. Their UI will monitor balance at the
542
- // origin intent address and continue independently of this send() call.
543
- const publishTransactionStates = (states: TransactionState[]) => {
544
- onTransactionStateChange(states)
545
- if (checkoutOnHandlers?.triggerCheckoutStatusUpdate) {
546
- checkoutOnHandlers.triggerCheckoutStatusUpdate(states)
547
- }
548
- }
549
-
550
- if (isExternalFundingMethod(fundMethod) && !depositTransactionHash) {
551
- publishTransactionStates(localTransactionStates)
552
-
553
- logger.console.log(
554
- "[trails-sdk] External funding flow: intent committed, returning early",
555
- {
556
- fundMethod,
557
- intentId: intent.intentId,
558
- },
559
- )
560
- return {
561
- depositUserTxnReceipt: null,
562
- originIntentTransaction: null,
563
- destinationIntentTransaction: null,
564
- totalCompletionSeconds: 0,
565
- }
566
- }
567
-
568
- // Balance check for wallet fund method
569
- if (fundMethod === "wallet") {
570
- const { hasEnoughBalance, balanceError } = await checkAccountBalance({
571
- account,
572
- tokenAddress: effectiveOriginTokenAddress,
573
- depositAmount,
574
- publicClient: effectivePublicClient,
575
- })
576
-
577
- if (!hasEnoughBalance) {
578
- throw balanceError
579
- }
580
- }
581
-
582
- // Switch chain if needed
583
- await attemptSwitchChain({
584
- walletClient,
585
- desiredChainId: effectiveOriginChainId,
586
- })
587
-
588
- // Set up transaction state tracking
589
- publishTransactionStates(localTransactionStates)
590
-
591
- if (!intent.intentProtocolVersion) {
592
- logger.console.log(
593
- "[trails-sdk] [intent-protocol] Intent protocol version not found in response, defaulting to v1",
594
- )
595
- }
596
- const intentProtocolVersion =
597
- intent.intentProtocolVersion ?? IntentProtocolVersion.v1
598
-
599
- logger.console.log(
600
- "[trails-sdk] [intent-protocol] === Intent Protocol Version ===",
601
- {
602
- version: intentProtocolVersion,
603
- isV1: intentProtocolVersion === IntentProtocolVersion.v1,
604
- isV1_5: intentProtocolVersion === IntentProtocolVersion.v1_5,
605
- intentId: intent.intentId,
606
- fundMethod,
607
- },
608
- )
609
-
610
- // Execute deposit transaction
611
- if (depositTransactionHash && fundMethod !== "wallet") {
612
- // External deposit with provided hash (onramp-meld, direct-transfer, etc.)
613
- let resolvedDepositTransactionHash = depositTransactionHash as `0x${string}`
614
- depositUserTxnReceipt =
615
- await effectivePublicClient.waitForTransactionReceipt({
616
- hash: depositTransactionHash as `0x${string}`,
617
- onReplaced: (replacement) => {
618
- resolvedDepositTransactionHash = replacement.transaction.hash
619
- logger.console.log(
620
- "[trails-sdk] External deposit transaction replaced",
621
- {
622
- reason: replacement.reason,
623
- replacedHash: replacement.replacedTransaction.hash,
624
- replacementHash: replacement.transaction.hash,
625
- },
626
- )
627
- },
628
- })
629
-
630
- if (depositUserTxnReceipt?.transactionHash) {
631
- resolvedDepositTransactionHash =
632
- depositUserTxnReceipt.transactionHash as `0x${string}`
633
- }
634
-
635
- logger.console.log("[trails-sdk] External deposit receipt resolved", {
636
- providedHash: depositTransactionHash,
637
- resolvedHash: resolvedDepositTransactionHash,
638
- status: depositUserTxnReceipt.status,
639
- })
640
-
641
- // Update transaction state with receipt
642
- if (depositUserTxnReceipt) {
643
- localTransactionStates[0] = getTransactionStateFromReceipt(
644
- depositUserTxnReceipt,
645
- effectiveOriginChainId,
646
- localTransactionStates[0]?.label,
647
- )
648
- publishTransactionStates(localTransactionStates)
649
- }
650
-
651
- if (depositUserTxnReceipt.status === "success" && intent.intentId) {
652
- // Always signal external deposit success so UI can navigate to pending.
653
- if (onOriginSend) {
654
- logger.console.log(
655
- "[trails-sdk] Calling onOriginSend for external deposit",
656
- )
657
- onOriginSend()
658
- }
659
-
660
- if (hasExecutedIntentEarly) {
661
- // Intent execution was already triggered immediately after commit.
662
- // Skip the duplicate executeIntent call, but continue into receipt polling.
663
- } else {
664
- // Try to execute the intent if early execution didn't run.
665
- try {
666
- if (executeIntentFn) {
667
- await executeIntentFn({
668
- intentId: intent.intentId,
669
- })
670
- } else {
671
- await executeIntentRequest(trailsClient, intent.intentId, undefined)
672
- }
673
- } catch (executeError: unknown) {
674
- // If intent is already executing, that's fine - it means the system picked it up
675
- if (getIsAlreadyExecutingError(executeError)) {
676
- logger.console.log(
677
- "[trails-sdk] Intent already executing, continuing...",
678
- )
679
- } else {
680
- throw executeError
681
- }
682
- }
683
- }
684
- }
685
- } else if (fundMethod === "wallet") {
686
- // Wallet deposit
687
- depositUserTxnReceipt = await attemptUserDepositTx({
688
- queryClient: effectiveQueryClient,
689
- originTokenAddress: effectiveOriginTokenAddress,
690
- paymasterUrl,
691
- chain: effectiveOriginChain,
692
- account,
693
- depositAmount,
694
- originIntentAddress: intent.originIntentAddress,
695
- onOriginSend,
696
- publicClient: effectivePublicClient,
697
- walletClient,
698
- destinationTokenDecimals,
699
- sourceTokenDecimals: originTokenDecimals,
700
- sourceTokenPriceUsd: sourceTokenPriceUsd ?? null,
701
- destinationTokenPriceUsd: destinationTokenPriceUsd ?? null,
702
- swapAmount,
703
- onTransactionStateChange,
704
- transactionStates: localTransactionStates,
705
- fundMethod,
706
- originTokenSymbol,
707
- destinationTokenSymbol,
708
- depositAmountUsd,
709
- feeOptions: gasFeeOptions,
710
- trailsContracts,
711
- trailsClient,
712
- selectedFeeOption: effectiveSelectedFeeOption,
713
- walletId,
714
- abortSignal,
715
- checkoutOnHandlers,
716
- intentId: intent.intentId,
717
- executeIntentFn,
718
- isSameChainSameToken,
719
- destinationCalldata,
720
- depositTransaction: intent.depositTransaction,
721
- intentProtocolVersion,
722
- })
723
-
724
- // Update state and call executeIntent
725
- if (depositUserTxnReceipt) {
726
- localTransactionStates[0] = getTransactionStateFromReceipt(
727
- depositUserTxnReceipt,
728
- effectiveOriginChainId,
729
- localTransactionStates[0]?.label,
730
- )
731
-
732
- // Decode events
733
- try {
734
- localTransactionStates[0].decodedTokenSweeperEvents =
735
- decodeTokenSweeperEvents(depositUserTxnReceipt)
736
- localTransactionStates[0].decodedGuestModuleEvents =
737
- decodeGuestModuleEvents(depositUserTxnReceipt)
738
- localTransactionStates[0].refunded =
739
- localTransactionStates[0].decodedTokenSweeperEvents.findIndex(
740
- (event) =>
741
- event.type === "Refund" || event.type === "RefundAndSweep",
742
- ) !== -1
743
- } catch (error) {
744
- logger.console.error(
745
- "[trails-sdk] Error decoding deposit events",
746
- error,
747
- )
748
- }
749
-
750
- publishTransactionStates(localTransactionStates)
751
- }
752
- }
753
- // Start polling for intent completion to update transaction states
754
- let finalReceipt: Awaited<ReturnType<typeof pollIntentReceipt>> = null
755
- let pollStartMs = 0
756
- if (intent.intentId) {
757
- // Determine max wait time based on route provider.
758
- // OFT routes (LayerZero OFT) can take 5-10+ minutes to complete.
759
- const isOFTRoute = intent.quote?.routeProviders?.some((p) => p === "LZ_OFT")
760
- const maxWaitTime = isOFTRoute ? HOUR_MS : 10 * 60 * 1000 // 1 hour for OFT, 10 min for others
761
-
762
- logger.console.log("[trails-sdk] Intent polling configuration:", {
763
- isOFTRoute,
764
- maxWaitTime,
765
- routeProviders: intent.quote?.routeProviders,
766
- })
767
- try {
768
- pollStartMs = Date.now()
769
- finalReceipt = await pollIntentReceipt({
770
- intentId: intent.intentId,
771
- trailsClient,
772
- abortSignal,
773
- callbacks: {
774
- onDepositTransactionFound: async (txHash, receipt) => {
775
- logger.console.log(
776
- "[trails-sdk] Deposit transaction found:",
777
- txHash,
778
- )
779
-
780
- if (localTransactionStates[0]) {
781
- if (isSyntheticTransactionHash(txHash)) {
782
- logger.console.log(
783
- "[trails-sdk] Deposit transaction hash is synthetic, marking deposit from status",
784
- {
785
- txHash,
786
- status: receipt.depositTransaction?.status,
787
- },
788
- )
789
-
790
- if (receipt.depositTransaction?.status === "SUCCEEDED") {
791
- localTransactionStates[0] = {
792
- ...localTransactionStates[0],
793
- state: "confirmed",
794
- transactionHash: "",
795
- explorerUrl: "",
796
- txnMinedAt:
797
- receipt.depositTransaction?.txnMinedAt || undefined,
798
- }
799
-
800
- publishTransactionStates(localTransactionStates)
801
- }
802
- return
803
- }
804
-
805
- try {
806
- const depositTxReceipt =
807
- await effectivePublicClient.getTransactionReceipt({
808
- hash: txHash as `0x${string}`,
809
- })
810
-
811
- localTransactionStates[0] = getTransactionStateFromReceipt(
812
- depositTxReceipt,
813
- effectiveOriginChainId,
814
- localTransactionStates[0]?.label,
815
- )
816
-
817
- // Decode events
818
- localTransactionStates[0].decodedTokenSweeperEvents =
819
- decodeTokenSweeperEvents(depositTxReceipt)
820
- localTransactionStates[0].decodedGuestModuleEvents =
821
- decodeGuestModuleEvents(depositTxReceipt)
822
-
823
- publishTransactionStates(localTransactionStates)
824
- } catch (error) {
825
- logger.console.error(
826
- "[trails-sdk] Error fetching deposit receipt:",
827
- error,
828
- )
829
- }
830
- }
831
- },
832
- onOriginTransactionFound: async (txHash, receipt) => {
833
- logger.console.log("[trails-sdk] Origin transaction found:", txHash)
834
-
835
- originIntentTransaction = { txnHash: txHash } as IntentTransaction
836
-
837
- try {
838
- const originTxReceipt =
839
- await effectivePublicClient.getTransactionReceipt({
840
- hash: txHash as `0x${string}`,
841
- })
842
-
843
- // Find the appropriate index for origin transaction
844
- const originStateIndex = localTransactionStates.length > 1 ? 1 : 0
845
- if (localTransactionStates[originStateIndex]) {
846
- localTransactionStates[originStateIndex] =
847
- getTransactionStateFromReceipt(
848
- originTxReceipt,
849
- effectiveOriginChainId,
850
- localTransactionStates[originStateIndex]?.label,
851
- )
852
-
853
- // Decode events
854
- localTransactionStates[
855
- originStateIndex
856
- ].decodedTokenSweeperEvents =
857
- decodeTokenSweeperEvents(originTxReceipt)
858
- localTransactionStates[
859
- originStateIndex
860
- ].decodedGuestModuleEvents =
861
- decodeGuestModuleEvents(originTxReceipt)
862
-
863
- // Some external funding flows do not surface a distinct
864
- // depositTransaction in the receipt. In those cases the origin
865
- // transaction implicitly covers the deposit step as well.
866
- if (
867
- !receipt.depositTransaction?.txnHash &&
868
- !receipt.depositTransaction?.status &&
869
- localTransactionStates.length > 1 &&
870
- localTransactionStates[0]
871
- ) {
872
- localTransactionStates[0] = getTransactionStateFromReceipt(
873
- originTxReceipt,
874
- effectiveOriginChainId,
875
- localTransactionStates[0]?.label,
876
- )
877
- localTransactionStates[0].decodedTokenSweeperEvents =
878
- decodeTokenSweeperEvents(originTxReceipt)
879
- localTransactionStates[0].decodedGuestModuleEvents =
880
- decodeGuestModuleEvents(originTxReceipt)
881
- }
882
-
883
- publishTransactionStates(localTransactionStates)
884
- }
885
- } catch (error) {
886
- logger.console.error(
887
- "[trails-sdk] Error fetching origin receipt:",
888
- error,
889
- )
890
- }
891
- },
892
- onDestinationTransactionFound: async (txHash) => {
893
- logger.console.log(
894
- "[trails-sdk] Destination transaction found:",
895
- txHash,
896
- )
897
-
898
- destinationIntentTransaction = {
899
- txnHash: txHash,
900
- } as IntentTransaction
901
-
902
- try {
903
- const destinationTxReceipt =
904
- await destinationPublicClient.getTransactionReceipt({
905
- hash: txHash as `0x${string}`,
906
- })
907
-
908
- // Find the appropriate index for destination transaction
909
- const destStateIndex = localTransactionStates.length - 1
910
- if (localTransactionStates[destStateIndex]) {
911
- localTransactionStates[destStateIndex] =
912
- getTransactionStateFromReceipt(
913
- destinationTxReceipt,
914
- params.destinationChainId,
915
- localTransactionStates[destStateIndex]?.label,
916
- )
917
-
918
- // Decode events
919
- localTransactionStates[
920
- destStateIndex
921
- ].decodedTokenSweeperEvents =
922
- decodeTokenSweeperEvents(destinationTxReceipt)
923
- localTransactionStates[
924
- destStateIndex
925
- ].decodedGuestModuleEvents =
926
- decodeGuestModuleEvents(destinationTxReceipt)
927
-
928
- publishTransactionStates(localTransactionStates)
929
- }
930
- } catch (error) {
931
- logger.console.error(
932
- "[trails-sdk] Error fetching destination receipt:",
933
- error,
934
- )
935
- }
936
- },
937
- onReceiptUpdate: async (receipt, done) => {
938
- // Log receipt updates for debugging
939
- logger.console.log("[trails-sdk] Receipt update:", {
940
- status: receipt.status,
941
- done,
942
- hasOrigin: !!receipt.originTransaction,
943
- hasDestination: !!receipt.destinationTransaction,
944
- hasRefund: !!receipt.refundTransaction,
945
- })
946
-
947
- const reconciledStates = applyIntentReceiptToTransactionStates({
948
- currentStates: localTransactionStates,
949
- receipt,
950
- })
951
- if (reconciledStates.changed) {
952
- localTransactionStates = reconciledStates.transactionStates
953
- publishTransactionStates(localTransactionStates)
954
- }
955
-
956
- // Handle terminal status - mark pending steps as aborted/failed
957
- if (
958
- done &&
959
- (receipt.status === "ABORTED" || receipt.status === "FAILED")
960
- ) {
961
- const targetState =
962
- receipt.status === "ABORTED" ? "aborted" : "failed"
963
- const statusReason =
964
- receipt.depositTransaction?.statusReason ||
965
- receipt.originTransaction?.statusReason ||
966
- receipt.destinationTransaction?.statusReason
967
-
968
- for (const state of localTransactionStates) {
969
- if (state.state === "pending") {
970
- state.state = targetState as "aborted" | "failed"
971
- if (statusReason) state.statusReason = statusReason
972
- }
973
- }
974
-
975
- publishTransactionStates(localTransactionStates)
976
- }
977
-
978
- // Handle deposit tx revert - mark all txs as failed
979
- if (receipt.depositTransaction?.status === "REVERTED") {
980
- const statusReason =
981
- receipt.depositTransaction.statusReason || "deposit reverted"
982
-
983
- for (const state of localTransactionStates) {
984
- if (state.state === "pending") {
985
- state.state = "failed"
986
- state.statusReason = statusReason
987
- }
988
- }
989
-
990
- publishTransactionStates(localTransactionStates)
991
- }
992
-
993
- // Insert refund transaction state if refund exists
994
- if (receipt.refundTransaction) {
995
- const updatedStates = insertRefundTransactionState(
996
- localTransactionStates,
997
- {
998
- chainId: receipt.refundTransaction.chainId,
999
- txnHash: receipt.refundTransaction.txnHash,
1000
- status: receipt.refundTransaction.status,
1001
- },
1002
- )
1003
-
1004
- // Check if states actually changed (length or content)
1005
- const statesChanged =
1006
- updatedStates.length !== localTransactionStates.length ||
1007
- JSON.stringify(updatedStates) !==
1008
- JSON.stringify(localTransactionStates)
1009
-
1010
- if (statesChanged) {
1011
- localTransactionStates.length = 0
1012
- localTransactionStates.push(...updatedStates)
1013
- publishTransactionStates(localTransactionStates)
1014
- }
1015
- }
1016
- },
1017
- },
1018
- maxWaitTime,
1019
- })
1020
-
1021
- // Verify the receipt status is terminal before proceeding to success
1022
- const terminalStatuses: string[] = [
1023
- IntentStatus.SUCCEEDED,
1024
- IntentStatus.FAILED,
1025
- IntentStatus.REFUNDED,
1026
- IntentStatus.ABORTED,
1027
- ]
1028
- const summary = (
1029
- finalReceipt as unknown as { summary?: { finishedAt?: string | null } }
1030
- )?.summary
1031
- const hasFinishedMarker = Boolean(
1032
- summary?.finishedAt ||
1033
- finalReceipt?.destinationTransaction?.txnMinedAt ||
1034
- finalReceipt?.destinationTransaction?.txnHash,
1035
- )
1036
- const destinationSucceeded =
1037
- finalReceipt?.destinationTransaction?.status === "SUCCEEDED"
1038
- const completeViaDestinationFallback =
1039
- !!finalReceipt && destinationSucceeded && hasFinishedMarker
1040
- const isComplete =
1041
- !!finalReceipt &&
1042
- (terminalStatuses.includes(finalReceipt.status) ||
1043
- completeViaDestinationFallback)
1044
-
1045
- if (!isComplete) {
1046
- const elapsedMs = pollStartMs > 0 ? Date.now() - pollStartMs : 0
1047
- const timedOut = elapsedMs >= maxWaitTime
1048
- const reason = timedOut
1049
- ? `Intent execution timed out after ${Math.round(maxWaitTime / 60000)} minutes.`
1050
- : "Unable to confirm final intent status from receipt polling."
1051
-
1052
- logger.console.warn(
1053
- "[trails-sdk] Intent polling ended without terminal status",
1054
- {
1055
- intentId: intent.intentId,
1056
- status: finalReceipt?.status,
1057
- maxWaitTime,
1058
- elapsedMs,
1059
- timedOut,
1060
- },
1061
- )
1062
-
1063
- trackPaymentError({
1064
- error: `${reason} Please check transaction history or query GetIntentReceipt.`,
1065
- userAddress: account.address,
1066
- mode,
1067
- fundMethod,
1068
- originTokenAddress: params.originTokenAddress,
1069
- })
1070
-
1071
- invalidateTokenBalancesCache(undefined, effectiveQueryClient)
1072
-
1073
- if (checkoutOnHandlers?.triggerCheckoutError) {
1074
- checkoutOnHandlers.triggerCheckoutError(
1075
- "Unable to confirm final transaction status",
1076
- )
1077
- }
1078
-
1079
- throw new Error(
1080
- `${reason} Please check transaction history or query GetIntentReceipt with this intent ID.`,
1081
- )
1082
- }
1083
- } catch (error) {
1084
- logger.console.error(
1085
- "[trails-sdk] Error polling for intent receipt:",
1086
- error,
1087
- )
1088
- // Polling failed — outcome is unknown. Do not report success.
1089
- trackPaymentError({
1090
- error: `Polling failed: ${getFullErrorMessage(error)}`,
1091
- userAddress: account.address,
1092
- mode,
1093
- fundMethod,
1094
- originTokenAddress: params.originTokenAddress,
1095
- })
1096
-
1097
- invalidateTokenBalancesCache(undefined, effectiveQueryClient)
1098
-
1099
- if (checkoutOnHandlers?.triggerCheckoutError) {
1100
- checkoutOnHandlers.triggerCheckoutError(
1101
- "Unable to confirm transaction status",
1102
- )
1103
- }
1104
-
1105
- throw new Error(
1106
- `Unable to confirm transaction status: polling for intent receipt failed: ${getFullErrorMessage(error)}`,
1107
- )
1108
- }
1109
- }
1110
-
1111
- // Check if intent was ABORTED or FAILED
1112
- if (
1113
- finalReceipt &&
1114
- (finalReceipt.status === "ABORTED" || finalReceipt.status === "FAILED")
1115
- ) {
1116
- const statusReason = localTransactionStates[0]?.statusReason
1117
- const errorMsg = statusReason
1118
- ? `Transaction ${finalReceipt.status.toLowerCase()}: ${statusReason}`
1119
- : `Transaction ${finalReceipt.status.toLowerCase()}`
1120
- logger.console.error(
1121
- `[trails-sdk] Intent ${finalReceipt.status}:`,
1122
- intent.intentId,
1123
- )
1124
-
1125
- trackPaymentError({
1126
- error: errorMsg,
1127
- userAddress: account.address,
1128
- mode,
1129
- fundMethod,
1130
- originTokenAddress: params.originTokenAddress,
1131
- })
1132
-
1133
- invalidateTokenBalancesCache(undefined, effectiveQueryClient)
1134
-
1135
- if (checkoutOnHandlers?.triggerCheckoutError) {
1136
- checkoutOnHandlers.triggerCheckoutError(errorMsg)
1137
- }
1138
-
1139
- throw new Error(errorMsg)
1140
- }
1141
-
1142
- // Track payment completion
1143
- const hasAnyCallFailed = localTransactionStates.some((tx) =>
1144
- tx?.decodedGuestModuleEvents?.some((e: any) => e?.type === "CallFailed"),
1145
- )
1146
- const hasAnyRefunded = localTransactionStates.some((tx) => tx?.refunded)
1147
- const hasAnyFailed = localTransactionStates.some(
1148
- (tx) => tx?.state === "failed",
1149
- )
1150
- const txStatus =
1151
- !hasAnyCallFailed && !hasAnyRefunded && !hasAnyFailed ? "success" : "fail"
1152
-
1153
- trackPaymentCompleted({
1154
- userAddress: account.address,
1155
- originIntentAddress: intent.originIntentAddress,
1156
- originTxHash: depositUserTxnReceipt?.transactionHash,
1157
- destinationTxHash: (
1158
- destinationIntentTransaction as IntentTransaction | null
1159
- )?.txnHash,
1160
- originChainId: params.originChainId,
1161
- destinationChainId: params.destinationChainId,
1162
- swapProvider: swapProvider || undefined,
1163
- bridgeProvider: bridgeProvider || undefined,
1164
- mode,
1165
- fundMethod,
1166
- originTokenAddress: params.originTokenAddress,
1167
- originTokenSymbol,
1168
- originTokenAmount: depositAmount,
1169
- originTokenAmountFormatted: depositAmountFormatted,
1170
- destinationTokenAddress: params.destinationTokenAddress,
1171
- destinationTokenSymbol,
1172
- depositTokenAmount: depositAmount,
1173
- depositTokenAmountFormatted: depositAmountFormatted,
1174
- depositTokenAmountUsd: depositAmountUsd,
1175
- destinationTokenAmount: intent.quote?.toAmount?.toString() || depositAmount,
1176
- destinationTokenAmountFormatted: formatRawAmount(
1177
- intent.quote?.toAmount?.toString() || depositAmount,
1178
- destinationTokenDecimals,
1179
- ),
1180
- originTokenDecimals,
1181
- destinationTokenDecimals,
1182
- tradeType: tradeType?.toString(),
1183
- sourceTokenPriceUsd,
1184
- destinationTokenPriceUsd,
1185
- walletId,
1186
- destinationCalldata,
1187
- })
1188
-
1189
- invalidateTokenBalancesCache(undefined, effectiveQueryClient)
1190
-
1191
- if (checkoutOnHandlers?.triggerCheckoutComplete) {
1192
- checkoutOnHandlers.triggerCheckoutComplete(txStatus, account.address)
1193
- }
1194
-
1195
- return {
1196
- depositUserTxnReceipt,
1197
- originIntentTransaction,
1198
- destinationIntentTransaction,
1199
- totalCompletionSeconds: await getTxTimeDiff(
1200
- localTransactionStates[0],
1201
- localTransactionStates[localTransactionStates.length - 1],
1202
- ),
1203
- }
1204
- }
1205
-
1206
- /**
1207
- * Unified intent handler that supports both passthrough and intent flows.
1208
- * The backend decides the flow type via `intent.passthrough` flag.
1209
- */
1210
- export async function handleIntent(
1211
- params: IntentHandlerParams,
1212
- ): Promise<PrepareSendReturn> {
1213
- const {
1214
- mainSignerAddress,
1215
- originChainId,
1216
- originTokenAddress,
1217
- originTokenBalance,
1218
- originTokenDecimals,
1219
- originTokenSymbol,
1220
- destinationChainId,
1221
- destinationTokenAddress,
1222
- destinationTokenSymbol,
1223
- destinationTokenDecimals,
1224
- swapAmount,
1225
- recipient,
1226
- destinationApproveAddress,
1227
- destinationCalldata,
1228
- account,
1229
- chain,
1230
- trailsClient,
1231
- sourceTokenPriceUsd,
1232
- destinationTokenPriceUsd,
1233
- originNativeTokenPriceUsd,
1234
- slippageTolerance,
1235
- tradeType = TradeType.EXACT_INPUT,
1236
- swapProvider: initialSwapProvider,
1237
- bridgeProvider: initialBridgeProvider,
1238
- swapProviderFallback,
1239
- bridgeProviderFallback,
1240
- fundMethod: fundMethodFromParams,
1241
- mode,
1242
- checkoutOnHandlers,
1243
- selectedFeeOption,
1244
- walletId,
1245
- abortSignal,
1246
- commitIntentFn,
1247
- isSmartWallet,
1248
- isSenderContractOnOrigin,
1249
- trailsApiKey,
1250
- trailsApiUrl,
1251
- sequenceMetadataUrl,
1252
- } = params
1253
-
1254
- logger.console.log("[trails-sdk] handleIntent called")
1255
-
1256
- const effectiveFundMethod = fundMethodFromParams ?? "wallet"
1257
- const effectiveOriginChain = chain
1258
- const effectiveOriginTokenAddress = originTokenAddress
1259
- const effectivePublicClient =
1260
- params.publicClient ?? getChainRpcClient(effectiveOriginChain.id)
1261
-
1262
- const isToSameChain = isSameChain(originChainId, destinationChainId)
1263
- const isToSameToken = isSameToken(originTokenAddress, destinationTokenAddress)
1264
- const isSameChainSameToken = isToSameChain && isToSameToken
1265
-
1266
- const swapProvider = initialSwapProvider
1267
- const bridgeProvider = initialBridgeProvider
1268
-
1269
- // SPEC: Same-chain same-token wallet scenarios (C9b/C10/C11b/C12/D9b/D10/D11b/D12) may use passthrough when native gas is selected.
1270
- // SPEC: Intent-only scenarios (C9a/C11a/D9a/D11a) require gasless fee options or have insufficient allowance.
1271
- // SPEC: Non-wallet fund methods (C13/C14/D13/D14) must use intent flow to provide deposit addresses.
1272
- // Balance check is done later after we know the actual deposit amount from the intent API
1273
- // For cross-token swaps, swapAmount is in destination token units, not origin token units
1274
- let noSufficientBalance = false
1275
-
1276
- const hasCustomCalldata = getIsCustomCalldata(destinationCalldata)
1277
- const isNativeOriginToken = isNativeToken(effectiveOriginTokenAddress)
1278
-
1279
- // Build intent args
1280
- // EXACT_OUTPUT: pass swapAmount for both (backend uses destination as target, origin as hint)
1281
- // EXACT_INPUT: pass swapAmount as origin, 0 as destination (backend calculates destination)
1282
- const intentArgs = await getIntentArgs(
1283
- mainSignerAddress,
1284
- originChainId,
1285
- originTokenAddress,
1286
- swapAmount,
1287
- destinationChainId,
1288
- destinationTokenAddress,
1289
- tradeType === TradeType.EXACT_OUTPUT ? swapAmount : "0",
1290
- recipient,
1291
- destinationApproveAddress,
1292
- destinationCalldata,
1293
- slippageTolerance,
1294
- tradeType,
1295
- swapProvider,
1296
- bridgeProvider,
1297
- swapProviderFallback,
1298
- bridgeProviderFallback,
1299
- undefined,
1300
- walletId,
1301
- isSmartWallet,
1302
- isSenderContractOnOrigin,
1303
- )
1304
-
1305
- // For same-chain same-token with native calldata, add call value
1306
- if (isSameChainSameToken && hasCustomCalldata && isNativeOriginToken) {
1307
- intentArgs.destinationCallValue = BigInt(swapAmount)
1308
- }
1309
-
1310
- // Add fundMethod to intent args for backend passthrough decision
1311
- intentArgs.fundMethod = toApiFundMethod(effectiveFundMethod)
1312
-
1313
- logger.console.log("[trails-sdk] Creating intent with args:", intentArgs)
1314
-
1315
- // Call quoteIntent first to get depositTransaction from API
1316
- const quoteResult = await quoteIntent(
1317
- trailsClient,
1318
- intentArgs,
1319
- {
1320
- originTokenSymbol,
1321
- destinationTokenSymbol,
1322
- feeTokenSymbol: originTokenSymbol,
1323
- },
1324
- abortSignal,
1325
- )
1326
-
1327
- const {
1328
- intent,
1329
- gasFeeOptions,
1330
- trailsContracts,
1331
- passthrough,
1332
- transactionStates: apiTransactionStates,
1333
- } = quoteResult
1334
- logger.console.log("[trails-sdk] Quote intent:", intent)
1335
- logger.console.log("[trails-sdk] Quote intent gasFeeOptions:", gasFeeOptions)
1336
- logger.console.log("[trails-sdk] Quote passthrough:", passthrough)
1337
- logger.console.log(
1338
- "[trails-sdk] Quote transactionStates:",
1339
- apiTransactionStates,
1340
- )
1341
-
1342
- if (!intent.originPrecondition || !intent.originCalls) {
1343
- throw new Error("Invalid intent")
1344
- }
1345
-
1346
- // Determine if passthrough should be used
1347
- // SPEC: Only same-chain same-token with wallet fund method may use passthrough (C9b/C10/C11b/C12/D9b/D10/D11b/D12).
1348
- // SPEC: Cross-chain (A/B), different-token (C1-C8/D1-D8), non-wallet (C13/C14/D13/D14), and gasless (G1-G20) must always use intents.
1349
- // SPEC: Intent-only scenarios (C9a/C11a/D9a/D11a) cannot use passthrough due to gasless fee options.
1350
- // Backend sets passthrough.eligible, but we enforce structural invariants client-side as a safety net.
1351
- // For ERC20 passthrough with custom calldata, the SDK handles approval if insufficient (see executePassthrough).
1352
- const usePassthrough =
1353
- effectiveFundMethod === "wallet" &&
1354
- passthrough?.eligible === true &&
1355
- !!passthrough?.passthroughTransaction &&
1356
- isFeeSelectionPassthroughEligible({
1357
- selectedFeeOption,
1358
- gasFeeOptions,
1359
- })
1360
-
1361
- logger.console.log("[trails-sdk] Passthrough decision:", {
1362
- usePassthrough,
1363
- isSameChainSameToken,
1364
- fundMethod: effectiveFundMethod,
1365
- passthroughEligible: passthrough?.eligible,
1366
- hasPassthroughTransaction: !!passthrough?.passthroughTransaction,
1367
- feeOptionPassthroughEligible: selectedFeeOption?.isPassthroughEligible,
1368
- selectedFeeOption,
1369
- })
1370
-
1371
- // Use passthrough-specific deposit transaction and states when doing passthrough
1372
- const effectiveDepositTransaction: DepositTransaction | undefined =
1373
- usePassthrough && passthrough?.passthroughTransaction
1374
- ? passthrough.passthroughTransaction
1375
- : intent.depositTransaction
1376
-
1377
- const depositAmount = effectiveDepositTransaction.amount.toString()
1378
- const quoteToAmount = intent.quote.toAmount.toString()
1379
- const quoteToAmountMin = intent.quote.toAmountMin.toString() || quoteToAmount
1380
-
1381
- // Compute transaction states for both passthrough and intent flows
1382
- // This allows the UI to switch between them based on fee option selection
1383
- // SPEC: Passthrough-capable scenarios (C9b/C10/C11b/C12/D9b/D10/D11b/D12) expose passthrough transaction states; other scenarios use intent-flow states.
1384
- const passthroughTransactionStates = passthrough?.transactionStates?.length
1385
- ? getNormalizedTransactionStates({
1386
- transactionStates: passthrough.transactionStates,
1387
- })
1388
- : []
1389
-
1390
- const intentTransactionStates = apiTransactionStates?.length
1391
- ? getNormalizedTransactionStates({
1392
- transactionStates: apiTransactionStates,
1393
- })
1394
- : []
1395
-
1396
- // Use the appropriate states based on current passthrough decision
1397
- const transactionStates = usePassthrough
1398
- ? passthroughTransactionStates
1399
- : intentTransactionStates
1400
-
1401
- // Run balance check and quote normalization in parallel to reduce latency
1402
- const [balanceResult, quote] = await Promise.all([
1403
- effectiveFundMethod === "wallet"
1404
- ? checkAccountBalance({
1405
- account,
1406
- tokenAddress: originTokenAddress,
1407
- depositAmount: depositAmount,
1408
- publicClient: effectivePublicClient,
1409
- knownBalance: originTokenBalance,
1410
- decimals: originTokenDecimals,
1411
- })
1412
- : Promise.resolve({ hasEnoughBalance: true }),
1413
- getNormalizedQuoteObject({
1414
- originDepositAddress: usePassthrough
1415
- ? recipient
1416
- : intent.originIntentAddress,
1417
- destinationDepositAddress: usePassthrough
1418
- ? recipient
1419
- : intent.destinationIntentAddress,
1420
- destinationAddress: recipient,
1421
- trailsApiKey: trailsApiKey || "",
1422
- trailsApiUrl: trailsApiUrl || "",
1423
- sequenceMetadataUrl: sequenceMetadataUrl || "",
1424
- destinationCalldata,
1425
- originAmount: depositAmount,
1426
- destinationAmount: quoteToAmount,
1427
- originAmountMin: depositAmount,
1428
- destinationAmountMin: quoteToAmountMin,
1429
- originTokenAddress,
1430
- destinationTokenAddress,
1431
- originTokenPriceUsd: sourceTokenPriceUsd?.toString() || null,
1432
- destinationTokenPriceUsd: destinationTokenPriceUsd?.toString() || null,
1433
- fees: isSameChainSameToken
1434
- ? undefined
1435
- : getFeesFromIntent(intent, {
1436
- tradeType,
1437
- fromAmountUsd: calcAmountUsdPrice({
1438
- amount: rawAmountToNumber(depositAmount, originTokenDecimals),
1439
- usdPrice: sourceTokenPriceUsd,
1440
- }),
1441
- toAmountUsd: calcAmountUsdPrice({
1442
- amount: rawAmountToNumber(
1443
- quoteToAmount,
1444
- destinationTokenDecimals,
1445
- ),
1446
- usdPrice: destinationTokenPriceUsd,
1447
- }),
1448
- }),
1449
- originChainId,
1450
- destinationChainId,
1451
- slippageTolerance,
1452
- priceImpact: getPriceImpactFromIntent(intent),
1453
- priceImpactUsd: getPriceImpactUsdFromIntent(intent),
1454
- transactionStates,
1455
- originNativeTokenPriceUsd,
1456
- intent: usePassthrough ? undefined : intent,
1457
- }),
1458
- ])
1459
-
1460
- noSufficientBalance = !balanceResult.hasEnoughBalance
1461
- quote.noSufficientBalance = noSufficientBalance
1462
- if (effectiveFundMethod === "wallet") {
1463
- logger.console.log(
1464
- "[trails-sdk] Balance check with actual deposit amount:",
1465
- {
1466
- depositAmount,
1467
- originTokenAddress,
1468
- hasEnoughBalance: balanceResult.hasEnoughBalance,
1469
- noSufficientBalance,
1470
- },
1471
- )
1472
- }
1473
-
1474
- // Add passthrough-specific fields to the quote
1475
- // This allows the UI to switch between passthrough and intent states based on fee option
1476
- // SPEC: Quote includes passthrough info for passthrough-capable scenarios (C9b/C10/C11b/C12/D9b/D10/D11b/D12) so UI can toggle flows.
1477
- quote.passthroughTransactionStates = passthroughTransactionStates
1478
- quote.passthroughEligible = passthrough?.eligible === true
1479
-
1480
- // Call onCheckoutQuote callback
1481
- if (checkoutOnHandlers?.triggerCheckoutQuote) {
1482
- checkoutOnHandlers.triggerCheckoutQuote(quote)
1483
- }
1484
-
1485
- logger.console.log(
1486
- "[trails-sdk] handleIntent returning quote and send function",
1487
- )
1488
-
1489
- return {
1490
- quote,
1491
- feeOptions: gasFeeOptions,
1492
- send: async (options) => {
1493
- const { skipCommit } = options
1494
-
1495
- try {
1496
- // Recalculate passthrough decision at send time based on fee option.
1497
- // This allows switching between passthrough and intent flow after quote.
1498
- const sendFeeOption = options.selectedFeeOption
1499
- const sendUsePassthrough =
1500
- effectiveFundMethod === "wallet" &&
1501
- passthrough?.eligible === true &&
1502
- !!passthrough?.passthroughTransaction &&
1503
- isFeeSelectionPassthroughEligible({
1504
- selectedFeeOption: sendFeeOption,
1505
- gasFeeOptions,
1506
- })
1507
-
1508
- logger.console.log("[trails-sdk] Send passthrough decision:", {
1509
- sendUsePassthrough,
1510
- passthroughEligible: passthrough?.eligible,
1511
- hasPassthroughTransaction: !!passthrough?.passthroughTransaction,
1512
- sendFeeOptionPassthroughEligible:
1513
- sendFeeOption?.isPassthroughEligible,
1514
- sendFeeOption,
1515
- })
1516
-
1517
- // Select the correct deposit transaction based on passthrough decision at send time
1518
- const sendDepositTransaction: DepositTransaction | undefined =
1519
- sendUsePassthrough && passthrough?.passthroughTransaction
1520
- ? passthrough.passthroughTransaction
1521
- : intent.depositTransaction
1522
-
1523
- // Select the correct transaction states based on passthrough decision at send time
1524
- const sendTransactionStates = sendUsePassthrough
1525
- ? passthroughTransactionStates
1526
- : intentTransactionStates
1527
-
1528
- const commitIntentIfNeeded = async () => {
1529
- if (skipCommit) {
1530
- return
1531
- }
1532
-
1533
- try {
1534
- logger.console.log(
1535
- "[trails-sdk] intentHandler: About to commit intent",
1536
- {
1537
- hasCommitIntentFn: !!commitIntentFn,
1538
- intentId: intent.intentId,
1539
- },
1540
- )
1541
-
1542
- const commitIntentFnToUse =
1543
- commitIntentFn ||
1544
- ((intent: Intent) =>
1545
- commitIntent(trailsClient, intent, {
1546
- originTokenSymbol,
1547
- destinationTokenSymbol,
1548
- }))
1549
- await commitIntentFnToUse(intent)
1550
-
1551
- logger.console.log("[trails-sdk] Intent committed successfully")
1552
- } catch (error) {
1553
- logger.console.error("[trails-sdk] Error committing intent", error)
1554
- throw error
1555
- }
1556
- }
1557
-
1558
- if (sendUsePassthrough && sendDepositTransaction) {
1559
- return executePassthrough(
1560
- params,
1561
- sendDepositTransaction,
1562
- sendTransactionStates,
1563
- options,
1564
- )
1565
- } else {
1566
- await commitIntentIfNeeded()
1567
- return executeIntent(
1568
- params,
1569
- intent,
1570
- sendTransactionStates,
1571
- gasFeeOptions,
1572
- trailsContracts,
1573
- options,
1574
- )
1575
- }
1576
- } catch (error) {
1577
- const errorMessage = getFullErrorMessage(error)
1578
- logger.console.error("[trails-sdk] Error in handleIntent send:", error)
1579
-
1580
- trackPaymentError({
1581
- error: errorMessage,
1582
- userAddress: account.address,
1583
- mode,
1584
- fundMethod: effectiveFundMethod,
1585
- originTokenAddress,
1586
- })
1587
-
1588
- if (checkoutOnHandlers?.triggerCheckoutError) {
1589
- checkoutOnHandlers.triggerCheckoutError(errorMessage)
1590
- }
1591
-
1592
- throw error
1593
- }
1594
- },
1595
- }
1596
- }