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,2331 +0,0 @@
1
- import { ArrowLeftRight } from "lucide-react"
2
- import type React from "react"
3
- import { useCallback, useEffect, useMemo, useRef, useState } from "react"
4
- import { trackOnrampWidgetSession } from "../../analytics.js"
5
- import { isPositiveNumber, toSafeNumber } from "../../utils/validation.js"
6
- import { getChainInfo } from "../../chains.js"
7
- import { FIAT_CURRENCY_SYMBOLS, USDC_BASE } from "../../constants.js"
8
- import { getFullErrorMessage, getPrettifiedErrorMessage } from "../../error.js"
9
- import { logger } from "../../logger.js"
10
- import { MeldProvidersList } from "../../meld/components/MeldProvidersList.js"
11
- import { TradeType } from "../../prepareSend.js"
12
- import {
13
- formatUsdAmountDisplay,
14
- formatUsdAmountLocaleDisplay,
15
- } from "../../utils/format.js"
16
- import { useSupportedTokens, type Token } from "../../tokens.js"
17
- import type { FundMethod } from "../../transactionIntent/types.js"
18
- import { isPassthroughEligible } from "../../utils/passthrough.js"
19
- import { useWidgetProps } from "../hooks/useWidgetProps.js"
20
- import type { Screen } from "../hooks/useViewManager.js"
21
- import { useViewManager } from "../hooks/useViewManager.js"
22
- import { useDefaultDestinationToken } from "../hooks/useDefaultDestinationToken.js"
23
- import { useDefaultOriginToken } from "../hooks/useDefaultOriginToken.js"
24
- import { useDestinationSelectedToken } from "../hooks/useDestinationSelectedToken.js"
25
- import { useExchangeRate } from "../../query/fiat.hooks.js"
26
- import { useFiatOnRampCurrencies } from "../hooks/useFiatOnRampCurrencies.js"
27
- import { useFiatSelectedCurrency } from "../hooks/useFiatSelectedCurrency.js"
28
- import { useOnRampCountryDefaults } from "../hooks/useOnRampCountryDefaults.js"
29
- import { useOnRampProviderWidget } from "../hooks/useOnRampProviderWidget.js"
30
- import type { OnrampQuote } from "../hooks/useOnRampQuote.js"
31
- import { useOnRampQuote } from "../hooks/useOnRampQuote.js"
32
- import { useOriginSelectedToken } from "../hooks/useOriginSelectedToken.js"
33
- import type { ProcessedFeeOption } from "../hooks/useSelectedFeeOption.js"
34
- import { useSelectedFundMethod } from "../hooks/useSelectedFundMethod.js"
35
- import { useSelectedRecipient } from "../hooks/useSelectedRecipient.js"
36
- import { useSendForm } from "../hooks/useSendForm.js"
37
- import { useSwapState } from "../hooks/useSwapState.js"
38
- import { useTokenWithFreshBalance } from "../hooks/useTokenWithFreshBalance.js"
39
- import type { BaseProps, OnrampConfirmCallback } from "../types/commonProps.js"
40
- import { isWithinCooldown, SECOND_MS } from "../../utils/time.js"
41
- import { forexRateStore } from "../utils/forexRateStore.js"
42
- import { openPopup, setPopupUrl, closePopup } from "../utils/windowUtils.js"
43
- import { ChainList } from "./ChainList.js"
44
- import { DynamicSizeInputField } from "./DynamicSizeInputField.js"
45
- import { ErrorDisplay } from "./ErrorDisplay.js"
46
- import { isFeeOptionDisabled } from "./FeeOption.js"
47
- import { FeeOptions } from "./FeeOptions.js"
48
- import { FiatSelector } from "./FiatSelector.js"
49
- import { FiatSelectorButton } from "./FiatSelectorButton.js"
50
- import { OnRampProviderSelector } from "./OnRampProviderSelector.js"
51
- import { PercentageMaxButtons } from "./PercentageMaxButtons.js"
52
- import { QuoteDetails } from "./QuoteDetails.js"
53
- import { RecipientSelectorButton } from "./RecipientSelectorButton.js"
54
- import { RefundWarning } from "./RefundWarning.js"
55
- import { ScreenHeader } from "./ScreenHeader.js"
56
- import { TokenSelector } from "./TokenSelector.js"
57
- import { TokenSelectorButton } from "./TokenSelectorButton.js"
58
- import LoadingSpinner from "./LoadingSpinner.js"
59
-
60
- import { addressEqual } from "../../utils/address.js"
61
- interface FundProps extends BaseProps {
62
- onWaitingForOnrampConfirm?: OnrampConfirmCallback
63
- title?: string
64
- exactInputOnly?: boolean
65
- onrampPropsCallback?: (props: any) => void
66
- screenNavigationCallback?: (screen: Screen) => void
67
- /** Default input mode: "fiat" starts with USD input, "token" starts with token input */
68
- defaultInputMode?: "fiat" | "token"
69
- }
70
-
71
- const Fund: React.FC<FundProps> = ({
72
- selectedToken: initialSelectedToken,
73
- onSend,
74
- onConfirm,
75
- onComplete,
76
- account,
77
- toRecipient,
78
- toAmount,
79
- toChainId,
80
- toToken,
81
- toCalldata,
82
- walletClient,
83
- onTransactionStateChange,
84
- onError,
85
- onWaitingForWalletConfirm,
86
- onrampPropsCallback,
87
- screenNavigationCallback,
88
- onWaitingForOnrampConfirm,
89
- paymasterUrls,
90
- setWalletConfirmRetryHandler,
91
- swapProvider,
92
- bridgeProvider,
93
- swapProviderFallback,
94
- bridgeProviderFallback,
95
- fundMethod,
96
- onAmountUpdate,
97
- checkoutOnHandlers,
98
- recentTokens,
99
- onTrackToken,
100
- isSequenceWallet = false,
101
- exactInputOnly = true, // Fund mode is always exact input only
102
- defaultInputMode,
103
- }) => {
104
- const { mode, navigate } = useViewManager()
105
- const { fundOptions } = useWidgetProps()
106
- const {
107
- selectedToken: originToken,
108
- setSelectedToken: setOriginToken,
109
- hasManualSelection: hasManualOriginSelection,
110
- setHasManualSelection: setHasManualOriginSelection,
111
- } = useOriginSelectedToken()
112
- const {
113
- selectedToken: destinationToken,
114
- setSelectedToken: setDestinationToken,
115
- hasManualSelection: hasManualDestinationSelection,
116
- setHasManualSelection: setHasManualDestinationSelection,
117
- isControlledByProps: isDestinationControlledByProps,
118
- } = useDestinationSelectedToken()
119
- const { paymentMethod } = useSelectedFundMethod()
120
-
121
- // Check if fee options will be shown (not needed for onramp/direct-transfer modes)
122
- const skipFeeBalanceFetch =
123
- fundMethod === "onramp-meld" ||
124
- fundMethod === "direct-transfer" ||
125
- fundMethod === "onramp-mesh"
126
-
127
- // Get origin token with fresh balance for fee option checks
128
- // Skip fetching if fee options won't be shown
129
- const {
130
- token: freshOriginToken,
131
- isLoadingBalance: isLoadingFreshOriginBalance,
132
- } = useTokenWithFreshBalance(
133
- originToken,
134
- account?.address,
135
- skipFeeBalanceFetch,
136
- )
137
-
138
- const { selectedRecipient, setSelectedRecipient } = useSelectedRecipient()
139
- const {
140
- selectedCurrency: selectedFiatCurrency,
141
- setSelectedCurrency: setSelectedFiatCurrency,
142
- hasManualSelection: hasManualFiatSelection,
143
- setHasManualSelection: setHasManualFiatSelection,
144
- fiatAmount: sellFiatAmount,
145
- setFiatAmount: setSellFiatAmount,
146
- } = useFiatSelectedCurrency()
147
- const [showFiatSelector, setShowFiatSelector] = useState(false)
148
- const [selectedCountryCode, setSelectedCountryCode] = useState<string | null>(
149
- null,
150
- )
151
- const [showProviderSelector, setShowProviderSelector] = useState(false)
152
- const [selectedOnrampProvider, setSelectedOnrampProvider] =
153
- useState<OnrampQuote | null>(null)
154
-
155
- // Add debounced state for Meld quote fetching
156
- const [debouncedSellFiatAmount, setDebouncedSellFiatAmount] =
157
- useState(sellFiatAmount)
158
- const debounceTimerRef = useRef<NodeJS.Timeout | null>(null)
159
-
160
- // Check if onramp is active
161
- const isMeldOnRampActive = fundMethod === "onramp-meld"
162
-
163
- // Derive the origin token for useSendForm at render time.
164
- // When onramp is active the origin is always USDC on Base (what the
165
- // onramp provider delivers). We derive this instead of relying on the
166
- // useEffect below because the effect runs *after* render, leaving
167
- // originToken null on the first pass and preventing the quote from firing.
168
- const effectiveOriginToken = isMeldOnRampActive ? USDC_BASE : originToken
169
-
170
- // Unified state for tracking USD display mode (works for both token and fiat)
171
- // In onramp mode, always default to the selected fiat currency (not USD/$)
172
- const [isEnteringFiat, setIsEnteringFiat] = useState(
173
- !isMeldOnRampActive && defaultInputMode === "fiat",
174
- )
175
- // Separate state for display value to handle USD toggle properly
176
- const [inputDisplayValue, setInputDisplayValue] = useState("")
177
- const lastInputModeRef = useRef(false)
178
- // Track if user is actively typing to prevent conversion loops
179
- const [isUserTyping, setIsUserTyping] = useState(false)
180
- const typingTimeoutRef = useRef<NodeJS.Timeout | null>(null)
181
-
182
- // Get country defaults when onramp is active
183
- const {
184
- countryCode: detectedCountryCode,
185
- defaultCurrencyCode,
186
- isLoading: isLoadingCountryDefaults,
187
- } = useOnRampCountryDefaults({
188
- enabled: isMeldOnRampActive,
189
- })
190
-
191
- // Use selected country if available, otherwise use detected country
192
- const effectiveCountryCode = selectedCountryCode || detectedCountryCode
193
-
194
- // Fetch fiat currencies when onramp is active
195
- const { fiatCurrencies, isLoading: isLoadingFiatCurrencies } =
196
- useFiatOnRampCurrencies({
197
- countryCode: effectiveCountryCode || "US",
198
- enabled: isMeldOnRampActive && !!effectiveCountryCode,
199
- })
200
-
201
- // Auto-select default currency when onramp is active: use location-based currency first,
202
- // only fall back to USD when location fetch is done and no default currency was returned
203
- useEffect(() => {
204
- if (
205
- isMeldOnRampActive &&
206
- !selectedFiatCurrency &&
207
- fiatCurrencies.length > 0 &&
208
- !isLoadingCountryDefaults &&
209
- !isLoadingFiatCurrencies &&
210
- !hasManualFiatSelection
211
- ) {
212
- // Prefer location-based currency; only then fall back to USD
213
- const currencyCodeToSelect = defaultCurrencyCode ?? "USD"
214
-
215
- const defaultCurrency = fiatCurrencies.find(
216
- (currency) => currency.currencyCode === currencyCodeToSelect,
217
- )
218
-
219
- if (defaultCurrency) {
220
- logger.console.log(
221
- "[Fund] Auto-selecting default currency:",
222
- defaultCurrency,
223
- defaultCurrencyCode
224
- ? "(from location)"
225
- : "(fallback to USD - location not available)",
226
- )
227
- setSelectedFiatCurrency(defaultCurrency)
228
- }
229
- }
230
- }, [
231
- isMeldOnRampActive,
232
- selectedFiatCurrency,
233
- defaultCurrencyCode,
234
- fiatCurrencies,
235
- isLoadingCountryDefaults,
236
- isLoadingFiatCurrencies,
237
- hasManualFiatSelection,
238
- setSelectedFiatCurrency,
239
- ])
240
-
241
- const lastAppliedConfiguredFiatRef = useRef<string | null>(null)
242
- useEffect(() => {
243
- if (!isMeldOnRampActive) {
244
- lastAppliedConfiguredFiatRef.current = null
245
- }
246
- }, [isMeldOnRampActive])
247
-
248
- useEffect(() => {
249
- if (!isMeldOnRampActive || isLoadingFiatCurrencies) return
250
- if (fiatCurrencies.length === 0) return
251
- const configuredFiatCurrency = fundOptions?.fiatCurrency?.trim() || ""
252
- const configuredFiatAmount = fundOptions?.fiatAmount?.trim() || ""
253
- const configKey = `${configuredFiatCurrency.toUpperCase()}|${configuredFiatAmount}`
254
- if (lastAppliedConfiguredFiatRef.current === configKey) return
255
- lastAppliedConfiguredFiatRef.current = configKey
256
-
257
- if (configuredFiatCurrency) {
258
- const match = fiatCurrencies.find(
259
- (c) =>
260
- c.currencyCode.toUpperCase() === configuredFiatCurrency.toUpperCase(),
261
- )
262
- if (match) {
263
- setSelectedFiatCurrency(match)
264
- setHasManualFiatSelection(true)
265
- }
266
- }
267
-
268
- if (configuredFiatAmount) {
269
- setSellFiatAmount(configuredFiatAmount)
270
- setInputDisplayValue(configuredFiatAmount)
271
- }
272
- }, [
273
- isMeldOnRampActive,
274
- isLoadingFiatCurrencies,
275
- fiatCurrencies,
276
- fundOptions?.fiatCurrency,
277
- fundOptions?.fiatAmount,
278
- setSelectedFiatCurrency,
279
- setHasManualFiatSelection,
280
- setSellFiatAmount,
281
- ])
282
-
283
- const normalizedConfiguredFiatCurrency =
284
- fundOptions?.fiatCurrency?.trim().toUpperCase() || null
285
- const isConfiguredFiatCurrencyApplied =
286
- !!normalizedConfiguredFiatCurrency &&
287
- !!selectedFiatCurrency &&
288
- selectedFiatCurrency.currencyCode.toUpperCase() ===
289
- normalizedConfiguredFiatCurrency
290
- const isFiatCurrencyLocked =
291
- isMeldOnRampActive && isConfiguredFiatCurrencyApplied
292
- const isFiatAmountLocked = isMeldOnRampActive && !!fundOptions?.fiatAmount
293
-
294
- // Use a ref to track user actions to prevent race conditions with async state updates
295
- const userActionRef = useRef({
296
- hasManualDestinationSelection: false,
297
- lastOriginSelectionTime: 0,
298
- lastDestinationSelectionTime: 0,
299
- })
300
-
301
- // Use separated default token selection hooks
302
- const { defaultOriginToken, isLoading: isLoadingOriginDefaults } =
303
- useDefaultOriginToken()
304
-
305
- const { defaultDestinationToken, isLoading: isLoadingDestinationDefaults } =
306
- useDefaultDestinationToken(originToken)
307
-
308
- const originChainId =
309
- effectiveOriginToken?.chainId ?? initialSelectedToken?.chainId ?? null
310
- const {
311
- tradeType: globalTradeType,
312
- setTradeType,
313
- sellAmount,
314
- setSellAmount,
315
- buyAmount,
316
- setBuyAmount,
317
- enterFormMode,
318
- } = useSwapState()
319
-
320
- // Determine the form mode based on fund method
321
- const currentFormMode = useMemo(() => {
322
- if (fundMethod === "onramp-meld") return "fund-onramp-meld" as const
323
- if (fundMethod === "onramp-mesh") return "fund-onramp-mesh" as const
324
- if (fundMethod === "direct-transfer") return "fund-direct-transfer" as const
325
- return "fund-wallet" as const
326
- }, [fundMethod])
327
-
328
- // Reset swap state only when switching between different form modes
329
- // biome-ignore lint/correctness/useExhaustiveDependencies: Stable setters, only react to currentFormMode changes
330
- useEffect(() => {
331
- const didReset = enterFormMode(currentFormMode)
332
- if (didReset) {
333
- // Also clear fiat amount and display value when mode changes
334
- setSellFiatAmount("")
335
- setInputDisplayValue("")
336
- }
337
- }, [currentFormMode])
338
-
339
- // Initialize input display value from cached amounts on mount
340
- // This ensures the display syncs with context values when returning from settings/history etc
341
- // biome-ignore lint/correctness/useExhaustiveDependencies: Only run on mount to initialize display
342
- useEffect(() => {
343
- if (isMeldOnRampActive && sellFiatAmount) {
344
- setInputDisplayValue(sellFiatAmount)
345
- } else if (!isMeldOnRampActive && sellAmount) {
346
- setInputDisplayValue(sellAmount)
347
- }
348
- }, [])
349
-
350
- const tradeType = globalTradeType || TradeType.EXACT_INPUT
351
- const [isCreatingWidgetSession, setIsCreatingWidgetSession] = useState(false)
352
- const [widgetError, setWidgetError] = useState<string | null>(null)
353
-
354
- // Initialize and update selected recipient from toRecipient prop (but don't auto-set to account address)
355
- // biome-ignore lint/correctness/useExhaustiveDependencies: selectedRecipient is intentionally excluded to avoid infinite loops
356
- useEffect(() => {
357
- logger.console.log("[trails-sdk] Fund toRecipient prop effect:", {
358
- toRecipient,
359
- selectedRecipient,
360
- accountAddress: account?.address,
361
- })
362
-
363
- if (toRecipient) {
364
- // Always sync with toRecipient prop when it changes
365
- logger.console.log(
366
- "[trails-sdk] Fund Setting selectedRecipient to toRecipient:",
367
- toRecipient,
368
- )
369
- setSelectedRecipient(toRecipient)
370
- }
371
- // Don't auto-set to account.address - let user select via RecipientSelectorButton
372
- }, [toRecipient, setSelectedRecipient])
373
-
374
- // Calculate effective recipient for useSendForm (same pattern as Pay.tsx)
375
- // Use selectedRecipient if set, otherwise toRecipient prop, otherwise account address as fallback
376
- const effectiveRecipient =
377
- selectedRecipient || toRecipient || account?.address
378
-
379
- const effectiveFundMethod: FundMethod | undefined = isMeldOnRampActive
380
- ? "onramp-meld"
381
- : (fundMethod as FundMethod | undefined)
382
-
383
- // Add debounce effect for sellFiatAmount
384
- useEffect(() => {
385
- // Clear existing timer
386
- if (debounceTimerRef.current) {
387
- clearTimeout(debounceTimerRef.current)
388
- }
389
-
390
- // Set new timer for 500ms debounce
391
- debounceTimerRef.current = setTimeout(() => {
392
- setDebouncedSellFiatAmount(sellFiatAmount)
393
- }, 500)
394
-
395
- // Cleanup on unmount or when sellFiatAmount changes
396
- return () => {
397
- if (debounceTimerRef.current) {
398
- clearTimeout(debounceTimerRef.current)
399
- }
400
- }
401
- }, [sellFiatAmount])
402
-
403
- // Get onramp quote when onramp is active (using debounced amount)
404
- const {
405
- quotes: onrampQuotes,
406
- selectedQuote: autoSelectedOnrampQuote,
407
- isLoading: isLoadingOnrampQuote,
408
- error: onrampQuoteError,
409
- onrampTrackingData,
410
- } = useOnRampQuote({
411
- amount: debouncedSellFiatAmount,
412
- sourceCurrencyCode: selectedFiatCurrency?.currencyCode,
413
- destinationCurrencyCode: "USDC_BASE",
414
- countryCode: effectiveCountryCode || undefined,
415
- walletAddress: account?.address || "",
416
- paymentMethodType: paymentMethod?.id,
417
- enabled:
418
- isMeldOnRampActive &&
419
- !!debouncedSellFiatAmount &&
420
- !!selectedFiatCurrency &&
421
- !!effectiveCountryCode &&
422
- !!effectiveRecipient,
423
- })
424
-
425
- const {
426
- amount,
427
- amountRaw,
428
- balanceFormatted,
429
- balanceRaw,
430
- tokenDecimals,
431
- balanceLocaleDisplay,
432
- balanceUsdDisplay,
433
- balanceUsdLocaleDisplay,
434
- handleSubmit,
435
- isSubmitting,
436
- isLoadingQuote,
437
- selectedDestToken,
438
- setSelectedDestinationChain,
439
- setSelectedDestToken,
440
- buttonText,
441
- destinationTokenAddress,
442
- isValidCustomToken,
443
- prepareSendQuote,
444
- processedFeeOptions,
445
- selectedFeeOption,
446
- setSelectedFeeOption,
447
- sendFn,
448
- sourceTokenPrices,
449
- } = useSendForm({
450
- account,
451
- toAmount: tradeType === TradeType.EXACT_OUTPUT ? buyAmount : toAmount,
452
- fromAmount: tradeType === TradeType.EXACT_INPUT ? sellAmount : undefined,
453
- toRecipient: effectiveRecipient,
454
- toChainId,
455
- toToken,
456
- toCalldata,
457
- walletClient,
458
- onTransactionStateChange,
459
- onError,
460
- onWaitingForWalletConfirm,
461
- onWaitingForOnrampConfirm,
462
- paymasterUrls,
463
- onSend,
464
- onConfirm,
465
- onComplete,
466
- selectedToken: effectiveOriginToken as any,
467
- setWalletConfirmRetryHandler,
468
- tradeType: tradeType,
469
- swapProvider,
470
- bridgeProvider,
471
- swapProviderFallback,
472
- bridgeProviderFallback,
473
- fundMethod: effectiveFundMethod,
474
- mode,
475
- checkoutOnHandlers,
476
- onrampTrackingData: isMeldOnRampActive ? onrampTrackingData : null,
477
- // Skip fee balance fetching for onramp/direct-transfer modes where fee options aren't shown
478
- skipFeeBalanceFetch:
479
- effectiveFundMethod === "onramp-meld" ||
480
- effectiveFundMethod === "direct-transfer" ||
481
- effectiveFundMethod === "onramp-mesh",
482
- onNavigateToOnrampMesh:
483
- onrampPropsCallback && screenNavigationCallback
484
- ? (props) => {
485
- // Set the onramp props and navigate to onramp-mesh screen
486
- onrampPropsCallback(props)
487
- screenNavigationCallback("onramp-mesh")
488
- }
489
- : undefined,
490
- })
491
-
492
- const selectedOnrampProviderQuote =
493
- selectedOnrampProvider || autoSelectedOnrampQuote
494
-
495
- const shouldValidateFeeOption =
496
- fundMethod !== "direct-transfer" && fundMethod !== "onramp-mesh"
497
-
498
- const isAwaitingTrailsQuote =
499
- isMeldOnRampActive && !!selectedOnrampProviderQuote && !prepareSendQuote
500
-
501
- // Get exchange rate for fiat to USD conversion
502
- // Use the selected fiat currency for real-time conversion as user types
503
- const {
504
- exchangeRate: fiatToUsdExchangeRate,
505
- isLoading: isLoadingFiatToUsdExchangeRate,
506
- } = useExchangeRate({
507
- fromCurrency: "USD",
508
- toCurrency:
509
- isMeldOnRampActive && selectedFiatCurrency?.currencyCode
510
- ? selectedFiatCurrency.currencyCode
511
- : "USD",
512
- disabled:
513
- !isMeldOnRampActive ||
514
- !selectedFiatCurrency ||
515
- selectedFiatCurrency?.currencyCode === "USD",
516
- })
517
-
518
- // Sync input display with cached values when switching to/from onramp mode
519
- const lastOnrampModeRef = useRef(isMeldOnRampActive)
520
-
521
- useEffect(() => {
522
- // Only sync when mode actually changes
523
- if (lastOnrampModeRef.current !== isMeldOnRampActive) {
524
- lastOnrampModeRef.current = isMeldOnRampActive
525
-
526
- if (isMeldOnRampActive && sellFiatAmount) {
527
- // When switching to onramp mode, sync with cached fiat amount
528
- setInputDisplayValue(sellFiatAmount)
529
- } else if (!isMeldOnRampActive && sellAmount) {
530
- // When switching from onramp mode, sync with cached token amount
531
- setInputDisplayValue(sellAmount)
532
- } else {
533
- // Clear input if no cached value for the new mode
534
- setInputDisplayValue("")
535
- }
536
- }
537
- }, [isMeldOnRampActive, sellFiatAmount, sellAmount])
538
-
539
- // Get the token price for USD conversions
540
- const tokenPriceUsd = sourceTokenPrices?.[0]?.priceUsd || 0
541
-
542
- // Sync display value ONLY when toggle button is clicked (mode actually changes)
543
- useEffect(() => {
544
- if (lastInputModeRef.current !== isEnteringFiat) {
545
- lastInputModeRef.current = isEnteringFiat
546
-
547
- // Don't do any conversion if user is typing
548
- if (isUserTyping) {
549
- return
550
- }
551
-
552
- if (isMeldOnRampActive && sellFiatAmount) {
553
- // Fiat mode
554
- const fiatAmount = toSafeNumber(sellFiatAmount)
555
- if (fiatAmount > 0) {
556
- // Only update if there's an actual amount
557
- if (isEnteringFiat && fiatToUsdExchangeRate) {
558
- // Switching to USD mode - show USD value
559
- const usdAmount = fiatAmount / fiatToUsdExchangeRate
560
- // Format to 2 decimals and remove unnecessary trailing zeros
561
- const formatted = Number(usdAmount.toFixed(2)).toString()
562
- setInputDisplayValue(formatted)
563
- } else {
564
- // Switching to local currency mode - show fiat value
565
- const formatted = Number(fiatAmount.toFixed(2)).toString()
566
- setInputDisplayValue(formatted)
567
- }
568
- }
569
- } else if (!isMeldOnRampActive && sellAmount) {
570
- // Token mode
571
- const tokenAmount = toSafeNumber(sellAmount)
572
- if (tokenAmount > 0) {
573
- // Only update if there's an actual amount
574
- if (isEnteringFiat && tokenPriceUsd > 0) {
575
- // Switching to fiat mode - show preferred currency value
576
- const usdAmount = tokenAmount * tokenPriceUsd
577
-
578
- // Apply forex rate if available to convert USD to preferred currency
579
- const rateData = forexRateStore.getRate()
580
- const displayValue =
581
- rateData && rateData.currency !== "USD"
582
- ? usdAmount * rateData.rate
583
- : usdAmount
584
-
585
- // Format to 2 decimals and remove unnecessary trailing zeros
586
- const formatted = Number(displayValue.toFixed(2)).toString()
587
- logger.console.log(
588
- "[TRAILS EFFECT] Setting display value in useEffect:",
589
- formatted,
590
- "from USD:",
591
- usdAmount,
592
- "with rate:",
593
- rateData?.rate,
594
- )
595
- setInputDisplayValue(formatted)
596
- } else {
597
- // Show token amount - remove unnecessary trailing zeros
598
- // First round to 8 decimals to avoid floating point issues
599
- const rounded = Math.round(tokenAmount * 100000000) / 100000000
600
- setInputDisplayValue(rounded.toString())
601
- }
602
- }
603
- }
604
- }
605
- }, [
606
- isEnteringFiat,
607
- fiatToUsdExchangeRate,
608
- sellFiatAmount,
609
- sellAmount,
610
- isMeldOnRampActive,
611
- tokenPriceUsd,
612
- isUserTyping,
613
- ])
614
-
615
- // Reset mode only when currency actually changes (but respect defaultInputMode)
616
- const prevFiatCurrencyRef = useRef(selectedFiatCurrency)
617
- useEffect(() => {
618
- // Only reset if currency actually changed (not on initial mount)
619
- if (
620
- selectedFiatCurrency &&
621
- prevFiatCurrencyRef.current !== selectedFiatCurrency
622
- ) {
623
- // Reset to default mode when currency changes
624
- setIsEnteringFiat(defaultInputMode === "fiat")
625
- lastInputModeRef.current = defaultInputMode === "fiat"
626
- }
627
- prevFiatCurrencyRef.current = selectedFiatCurrency
628
- }, [selectedFiatCurrency, defaultInputMode]) // Only reset mode on currency change
629
-
630
- // Update display value when amount changes (but don't reset mode)
631
- useEffect(() => {
632
- if (selectedFiatCurrency && !isUserTyping && !isEnteringFiat) {
633
- // Only update display if not in USD mode and not typing
634
- // Don't update if the user has cleared the input (inputDisplayValue is empty but sellFiatAmount has value)
635
- if (
636
- inputDisplayValue !== "" &&
637
- sellFiatAmount !== "" &&
638
- sellFiatAmount !== undefined &&
639
- sellFiatAmount !== null
640
- ) {
641
- setInputDisplayValue(sellFiatAmount)
642
- }
643
- }
644
- }, [
645
- selectedFiatCurrency,
646
- sellFiatAmount,
647
- isUserTyping,
648
- isEnteringFiat,
649
- inputDisplayValue,
650
- ])
651
-
652
- // Reset mode only when token actually changes (but respect defaultInputMode)
653
- const prevOriginTokenRef = useRef(originToken)
654
- useEffect(() => {
655
- // Only reset if token actually changed (not on initial mount)
656
- if (
657
- originToken &&
658
- !isMeldOnRampActive &&
659
- prevOriginTokenRef.current !== originToken
660
- ) {
661
- // Reset to default mode when token changes
662
- setIsEnteringFiat(defaultInputMode === "fiat")
663
- lastInputModeRef.current = defaultInputMode === "fiat"
664
- }
665
- prevOriginTokenRef.current = originToken
666
- }, [originToken, isMeldOnRampActive, defaultInputMode]) // Only reset mode on token change
667
-
668
- // Update display value when amount changes (but don't reset mode)
669
- useEffect(() => {
670
- if (
671
- originToken &&
672
- !isMeldOnRampActive &&
673
- !isUserTyping &&
674
- !isEnteringFiat
675
- ) {
676
- // Only update display if not in USD mode and not typing
677
- // Don't update if the user has cleared the input (inputDisplayValue is empty but sellAmount has value)
678
- if (
679
- inputDisplayValue !== "" &&
680
- sellAmount !== "" &&
681
- sellAmount !== undefined &&
682
- sellAmount !== null
683
- ) {
684
- setInputDisplayValue(sellAmount)
685
- }
686
- }
687
- }, [
688
- originToken,
689
- isMeldOnRampActive,
690
- sellAmount,
691
- isUserTyping,
692
- isEnteringFiat,
693
- inputDisplayValue,
694
- ])
695
-
696
- // Hook to create onramp widget session
697
- const {
698
- createWidgetSession,
699
- isLoading: isLoadingWidgetSession,
700
- error: widgetSessionError,
701
- } = useOnRampProviderWidget()
702
-
703
- const [showSourceTokenSelector, setShowSourceTokenSelector] = useState(false)
704
- const [showDestinationTokenSelector, setShowDestinationTokenSelector] =
705
- useState(false)
706
-
707
- const { supportedTokens } = useSupportedTokens({
708
- disabled:
709
- !!toToken || showSourceTokenSelector || showDestinationTokenSelector,
710
- })
711
-
712
- // Use a ref to track if we've already auto-selected from toToken prop
713
- const lastAutoSelectedRef = useRef<string | null>(null)
714
-
715
- // Initialize destination token from toToken prop (similar to Pay.tsx)
716
- // This should override any cached/manual selections when toToken is provided
717
- useEffect(() => {
718
- const currentKey = `${toToken}-${toChainId}`
719
-
720
- if (
721
- toToken &&
722
- toChainId &&
723
- supportedTokens?.length > 0 &&
724
- lastAutoSelectedRef.current !== currentKey
725
- ) {
726
- // Find the destination token from props
727
- const destinationToken = supportedTokens?.find(
728
- (token) =>
729
- token.chainId === Number(toChainId) &&
730
- (addressEqual(token.contractAddress, toToken) ||
731
- token.symbol.toLowerCase() === toToken.toLowerCase()),
732
- )
733
-
734
- if (destinationToken) {
735
- logger.console.log(
736
- "[trails-sdk] Fund: Setting destination token from toToken prop:",
737
- destinationToken,
738
- )
739
-
740
- setDestinationToken(destinationToken)
741
- setSelectedDestToken(destinationToken)
742
-
743
- // Set the destination chain
744
- const chainInfo = getChainInfo(Number(toChainId))
745
- if (chainInfo) {
746
- setSelectedDestinationChain(chainInfo)
747
- }
748
-
749
- // Mark this combination as processed
750
- lastAutoSelectedRef.current = currentKey
751
-
752
- // Don't mark as manually selected - this is from props
753
- // This allows the token to be properly set from props without interference
754
- }
755
- } else if (!toToken && hasManualDestinationSelection) {
756
- // Clear manual selection flag when toToken prop is removed
757
- // This allows default selection to work again
758
- setHasManualDestinationSelection(false)
759
- userActionRef.current.hasManualDestinationSelection = false
760
- lastAutoSelectedRef.current = null
761
- }
762
- }, [
763
- toToken,
764
- toChainId,
765
- supportedTokens,
766
- setDestinationToken,
767
- setSelectedDestToken,
768
- setSelectedDestinationChain,
769
- hasManualDestinationSelection,
770
- setHasManualDestinationSelection,
771
- ])
772
-
773
- // Fund mode is always exact input only - enforce this
774
- useEffect(() => {
775
- if (exactInputOnly) {
776
- setTradeType(TradeType.EXACT_INPUT)
777
- setBuyAmount("") // Clear any buy amount
778
- }
779
- }, [exactInputOnly, setTradeType, setBuyAmount])
780
-
781
- // Handle sell amount input changes
782
- const handleSellAmountChange = useCallback(
783
- (value: string) => {
784
- // Don't process single "0" or values starting with "0."
785
- // Only strip leading zeros from values like "00", "01", "005" etc.
786
- let processedValue = value
787
- if (
788
- value !== "0" &&
789
- value.length > 1 &&
790
- value.startsWith("0") &&
791
- value[1] !== "."
792
- ) {
793
- processedValue = value.replace(/^0+/, "") || "0"
794
- }
795
- setTradeType(TradeType.EXACT_INPUT)
796
- setSellAmount(processedValue)
797
- },
798
- [setTradeType, setSellAmount],
799
- )
800
-
801
- // Handle sell input focus
802
- const handleSellInputFocus = useCallback(() => {
803
- // Copy displayed value for editing
804
- if (
805
- tradeType === TradeType.EXACT_OUTPUT &&
806
- prepareSendQuote?.originAmountDisplay &&
807
- !sellAmount
808
- ) {
809
- setSellAmount(prepareSendQuote.originAmountDisplay)
810
- }
811
- }, [
812
- tradeType,
813
- prepareSendQuote?.originAmountDisplay,
814
- sellAmount,
815
- setSellAmount,
816
- ])
817
-
818
- // Check if we received a quote from on ramp for USDC BASE, if so set the origin token amount to the quote.destinationAmount
819
- // This will trigger useSendForm to get the trails quote
820
- // Subtract 0.25 USDC from the amount to cover fees
821
- useEffect(() => {
822
- if (
823
- isMeldOnRampActive &&
824
- selectedOnrampProviderQuote &&
825
- effectiveOriginToken &&
826
- effectiveOriginToken.contractAddress
827
- ) {
828
- // Subtract 0.25 USDC from the destination amount to cover fees
829
- const destinationAmount = Number(
830
- selectedOnrampProviderQuote.destinationAmount,
831
- )
832
- const adjustedAmount = Math.max(0, destinationAmount - 0.25)
833
-
834
- logger.console.log("[trails-sdk] Adjusting onramp amount for fees:", {
835
- originalAmount: destinationAmount,
836
- adjustedAmount,
837
- feeSubtracted: 0.25,
838
- })
839
-
840
- setSellAmount(adjustedAmount.toString())
841
- setTradeType(TradeType.EXACT_INPUT)
842
- }
843
- }, [
844
- isMeldOnRampActive,
845
- selectedOnrampProviderQuote,
846
- effectiveOriginToken,
847
- setSellAmount,
848
- setTradeType,
849
- ])
850
-
851
- // Update amounts when quote is received
852
- // Always update the calculated field based on the current trade type
853
- useEffect(() => {
854
- if (!prepareSendQuote) return
855
-
856
- if (
857
- tradeType === TradeType.EXACT_OUTPUT &&
858
- prepareSendQuote.originAmountDisplay
859
- ) {
860
- // In EXACT_OUTPUT mode, update sellAmount from the quote
861
- setSellAmount(prepareSendQuote.originAmountDisplay)
862
- } else if (
863
- tradeType === TradeType.EXACT_INPUT &&
864
- prepareSendQuote.destinationAmountDisplay
865
- ) {
866
- // In EXACT_INPUT mode, update buyAmount from the quote
867
- setBuyAmount(prepareSendQuote.destinationAmountDisplay)
868
- }
869
- }, [prepareSendQuote, tradeType, setSellAmount, setBuyAmount])
870
-
871
- // Call onAmountUpdate when amountRaw changes
872
- useEffect(() => {
873
- if (onAmountUpdate) {
874
- onAmountUpdate(amountRaw)
875
- }
876
- }, [amountRaw, onAmountUpdate])
877
-
878
- // Reset the flag so auto-selection can work as a fallback if has manual origin token is cleared
879
- useEffect(() => {
880
- if (hasManualOriginSelection && !originToken && !isLoadingOriginDefaults) {
881
- logger.console.log(
882
- "[trails-sdk] Resetting hasManualOriginSelection - token was cleared",
883
- )
884
- setHasManualOriginSelection(false)
885
- }
886
- }, [
887
- hasManualOriginSelection,
888
- originToken,
889
- isLoadingOriginDefaults,
890
- setHasManualOriginSelection,
891
- ])
892
-
893
- // Auto-select origin token using separated hook
894
- useEffect(() => {
895
- if (
896
- !originToken &&
897
- !isLoadingOriginDefaults &&
898
- defaultOriginToken &&
899
- !hasManualOriginSelection
900
- ) {
901
- logger.console.log(
902
- "[trails-sdk] Auto-selecting origin token:",
903
- defaultOriginToken,
904
- )
905
- setOriginToken(defaultOriginToken as any)
906
- }
907
- }, [
908
- originToken,
909
- isLoadingOriginDefaults,
910
- defaultOriginToken,
911
- setOriginToken,
912
- hasManualOriginSelection,
913
- ])
914
-
915
- // Auto-select destination token using separated hook
916
- // IMPORTANT: Only auto-select if user hasn't made manual selections and toToken prop is not provided
917
- useEffect(() => {
918
- // Skip auto-selection if toToken prop is provided
919
- if (toToken) {
920
- return
921
- }
922
-
923
- // hasManualOriginSelection is now persisted in context across component mounts
924
- const hasRecentOriginSelection =
925
- hasManualOriginSelection ||
926
- isWithinCooldown(userActionRef.current.lastOriginSelectionTime, SECOND_MS)
927
-
928
- const hasRecentDestSelection =
929
- userActionRef.current.hasManualDestinationSelection ||
930
- hasManualDestinationSelection ||
931
- isWithinCooldown(
932
- userActionRef.current.lastDestinationSelectionTime,
933
- SECOND_MS,
934
- )
935
-
936
- if (
937
- !destinationToken &&
938
- !isLoadingDestinationDefaults &&
939
- defaultDestinationToken &&
940
- !hasRecentDestSelection &&
941
- !hasRecentOriginSelection // Don't auto-select destination if user recently selected origin
942
- ) {
943
- logger.console.log(
944
- "[trails-sdk] Auto-selecting destination token:",
945
- defaultDestinationToken,
946
- )
947
- setDestinationToken(defaultDestinationToken as any)
948
- setSelectedDestToken(defaultDestinationToken as any)
949
-
950
- // Also set the destination chain
951
- const chainInfo = getChainInfo(defaultDestinationToken.chainId)
952
- if (chainInfo) {
953
- setSelectedDestinationChain(chainInfo)
954
- }
955
- }
956
- }, [
957
- destinationToken,
958
- isLoadingDestinationDefaults,
959
- defaultDestinationToken,
960
- hasManualDestinationSelection,
961
- hasManualOriginSelection,
962
- setDestinationToken,
963
- setSelectedDestToken,
964
- setSelectedDestinationChain,
965
- toToken, // Add toToken as dependency to skip when provided
966
- ])
967
-
968
- // Auto-focus the input field when component mounts
969
- useEffect(() => {
970
- if (inputRef.current) {
971
- inputRef.current.focus()
972
- }
973
- }, [])
974
-
975
- const inputRef = useRef<HTMLInputElement>(null)
976
-
977
- const [showSourceChainList, setShowSourceChainList] = useState(false)
978
- const [showDestinationChainList, setShowDestinationChainList] =
979
- useState(false)
980
-
981
- // Sync destination token from hook with useSendForm
982
- // This ensures the destination token auto-selection flows into useSendForm
983
- useEffect(() => {
984
- if (destinationToken) {
985
- logger.console.log(
986
- "[trails-sdk] Syncing destination token to useSendForm:",
987
- destinationToken,
988
- )
989
- setSelectedDestToken(destinationToken as any)
990
- }
991
- }, [destinationToken, setSelectedDestToken])
992
-
993
- useEffect(() => {
994
- // Skip if not controlled by props or no resolved token
995
- if (!isDestinationControlledByProps || !selectedDestToken || !toToken) {
996
- return
997
- }
998
-
999
- // Check if the resolved token matches what we're looking for
1000
- const chainIdMatches = selectedDestToken.chainId === Number(toChainId)
1001
- const tokenMatches =
1002
- selectedDestToken.contractAddress?.toLowerCase() ===
1003
- toToken.toLowerCase() ||
1004
- selectedDestToken.symbol?.toLowerCase() === toToken.toLowerCase()
1005
-
1006
- // Only sync if the token matches the toToken prop
1007
- if (chainIdMatches && tokenMatches) {
1008
- const globalMatches =
1009
- destinationToken &&
1010
- destinationToken.chainId === selectedDestToken.chainId &&
1011
- destinationToken.contractAddress?.toLowerCase() ===
1012
- selectedDestToken.contractAddress?.toLowerCase()
1013
-
1014
- if (!globalMatches) {
1015
- logger.console.log(
1016
- "[trails-sdk] Fund: Syncing resolved token from useSendForm to global provider:",
1017
- selectedDestToken.symbol,
1018
- )
1019
- setDestinationToken(selectedDestToken)
1020
- }
1021
- }
1022
- }, [
1023
- isDestinationControlledByProps,
1024
- selectedDestToken,
1025
- destinationToken,
1026
- setDestinationToken,
1027
- toToken,
1028
- toChainId,
1029
- ])
1030
-
1031
- // Handle source token selection from full-screen selector
1032
- const handleSourceTokenSelectorSelect = useCallback(
1033
- (token: Token) => {
1034
- // Only reset input fields if switching from one token to a different one
1035
- // Don't reset when selecting a token for the first time (originToken is null)
1036
- const isDifferentToken =
1037
- !!originToken && originToken.symbol !== token.symbol
1038
- if (isDifferentToken) {
1039
- setSellAmount("")
1040
- setBuyAmount("")
1041
- setInputDisplayValue("")
1042
- setTradeType(TradeType.EXACT_INPUT)
1043
- }
1044
-
1045
- setOriginToken(token)
1046
- setShowSourceTokenSelector(false)
1047
-
1048
- // Mark as manual selection to prevent auto-selection override
1049
- setHasManualOriginSelection(true)
1050
- userActionRef.current.lastOriginSelectionTime = Date.now()
1051
-
1052
- onTrackToken?.(token)
1053
- logger.console.log("[trails-sdk] selected origin token", token)
1054
- },
1055
- [
1056
- setOriginToken,
1057
- setHasManualOriginSelection,
1058
- onTrackToken,
1059
- originToken,
1060
- setSellAmount,
1061
- setBuyAmount,
1062
- setTradeType,
1063
- ],
1064
- )
1065
-
1066
- // Handle destination token selection from full-screen selector
1067
- const handleDestinationTokenSelectorSelect = useCallback(
1068
- (token: Token) => {
1069
- setDestinationToken(token)
1070
- setSelectedDestToken(token)
1071
-
1072
- // Update destination chain
1073
- const chainInfo = getChainInfo(token.chainId)
1074
- if (chainInfo) {
1075
- setSelectedDestinationChain(chainInfo)
1076
- }
1077
-
1078
- setShowDestinationTokenSelector(false)
1079
-
1080
- // Mark as manual selection to prevent auto-selection override
1081
- setHasManualDestinationSelection(true)
1082
- userActionRef.current.hasManualDestinationSelection = true
1083
- userActionRef.current.lastDestinationSelectionTime = Date.now()
1084
-
1085
- onTrackToken?.(token)
1086
- logger.console.log("[trails-sdk] selected destination token", token)
1087
- },
1088
- [
1089
- setDestinationToken,
1090
- setSelectedDestToken,
1091
- setSelectedDestinationChain,
1092
- setHasManualDestinationSelection,
1093
- onTrackToken,
1094
- ],
1095
- )
1096
-
1097
- // Handle recent token selection
1098
- const handleRecentTokenSelect = useCallback(
1099
- (token: any) => {
1100
- if (showSourceTokenSelector) {
1101
- handleSourceTokenSelectorSelect(token)
1102
- } else if (showDestinationTokenSelector) {
1103
- handleDestinationTokenSelectorSelect(token)
1104
- }
1105
- },
1106
- [
1107
- showSourceTokenSelector,
1108
- showDestinationTokenSelector,
1109
- handleSourceTokenSelectorSelect,
1110
- handleDestinationTokenSelectorSelect,
1111
- ],
1112
- )
1113
-
1114
- // Show provider selector screen
1115
- if (showProviderSelector) {
1116
- return (
1117
- <MeldProvidersList
1118
- onBack={() => setShowProviderSelector(false)}
1119
- onSelectProvider={(provider) => {
1120
- setSelectedOnrampProvider(provider as OnrampQuote)
1121
- setShowProviderSelector(false)
1122
- }}
1123
- selectedProvider={selectedOnrampProviderQuote}
1124
- providers={onrampQuotes}
1125
- isLoading={isLoadingOnrampQuote}
1126
- />
1127
- )
1128
- }
1129
-
1130
- // Show fiat selector screen
1131
- if (showFiatSelector) {
1132
- return (
1133
- <div className="space-y-2">
1134
- <ScreenHeader
1135
- onBack={() => setShowFiatSelector(false)}
1136
- headerContent="Select Currency"
1137
- headerContentAlign="left"
1138
- />
1139
- <FiatSelector
1140
- onCurrencySelect={(currency) => {
1141
- setSelectedFiatCurrency(currency)
1142
- setShowFiatSelector(false)
1143
- setHasManualFiatSelection(true)
1144
- }}
1145
- onAutoSelect={(currency) => {
1146
- // Auto-select doesn't close the selector, just sets the currency
1147
- setSelectedFiatCurrency(currency)
1148
- }}
1149
- onSelectCountry={(countryCode) => {
1150
- setSelectedCountryCode(countryCode)
1151
- }}
1152
- onError={onError}
1153
- selectedCurrency={selectedFiatCurrency}
1154
- />
1155
- </div>
1156
- )
1157
- }
1158
-
1159
- // Show source chain list screen
1160
- if (showSourceChainList) {
1161
- return (
1162
- <ChainList
1163
- onBack={() => {
1164
- setShowSourceChainList(false)
1165
- setShowSourceTokenSelector(true)
1166
- }}
1167
- />
1168
- )
1169
- }
1170
-
1171
- // Show source token selector screen
1172
- if (showSourceTokenSelector) {
1173
- return (
1174
- <div className="space-y-2">
1175
- <ScreenHeader
1176
- onBack={() => setShowSourceTokenSelector(false)}
1177
- headerContent="Select From Token"
1178
- headerContentAlign="left"
1179
- />
1180
- <TokenSelector
1181
- onTokenSelect={handleSourceTokenSelectorSelect}
1182
- onError={onError}
1183
- showContinueButton={false}
1184
- compactMode={false}
1185
- allSupportedTokens={false}
1186
- fundMethod={fundMethod}
1187
- chainListScreen={true}
1188
- onNavigateToChainList={() => {
1189
- setShowSourceTokenSelector(false)
1190
- setShowSourceChainList(true)
1191
- }}
1192
- recentTokens={recentTokens}
1193
- onRecentTokenSelect={handleRecentTokenSelect}
1194
- />
1195
- </div>
1196
- )
1197
- }
1198
-
1199
- // Show destination chain list screen
1200
- if (showDestinationChainList) {
1201
- return (
1202
- <ChainList
1203
- onBack={() => {
1204
- setShowDestinationChainList(false)
1205
- setShowDestinationTokenSelector(true)
1206
- }}
1207
- />
1208
- )
1209
- }
1210
-
1211
- // Show destination token selector screen
1212
- if (showDestinationTokenSelector) {
1213
- return (
1214
- <div className="space-y-2">
1215
- <ScreenHeader
1216
- onBack={() => setShowDestinationTokenSelector(false)}
1217
- headerContent="Select To Token"
1218
- headerContentAlign="left"
1219
- />
1220
- <TokenSelector
1221
- onTokenSelect={handleDestinationTokenSelectorSelect}
1222
- onError={onError}
1223
- showContinueButton={false}
1224
- compactMode={false}
1225
- allSupportedTokens={true}
1226
- fundMethod={fundMethod}
1227
- chainListScreen={true}
1228
- onNavigateToChainList={() => {
1229
- setShowDestinationTokenSelector(false)
1230
- setShowDestinationChainList(true)
1231
- }}
1232
- recentTokens={recentTokens}
1233
- onRecentTokenSelect={handleRecentTokenSelect}
1234
- />
1235
- </div>
1236
- )
1237
- }
1238
-
1239
- return (
1240
- <div className="space-y-2">
1241
- <ScreenHeader
1242
- onBack={() => navigate("fund-methods")}
1243
- headerContent="Fund"
1244
- headerContentAlign="left"
1245
- showAccountActions={true}
1246
- customActions={
1247
- fundOptions?.hideSwap ? undefined : (
1248
- <button
1249
- type="button"
1250
- onClick={() => navigate("swap", { backTarget: "fund-form" })}
1251
- className="flex h-8 px-3 justify-center items-center gap-1.5 rounded-full bg-gray-50 dark:bg-gray-700 cursor-pointer transition-colors text-gray-900 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-600"
1252
- title="Swap"
1253
- >
1254
- <ArrowLeftRight className="h-4 w-4" />
1255
- <span className="text-sm font-medium">Swap</span>
1256
- </button>
1257
- )
1258
- }
1259
- />
1260
-
1261
- <form
1262
- onSubmit={async (e) => {
1263
- e.preventDefault()
1264
-
1265
- logger.console.log(
1266
- "[trails-sdk] Creating widget session",
1267
- isMeldOnRampActive,
1268
- )
1269
- // Handle onramp flow separately
1270
- if (
1271
- isMeldOnRampActive &&
1272
- selectedOnrampProviderQuote &&
1273
- selectedFiatCurrency
1274
- ) {
1275
- const {
1276
- popup,
1277
- blocked,
1278
- error: popupError,
1279
- } = openPopup("meld-widget", 450, 700)
1280
-
1281
- if (blocked) {
1282
- setWidgetError(
1283
- popupError ||
1284
- "Popup blocked. Please allow popups for this site.",
1285
- )
1286
- onError(popupError || "Popup blocked")
1287
- return
1288
- }
1289
-
1290
- try {
1291
- setIsCreatingWidgetSession(true)
1292
- setWidgetError(null)
1293
-
1294
- logger.console.log(
1295
- "[trails-sdk] prepareSendQuote",
1296
- prepareSendQuote,
1297
- )
1298
-
1299
- // Commit the intent immediately when user clicks continue
1300
- // Call sendFn to trigger the commit without deposit
1301
- if (sendFn) {
1302
- logger.console.log(
1303
- "[trails-sdk] Committing intent for onramp-meld flow",
1304
- )
1305
-
1306
- try {
1307
- // Call sendFn without depositTransactionHash to just commit
1308
- // The crossChain handler will commit but not execute/wait for deposit
1309
- await sendFn({
1310
- selectedFeeOption: selectedFeeOption ?? null,
1311
- })
1312
-
1313
- logger.console.log(
1314
- "[trails-sdk] Intent committed for onramp-meld",
1315
- )
1316
- } catch (error) {
1317
- logger.console.error(
1318
- "[trails-sdk] Failed to commit intent:",
1319
- error,
1320
- )
1321
- // Continue anyway
1322
- }
1323
- }
1324
-
1325
- // Create widget session
1326
- const widgetSessionResponse = await createWidgetSession({
1327
- depositAddress: prepareSendQuote?.originDepositAddress || "",
1328
- userAddress: account?.address || "",
1329
- countryCode: effectiveCountryCode || "",
1330
- sourceCurrencyCode: selectedFiatCurrency.currencyCode,
1331
- sourceAmount: sellFiatAmount,
1332
- destinationCurrencyCode: "USDC_BASE",
1333
- serviceProvider: selectedOnrampProviderQuote.serviceProvider,
1334
- paymentMethodType:
1335
- selectedOnrampProviderQuote.paymentMethodType,
1336
- lockFields: [
1337
- "cryptoCurrency",
1338
- "destinationCurrencyCode",
1339
- "sourceCurrencyCode",
1340
- "walletAddress",
1341
- ],
1342
- })
1343
-
1344
- logger.console.log(
1345
- "[Fund] Widget session response:",
1346
- widgetSessionResponse,
1347
- )
1348
- const { widgetUrl, id, externalSessionId } = widgetSessionResponse
1349
-
1350
- // Track widget session
1351
- trackOnrampWidgetSession({
1352
- sessionId: onrampTrackingData?.sessionId || externalSessionId,
1353
- provider:
1354
- selectedOnrampProviderQuote?.serviceProvider || "Meld",
1355
- widgetUrl,
1356
- depositAddress: prepareSendQuote?.originDepositAddress || "",
1357
- userAddress: account?.address?.toLowerCase() || "",
1358
- countryCode: effectiveCountryCode || "",
1359
- sourceCurrencyCode: selectedFiatCurrency?.currencyCode || "",
1360
- sourceAmount: sellFiatAmount,
1361
- destinationCurrencyCode: "USDC_BASE",
1362
- paymentMethodType:
1363
- selectedOnrampProviderQuote?.paymentMethodType || "",
1364
- })
1365
-
1366
- if (!setPopupUrl(popup, widgetUrl)) {
1367
- throw new Error("Payment window was closed. Please try again.")
1368
- }
1369
-
1370
- logger.console.log("[Fund] Opened onramp widget in popup", {
1371
- widgetUrl,
1372
- meldTransactionId: id,
1373
- })
1374
-
1375
- if (onWaitingForOnrampConfirm && prepareSendQuote) {
1376
- // Pass both quote and widget creation parameters
1377
- logger.console.log(
1378
- "[Fund] Calling onWaitingForOnrampConfirm with externalSessionId:",
1379
- externalSessionId,
1380
- )
1381
- onWaitingForOnrampConfirm(
1382
- prepareSendQuote,
1383
- selectedOnrampProviderQuote,
1384
- {
1385
- depositAddress:
1386
- prepareSendQuote?.originDepositAddress || "",
1387
- userAddress: account?.address?.toLowerCase() || "",
1388
- countryCode: effectiveCountryCode || "",
1389
- sourceCurrencyCode: selectedFiatCurrency.currencyCode,
1390
- sourceAmount: sellFiatAmount,
1391
- destinationCurrencyCode: "USDC_BASE",
1392
- serviceProvider:
1393
- selectedOnrampProviderQuote.serviceProvider,
1394
- paymentMethodType:
1395
- selectedOnrampProviderQuote.paymentMethodType,
1396
- },
1397
- externalSessionId,
1398
- popup,
1399
- )
1400
- }
1401
-
1402
- await handleSubmit(e)
1403
- } catch (err) {
1404
- closePopup(popup)
1405
- logger.console.error("[Fund] Error creating widget session", err)
1406
- const errorMessage =
1407
- err instanceof Error
1408
- ? err.message
1409
- : "Failed to create widget session"
1410
- setWidgetError(errorMessage)
1411
- onError(errorMessage)
1412
- } finally {
1413
- setIsCreatingWidgetSession(false)
1414
- }
1415
- return
1416
- }
1417
-
1418
- logger.console.log("[trails-sdk] Calling handleSubmit from Fund")
1419
- handleSubmit(e)
1420
- }}
1421
- className="space-y-1"
1422
- >
1423
- {/* Input Section - Amount Only */}
1424
- <div className="pt-4 pb-4 trails-border-radius-container p-3 flex flex-col border border-gray-200 dark:border-gray-700 rounded-lg relative">
1425
- {/* Amount Input - Centered */}
1426
- <div className="flex items-center justify-center">
1427
- <div className="flex items-center justify-center space-x-2">
1428
- <DynamicSizeInputField
1429
- ref={inputRef}
1430
- value={inputDisplayValue}
1431
- disabled={isFiatAmountLocked}
1432
- onChange={(e) => {
1433
- const value = e.target.value
1434
-
1435
- // Mark that user is typing
1436
- setIsUserTyping(true)
1437
-
1438
- // Clear any existing timeout
1439
- if (typingTimeoutRef.current) {
1440
- clearTimeout(typingTimeoutRef.current)
1441
- }
1442
-
1443
- // Clear typing flag after a short delay
1444
- typingTimeoutRef.current = setTimeout(() => {
1445
- setIsUserTyping(false)
1446
- }, 300)
1447
-
1448
- // Allow empty string
1449
- if (value === "") {
1450
- setInputDisplayValue("")
1451
- if (isMeldOnRampActive) {
1452
- setSellFiatAmount("")
1453
- } else {
1454
- setSellAmount("")
1455
- }
1456
- return
1457
- }
1458
-
1459
- if (isMeldOnRampActive) {
1460
- // Fiat/onramp mode
1461
- // Validate decimal places (max 2 decimals)
1462
- const decimalMatch = value.match(/^\d*\.?\d{0,2}$/)
1463
- if (!decimalMatch) {
1464
- return // Don't update if invalid format
1465
- }
1466
-
1467
- // Update display value - preserve the exact user input
1468
- setInputDisplayValue(value)
1469
-
1470
- // Just set the values directly without complex processing
1471
- if (isEnteringFiat && fiatToUsdExchangeRate) {
1472
- // User is entering preferred currency, convert to selected onramp currency for backend
1473
- const inputAmount = toSafeNumber(value)
1474
-
1475
- // First convert from preferred currency to USD if needed
1476
- const rateData = forexRateStore.getRate()
1477
- const usdAmount =
1478
- rateData && rateData.currency !== "USD"
1479
- ? inputAmount / rateData.rate
1480
- : inputAmount
1481
-
1482
- // Then convert USD to selected onramp currency
1483
- const convertedAmount = usdAmount * fiatToUsdExchangeRate
1484
- setSellFiatAmount(convertedAmount.toString())
1485
- } else {
1486
- // User is entering in selected currency directly
1487
- setSellFiatAmount(value)
1488
- }
1489
- } else {
1490
- // Token mode
1491
- // Validate decimal places (max 8 for tokens, max 2 for USD)
1492
- const maxDecimals = isEnteringFiat ? 2 : 8
1493
- const decimalRegex = new RegExp(
1494
- `^\\d*\\.?\\d{0,${maxDecimals}}$`,
1495
- )
1496
- const decimalMatch = value.match(decimalRegex)
1497
- if (!decimalMatch) {
1498
- return // Don't update if invalid format
1499
- }
1500
-
1501
- // Update display value - preserve the exact user input
1502
- setInputDisplayValue(value)
1503
-
1504
- // Just pass the value directly to handleSellAmountChange
1505
- // Let it handle any necessary processing
1506
- if (isEnteringFiat && tokenPriceUsd > 0) {
1507
- // User is entering fiat, convert to token amount for backend
1508
- // First convert from preferred currency to USD if needed
1509
- const inputAmount = toSafeNumber(value)
1510
- const rateData = forexRateStore.getRate()
1511
- const usdAmount =
1512
- rateData && rateData.currency !== "USD"
1513
- ? inputAmount / rateData.rate
1514
- : inputAmount
1515
- const tokenAmount = usdAmount / tokenPriceUsd
1516
- handleSellAmountChange(tokenAmount.toString())
1517
- } else {
1518
- // User is entering token amount directly - pass it as-is
1519
- handleSellAmountChange(value)
1520
- }
1521
- }
1522
- }}
1523
- onFocus={handleSellInputFocus}
1524
- isLoading={
1525
- isLoadingQuote && tradeType === TradeType.EXACT_OUTPUT
1526
- }
1527
- variant="default"
1528
- inputSize="large"
1529
- textAlign="center"
1530
- isFiatInput={isMeldOnRampActive || isEnteringFiat}
1531
- currencySymbol={
1532
- isEnteringFiat
1533
- ? (() => {
1534
- // Get the current currency from forexRateStore
1535
- const rateData = forexRateStore.getRate()
1536
- const currency = rateData?.currency || "USD"
1537
- // Return the appropriate symbol for the currency
1538
- return (
1539
- FIAT_CURRENCY_SYMBOLS[
1540
- currency as keyof typeof FIAT_CURRENCY_SYMBOLS
1541
- ] || "$"
1542
- )
1543
- })()
1544
- : isMeldOnRampActive
1545
- ? selectedFiatCurrency?.currencyCode
1546
- : originToken?.symbol
1547
- }
1548
- />
1549
- {isLoadingQuote && tradeType === TradeType.EXACT_OUTPUT && (
1550
- <LoadingSpinner />
1551
- )}
1552
- </div>
1553
- </div>
1554
-
1555
- {/* USD Value - hidden while onramp location/currency is loading to avoid showing undefined */}
1556
- {isMeldOnRampActive &&
1557
- (isLoadingCountryDefaults || isLoadingFiatCurrencies) ? (
1558
- <div className="mt-2 text-center text-sm text-gray-500 dark:text-gray-400">
1559
- Loading...
1560
- </div>
1561
- ) : (
1562
- <div className="mt-2 text-center text-sm">
1563
- {isMeldOnRampActive ? (
1564
- // Onramp mode - clickable USD toggle (only show when rate is ready to avoid undefined)
1565
- selectedFiatCurrency?.currencyCode === "USD" ? (
1566
- // If already USD, no toggle needed
1567
- inputDisplayValue && Number(inputDisplayValue) > 0 ? (
1568
- <div
1569
- className="text-xs text-gray-500 dark:text-gray-400 notranslate"
1570
- translate="no"
1571
- >
1572
- ≈ {formatUsdAmountDisplay(Number(inputDisplayValue))}
1573
- </div>
1574
- ) : null
1575
- ) : fiatToUsdExchangeRate != null &&
1576
- !isLoadingFiatToUsdExchangeRate ? (
1577
- // Clickable toggle between USD and selected currency
1578
- <div className="flex justify-center">
1579
- <button
1580
- type="button"
1581
- disabled={isFiatAmountLocked}
1582
- onClick={() => {
1583
- // When toggling USD mode, convert the current display value
1584
- const newMode = !isEnteringFiat
1585
- setIsEnteringFiat(newMode)
1586
-
1587
- // Convert the current display to the new mode
1588
- if (inputDisplayValue) {
1589
- const currentValue = parseFloat(inputDisplayValue)
1590
- if (isPositiveNumber(currentValue)) {
1591
- if (newMode && fiatToUsdExchangeRate) {
1592
- // Switching to USD mode - convert from local currency
1593
- const usdValue =
1594
- currentValue / fiatToUsdExchangeRate
1595
- setInputDisplayValue(
1596
- Number(usdValue.toFixed(2)).toString(),
1597
- )
1598
- } else if (!newMode && fiatToUsdExchangeRate) {
1599
- // Switching to local currency mode - convert from USD
1600
- const localValue =
1601
- currentValue * fiatToUsdExchangeRate
1602
- setInputDisplayValue(
1603
- Number(localValue.toFixed(2)).toString(),
1604
- )
1605
- }
1606
- }
1607
- }
1608
- }}
1609
- className={`text-xs transition-colors flex items-center gap-1 ${
1610
- isFiatAmountLocked
1611
- ? "text-gray-400 cursor-not-allowed"
1612
- : "text-blue-500 hover:text-blue-600 cursor-pointer"
1613
- }`}
1614
- title={
1615
- selectedFiatCurrency
1616
- ? `${selectedFiatCurrency.currencyCode}`
1617
- : ""
1618
- }
1619
- >
1620
- <svg
1621
- aria-hidden="true"
1622
- width="16"
1623
- height="16"
1624
- viewBox="0 0 16 16"
1625
- fill="none"
1626
- xmlns="http://www.w3.org/2000/svg"
1627
- >
1628
- <path
1629
- d="M3.16669 6.5L5.50002 4.16667M5.50002 4.16667L7.83335 6.5M5.50002 4.16667L5.50002 11.8333"
1630
- stroke="#3B82F6"
1631
- strokeWidth="1.5"
1632
- strokeLinecap="round"
1633
- strokeLinejoin="round"
1634
- />
1635
- <path
1636
- d="M12.8334 9.5L10.5 11.8333M10.5 11.8333L8.16669 9.5M10.5 11.8333L10.5 4.16667"
1637
- stroke="#3B82F6"
1638
- strokeWidth="1.5"
1639
- strokeLinecap="round"
1640
- strokeLinejoin="round"
1641
- />
1642
- </svg>
1643
- {(() => {
1644
- const inputValue = toSafeNumber(inputDisplayValue)
1645
-
1646
- if (isEnteringFiat) {
1647
- // Currently entering in USD, show the local currency value
1648
- const localAmount = inputValue * fiatToUsdExchangeRate
1649
- const localDisplay =
1650
- localAmount > 0
1651
- ? `${localAmount.toFixed(2)} ${selectedFiatCurrency?.currencyCode}`
1652
- : `0.00 ${selectedFiatCurrency?.currencyCode}`
1653
-
1654
- return (
1655
- <span
1656
- className="notranslate"
1657
- translate="no"
1658
- title={localDisplay}
1659
- >
1660
- ≈ {localDisplay}
1661
- </span>
1662
- )
1663
- } else {
1664
- // Currently entering in local currency, show USD value
1665
- const usdAmount = inputValue / fiatToUsdExchangeRate
1666
- const displayValue = formatUsdAmountDisplay(usdAmount)
1667
- const localeValue =
1668
- formatUsdAmountLocaleDisplay(usdAmount)
1669
-
1670
- return (
1671
- <span
1672
- className="notranslate"
1673
- translate="no"
1674
- title={displayValue}
1675
- >
1676
- ≈ {localeValue}
1677
- </span>
1678
- )
1679
- }
1680
- })()}
1681
- </button>
1682
- </div>
1683
- ) : null
1684
- ) : (
1685
- // Regular mode - clickable USD/token value swap
1686
- <div className="flex justify-center">
1687
- <button
1688
- type="button"
1689
- onClick={() => {
1690
- // When toggling USD mode, convert the current display value
1691
- const newMode = !isEnteringFiat
1692
- logger.console.log(
1693
- "[TRAILS TOGGLE] Starting toggle, newMode (entering fiat):",
1694
- newMode,
1695
- )
1696
- logger.console.log(
1697
- "[TRAILS TOGGLE] Current inputDisplayValue:",
1698
- inputDisplayValue,
1699
- )
1700
- logger.console.log(
1701
- "[TRAILS TOGGLE] tokenPriceUsd:",
1702
- tokenPriceUsd,
1703
- )
1704
-
1705
- setIsEnteringFiat(newMode)
1706
-
1707
- // Convert the current display to the new mode
1708
- if (inputDisplayValue && tokenPriceUsd > 0) {
1709
- const currentValue = parseFloat(inputDisplayValue)
1710
- logger.console.log(
1711
- "[TRAILS TOGGLE] Parsed currentValue:",
1712
- currentValue,
1713
- )
1714
-
1715
- if (isPositiveNumber(currentValue)) {
1716
- const rateData = forexRateStore.getRate()
1717
- logger.console.log(
1718
- "[TRAILS TOGGLE] ForexRate data:",
1719
- rateData,
1720
- )
1721
-
1722
- if (newMode) {
1723
- // Switching to fiat mode - convert from token amount to preferred currency
1724
- const usdValue = currentValue * tokenPriceUsd
1725
- logger.console.log(
1726
- "[TRAILS TOGGLE] Token->Fiat: usdValue (token * price):",
1727
- usdValue,
1728
- )
1729
-
1730
- // Apply forex rate if available to convert USD to preferred currency
1731
- const displayValue =
1732
- rateData && rateData.currency !== "USD"
1733
- ? usdValue * rateData.rate
1734
- : usdValue
1735
- logger.console.log(
1736
- "[TRAILS TOGGLE] Token->Fiat: displayValue after forex:",
1737
- displayValue,
1738
- )
1739
- logger.console.log(
1740
- "[TRAILS TOGGLE] Token->Fiat: forex rate used:",
1741
- rateData?.rate || "none (USD)",
1742
- )
1743
-
1744
- const finalValue = Number(
1745
- displayValue.toFixed(2),
1746
- ).toString()
1747
- logger.console.log(
1748
- "[TRAILS TOGGLE] Token->Fiat: Setting input to:",
1749
- finalValue,
1750
- )
1751
- setInputDisplayValue(finalValue)
1752
- } else {
1753
- // Switching to token mode - convert from preferred currency to token
1754
- // First convert from preferred currency to USD if needed
1755
- const usdValue =
1756
- rateData && rateData.currency !== "USD"
1757
- ? currentValue / rateData.rate
1758
- : currentValue
1759
- logger.console.log(
1760
- "[TRAILS TOGGLE] Fiat->Token: usdValue (input / rate):",
1761
- usdValue,
1762
- )
1763
- logger.console.log(
1764
- "[TRAILS TOGGLE] Fiat->Token: forex rate used:",
1765
- rateData?.rate || "none (USD)",
1766
- )
1767
-
1768
- const tokenValue = usdValue / tokenPriceUsd
1769
- logger.console.log(
1770
- "[TRAILS TOGGLE] Fiat->Token: tokenValue (usd / price):",
1771
- tokenValue,
1772
- )
1773
-
1774
- // Round to 8 decimals to avoid floating point issues
1775
- const rounded =
1776
- Math.round(tokenValue * 100000000) / 100000000
1777
- setInputDisplayValue(rounded.toString())
1778
- }
1779
- }
1780
- }
1781
- }}
1782
- className="text-base text-blue-500 hover:text-blue-600 transition-colors cursor-pointer flex items-center gap-2 py-1.5"
1783
- title={
1784
- originToken
1785
- ? `Toggle between USD and ${originToken.symbol}`
1786
- : ""
1787
- }
1788
- >
1789
- <svg
1790
- aria-hidden="true"
1791
- width="20"
1792
- height="20"
1793
- viewBox="0 0 16 16"
1794
- fill="none"
1795
- xmlns="http://www.w3.org/2000/svg"
1796
- >
1797
- <path
1798
- d="M3.16669 6.5L5.50002 4.16667M5.50002 4.16667L7.83335 6.5M5.50002 4.16667L5.50002 11.8333"
1799
- stroke="#3B82F6"
1800
- strokeWidth="1.5"
1801
- strokeLinecap="round"
1802
- strokeLinejoin="round"
1803
- />
1804
- <path
1805
- d="M12.8334 9.5L10.5 11.8333M10.5 11.8333L8.16669 9.5M10.5 11.8333L10.5 4.16667"
1806
- stroke="#3B82F6"
1807
- strokeWidth="1.5"
1808
- strokeLinecap="round"
1809
- strokeLinejoin="round"
1810
- />
1811
- </svg>
1812
- {(() => {
1813
- const inputValue = toSafeNumber(inputDisplayValue)
1814
- logger.console.log(
1815
- "[TRAILS DISPLAY] isEnteringFiat:",
1816
- isEnteringFiat,
1817
- )
1818
- logger.console.log(
1819
- "[TRAILS DISPLAY] inputValue:",
1820
- inputValue,
1821
- )
1822
-
1823
- if (isEnteringFiat) {
1824
- // Currently entering in preferred currency, show the token amount
1825
- // First convert from preferred currency to USD if needed
1826
- const rateData = forexRateStore.getRate()
1827
- logger.console.log(
1828
- "[TRAILS DISPLAY] ForexRate data:",
1829
- rateData,
1830
- )
1831
-
1832
- const usdValue =
1833
- rateData && rateData.currency !== "USD"
1834
- ? inputValue / rateData.rate
1835
- : inputValue
1836
- logger.console.log(
1837
- "[TRAILS DISPLAY] Fiat mode - usdValue (input / rate):",
1838
- usdValue,
1839
- )
1840
-
1841
- const tokenAmount =
1842
- tokenPriceUsd > 0 ? usdValue / tokenPriceUsd : 0
1843
- logger.console.log(
1844
- "[TRAILS DISPLAY] Fiat mode - tokenAmount:",
1845
- tokenAmount,
1846
- )
1847
-
1848
- const tokenDisplay =
1849
- tokenAmount > 0
1850
- ? `${tokenAmount.toFixed(8)} ${originToken?.symbol || ""}`
1851
- : `0 ${originToken?.symbol || ""}`
1852
-
1853
- return (
1854
- <span title={tokenDisplay}>≈ {tokenDisplay}</span>
1855
- )
1856
- } else {
1857
- // Currently entering in token amount, show USD value
1858
- const usdAmount = inputValue * tokenPriceUsd
1859
- logger.console.log(
1860
- "[TRAILS DISPLAY] Token mode - usdAmount:",
1861
- usdAmount,
1862
- )
1863
-
1864
- const displayValue = formatUsdAmountDisplay(usdAmount)
1865
- const localeValue =
1866
- formatUsdAmountLocaleDisplay(usdAmount)
1867
- logger.console.log(
1868
- "[TRAILS DISPLAY] Token mode - displayValue:",
1869
- displayValue,
1870
- )
1871
- logger.console.log(
1872
- "[TRAILS DISPLAY] Token mode - localeValue:",
1873
- localeValue,
1874
- )
1875
-
1876
- return <span title={displayValue}>≈ {localeValue}</span>
1877
- }
1878
- })()}
1879
- </button>
1880
- </div>
1881
- )}
1882
- </div>
1883
- )}
1884
-
1885
- {/* Percentage/USD Amount Buttons */}
1886
- {isMeldOnRampActive ? (
1887
- // USD Amount Buttons for onramp - convert from USD to selected currency
1888
- <div className="mt-3 flex justify-center items-center space-x-2">
1889
- <button
1890
- type="button"
1891
- disabled={isFiatAmountLocked}
1892
- className={`py-0.5 px-1.5 text-xs font-medium rounded-full transition-colors trails-bg-percentage-button trails-text-percentage-button ${
1893
- isFiatAmountLocked
1894
- ? "opacity-50 cursor-not-allowed"
1895
- : "cursor-pointer trails-hover-percentage-button"
1896
- }`}
1897
- onClick={() => {
1898
- if (selectedFiatCurrency?.currencyCode === "USD") {
1899
- setSellFiatAmount("25")
1900
- setInputDisplayValue("25")
1901
- } else if (fiatToUsdExchangeRate) {
1902
- // Convert $25 USD to the selected currency
1903
- const convertedAmount = 25 * fiatToUsdExchangeRate
1904
- setSellFiatAmount(convertedAmount.toFixed(2))
1905
-
1906
- // Update display based on current mode
1907
- if (isEnteringFiat) {
1908
- setInputDisplayValue("25")
1909
- } else {
1910
- setInputDisplayValue(convertedAmount.toString())
1911
- }
1912
- }
1913
- }}
1914
- >
1915
- $25
1916
- </button>
1917
- <button
1918
- type="button"
1919
- disabled={isFiatAmountLocked}
1920
- className={`py-0.5 px-1.5 text-xs font-medium rounded-full transition-colors trails-bg-percentage-button trails-text-percentage-button ${
1921
- isFiatAmountLocked
1922
- ? "opacity-50 cursor-not-allowed"
1923
- : "cursor-pointer trails-hover-percentage-button"
1924
- }`}
1925
- onClick={() => {
1926
- if (selectedFiatCurrency?.currencyCode === "USD") {
1927
- setSellFiatAmount("50")
1928
- setInputDisplayValue("50")
1929
- } else if (fiatToUsdExchangeRate) {
1930
- // Convert $50 USD to the selected currency
1931
- const convertedAmount = 50 * fiatToUsdExchangeRate
1932
- setSellFiatAmount(convertedAmount.toFixed(2))
1933
-
1934
- // Update display based on current mode
1935
- if (isEnteringFiat) {
1936
- setInputDisplayValue("50")
1937
- } else {
1938
- setInputDisplayValue(convertedAmount.toString())
1939
- }
1940
- }
1941
- }}
1942
- >
1943
- $50
1944
- </button>
1945
- <button
1946
- type="button"
1947
- disabled={isFiatAmountLocked}
1948
- className={`py-0.5 px-1.5 text-xs font-medium rounded-full transition-colors trails-bg-percentage-button trails-text-percentage-button ${
1949
- isFiatAmountLocked
1950
- ? "opacity-50 cursor-not-allowed"
1951
- : "cursor-pointer trails-hover-percentage-button"
1952
- }`}
1953
- onClick={() => {
1954
- if (selectedFiatCurrency?.currencyCode === "USD") {
1955
- setSellFiatAmount("100")
1956
- setInputDisplayValue("100")
1957
- } else if (fiatToUsdExchangeRate) {
1958
- // Convert $100 USD to the selected currency
1959
- const convertedAmount = 100 * fiatToUsdExchangeRate
1960
- setSellFiatAmount(convertedAmount.toFixed(2))
1961
-
1962
- // Update display based on current mode
1963
- if (isEnteringFiat) {
1964
- setInputDisplayValue("100")
1965
- } else {
1966
- setInputDisplayValue(convertedAmount.toString())
1967
- }
1968
- }
1969
- }}
1970
- >
1971
- $100
1972
- </button>
1973
- </div>
1974
- ) : originToken &&
1975
- balanceFormatted &&
1976
- fundMethod !== "direct-transfer" &&
1977
- fundMethod !== "onramp-mesh" ? (
1978
- <div className="mt-3 flex justify-center items-center space-x-2">
1979
- <PercentageMaxButtons
1980
- userBalance={balanceFormatted}
1981
- userBalanceRaw={balanceRaw}
1982
- decimals={tokenDecimals}
1983
- isNativeToken={originToken.isNativeToken ?? false}
1984
- gasCostFormatted={prepareSendQuote?.gasCostFormatted}
1985
- chainId={originChainId || undefined}
1986
- onAmountSelect={(amount) => {
1987
- setTradeType(TradeType.EXACT_INPUT)
1988
- setSellAmount(amount)
1989
- setBuyAmount("")
1990
- if (isEnteringFiat && tokenPriceUsd > 0) {
1991
- const usdAmount = parseFloat(amount) * tokenPriceUsd
1992
- setInputDisplayValue(
1993
- Number(usdAmount.toFixed(2)).toString(),
1994
- )
1995
- } else {
1996
- setInputDisplayValue(amount)
1997
- }
1998
- }}
1999
- className="opacity-100"
2000
- />
2001
- </div>
2002
- ) : null}
2003
- </div>
2004
-
2005
- {/* Sending and Receiving Section */}
2006
- <div className="mt-4 pt-4 pb-4 trails-border-radius-container p-3 mb-4 border border-gray-200 dark:border-gray-700 rounded-lg">
2007
- {/* Sending and Receiving Labels */}
2008
- <div className="flex items-center justify-between mb-3 px-1">
2009
- <span
2010
- className="text-sm font-medium text-black dark:text-white"
2011
- style={{ minWidth: "138px" }}
2012
- >
2013
- Sending
2014
- </span>
2015
- <div className="w-7 flex-shrink-0"></div> {/* Spacer for arrow */}
2016
- {toRecipient ? (
2017
- <span
2018
- className="text-sm font-medium text-black dark:text-white"
2019
- style={{ minWidth: "138px" }}
2020
- >
2021
- Receiving
2022
- </span>
2023
- ) : (
2024
- <RecipientSelectorButton selectedRecipient={selectedRecipient} />
2025
- )}
2026
- </div>
2027
-
2028
- {/* Token Selectors with Arrow */}
2029
- <div className="flex items-center justify-between space-x-2">
2030
- {/* Origin Token Selector */}
2031
- <div className="min-w-[138px] flex flex-col mr-0">
2032
- {isMeldOnRampActive ? (
2033
- <FiatSelectorButton
2034
- currency={selectedFiatCurrency}
2035
- onSelect={() => setShowFiatSelector(true)}
2036
- unselectable={isFiatCurrencyLocked}
2037
- />
2038
- ) : prepareSendQuote?.noSufficientBalance ? (
2039
- // Show "Add funds" button when user has insufficient balance
2040
- <button
2041
- type="button"
2042
- onClick={() => {
2043
- // Navigate to payment selection screen
2044
- navigate("fund-methods")
2045
- }}
2046
- className="w-full flex items-center justify-center space-x-1.5 trails-border-radius-input px-2.5 py-1.5 border transition-all duration-200 bg-blue-500 hover:bg-blue-600 border-blue-500 text-white cursor-pointer"
2047
- >
2048
- <span className="font-medium text-sm text-white">
2049
- Add funds
2050
- </span>
2051
- </button>
2052
- ) : !originToken ? (
2053
- // No token selected, show "Select Token" button
2054
- <button
2055
- type="button"
2056
- onClick={() => {
2057
- setShowSourceTokenSelector(true)
2058
- }}
2059
- className="w-full flex items-center justify-center space-x-1.5 trails-border-radius-input px-2.5 py-1.5 border transition-all duration-200 bg-blue-500 hover:bg-blue-600 border-blue-500 text-white cursor-pointer"
2060
- >
2061
- <span className="font-medium text-sm text-white">
2062
- Select Token
2063
- </span>
2064
- </button>
2065
- ) : (
2066
- <TokenSelectorButton
2067
- token={originToken}
2068
- chainId={originChainId}
2069
- onSelect={() => setShowSourceTokenSelector(true)}
2070
- fullWidth={true}
2071
- />
2072
- )}
2073
- </div>
2074
-
2075
- {/* Arrow Icon in Circle - 28x28 */}
2076
- <div className="flex-shrink-0 mr-0">
2077
- <div className="w-7 h-7 rounded-full bg-gray-100 dark:bg-gray-800 flex items-center justify-center">
2078
- <svg
2079
- aria-hidden="true"
2080
- xmlns="http://www.w3.org/2000/svg"
2081
- width="16"
2082
- height="16"
2083
- viewBox="0 0 16 16"
2084
- fill="none"
2085
- >
2086
- <path
2087
- d="M7.52861 2.86201C7.78895 2.60166 8.21096 2.60166 8.47131 2.86201L13.138 7.52868C13.3983 7.78903 13.3983 8.21104 13.138 8.47138L8.47131 13.1381C8.21096 13.3984 7.78895 13.3984 7.52861 13.1381C7.26826 12.8777 7.26826 12.4557 7.52861 12.1953L11.0573 8.6667H3.33329C2.9651 8.6667 2.66663 8.36822 2.66663 8.00003C2.66663 7.63184 2.9651 7.33336 3.33329 7.33336H11.0573L7.52861 3.80472C7.26826 3.54437 7.26826 3.12236 7.52861 2.86201Z"
2088
- fill="black"
2089
- />
2090
- </svg>
2091
- </div>
2092
- </div>
2093
-
2094
- {/* Destination Token Selector */}
2095
- <div className="min-w-[138px] flex">
2096
- <TokenSelectorButton
2097
- token={selectedDestToken}
2098
- chainId={(selectedDestToken as any)?.chainId}
2099
- onSelect={() => setShowDestinationTokenSelector(true)}
2100
- unselectable={!!toToken}
2101
- fullWidth={true}
2102
- />
2103
- </div>
2104
- </div>
2105
-
2106
- {/* Token Balance Display or Insufficient Funds Warning */}
2107
- {(!fundMethod || fundMethod === "wallet") && originToken && (
2108
- <div className="mt-3 pl-1 text-xs text-left">
2109
- {prepareSendQuote?.noSufficientBalance ? (
2110
- <span style={{ color: "#F97316" }}>
2111
- Insufficient funds
2112
- {balanceFormatted
2113
- ? `. Have ${balanceFormatted} ${originToken.symbol}`
2114
- : ""}
2115
- </span>
2116
- ) : balanceFormatted ? (
2117
- <>
2118
- <span
2119
- className="text-black dark:text-white notranslate"
2120
- translate="no"
2121
- >
2122
- Balance:
2123
- </span>
2124
- <span
2125
- className="text-gray-500 dark:text-gray-400 notranslate"
2126
- translate="no"
2127
- >
2128
- {" "}
2129
- {balanceLocaleDisplay || balanceFormatted}{" "}
2130
- {originToken.symbol}
2131
- {balanceUsdDisplay ? (
2132
- <span className="notranslate" translate="no">
2133
- {" "}
2134
- ({balanceUsdLocaleDisplay || balanceUsdDisplay})
2135
- </span>
2136
- ) : null}
2137
- </span>
2138
- </>
2139
- ) : null}
2140
- </div>
2141
- )}
2142
- </div>
2143
- {/* Exchange/Contract Warning */}
2144
- <RefundWarning
2145
- fundMethod={fundMethod}
2146
- isSenderContractOnOrigin={false}
2147
- isSenderContractOnDestination={false}
2148
- isSequenceWallet={isSequenceWallet}
2149
- />
2150
-
2151
- {/* Fee Options */}
2152
- {!isMeldOnRampActive &&
2153
- fundMethod !== "direct-transfer" &&
2154
- fundMethod !== "onramp-mesh" && (
2155
- <FeeOptions
2156
- processedFeeOptions={processedFeeOptions || []}
2157
- selectedFeeOption={selectedFeeOption}
2158
- setSelectedFeeOption={(feeOption) =>
2159
- setSelectedFeeOption(feeOption)
2160
- }
2161
- chainId={originToken?.chainId}
2162
- isRefetching={isLoadingQuote}
2163
- originTokenInfo={{
2164
- originToken: freshOriginToken ?? originToken!,
2165
- originTokenBalance:
2166
- freshOriginToken?.balance ?? originToken?.balance ?? "0",
2167
- originTokenAmount: sellAmount,
2168
- isLoadingBalance: isLoadingFreshOriginBalance,
2169
- }}
2170
- />
2171
- )}
2172
-
2173
- {/* Onramp Provider Selector */}
2174
- {isMeldOnRampActive &&
2175
- !isLoadingOnrampQuote &&
2176
- !isLoadingQuote &&
2177
- prepareSendQuote &&
2178
- onrampQuotes &&
2179
- onrampQuotes.length > 0 && (
2180
- <OnRampProviderSelector
2181
- providers={onrampQuotes}
2182
- selectedProvider={selectedOnrampProviderQuote}
2183
- trailsQuote={prepareSendQuote}
2184
- setSelectedProvider={(provider) => {
2185
- setSelectedOnrampProvider(provider as OnrampQuote)
2186
- }}
2187
- isRefetching={isLoadingOnrampQuote}
2188
- />
2189
- )}
2190
-
2191
- {/* Quote Details - only show for non-onramp quotes */}
2192
- {prepareSendQuote && !isLoadingQuote && !isLoadingOnrampQuote && (
2193
- <div className="mb-4">
2194
- <QuoteDetails
2195
- quote={prepareSendQuote}
2196
- fiatToUsdExchangeRate={fiatToUsdExchangeRate}
2197
- onRampQuote={selectedOnrampProviderQuote}
2198
- showContent={true}
2199
- swapMode={false}
2200
- isRefetching={isLoadingQuote}
2201
- showInsufficientFunds={false}
2202
- isPassthrough={isPassthroughEligible(
2203
- prepareSendQuote.passthroughEligible,
2204
- selectedFeeOption,
2205
- processedFeeOptions,
2206
- )}
2207
- />
2208
- </div>
2209
- )}
2210
-
2211
- {/* Onramp Quote Error */}
2212
- {isMeldOnRampActive && onrampQuoteError && (
2213
- <div className="mt-4">
2214
- <ErrorDisplay
2215
- errorPrettified={getPrettifiedErrorMessage(
2216
- onrampQuoteError,
2217
- "Error loading quote",
2218
- )}
2219
- error={getFullErrorMessage(onrampQuoteError)}
2220
- severity="error"
2221
- />
2222
- </div>
2223
- )}
2224
-
2225
- {/* Widget/Popup Error */}
2226
- {widgetError && (
2227
- <div className="mt-4">
2228
- <ErrorDisplay
2229
- errorPrettified={widgetError}
2230
- error={widgetError}
2231
- severity="error"
2232
- />
2233
- </div>
2234
- )}
2235
-
2236
- <button
2237
- type="submit"
2238
- disabled={
2239
- isMeldOnRampActive
2240
- ? !sellAmount ||
2241
- isSubmitting ||
2242
- isCreatingWidgetSession ||
2243
- !selectedFiatCurrency ||
2244
- !selectedDestToken ||
2245
- !effectiveCountryCode ||
2246
- !effectiveRecipient ||
2247
- isLoadingOnrampQuote ||
2248
- isLoadingWidgetSession ||
2249
- !selectedOnrampProviderQuote ||
2250
- !!onrampQuoteError ||
2251
- !!widgetSessionError ||
2252
- isLoadingQuote ||
2253
- isAwaitingTrailsQuote ||
2254
- !prepareSendQuote
2255
- : !amount ||
2256
- isSubmitting ||
2257
- !destinationTokenAddress ||
2258
- !isValidCustomToken ||
2259
- isLoadingQuote ||
2260
- !prepareSendQuote ||
2261
- (!isMeldOnRampActive &&
2262
- fundMethod !== "direct-transfer" &&
2263
- prepareSendQuote?.noSufficientBalance) ||
2264
- (shouldValidateFeeOption &&
2265
- (selectedFeeOption
2266
- ? isFeeOptionDisabled(
2267
- selectedFeeOption as ProcessedFeeOption,
2268
- {
2269
- originToken: freshOriginToken ?? originToken!,
2270
- originTokenBalance:
2271
- freshOriginToken?.balance ??
2272
- originToken?.balance ??
2273
- "0",
2274
- originTokenAmount: sellAmount,
2275
- },
2276
- )
2277
- : false))
2278
- }
2279
- className="w-full font-semibold py-4 px-4 trails-border-radius-button transition-colors bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white disabled:text-gray-500 disabled:cursor-not-allowed cursor-pointer relative"
2280
- >
2281
- {isSubmitting || isCreatingWidgetSession || isLoadingWidgetSession ? (
2282
- <div className="flex items-center justify-center">
2283
- <LoadingSpinner />
2284
- <span>
2285
- {isCreatingWidgetSession || isLoadingWidgetSession
2286
- ? "Creating session..."
2287
- : buttonText}
2288
- </span>
2289
- </div>
2290
- ) : isMeldOnRampActive &&
2291
- !prepareSendQuote &&
2292
- !selectedOnrampProviderQuote &&
2293
- (onrampQuoteError || widgetSessionError || widgetError) ? (
2294
- "Error Loading Quote"
2295
- ) : fundMethod !== "direct-transfer" &&
2296
- prepareSendQuote?.noSufficientBalance ? (
2297
- "Insufficient Balance"
2298
- ) : isMeldOnRampActive && !sellFiatAmount ? (
2299
- "Enter amount"
2300
- ) : !isMeldOnRampActive && !sellAmount ? (
2301
- "Enter amount"
2302
- ) : isMeldOnRampActive &&
2303
- (isLoadingOnrampQuote ||
2304
- isLoadingQuote ||
2305
- isAwaitingTrailsQuote ||
2306
- (selectedOnrampProviderQuote && !prepareSendQuote)) ? (
2307
- <div className="flex items-center justify-center">
2308
- <LoadingSpinner className="mr-2" />
2309
- <span>Getting quote...</span>
2310
- </div>
2311
- ) : isMeldOnRampActive &&
2312
- !isLoadingOnrampQuote &&
2313
- !isLoadingQuote &&
2314
- !isAwaitingTrailsQuote &&
2315
- prepareSendQuote ? (
2316
- "Continue"
2317
- ) : buttonText === "Getting quote..." ? (
2318
- <div className="flex items-center justify-center">
2319
- <LoadingSpinner className="mr-2" />
2320
- <span>{buttonText}</span>
2321
- </div>
2322
- ) : (
2323
- buttonText
2324
- )}
2325
- </button>
2326
- </form>
2327
- </div>
2328
- )
2329
- }
2330
-
2331
- export { Fund }