0xtrails 0.6.6 → 0.7.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 (365) hide show
  1. package/dist/aave.d.ts +10 -2
  2. package/dist/aave.d.ts.map +1 -1
  3. package/dist/analytics.d.ts +26 -0
  4. package/dist/analytics.d.ts.map +1 -1
  5. package/dist/{ccip-CbJrlK-L.js → ccip-fConRNoG.js} +21 -21
  6. package/dist/chains.d.ts +23 -8
  7. package/dist/chains.d.ts.map +1 -1
  8. package/dist/constants.d.ts +5 -5
  9. package/dist/constants.d.ts.map +1 -1
  10. package/dist/customTokens.d.ts +12 -0
  11. package/dist/customTokens.d.ts.map +1 -0
  12. package/dist/decoders.d.ts +2 -2
  13. package/dist/decoders.d.ts.map +1 -1
  14. package/dist/error.d.ts.map +1 -1
  15. package/dist/fees.d.ts +37 -2
  16. package/dist/fees.d.ts.map +1 -1
  17. package/dist/gasless.d.ts +15 -36
  18. package/dist/gasless.d.ts.map +1 -1
  19. package/dist/{index-w7_dK4c5.js → index-BbajxCG_.js} +59269 -77146
  20. package/dist/index.d.ts +8 -6
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +828 -359
  23. package/dist/indexerClient.d.ts.map +1 -1
  24. package/dist/intentReceiptMonitor.d.ts +1 -1
  25. package/dist/intentReceiptMonitor.d.ts.map +1 -1
  26. package/dist/intentReceiptPoller.d.ts +1 -1
  27. package/dist/intentReceiptPoller.d.ts.map +1 -1
  28. package/dist/intents.d.ts +3 -2
  29. package/dist/intents.d.ts.map +1 -1
  30. package/dist/mode.d.ts +1 -1
  31. package/dist/mode.d.ts.map +1 -1
  32. package/dist/mutations.d.ts +2 -2
  33. package/dist/mutations.d.ts.map +1 -1
  34. package/dist/prepareSend.d.ts +2 -2
  35. package/dist/prepareSend.d.ts.map +1 -1
  36. package/dist/prices.d.ts +1 -1
  37. package/dist/prices.d.ts.map +1 -1
  38. package/dist/sequenceWallet.d.ts +2 -2
  39. package/dist/sequenceWallet.d.ts.map +1 -1
  40. package/dist/time.d.ts +6 -0
  41. package/dist/time.d.ts.map +1 -1
  42. package/dist/tokenBalances.d.ts +40 -25
  43. package/dist/tokenBalances.d.ts.map +1 -1
  44. package/dist/tokens.d.ts +54 -14
  45. package/dist/tokens.d.ts.map +1 -1
  46. package/dist/trailsClient.d.ts +1 -1
  47. package/dist/trailsClient.d.ts.map +1 -1
  48. package/dist/trailsRouter.d.ts +2 -1
  49. package/dist/trailsRouter.d.ts.map +1 -1
  50. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +3 -2
  51. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
  52. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +2 -1
  53. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
  54. package/dist/transactionIntent/execution/transactionState.d.ts +1 -1
  55. package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -1
  56. package/dist/transactionIntent/handlers/crossChain.d.ts +5 -3
  57. package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -1
  58. package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +5 -3
  59. package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -1
  60. package/dist/transactionIntent/quote/feeExtractors.d.ts +1 -6
  61. package/dist/transactionIntent/quote/feeExtractors.d.ts.map +1 -1
  62. package/dist/transactionIntent/quote/normalizeQuote.d.ts +4 -2
  63. package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
  64. package/dist/transactionIntent/quote/quoteHelpers.d.ts +1 -1
  65. package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -1
  66. package/dist/transactionIntent/types.d.ts +28 -5
  67. package/dist/transactionIntent/types.d.ts.map +1 -1
  68. package/dist/transactionIntent/utils/testnetHelpers.d.ts +0 -1
  69. package/dist/transactionIntent/utils/testnetHelpers.d.ts.map +1 -1
  70. package/dist/transactionIntent/validators.d.ts +0 -2
  71. package/dist/transactionIntent/validators.d.ts.map +1 -1
  72. package/dist/transactions.d.ts +2 -2
  73. package/dist/transactions.d.ts.map +1 -1
  74. package/dist/utils.d.ts +7 -0
  75. package/dist/utils.d.ts.map +1 -1
  76. package/dist/wallets.d.ts +1 -0
  77. package/dist/wallets.d.ts.map +1 -1
  78. package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
  79. package/dist/widget/components/AddressWalletIcon.d.ts +6 -0
  80. package/dist/widget/components/AddressWalletIcon.d.ts.map +1 -0
  81. package/dist/widget/components/ChainFilterDropdown.d.ts +2 -6
  82. package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
  83. package/dist/widget/components/ChainImage.d.ts.map +1 -1
  84. package/dist/widget/components/ChainList.d.ts +0 -5
  85. package/dist/widget/components/ChainList.d.ts.map +1 -1
  86. package/dist/widget/components/ClassicSwap.d.ts +6 -6
  87. package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
  88. package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
  89. package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
  90. package/dist/widget/components/DebugMenu.d.ts +1 -1
  91. package/dist/widget/components/DebugMenu.d.ts.map +1 -1
  92. package/dist/widget/components/DebugScreensList.d.ts.map +1 -1
  93. package/dist/widget/components/DepositTracker.d.ts.map +1 -1
  94. package/dist/widget/components/Earn.d.ts +5 -5
  95. package/dist/widget/components/Earn.d.ts.map +1 -1
  96. package/dist/widget/components/FeeOption.d.ts +1 -1
  97. package/dist/widget/components/FeeOption.d.ts.map +1 -1
  98. package/dist/widget/components/FeeOptions.d.ts +2 -2
  99. package/dist/widget/components/FeeOptions.d.ts.map +1 -1
  100. package/dist/widget/components/Footer.d.ts +1 -1
  101. package/dist/widget/components/Footer.d.ts.map +1 -1
  102. package/dist/widget/components/Fund.d.ts +5 -5
  103. package/dist/widget/components/Fund.d.ts.map +1 -1
  104. package/dist/widget/components/FundMethods.d.ts +0 -1
  105. package/dist/widget/components/FundMethods.d.ts.map +1 -1
  106. package/dist/widget/components/FundSwap.d.ts +6 -6
  107. package/dist/widget/components/FundSwap.d.ts.map +1 -1
  108. package/dist/widget/components/HookModalContent.d.ts +8 -0
  109. package/dist/widget/components/HookModalContent.d.ts.map +1 -0
  110. package/dist/widget/components/OriginSelectionAmount.d.ts +11 -0
  111. package/dist/widget/components/OriginSelectionAmount.d.ts.map +1 -0
  112. package/dist/widget/components/Pay.d.ts +5 -5
  113. package/dist/widget/components/Pay.d.ts.map +1 -1
  114. package/dist/widget/components/PoolDeposit.d.ts +5 -5
  115. package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
  116. package/dist/widget/components/PoolWithdraw.d.ts +3 -3
  117. package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
  118. package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
  119. package/dist/widget/components/Receipt.d.ts +2 -1
  120. package/dist/widget/components/Receipt.d.ts.map +1 -1
  121. package/dist/widget/components/RecentTokens.d.ts +4 -4
  122. package/dist/widget/components/RecentTokens.d.ts.map +1 -1
  123. package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -1
  124. package/dist/widget/components/ShadowPortal.d.ts +6 -0
  125. package/dist/widget/components/ShadowPortal.d.ts.map +1 -0
  126. package/dist/widget/components/Swap.d.ts +6 -6
  127. package/dist/widget/components/Swap.d.ts.map +1 -1
  128. package/dist/widget/components/ThemeProvider.d.ts +1 -1
  129. package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
  130. package/dist/widget/components/TokenList.d.ts +3 -4
  131. package/dist/widget/components/TokenList.d.ts.map +1 -1
  132. package/dist/widget/components/TokenSelector.d.ts +3 -4
  133. package/dist/widget/components/TokenSelector.d.ts.map +1 -1
  134. package/dist/widget/components/Tooltip.d.ts +6 -1
  135. package/dist/widget/components/Tooltip.d.ts.map +1 -1
  136. package/dist/widget/components/TrailsHookModal.d.ts +10 -0
  137. package/dist/widget/components/TrailsHookModal.d.ts.map +1 -0
  138. package/dist/widget/components/WaasFeeOptions.d.ts +3 -0
  139. package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
  140. package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
  141. package/dist/widget/components/WalletConnect.d.ts.map +1 -1
  142. package/dist/widget/components/WidgetProviders.d.ts +14 -0
  143. package/dist/widget/components/WidgetProviders.d.ts.map +1 -0
  144. package/dist/widget/css/compiled.css +1 -1
  145. package/dist/widget/hooks/useAddressWalletIcon.d.ts +10 -0
  146. package/dist/widget/hooks/useAddressWalletIcon.d.ts.map +1 -0
  147. package/dist/widget/hooks/useBalanceVisible.d.ts +1 -1
  148. package/dist/widget/hooks/useBalanceVisible.d.ts.map +1 -1
  149. package/dist/widget/hooks/useChainFilter.d.ts +1 -1
  150. package/dist/widget/hooks/useChainFilter.d.ts.map +1 -1
  151. package/dist/widget/hooks/useCheckout.d.ts +13 -1
  152. package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
  153. package/dist/widget/hooks/useConnector.d.ts +4 -0
  154. package/dist/widget/hooks/useConnector.d.ts.map +1 -0
  155. package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
  156. package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
  157. package/dist/widget/hooks/useCustomTokenFetch.d.ts +19 -0
  158. package/dist/widget/hooks/useCustomTokenFetch.d.ts.map +1 -0
  159. package/dist/widget/hooks/useCustomTokenSearch.d.ts +20 -0
  160. package/dist/widget/hooks/useCustomTokenSearch.d.ts.map +1 -0
  161. package/dist/widget/hooks/useDebounce.d.ts +10 -0
  162. package/dist/widget/hooks/useDebounce.d.ts.map +1 -0
  163. package/dist/widget/hooks/useDebugScreens.d.ts +7 -2
  164. package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
  165. package/dist/widget/hooks/useDefaultTokenSelection.d.ts +3 -19
  166. package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
  167. package/dist/widget/hooks/useDestinationSelectedToken.d.ts +1 -14
  168. package/dist/widget/hooks/useDestinationSelectedToken.d.ts.map +1 -1
  169. package/dist/widget/hooks/useEarnPool.d.ts +1 -1
  170. package/dist/widget/hooks/useEarnPool.d.ts.map +1 -1
  171. package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
  172. package/dist/widget/hooks/useIsMobile.d.ts +5 -0
  173. package/dist/widget/hooks/useIsMobile.d.ts.map +1 -0
  174. package/dist/widget/hooks/useMode.d.ts +2 -2
  175. package/dist/widget/hooks/useMode.d.ts.map +1 -1
  176. package/dist/widget/hooks/useOriginSelectedToken.d.ts +2 -15
  177. package/dist/widget/hooks/useOriginSelectedToken.d.ts.map +1 -1
  178. package/dist/widget/hooks/usePayMessage.d.ts.map +1 -1
  179. package/dist/widget/hooks/usePriceImpactWarning.d.ts +1 -1
  180. package/dist/widget/hooks/usePriceImpactWarning.d.ts.map +1 -1
  181. package/dist/widget/hooks/useQuote.d.ts +173 -4
  182. package/dist/widget/hooks/useQuote.d.ts.map +1 -1
  183. package/dist/widget/hooks/useRecentTokens.d.ts +3 -3
  184. package/dist/widget/hooks/useRecentTokens.d.ts.map +1 -1
  185. package/dist/widget/hooks/useRecipients.d.ts +1 -1
  186. package/dist/widget/hooks/useRecipients.d.ts.map +1 -1
  187. package/dist/widget/hooks/useSelectedFeeOption.d.ts +2 -2
  188. package/dist/widget/hooks/useSelectedFeeOption.d.ts.map +1 -1
  189. package/dist/widget/hooks/useSelectedFundMethod.d.ts +1 -1
  190. package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -1
  191. package/dist/widget/hooks/useSelectedRecipient.d.ts +1 -1
  192. package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -1
  193. package/dist/widget/hooks/useSendForm.d.ts +9 -31
  194. package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
  195. package/dist/widget/hooks/useSwapAmount.d.ts +1 -1
  196. package/dist/widget/hooks/useSwapAmount.d.ts.map +1 -1
  197. package/dist/widget/hooks/useTheme.d.ts +1 -1
  198. package/dist/widget/hooks/useTheme.d.ts.map +1 -1
  199. package/dist/widget/hooks/useTokenList.d.ts +7 -31
  200. package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
  201. package/dist/widget/hooks/useTrailsSendTransaction.d.ts +83 -0
  202. package/dist/widget/hooks/useTrailsSendTransaction.d.ts.map +1 -0
  203. package/dist/widget/hooks/useWalletConnectUri.d.ts +11 -0
  204. package/dist/widget/hooks/useWalletConnectUri.d.ts.map +1 -0
  205. package/dist/widget/hooks/useWidgetProps.d.ts +5 -0
  206. package/dist/widget/hooks/useWidgetProps.d.ts.map +1 -1
  207. package/dist/widget/index.d.ts +2 -0
  208. package/dist/widget/index.d.ts.map +1 -1
  209. package/dist/widget/index.js +8 -5
  210. package/dist/widget/providers/TrailsModalProvider.d.ts +65 -0
  211. package/dist/widget/providers/TrailsModalProvider.d.ts.map +1 -0
  212. package/dist/widget/providers/TrailsProvider.d.ts +1 -1
  213. package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
  214. package/dist/widget/types.d.ts +11 -18
  215. package/dist/widget/types.d.ts.map +1 -1
  216. package/dist/widget/widget.d.ts +20 -11
  217. package/dist/widget/widget.d.ts.map +1 -1
  218. package/package.json +45 -49
  219. package/src/aave.ts +387 -138
  220. package/src/analytics.ts +208 -2
  221. package/src/chains.ts +65 -64
  222. package/src/constants.ts +18 -14
  223. package/src/customTokens.ts +151 -0
  224. package/src/decoders.ts +4 -7
  225. package/src/error.ts +7 -3
  226. package/src/fees.ts +239 -125
  227. package/src/gasless.ts +54 -108
  228. package/src/index.ts +29 -9
  229. package/src/indexerClient.ts +2 -0
  230. package/src/intentReceiptMonitor.ts +1 -4
  231. package/src/intentReceiptPoller.ts +2 -2
  232. package/src/intents.ts +16 -5
  233. package/src/mode.ts +1 -1
  234. package/src/mutations.ts +7 -3
  235. package/src/prepareSend.ts +19 -14
  236. package/src/prices.ts +1 -1
  237. package/src/sequenceWallet.ts +2 -2
  238. package/src/time.ts +28 -0
  239. package/src/tokenBalances.ts +348 -153
  240. package/src/tokens.ts +393 -142
  241. package/src/trailsClient.ts +1 -1
  242. package/src/trailsRouter.ts +4 -5
  243. package/src/transactionIntent/deposits/depositOrchestrator.ts +6 -2
  244. package/src/transactionIntent/deposits/gaslessDeposit.ts +13 -7
  245. package/src/transactionIntent/deposits/standardDeposit.ts +1 -1
  246. package/src/transactionIntent/execution/transactionState.ts +1 -1
  247. package/src/transactionIntent/handlers/crossChain.ts +75 -37
  248. package/src/transactionIntent/handlers/sameChainSameToken.ts +66 -20
  249. package/src/transactionIntent/quote/feeExtractors.ts +1 -29
  250. package/src/transactionIntent/quote/normalizeQuote.ts +99 -7
  251. package/src/transactionIntent/quote/quoteHelpers.ts +1 -1
  252. package/src/transactionIntent/types.ts +31 -6
  253. package/src/transactionIntent/utils/testnetHelpers.ts +0 -5
  254. package/src/transactionIntent/validators.ts +0 -30
  255. package/src/transactions.ts +3 -3
  256. package/src/utils.ts +18 -0
  257. package/src/wallets.ts +32 -10
  258. package/src/widget/compiled.css +1 -1
  259. package/src/widget/components/AccountIntentTransactionHistory.tsx +2 -1
  260. package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +2 -2
  261. package/src/widget/components/AddressWalletIcon.tsx +29 -0
  262. package/src/widget/components/ChainFilterDropdown.tsx +2 -8
  263. package/src/widget/components/ChainImage.tsx +8 -5
  264. package/src/widget/components/ChainList.tsx +6 -8
  265. package/src/widget/components/ClassicSwap.tsx +93 -85
  266. package/src/widget/components/ConnectWallet.tsx +1 -2
  267. package/src/widget/components/ConnectedWallets.tsx +17 -4
  268. package/src/widget/components/DebugMenu.tsx +2 -2
  269. package/src/widget/components/DebugScreensList.tsx +0 -1
  270. package/src/widget/components/DepositTracker.tsx +20 -34
  271. package/src/widget/components/Earn.tsx +7 -6
  272. package/src/widget/components/FeeOption.tsx +4 -4
  273. package/src/widget/components/FeeOptions.tsx +19 -39
  274. package/src/widget/components/Footer.tsx +1 -1
  275. package/src/widget/components/Fund.tsx +23 -119
  276. package/src/widget/components/FundMethods.tsx +9 -6
  277. package/src/widget/components/FundSwap.tsx +6 -5
  278. package/src/widget/components/FundingMethodSelectorButton.tsx +2 -2
  279. package/src/widget/components/HookModalContent.tsx +306 -0
  280. package/src/widget/components/Modal.tsx +1 -1
  281. package/src/widget/components/OriginSelectionAmount.tsx +135 -0
  282. package/src/widget/components/Pay.tsx +66 -124
  283. package/src/widget/components/PoolDeposit.tsx +11 -55
  284. package/src/widget/components/PoolWithdraw.tsx +3 -3
  285. package/src/widget/components/QuoteDetails.tsx +473 -728
  286. package/src/widget/components/Receipt.tsx +74 -7
  287. package/src/widget/components/RecentTokens.tsx +8 -8
  288. package/src/widget/components/RecipientSelectorButton.tsx +4 -2
  289. package/src/widget/components/ScreenHeader.tsx +2 -2
  290. package/src/widget/components/SearchInputField.tsx +1 -1
  291. package/src/widget/components/ShadowPortal.tsx +58 -0
  292. package/src/widget/components/Swap.tsx +6 -5
  293. package/src/widget/components/ThemeProvider.tsx +1 -1
  294. package/src/widget/components/TokenList.tsx +3 -4
  295. package/src/widget/components/TokenSelector.tsx +211 -80
  296. package/src/widget/components/Tooltip.tsx +18 -7
  297. package/src/widget/components/TrailsHookModal.tsx +118 -0
  298. package/src/widget/components/WaasFeeOptions.tsx +333 -138
  299. package/src/widget/components/WalletConfirmation.tsx +7 -2
  300. package/src/widget/components/WalletConnect.tsx +197 -235
  301. package/src/widget/components/WidgetProviders.tsx +75 -0
  302. package/src/widget/hooks/useAddressWalletIcon.ts +53 -0
  303. package/src/widget/hooks/useBalanceVisible.tsx +1 -1
  304. package/src/widget/hooks/useChainFilter.tsx +1 -1
  305. package/src/widget/hooks/useCheckout.ts +13 -1
  306. package/src/widget/hooks/useConnector.tsx +18 -0
  307. package/src/widget/hooks/useCurrentScreen.tsx +3 -3
  308. package/src/widget/hooks/useCustomTokenFetch.tsx +72 -0
  309. package/src/widget/hooks/useCustomTokenSearch.tsx +402 -0
  310. package/src/widget/hooks/useDebounce.ts +25 -0
  311. package/src/widget/hooks/useDebugScreens.ts +26 -10
  312. package/src/widget/hooks/useDefaultTokenSelection.tsx +99 -143
  313. package/src/widget/hooks/useDestinationSelectedToken.tsx +1 -14
  314. package/src/widget/hooks/useEarnPool.tsx +1 -1
  315. package/src/widget/hooks/useIntentTransactionHistory.ts +20 -11
  316. package/src/widget/hooks/useIsMobile.tsx +50 -0
  317. package/src/widget/hooks/useMode.ts +2 -3
  318. package/src/widget/hooks/useOriginSelectedToken.tsx +2 -15
  319. package/src/widget/hooks/usePayMessage.tsx +31 -11
  320. package/src/widget/hooks/usePriceImpactWarning.ts +1 -1
  321. package/src/widget/hooks/useQuote.ts +189 -6
  322. package/src/widget/hooks/useRecentTokens.ts +6 -6
  323. package/src/widget/hooks/useRecipients.ts +1 -1
  324. package/src/widget/hooks/useSelectedFeeOption.tsx +2 -2
  325. package/src/widget/hooks/useSelectedFundMethod.tsx +1 -1
  326. package/src/widget/hooks/useSelectedRecipient.tsx +1 -1
  327. package/src/widget/hooks/useSendForm.ts +328 -152
  328. package/src/widget/hooks/useSwapAmount.tsx +1 -1
  329. package/src/widget/hooks/useTheme.tsx +1 -1
  330. package/src/widget/hooks/useTokenList.ts +672 -400
  331. package/src/widget/hooks/useTrailsSendTransaction.ts +949 -0
  332. package/src/widget/hooks/useWalletConnectUri.tsx +228 -0
  333. package/src/widget/hooks/useWidgetProps.tsx +3 -1
  334. package/src/widget/index.tsx +12 -0
  335. package/src/widget/providers/TrailsModalProvider.tsx +195 -0
  336. package/src/widget/providers/TrailsProvider.tsx +9 -3
  337. package/src/widget/types.ts +12 -20
  338. package/src/widget/widget.tsx +598 -385
  339. package/dist/cctp.d.ts +0 -3
  340. package/dist/cctp.d.ts.map +0 -1
  341. package/dist/lifi.d.ts +0 -4
  342. package/dist/lifi.d.ts.map +0 -1
  343. package/dist/meshconnect.d.ts +0 -171
  344. package/dist/meshconnect.d.ts.map +0 -1
  345. package/dist/relaySdk.d.ts +0 -87
  346. package/dist/relaySdk.d.ts.map +0 -1
  347. package/dist/widget/components/MeshConnectExchanges.d.ts +0 -7
  348. package/dist/widget/components/MeshConnectExchanges.d.ts.map +0 -1
  349. package/dist/widget/components/MeshConnectFlow.d.ts +0 -13
  350. package/dist/widget/components/MeshConnectFlow.d.ts.map +0 -1
  351. package/dist/widget/components/MeshConnectIframe.d.ts +0 -15
  352. package/dist/widget/components/MeshConnectIframe.d.ts.map +0 -1
  353. package/dist/widget/components/Receive.d.ts +0 -12
  354. package/dist/widget/components/Receive.d.ts.map +0 -1
  355. package/dist/widget/hooks/useSelectedMeshExchange.d.ts +0 -14
  356. package/dist/widget/hooks/useSelectedMeshExchange.d.ts.map +0 -1
  357. package/src/cctp.ts +0 -54
  358. package/src/lifi.ts +0 -108
  359. package/src/meshconnect.ts +0 -531
  360. package/src/relaySdk.ts +0 -703
  361. package/src/widget/components/MeshConnectExchanges.tsx +0 -290
  362. package/src/widget/components/MeshConnectFlow.tsx +0 -90
  363. package/src/widget/components/MeshConnectIframe.tsx +0 -500
  364. package/src/widget/components/Receive.tsx +0 -175
  365. package/src/widget/hooks/useSelectedMeshExchange.tsx +0 -46
@@ -1,5 +1,5 @@
1
- import type { TokenPrice, FeeOption } from "@0xsequence/trails-api"
2
- import { JsonEncode } from "@0xsequence/trails-api"
1
+ import type { TokenPrice, FeeOption } from "@0xtrails/api"
2
+ import { JsonEncode } from "@0xtrails/api"
3
3
  import type React from "react"
4
4
  import { useCallback, useEffect, useMemo, useState, useRef } from "react"
5
5
  import {
@@ -32,11 +32,13 @@ import {
32
32
  formatAmount,
33
33
  formatAmountDisplay,
34
34
  } from "../../tokenBalances.js"
35
- import type { SupportedToken } from "../../tokens.js"
35
+ import { useQuery } from "@tanstack/react-query"
36
+ import type { Token } from "../../tokens.js"
36
37
  import {
37
38
  useSupportedTokens,
38
39
  useTokenAddress,
39
40
  useTokenInfo,
41
+ getSupportedTokens,
40
42
  } from "../../tokens.js"
41
43
  import type { CheckoutOnHandlers } from "./useCheckout.js"
42
44
  import { useResolveEnsAddress } from "../../ens.js"
@@ -51,30 +53,7 @@ import {
51
53
  type ProcessedFeeOption,
52
54
  } from "./useSelectedFeeOption.js"
53
55
  import { useWidgetProps } from "./useWidgetProps.js"
54
-
55
- export interface Token {
56
- id: number
57
- name: string
58
- symbol: string
59
- balance: string
60
- imageUrl: string
61
- chainId: number
62
- contractAddress: string
63
- tokenPriceUsd?: number
64
- balanceUsdFormatted?: string
65
- contractInfo?: {
66
- decimals: number
67
- symbol: string
68
- name: string
69
- }
70
- }
71
-
72
- export type TokenInfo = {
73
- symbol: string
74
- name: string
75
- imageUrl: string
76
- decimals: number
77
- }
56
+ import { useCustomTokens } from "../../customTokens.js"
78
57
 
79
58
  type ChainInfo = {
80
59
  id: number
@@ -112,8 +91,8 @@ export type UseSendProps = {
112
91
  tradeType?: TradeType
113
92
  quoteProvider?: string
114
93
  fundMethod?: string
115
- mode?: "pay" | "fund" | "earn" | "swap" | "receive"
116
- onNavigateToMeshConnect?: (
94
+ mode?: "pay" | "fund" | "earn" | "swap"
95
+ onNavigateToOnramp?: (
117
96
  props: {
118
97
  toTokenSymbol: string
119
98
  toTokenAmount: string
@@ -121,6 +100,7 @@ export type UseSendProps = {
121
100
  toRecipientAddress: string
122
101
  },
123
102
  quote?: PrepareSendQuote | null,
103
+ continueSend?: () => Promise<void>,
124
104
  ) => void
125
105
  checkoutOnHandlers?: CheckoutOnHandlers
126
106
  refetchTrigger?: number
@@ -144,15 +124,15 @@ export type UseSendReturn = {
144
124
  recipient: string
145
125
  recipientInput: string
146
126
  selectedDestinationChain: ChainInfo | null
147
- selectedDestToken: TokenInfo
127
+ selectedDestToken: Token | null
148
128
  setAmount: (amount: string) => void
149
129
  setRecipient: (recipient: string) => void
150
130
  setRecipientInput: (recipientInput: string) => void
151
131
  setSelectedDestinationChain: (chain: ChainInfo) => void
152
- setSelectedDestToken: (token: TokenInfo) => void
132
+ setSelectedDestToken: (token: Token | null) => void
153
133
  setSelectedFeeOption: (token: FeeOption | null) => void
154
134
  processedFeeOptions: ProcessedFeeOption[]
155
- supportedTokens: SupportedToken[]
135
+ supportedTokens: Token[]
156
136
  supportedChains: ChainInfo[]
157
137
  ensAddress: string | null
158
138
  isWaitingForWalletConfirm: boolean
@@ -198,7 +178,7 @@ export function useSendForm({
198
178
  quoteProvider,
199
179
  fundMethod,
200
180
  mode,
201
- onNavigateToMeshConnect,
181
+ onNavigateToOnramp,
202
182
  checkoutOnHandlers,
203
183
  refetchTrigger = 0,
204
184
  }: UseSendProps): UseSendReturn {
@@ -269,6 +249,24 @@ export function useSendForm({
269
249
  const { supportedTokens } = useSupportedTokens({
270
250
  chainId: selectedDestinationChain?.id,
271
251
  })
252
+ // Get official supported tokens (before merging with custom tokens) to check if token is truly custom
253
+ const trailsConfig = useTrails()
254
+ const { data: officialSupportedTokens = [] } = useQuery({
255
+ queryKey: [
256
+ "supportedTokens",
257
+ trailsConfig.trailsApiUrl,
258
+ trailsConfig.trailsApiKey,
259
+ ],
260
+ queryFn: () =>
261
+ getSupportedTokens({
262
+ trailsApiKey: trailsConfig.trailsApiKey,
263
+ trailsApiUrl: trailsConfig.trailsApiUrl,
264
+ }),
265
+ staleTime: 60 * 60 * 1000, // 1 hour
266
+ gcTime: 24 * 60 * 60 * 1000, // 24 hours
267
+ refetchOnWindowFocus: false,
268
+ refetchOnReconnect: false,
269
+ })
272
270
 
273
271
  // Get RPC clients for known chainIds using hooks (reads from TrailsProvider context)
274
272
  const destinationChainPublicClient = useChainRpcClient(
@@ -382,6 +380,8 @@ export function useSendForm({
382
380
 
383
381
  const isCustomToken = useMemo(() => toToken?.startsWith("0x"), [toToken])
384
382
 
383
+ const { addCustomToken } = useCustomTokens()
384
+
385
385
  const {
386
386
  tokenInfo: customTokenInfo,
387
387
  isLoading: isLoadingCustomToken,
@@ -404,9 +404,70 @@ export function useSendForm({
404
404
  )
405
405
  }, [isCustomToken, errorCustomToken, isLoadingCustomToken, customTokenInfo])
406
406
 
407
+ // Save custom token to storage when successfully fetched via toToken prop
408
+ // Only save if it doesn't exist in the base supported tokens list
409
+ useEffect(() => {
410
+ if (
411
+ customTokenInfo &&
412
+ !errorCustomToken &&
413
+ isCustomToken &&
414
+ toChainId &&
415
+ toToken &&
416
+ customTokenInfo.symbol &&
417
+ customTokenInfo.name &&
418
+ customTokenInfo.decimals !== undefined
419
+ ) {
420
+ // Check if token already exists in official supported tokens (before merging)
421
+ const existsInOfficialSupportedTokens = officialSupportedTokens.some(
422
+ (token: Token) =>
423
+ token.chainId === toChainId &&
424
+ token.contractAddress.toLowerCase() === toToken.toLowerCase(),
425
+ )
426
+
427
+ // Only add to custom tokens if it's not an official supported token
428
+ if (!existsInOfficialSupportedTokens) {
429
+ const chainInfo = getChainInfo(toChainId)
430
+ const chainName = chainInfo?.name || `Chain ${toChainId}`
431
+
432
+ // Convert tokenInfo to Token format, then to SupportedToken for storage
433
+ // isCustomToken will be set to true by addCustomToken
434
+ const customToken: Token = {
435
+ tokenId: `${toChainId}-${toToken.toLowerCase()}`,
436
+ chainId: toChainId,
437
+ contractAddress: toToken,
438
+ symbol: customTokenInfo.symbol,
439
+ name: customTokenInfo.name,
440
+ decimals: customTokenInfo.decimals,
441
+ chainName,
442
+ imageUrl: customTokenInfo.imageUrl || "",
443
+ isCustomToken: true,
444
+ }
445
+ addCustomToken(customToken)
446
+ logger.console.log(
447
+ "[trails-sdk] Added custom token from toToken prop to storage:",
448
+ customToken,
449
+ )
450
+ } else {
451
+ logger.console.log(
452
+ "[trails-sdk] Token from toToken prop already exists in supported tokens, skipping custom token addition:",
453
+ { toToken, toChainId },
454
+ )
455
+ }
456
+ }
457
+ }, [
458
+ customTokenInfo,
459
+ errorCustomToken,
460
+ isCustomToken,
461
+ toChainId,
462
+ toToken,
463
+ addCustomToken,
464
+ officialSupportedTokens,
465
+ ])
466
+
407
467
  useEffect(() => {
408
468
  if (isCustomToken && customTokenInfo && !isLoadingCustomToken) {
409
- setSelectedDestToken(customTokenInfo as TokenInfo)
469
+ // customTokenInfo is already Token from getTokenInfo
470
+ setSelectedDestToken(customTokenInfo as Token)
410
471
  }
411
472
  }, [customTokenInfo, isCustomToken, isLoadingCustomToken])
412
473
 
@@ -425,36 +486,41 @@ export function useSendForm({
425
486
  }
426
487
 
427
488
  if (selectedDestinationChain) {
428
- return supportedTokens.find(
429
- (token) => token.chainId === selectedDestinationChain.id,
489
+ return (
490
+ supportedTokens.find(
491
+ (token) => token.chainId === selectedDestinationChain.id,
492
+ ) || null
430
493
  )
431
494
  }
432
- return supportedTokens?.[0] as TokenInfo
495
+ return supportedTokens?.[0] || null
433
496
  }, [supportedTokens, selectedDestinationChain, mode])
434
497
 
435
498
  const [isChainDropdownOpen, setIsChainDropdownOpen] = useState(false)
436
499
  const [isTokenDropdownOpen, setIsTokenDropdownOpen] = useState(false)
437
- const [selectedDestToken, setSelectedDestToken] = useState<TokenInfo>(() => {
438
- let token = defaultDestToken
439
- if (toToken && !isCustomToken) {
440
- const isToTokenAddress = isAddress(toToken)
441
- token = supportedTokens.find(
442
- (token) =>
443
- (isToTokenAddress // Match by specified destination token address or symbol
444
- ? token.contractAddress.toLowerCase() === toToken.toLowerCase()
445
- : token.symbol === toToken) &&
446
- (toChainId // Match by specified destination chain id
447
- ? token.chainId === toChainId
448
- : selectedDestinationChain.id), // Select by selected destination chain id
449
- )
450
- }
500
+ const [selectedDestToken, setSelectedDestToken] = useState<Token | null>(
501
+ () => {
502
+ let token = defaultDestToken
503
+ if (toToken && !isCustomToken) {
504
+ const isToTokenAddress = isAddress(toToken)
505
+ token =
506
+ supportedTokens.find(
507
+ (token) =>
508
+ (isToTokenAddress // Match by specified destination token address or symbol
509
+ ? token.contractAddress.toLowerCase() === toToken.toLowerCase()
510
+ : token.symbol === toToken) &&
511
+ (toChainId // Match by specified destination chain id
512
+ ? token.chainId === toChainId
513
+ : selectedDestinationChain?.id), // Select by selected destination chain id
514
+ ) || null
515
+ }
451
516
 
452
- return token as TokenInfo
453
- })
517
+ return token
518
+ },
519
+ )
454
520
 
455
521
  useEffect(() => {
456
522
  if (!selectedDestToken && defaultDestToken) {
457
- setSelectedDestToken(defaultDestToken as TokenInfo)
523
+ setSelectedDestToken(defaultDestToken)
458
524
  }
459
525
  }, [selectedDestToken, defaultDestToken])
460
526
 
@@ -506,7 +572,7 @@ export function useSendForm({
506
572
  {
507
573
  tokenSymbol: selectedToken.symbol,
508
574
  tokenAddress: selectedToken.contractAddress,
509
- chainId: selectedToken.chainId,
575
+ chainId: selectedToken.chainId || 0,
510
576
  },
511
577
  ]
512
578
  : [],
@@ -537,7 +603,7 @@ export function useSendForm({
537
603
  : token.chainId === selectedDestinationChain.id),
538
604
  )
539
605
  if (newToken) {
540
- setSelectedDestToken(newToken as TokenInfo)
606
+ setSelectedDestToken(newToken)
541
607
  }
542
608
  }
543
609
  }, [
@@ -593,10 +659,10 @@ export function useSendForm({
593
659
  )
594
660
 
595
661
  const balanceFormatted =
596
- selectedToken?.balance && selectedToken?.contractInfo?.decimals
662
+ selectedToken?.balance && selectedToken?.decimals
597
663
  ? formatRawAmount(
598
- selectedToken.balance,
599
- selectedToken.contractInfo?.decimals,
664
+ selectedToken.balance || "0",
665
+ selectedToken.decimals || 18,
600
666
  )
601
667
  : "0"
602
668
  const balanceUsdDisplay = selectedToken?.balanceUsdFormatted ?? ""
@@ -635,11 +701,42 @@ export function useSendForm({
635
701
  })
636
702
 
637
703
  const destinationTokenAddress = useMemo(() => {
704
+ // If toToken prop is set and is a custom token address, use it
638
705
  if (isCustomToken) {
706
+ logger.console.log(
707
+ "[trails-sdk] [CUSTOM-TOKEN] Using toToken prop as destinationTokenAddress:",
708
+ toToken,
709
+ )
639
710
  return toToken ?? null
640
711
  }
641
- return destinationTokenAddressFromTokenSymbol ?? null
642
- }, [isCustomToken, toToken, destinationTokenAddressFromTokenSymbol])
712
+ // If selectedDestToken has a contractAddress, use it directly (handles custom tokens selected from UI)
713
+ if (selectedDestToken?.contractAddress) {
714
+ logger.console.log(
715
+ "[trails-sdk] [CUSTOM-TOKEN] Using contractAddress from selectedDestToken:",
716
+ {
717
+ contractAddress: selectedDestToken.contractAddress,
718
+ symbol: selectedDestToken.symbol,
719
+ },
720
+ )
721
+ return selectedDestToken.contractAddress
722
+ }
723
+ // Otherwise, try to look it up by symbol
724
+ const addressFromSymbol = destinationTokenAddressFromTokenSymbol ?? null
725
+ logger.console.log(
726
+ "[trails-sdk] [CUSTOM-TOKEN] Using address from symbol lookup:",
727
+ {
728
+ addressFromSymbol,
729
+ symbol: selectedDestToken?.symbol,
730
+ },
731
+ )
732
+ return addressFromSymbol
733
+ }, [
734
+ isCustomToken,
735
+ toToken,
736
+ selectedDestToken?.contractAddress,
737
+ selectedDestToken?.symbol,
738
+ destinationTokenAddressFromTokenSymbol,
739
+ ])
643
740
 
644
741
  // Calculate raw amount (in wei/smallest unit)
645
742
  const amountRaw = useMemo(() => {
@@ -648,10 +745,7 @@ export function useSendForm({
648
745
  return "0"
649
746
  }
650
747
 
651
- if (
652
- !amount &&
653
- !(selectedToken?.contractInfo?.decimals || selectedDestToken?.decimals)
654
- ) {
748
+ if (!amount && !(selectedToken?.decimals || selectedDestToken?.decimals)) {
655
749
  logger.console.warn("[trails-sdk] Missing token decimals for quote", {
656
750
  amount,
657
751
  selectedToken,
@@ -661,10 +755,7 @@ export function useSendForm({
661
755
  return "0"
662
756
  }
663
757
 
664
- if (
665
- tradeType === TradeType.EXACT_INPUT &&
666
- !selectedToken?.contractInfo?.decimals
667
- ) {
758
+ if (tradeType === TradeType.EXACT_INPUT && !selectedToken?.decimals) {
668
759
  logger.console.warn(
669
760
  "[trails-sdk] Missing source token decimals for quote",
670
761
  {
@@ -688,7 +779,7 @@ export function useSendForm({
688
779
  // For EXACT_OUTPUT: use destination token decimals (user enters destination amount)
689
780
  const decimals =
690
781
  tradeType === TradeType.EXACT_INPUT
691
- ? selectedToken?.contractInfo?.decimals
782
+ ? selectedToken?.decimals
692
783
  : selectedDestToken?.decimals
693
784
 
694
785
  if (!decimals) {
@@ -711,7 +802,7 @@ export function useSendForm({
711
802
  selectedDestToken,
712
803
  selectedToken,
713
804
  selectedDestToken?.decimals,
714
- selectedToken?.contractInfo?.decimals,
805
+ selectedToken?.decimals,
715
806
  tradeType,
716
807
  ])
717
808
 
@@ -770,12 +861,9 @@ export function useSendForm({
770
861
  ? {
771
862
  symbol: selectedToken.symbol,
772
863
  contractAddress: selectedToken.contractAddress,
773
- chainId: selectedToken.chainId,
774
- contractInfo: selectedToken.contractInfo,
864
+ chainId: selectedToken.chainId || 0,
775
865
  }
776
866
  : null,
777
- isCustomToken,
778
- toToken,
779
867
  recipient,
780
868
  conditions: {
781
869
  hasAccount: !!account,
@@ -861,8 +949,8 @@ export function useSendForm({
861
949
  setError(null)
862
950
  setQuoteError(null)
863
951
 
864
- const sourceTokenDecimals = selectedToken.contractInfo?.decimals
865
- const destinationTokenDecimals = selectedDestToken.decimals
952
+ const sourceTokenDecimals = selectedToken.decimals || 18
953
+ const destinationTokenDecimals = selectedDestToken.decimals || 18
866
954
 
867
955
  if (!sourceTokenDecimals || !destinationTokenDecimals) {
868
956
  logger.console.warn("[trails-sdk] Missing token decimals for quote", {
@@ -879,7 +967,7 @@ export function useSendForm({
879
967
  return
880
968
  }
881
969
 
882
- let sourceTokenPriceUsd = selectedToken.tokenPriceUsd ?? null
970
+ let sourceTokenPriceUsd = selectedToken.priceUsd ?? null
883
971
  let destinationTokenPriceUsd = destTokenPrices?.[0]?.priceUsd ?? null
884
972
 
885
973
  if (!sourceTokenPriceUsd) {
@@ -887,7 +975,7 @@ export function useSendForm({
887
975
  const price = await getTokenPrice(trailsClient, {
888
976
  tokenAddress: selectedToken.contractAddress,
889
977
  tokenSymbol: selectedToken.symbol,
890
- chainId: selectedToken.chainId,
978
+ chainId: selectedToken.chainId || 0,
891
979
  })
892
980
  sourceTokenPriceUsd = price?.priceUsd ?? null
893
981
  } catch (error) {
@@ -941,12 +1029,12 @@ export function useSendForm({
941
1029
  ) {
942
1030
  nativeTokenPriceUsd = sourceTokenPriceUsd
943
1031
  } else {
944
- const originChain = getChainInfo(selectedToken.chainId)
1032
+ const originChain = getChainInfo(selectedToken.chainId || 0)
945
1033
  const nativeTokenSymbol = originChain?.nativeCurrency?.symbol ?? ""
946
1034
  const nativePrice = await getTokenPrice(trailsClient, {
947
1035
  tokenSymbol: nativeTokenSymbol,
948
1036
  tokenAddress: zeroAddress,
949
- chainId: selectedToken.chainId,
1037
+ chainId: selectedToken.chainId || 0,
950
1038
  })
951
1039
  nativeTokenPriceUsd = nativePrice?.priceUsd ?? 0
952
1040
  }
@@ -954,14 +1042,11 @@ export function useSendForm({
954
1042
  const options = {
955
1043
  account,
956
1044
  originTokenAddress: selectedToken.contractAddress,
957
- originChainId: selectedToken.chainId,
1045
+ originChainId: selectedToken.chainId || 0,
958
1046
  originTokenBalance:
959
1047
  fundMethod === "qr-code" || fundMethod === "exchange"
960
- ? parseUnits(
961
- "100",
962
- selectedToken.contractInfo?.decimals ?? 18,
963
- ).toString() // needs to be an amount that is greater than the minimum amount for the swap
964
- : selectedToken.balance,
1048
+ ? parseUnits("100", selectedToken.decimals ?? 18).toString() // needs to be an amount that is greater than the minimum amount for the swap
1049
+ : selectedToken.balance || "0",
965
1050
  destinationChainId: selectedDestinationChain.id,
966
1051
  recipient,
967
1052
  destinationTokenAddress,
@@ -982,7 +1067,8 @@ export function useSendForm({
982
1067
  destinationTokenDecimals,
983
1068
  paymasterUrl:
984
1069
  paymasterUrls?.find(
985
- (p) => p.chainId.toString() === selectedToken.chainId.toString(),
1070
+ (p) =>
1071
+ p.chainId.toString() === (selectedToken.chainId || 0).toString(),
986
1072
  )?.url ?? undefined,
987
1073
  originNativeTokenPriceUsd: nativeTokenPriceUsd,
988
1074
  quoteProvider: effectiveQuoteProvider,
@@ -996,6 +1082,8 @@ export function useSendForm({
996
1082
  originPublicClient: originChainPublicClient ?? undefined,
997
1083
  destinationPublicClient: destinationChainPublicClient ?? undefined,
998
1084
  isSmartWallet,
1085
+ trailsApiKey,
1086
+ trailsApiUrl: trailsConfig.trailsApiUrl,
999
1087
  }
1000
1088
 
1001
1089
  logger.console.log(
@@ -1061,15 +1149,13 @@ export function useSendForm({
1061
1149
  recipient,
1062
1150
  destinationTokenAddress,
1063
1151
  destinationTokenAddressFromTokenSymbol,
1064
- isCustomToken,
1065
- toToken,
1066
1152
  sequenceIndexerUrl,
1067
1153
  selectedDestToken?.symbol,
1068
1154
  selectedDestinationChain?.id,
1069
1155
  selectedToken?.contractAddress,
1070
1156
  selectedToken?.chainId,
1071
1157
  selectedToken?.balance,
1072
- selectedToken?.tokenPriceUsd,
1158
+ selectedToken?.priceUsd,
1073
1159
  toCalldata,
1074
1160
  refundAddress,
1075
1161
  paymasterUrls,
@@ -1091,6 +1177,7 @@ export function useSendForm({
1091
1177
  originChainPublicClient,
1092
1178
  destinationChainPublicClient,
1093
1179
  isSmartWallet,
1180
+ trailsConfig.trailsApiUrl,
1094
1181
  ])
1095
1182
 
1096
1183
  // Auto-fetch quotes when inputs change (debounced)
@@ -1107,6 +1194,36 @@ export function useSendForm({
1107
1194
  const isSenderSameAsRecipient =
1108
1195
  account?.address?.toLowerCase() === recipient?.toLowerCase()
1109
1196
 
1197
+ const conditions = {
1198
+ hasAmount: !!amount,
1199
+ amountNotZero: amount !== "0",
1200
+ hasDestinationTokenAddress: !!destinationTokenAddress,
1201
+ isValidRecipient,
1202
+ hasSelectedDestTokenSymbol: !!selectedDestToken?.symbol,
1203
+ hasSelectedDestinationChain: !!selectedDestinationChain?.id,
1204
+ hasSelectedToken: !!selectedToken,
1205
+ isSameToken,
1206
+ isSenderSameAsRecipient,
1207
+ mode,
1208
+ }
1209
+
1210
+ logger.console.log(
1211
+ "[trails-sdk] [CUSTOM-TOKEN] Quote trigger conditions check:",
1212
+ {
1213
+ ...conditions,
1214
+ selectedDestToken: selectedDestToken
1215
+ ? {
1216
+ symbol: selectedDestToken.symbol,
1217
+ decimals: selectedDestToken.decimals,
1218
+ contractAddress: selectedDestToken.contractAddress,
1219
+ }
1220
+ : null,
1221
+ destinationTokenAddress,
1222
+ amount,
1223
+ recipient,
1224
+ },
1225
+ )
1226
+
1110
1227
  if (
1111
1228
  !amount ||
1112
1229
  amount === "0" ||
@@ -1119,6 +1236,24 @@ export function useSendForm({
1119
1236
  isSenderSameAsRecipient &&
1120
1237
  (mode === "swap" || mode === "fund"))
1121
1238
  ) {
1239
+ logger.console.log(
1240
+ "[trails-sdk] [CUSTOM-TOKEN] Quote blocked - missing conditions:",
1241
+ {
1242
+ blockedReasons: {
1243
+ noAmount: !amount || amount === "0",
1244
+ noDestinationTokenAddress: !destinationTokenAddress,
1245
+ invalidRecipient: !isValidRecipient,
1246
+ noSelectedDestTokenSymbol: !selectedDestToken?.symbol,
1247
+ noSelectedDestinationChain: !selectedDestinationChain?.id,
1248
+ noSelectedToken: !selectedToken,
1249
+ sameTokenAndRecipient:
1250
+ isSameToken &&
1251
+ isSenderSameAsRecipient &&
1252
+ (mode === "swap" || mode === "fund"),
1253
+ },
1254
+ conditions,
1255
+ },
1256
+ )
1122
1257
  setPrepareSendResult(null)
1123
1258
  latestResolvedIntentIdRef.current = null
1124
1259
  quoteInputsFingerprintRef.current = null
@@ -1129,9 +1264,19 @@ export function useSendForm({
1129
1264
 
1130
1265
  const nextQuoteInputsFingerprint = buildQuoteInputsFingerprint()
1131
1266
 
1267
+ logger.console.log("[trails-sdk] [CUSTOM-TOKEN] Quote fingerprint check:", {
1268
+ currentFingerprint: quoteInputsFingerprintRef.current,
1269
+ nextFingerprint: nextQuoteInputsFingerprint,
1270
+ willTrigger:
1271
+ quoteInputsFingerprintRef.current !== nextQuoteInputsFingerprint,
1272
+ })
1273
+
1132
1274
  // Fingerprint all quote-driving inputs so we can invalidate debounced quotes immediately when
1133
1275
  // the user switches tokens; this fixes the stale quote so that it stays loading until the new quote is ready.
1134
1276
  if (quoteInputsFingerprintRef.current !== nextQuoteInputsFingerprint) {
1277
+ logger.console.log(
1278
+ "[trails-sdk] [CUSTOM-TOKEN] Quote fingerprint changed, triggering quote fetch",
1279
+ )
1135
1280
  quoteInputsFingerprintRef.current = nextQuoteInputsFingerprint
1136
1281
  latestResolvedIntentIdRef.current = null
1137
1282
  setPrepareSendResult(null)
@@ -1140,6 +1285,9 @@ export function useSendForm({
1140
1285
  }
1141
1286
 
1142
1287
  const timeoutId = setTimeout(() => {
1288
+ logger.console.log(
1289
+ "[trails-sdk] [CUSTOM-TOKEN] Debounce timeout completed, calling getQuote",
1290
+ )
1143
1291
  getQuote()
1144
1292
  }, 500) // Debounce by 500ms
1145
1293
 
@@ -1157,7 +1305,7 @@ export function useSendForm({
1157
1305
  selectedToken?.contractAddress,
1158
1306
  selectedToken?.chainId,
1159
1307
  selectedToken?.balance,
1160
- selectedToken?.tokenPriceUsd,
1308
+ selectedToken?.priceUsd,
1161
1309
  recipient, // Add recipient to trigger quote re-fetch when it changes
1162
1310
  // selectedFeeOption is passed to send() at execution time, not needed here
1163
1311
  buildQuoteInputsFingerprint,
@@ -1190,14 +1338,25 @@ export function useSendForm({
1190
1338
  },
1191
1339
  )
1192
1340
 
1193
- setFeeOptions(
1194
- apiFeeOptions,
1195
- selectedToken?.chainId,
1196
- filteredTokensFormattedRef.current,
1341
+ // Convert Token[] to TokenWithBalance[] for setFeeOptions
1342
+ const tokensWithBalance = filteredTokensFormattedRef.current.map(
1343
+ (token) => ({
1344
+ chainId: token.chainId || 0,
1345
+ contractAddress: token.contractAddress,
1346
+ balance: token.balance,
1347
+ imageUrl: token.imageUrl,
1348
+ }),
1197
1349
  )
1350
+
1351
+ setFeeOptions(apiFeeOptions, selectedToken?.chainId, tokensWithBalance)
1198
1352
  }, [prepareSendResult, selectedToken?.chainId, setFeeOptions])
1199
1353
 
1200
1354
  const processSend = useCallback(async () => {
1355
+ logger.console.log("[trails-sdk] processSend called", {
1356
+ fundMethod,
1357
+ hasOnNavigateToOnramp: !!onNavigateToOnramp,
1358
+ hasPrepareSendResult: !!prepareSendResult,
1359
+ })
1201
1360
  try {
1202
1361
  if (!prepareSendResult) {
1203
1362
  setError("No quote available. Please wait for quote to load.")
@@ -1249,59 +1408,6 @@ export function useSendForm({
1249
1408
  quote,
1250
1409
  )
1251
1410
 
1252
- // Handle exchange fund method - navigate to mesh-connect
1253
- if (fundMethod === "exchange" && onNavigateToMeshConnect) {
1254
- const originChainId = quote?.originChain?.id
1255
- const destinationChainId = quote?.destinationChain?.id
1256
-
1257
- const toTokenSymbol = quote?.originToken?.symbol // MeshConnect will deposit origin token
1258
- const toTokenAmount = normalizeNumber(
1259
- quote.originAmountFormatted,
1260
- ).toString() // MeshConnect will deposit origin token amount
1261
- const toChainId = quote?.originChain?.id // MeshConnect will deposit to origin chain
1262
- const toRecipientAddress = quote.originDepositAddress // MeshConnect will deposit to origin address
1263
-
1264
- logger.console.log(
1265
- "[trails-sdk] Navigating to mesh-connect with props:",
1266
- {
1267
- toTokenSymbol,
1268
- toTokenAmount,
1269
- toChainId,
1270
- toRecipientAddress,
1271
- },
1272
- )
1273
-
1274
- if (originChainId === destinationChainId) {
1275
- throw new Error(
1276
- "[trails-sdk] Must be different chain than the origin chain to use mesh-connect",
1277
- )
1278
- }
1279
-
1280
- if (
1281
- !toTokenSymbol ||
1282
- !toTokenAmount ||
1283
- !toChainId ||
1284
- !toRecipientAddress
1285
- ) {
1286
- throw new Error(
1287
- "[trails-sdk] Missing required props for mesh-connect",
1288
- )
1289
- }
1290
-
1291
- onNavigateToMeshConnect(
1292
- {
1293
- toTokenSymbol,
1294
- toTokenAmount,
1295
- toChainId,
1296
- toRecipientAddress,
1297
- },
1298
- prepareSendResult.quote,
1299
- )
1300
-
1301
- await handleSend()
1302
- return
1303
- }
1304
-
1305
1411
  function onOriginSend() {
1306
1412
  logger.console.log("[trails-sdk] onOriginSend called")
1307
1413
  onConfirm()
@@ -1347,6 +1453,78 @@ export function useSendForm({
1347
1453
  })
1348
1454
  }
1349
1455
 
1456
+ // Handle exchange fund method - navigate to onramp
1457
+ if (fundMethod === "exchange" && onNavigateToOnramp) {
1458
+ logger.console.log(
1459
+ "[trails-sdk] Exchange fund method detected, navigating to onramp",
1460
+ {
1461
+ fundMethod,
1462
+ hasOnNavigateToOnramp: !!onNavigateToOnramp,
1463
+ quote: !!quote,
1464
+ },
1465
+ )
1466
+
1467
+ const originChainId = quote?.originChain?.id
1468
+ const destinationChainId = quote?.destinationChain?.id
1469
+
1470
+ const toTokenSymbol = quote?.originToken?.symbol // Onramp will deposit origin token
1471
+ const toTokenAmount = normalizeNumber(
1472
+ quote.originAmountFormatted,
1473
+ ).toString() // Onramp will deposit origin token amount
1474
+ const toChainId = quote?.originChain?.id // Onramp will deposit to origin chain
1475
+ const toRecipientAddress = quote.originDepositAddress // Onramp will deposit to origin address
1476
+
1477
+ logger.console.log("[trails-sdk] Navigating to onramp with props:", {
1478
+ toTokenSymbol,
1479
+ toTokenAmount,
1480
+ toChainId,
1481
+ toRecipientAddress,
1482
+ originChainId,
1483
+ destinationChainId,
1484
+ })
1485
+
1486
+ // Onramp can be used for both same-chain and cross-chain transfers
1487
+ // It deposits funds to the origin deposit address, which works for both scenarios
1488
+ // No need to restrict to cross-chain only
1489
+
1490
+ if (
1491
+ !toTokenSymbol ||
1492
+ !toTokenAmount ||
1493
+ !toChainId ||
1494
+ !toRecipientAddress
1495
+ ) {
1496
+ throw new Error("[trails-sdk] Missing required props for onramp")
1497
+ }
1498
+
1499
+ // Store handleSend to be called after onramp completes
1500
+ onNavigateToOnramp(
1501
+ {
1502
+ toTokenSymbol,
1503
+ toTokenAmount,
1504
+ toChainId,
1505
+ toRecipientAddress,
1506
+ },
1507
+ prepareSendResult.quote,
1508
+ handleSend, // Pass handleSend callback to be called after onramp completes
1509
+ )
1510
+
1511
+ // Don't call handleSend here - it will be called after onramp completes
1512
+ setIsSubmitting(false)
1513
+ setIsWaitingForWalletConfirm(false)
1514
+ return
1515
+ }
1516
+
1517
+ // Log if exchange method was expected but not handled
1518
+ if (fundMethod === "exchange") {
1519
+ logger.console.error(
1520
+ "[trails-sdk] Exchange fund method detected but onNavigateToOnramp is not available",
1521
+ {
1522
+ fundMethod,
1523
+ hasOnNavigateToOnramp: !!onNavigateToOnramp,
1524
+ },
1525
+ )
1526
+ }
1527
+
1350
1528
  async function walletConfirmRetryHandler() {
1351
1529
  logger.console.log("[trails-sdk] walletConfirmRetryHandler called")
1352
1530
  try {
@@ -1393,7 +1571,7 @@ export function useSendForm({
1393
1571
  recipient,
1394
1572
  onError,
1395
1573
  fundMethod,
1396
- onNavigateToMeshConnect,
1574
+ onNavigateToOnramp,
1397
1575
  selectedFeeOption, // Include so handleSend captures latest value
1398
1576
  buildQuoteInputsFingerprint,
1399
1577
  ])
@@ -1465,8 +1643,6 @@ export function useSendForm({
1465
1643
  return `Swap`
1466
1644
  } else if (mode === "earn") {
1467
1645
  return `Deposit`
1468
- } else if (mode === "receive") {
1469
- return `Pay`
1470
1646
  } else {
1471
1647
  return `Continue on wallet`
1472
1648
  }