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,1099 +0,0 @@
1
- import type { Address } from "ox"
2
- import { useEffect, useMemo, useState } from "react"
3
- import { isAddress, zeroAddress } from "viem"
4
- import { useAccount } from "wagmi"
5
- import { useQuery } from "@tanstack/react-query"
6
- import { getChainInfo } from "../../chains.js"
7
- import { useSupportedChains } from "../../query/chains.hooks.js"
8
- import { SECOND_MS, MINUTE_MS, DAY_MS } from "../../utils/time.js"
9
- import type { Token } from "../../tokens.js"
10
- import {
11
- addressEqual,
12
- isNativeToken as isNativeTokenUtil,
13
- normalizeAddress,
14
- } from "../../utils/address.js"
15
- import { isValidDecimals } from "../../utils/validation.js"
16
- import {
17
- useAccountTotalBalanceUsd,
18
- useHasSufficientBalanceUsd,
19
- useTokenBalances,
20
- WIDGET_REFRESH_INTERVAL,
21
- } from "../../query/balance.hooks.js"
22
- import {
23
- formatPriceFields,
24
- formatUsdAmountDisplay,
25
- } from "../../utils/format.js"
26
- import { useSupportedTokens, useGetTokenImageUrl } from "../../tokens.js"
27
- import { useTrailsClient } from "../../trailsClient.js"
28
- import { useTokenPrices } from "../../query/price.hooks.js"
29
- import { logger } from "../../logger.js"
30
- import { useTrails } from "../providers/TrailsProvider.js"
31
- import { useCustomTokenFetch } from "./useCustomTokenFetch.js"
32
- import { useChainFilter } from "./useChainFilter.js"
33
- import { useDebounce } from "./useDebounce.js"
34
- import type { FundMethod } from "../../transactionIntent/types.js"
35
-
36
- // Standard tokens for QR code and exchange modes
37
- const STANDARD_TOKENS = [
38
- "ETH",
39
- "POL",
40
- "USDC",
41
- "USDT",
42
- "DAI",
43
- "BAT",
44
- "WETH",
45
- ] as const
46
-
47
- // Type for API token info from getTokenList endpoint
48
- type ApiTokenInfo = {
49
- chainId: number
50
- address: string
51
- name: string
52
- symbol: string
53
- decimals: number
54
- supportsBridging?: boolean
55
- logoUri?: string
56
- }
57
-
58
- // Helper function to validate and clamp decimals (1-18)
59
- function validateDecimals(decimals: number): number {
60
- return Math.max(1, Math.min(18, Math.floor(decimals || 18)))
61
- }
62
-
63
- // Helper function to check if token is native
64
- function isNativeToken(token: Token | ApiTokenInfo): boolean {
65
- // Token has isNativeToken property
66
- if ("isNativeToken" in token && typeof token.isNativeToken === "boolean") {
67
- return token.isNativeToken
68
- }
69
- // ApiTokenInfo uses "address" field (intermediate type before conversion to Token)
70
- if ("address" in token) {
71
- return isNativeTokenUtil(token.address)
72
- }
73
- return false
74
- }
75
-
76
- // Helper function to get token key for mapping
77
- function getTokenKey(chainId: number, contractAddress: string): string {
78
- return `${chainId}:${normalizeAddress(contractAddress)}`
79
- }
80
-
81
- // Helper function to convert API token info to Token
82
- function convertApiTokenToToken(
83
- tokenInfo: ApiTokenInfo,
84
- getTokenImageUrl: (params: {
85
- chainId: number
86
- contractAddress: string
87
- symbol: string
88
- }) => string,
89
- ): Token {
90
- const chainInfo = getChainInfo(tokenInfo.chainId)
91
- const isNative = isNativeToken(tokenInfo)
92
- const validatedDecimals = validateDecimals(tokenInfo.decimals)
93
-
94
- return {
95
- symbol: isNative
96
- ? chainInfo?.nativeCurrency.symbol || "Unknown"
97
- : tokenInfo.symbol,
98
- name: isNative
99
- ? chainInfo?.nativeCurrency.name || "Unknown"
100
- : tokenInfo.name,
101
- decimals: isNative
102
- ? chainInfo?.nativeCurrency.decimals || 18
103
- : validatedDecimals,
104
- contractAddress: isNative ? zeroAddress : tokenInfo.address,
105
- chainId: tokenInfo.chainId,
106
- chainName: chainInfo?.name || `Chain ${tokenInfo.chainId}`,
107
- imageUrl:
108
- tokenInfo.logoUri ||
109
- getTokenImageUrl({
110
- chainId: tokenInfo.chainId,
111
- contractAddress: isNative ? zeroAddress : tokenInfo.address,
112
- symbol: isNative
113
- ? chainInfo?.nativeCurrency.symbol || "Unknown"
114
- : tokenInfo.symbol,
115
- }),
116
- isNativeToken: isNative,
117
- }
118
- }
119
-
120
- // Helper function to calculate search relevance score
121
- function calculateSearchRelevanceScore(
122
- tokenSymbol: string,
123
- tokenName: string,
124
- chainName: string,
125
- queryParts: string[],
126
- ): number {
127
- let score = 0
128
-
129
- for (const part of queryParts) {
130
- // Exact symbol match gets highest priority (100 points)
131
- if (tokenSymbol === part) score += 100
132
-
133
- // Symbol starts with query gets high priority (50 points)
134
- if (tokenSymbol.startsWith(part)) score += 50
135
-
136
- // Symbol contains query gets medium priority (25 points)
137
- if (tokenSymbol.includes(part)) score += 25
138
-
139
- // Token name exact match (20 points)
140
- if (tokenName === part) score += 20
141
-
142
- // Token name starts with query (15 points)
143
- if (tokenName.startsWith(part)) score += 15
144
-
145
- // Token name contains query (10 points)
146
- if (tokenName.includes(part)) score += 10
147
-
148
- // Chain name exact match (5 points)
149
- if (chainName === part) score += 5
150
-
151
- // Chain name contains query (2 points)
152
- if (chainName.includes(part)) score += 2
153
- }
154
-
155
- return score
156
- }
157
-
158
- export type UseTokenListProps = {
159
- onContinue: (selectedToken: Token) => void
160
- targetAmountUsd?: number | null
161
- onError: (error: Error | string | null) => void
162
- fundMethod?: FundMethod | null
163
- allSupportedTokens?: boolean
164
- includePrice?: boolean
165
- }
166
-
167
- export type UseTokenListReturn = {
168
- selectedToken: Token | null
169
- searchQuery: string
170
- handleTokenSelect: (token: Token) => void
171
- filteredTokens: Token[]
172
- isLoadingSortedTokens: boolean
173
- isLoadingSearchTokens?: boolean
174
- isSearching: boolean // True when search is in progress (typing)
175
- balanceError: Error | null
176
- showContinueButton: boolean
177
- isTokenSelected: (token: Token) => boolean
178
- setSearchQuery: (query: string) => void
179
- filteredTokensFormatted: Token[]
180
- totalBalanceUsd: number
181
- totalBalanceUsdFormatted: string
182
- isLoadingTotalBalanceUsd: boolean
183
- showInsufficientBalance: boolean
184
- isLoadingTokens: boolean
185
- }
186
-
187
- export function useTokenList({
188
- onContinue,
189
- targetAmountUsd,
190
- onError,
191
- fundMethod,
192
- allSupportedTokens = false,
193
- includePrice = false,
194
- }: UseTokenListProps): UseTokenListReturn {
195
- const [selectedToken, setSelectedToken] = useState<Token | null>(null)
196
- const [searchQuery, setSearchQuery] = useState("")
197
- const { address } = useAccount()
198
- const trailsClient = useTrailsClient()
199
- const { getTokenImageUrl } = useGetTokenImageUrl()
200
- const {
201
- sortedTokens: allSortedTokens,
202
- isLoadingSortedTokens,
203
- balanceError,
204
- } = useTokenBalances(address as Address.Address, undefined, {
205
- refetchInterval: WIDGET_REFRESH_INTERVAL,
206
- })
207
-
208
- // Use cached supported tokens hook
209
- const { supportedTokens, isLoadingTokens: isLoadingSupportedTokens } =
210
- useSupportedTokens()
211
-
212
- // Get trails config for API calls
213
- const trailsConfig = useTrails()
214
-
215
- // Get supported chains for getTokenList API
216
- const { data: supportedChains = [] } = useSupportedChains()
217
-
218
- // Get chain filter for destination token list
219
- const { selectedChainId: filterByChainId } = useChainFilter()
220
-
221
- // Only use API search for exchange/meld/qr-code modes or when allSupportedTokens is true
222
- // (where we show all tokens, not just user balances)
223
- // For other modes, we only filter user's token balances locally
224
- const shouldUseApiSearch =
225
- (fundMethod && fundMethod !== "wallet") || allSupportedTokens
226
-
227
- // Memoize chain IDs to avoid recalculating
228
- const apiSearchChainIds = useMemo(
229
- () => supportedChains.map((chain) => chain.id),
230
- [supportedChains],
231
- )
232
-
233
- // Check if search query is an address
234
- const trimmedSearchQuery = useMemo(() => searchQuery.trim(), [searchQuery])
235
- // Debounce the search query to avoid excessive API calls (300ms delay)
236
- const debouncedSearchQuery = useDebounce(trimmedSearchQuery, 300)
237
- const isSearchQueryAddress = useMemo(
238
- () => (debouncedSearchQuery ? isAddress(debouncedSearchQuery) : false),
239
- [debouncedSearchQuery],
240
- )
241
-
242
- // Track if user is actively typing (search query changed but debounce hasn't fired yet)
243
- const isSearchPending = trimmedSearchQuery !== debouncedSearchQuery
244
-
245
- // Call getTokenList API when there's a search query (for any search, not just addresses)
246
- const { data: searchTokensResult, isLoading: isLoadingSearchTokens } =
247
- useQuery({
248
- queryKey: [
249
- "getTokenList",
250
- "search",
251
- debouncedSearchQuery,
252
- apiSearchChainIds,
253
- trailsConfig.trailsApiUrl,
254
- trailsConfig.trailsApiKey,
255
- ],
256
- queryFn: async () => {
257
- if (
258
- !debouncedSearchQuery ||
259
- !trailsClient ||
260
- !trailsConfig.trailsApiKey
261
- ) {
262
- return { tokens: [] }
263
- }
264
-
265
- try {
266
- const response = await trailsClient.getTokenList({
267
- searchQuery: debouncedSearchQuery,
268
- chainIds: apiSearchChainIds,
269
- includeAllListed: true,
270
- limit: 30,
271
- })
272
- return response
273
- } catch (error) {
274
- logger.console.warn("[trails-sdk] Error searching tokens:", error)
275
- return { tokens: [] }
276
- }
277
- },
278
- enabled:
279
- shouldUseApiSearch &&
280
- debouncedSearchQuery.length > 0 &&
281
- !!trailsClient &&
282
- !!trailsConfig.trailsApiKey,
283
- staleTime: 30 * SECOND_MS, // 30 seconds
284
- gcTime: 5 * MINUTE_MS, // 5 minutes
285
- })
286
-
287
- // Fetch custom token info if searching by address and getTokenList returned no results
288
- const hasNoSearchResults = searchTokensResult?.tokens?.length === 0
289
- const shouldFetchCustomToken =
290
- shouldUseApiSearch &&
291
- isSearchQueryAddress &&
292
- hasNoSearchResults &&
293
- !isLoadingSearchTokens &&
294
- trimmedSearchQuery.length > 0
295
- const customTokenChainId = supportedChains[0]?.id ?? null
296
-
297
- const { tokenInfo: customTokenInfo, isLoading: isLoadingCustomToken } =
298
- useCustomTokenFetch({
299
- address: shouldFetchCustomToken ? trimmedSearchQuery : null,
300
- chainId: customTokenChainId,
301
- enabled: shouldFetchCustomToken,
302
- })
303
-
304
- // Fetch tokens from getTokenList when a chain is selected (for destination token list only)
305
- // This fetches all available tokens from that chain, not just filtering existing tokens
306
- const {
307
- data: chainFilteredTokenList,
308
- isLoading: isLoadingChainFilteredTokens,
309
- } = useQuery({
310
- queryKey: [
311
- "getTokenList",
312
- filterByChainId,
313
- trailsConfig.trailsApiUrl,
314
- trailsConfig.trailsApiKey,
315
- ],
316
- queryFn: async () => {
317
- if (
318
- !filterByChainId ||
319
- !trailsClient ||
320
- !trailsConfig.trailsApiKey ||
321
- !shouldUseApiSearch
322
- ) {
323
- return { tokens: [] }
324
- }
325
-
326
- try {
327
- // Fetch tokens from the selected chain with limit of 100 for single chain
328
- const response = await trailsClient.getTokenList({
329
- chainIds: [filterByChainId],
330
- includeAllListed: true,
331
- limit: 100,
332
- })
333
- return response
334
- } catch (error) {
335
- logger.console.warn(
336
- "[trails-sdk] Error fetching tokens for chain filter:",
337
- error,
338
- )
339
- return { tokens: [] }
340
- }
341
- },
342
- enabled:
343
- shouldUseApiSearch &&
344
- filterByChainId !== null &&
345
- !!trailsClient &&
346
- !!trailsConfig.trailsApiKey,
347
- staleTime: DAY_MS, // 24 hours - token list is static
348
- gcTime: DAY_MS, // 24 hours
349
- refetchOnMount: false,
350
- refetchOnWindowFocus: false,
351
- refetchOnReconnect: false,
352
- })
353
-
354
- // Fetch prices for supported tokens when allSupportedTokens is true OR for qr-code/exchange/meld modes
355
- const supportedTokensForPricing = useMemo(() => {
356
- if (
357
- fundMethod === "direct-transfer" ||
358
- fundMethod === "onramp-mesh" ||
359
- fundMethod === "onramp-meld"
360
- ) {
361
- // For QR code and exchange modes, get prices for the filtered tokens
362
- if (!supportedTokens?.length) return []
363
-
364
- const filteredTokens = supportedTokens.filter((token: any) => {
365
- const symbol = token.symbol.toUpperCase()
366
- return STANDARD_TOKENS.includes(symbol as any)
367
- })
368
-
369
- return filteredTokens.map((token: any) => ({
370
- chainId: token.chainId,
371
- tokenAddress: token.contractAddress || zeroAddress,
372
- tokenSymbol: token.symbol,
373
- }))
374
- }
375
-
376
- if (!allSupportedTokens || !supportedTokens?.length) return []
377
-
378
- return supportedTokens.map((token: any) => ({
379
- chainId: token.chainId,
380
- tokenAddress: token.contractAddress || zeroAddress,
381
- tokenSymbol: token.symbol,
382
- }))
383
- }, [allSupportedTokens, supportedTokens, fundMethod])
384
-
385
- const {
386
- tokenPrices: supportedTokenPrices,
387
- isLoadingTokenPrices: isLoadingSupportedTokenPrices,
388
- } = useTokenPrices(supportedTokensForPricing, !includePrice)
389
-
390
- // Determine loading state based on fund method and allSupportedTokens
391
- const isLoadingTokens =
392
- fundMethod && fundMethod !== "wallet"
393
- ? isLoadingSupportedTokens ||
394
- isLoadingSupportedTokenPrices ||
395
- isLoadingSearchTokens ||
396
- isLoadingCustomToken ||
397
- isLoadingChainFilteredTokens
398
- : allSupportedTokens
399
- ? isLoadingSortedTokens ||
400
- isLoadingSupportedTokens ||
401
- isLoadingSupportedTokenPrices ||
402
- isLoadingChainFilteredTokens
403
- : isLoadingSortedTokens
404
-
405
- const { data: totalBalanceUsd = 0, isLoading: isLoadingTotalBalanceUsd } =
406
- useAccountTotalBalanceUsd(address as Address.Address)
407
- const totalBalanceUsdFormatted = formatUsdAmountDisplay(totalBalanceUsd)
408
- const {
409
- data: hasSufficientBalanceUsd = false,
410
- isLoading: isLoadingHasSufficientBalanceUsd,
411
- error: hasSufficientBalanceUsdError,
412
- } = useHasSufficientBalanceUsd(address as Address.Address, targetAmountUsd)
413
- const showContinueButton = false
414
- // Note: Supported tokens are now fetched via useSupportedTokens hook with caching
415
-
416
- // Map chain-filtered token list results to Token format
417
- // Used when a chain is selected for destination token list
418
- const chainFilteredApiTokens = useMemo(() => {
419
- if (
420
- !shouldUseApiSearch ||
421
- !chainFilteredTokenList?.tokens?.length ||
422
- filterByChainId === null
423
- ) {
424
- return []
425
- }
426
-
427
- return chainFilteredTokenList.tokens
428
- .filter((tokenInfo: ApiTokenInfo) => {
429
- if (!isValidDecimals(tokenInfo.decimals)) {
430
- logger.console.warn(
431
- "[trails-sdk] Skipping token with invalid decimals:",
432
- {
433
- symbol: tokenInfo.symbol,
434
- address: tokenInfo.address,
435
- decimals: tokenInfo.decimals,
436
- },
437
- )
438
- return false
439
- }
440
- return true
441
- })
442
- .map((tokenInfo: ApiTokenInfo) =>
443
- convertApiTokenToToken(tokenInfo, getTokenImageUrl),
444
- )
445
- }, [
446
- chainFilteredTokenList,
447
- getTokenImageUrl,
448
- shouldUseApiSearch,
449
- filterByChainId,
450
- ])
451
-
452
- const sortedTokens = useMemo<Array<Token>>(() => {
453
- // If fundMethod is not wallet, use filtered supported tokens
454
- if (fundMethod && fundMethod !== "wallet") {
455
- // If chain filter is active and we have chain-filtered tokens, use those
456
- if (
457
- shouldUseApiSearch &&
458
- filterByChainId !== null &&
459
- chainFilteredApiTokens.length > 0
460
- ) {
461
- // Merge chain-filtered tokens with local tokens (prefer local tokens with balances)
462
- const localTokensMap = new Map<string, Token>()
463
- for (const tokenItem of allSortedTokens) {
464
- const contractAddress = tokenItem.contractAddress || zeroAddress
465
- const key = getTokenKey(tokenItem.chainId || 0, contractAddress)
466
- localTokensMap.set(key, tokenItem)
467
- }
468
-
469
- const mergedTokens: Token[] = chainFilteredApiTokens.map(
470
- (apiToken: Token) => {
471
- const contractAddress = apiToken.contractAddress || zeroAddress
472
- const key = getTokenKey(apiToken.chainId || 0, contractAddress)
473
- const localToken = localTokensMap.get(key)
474
-
475
- // If local token exists and has balance, use it; otherwise use API token
476
- return localToken && (localToken.balanceUsd || 0) > 0
477
- ? localToken
478
- : apiToken
479
- },
480
- )
481
-
482
- // Add any local tokens that weren't in API results
483
- const apiTokenKeys = new Set(
484
- mergedTokens.map((token) =>
485
- getTokenKey(
486
- token.chainId || 0,
487
- token.contractAddress || zeroAddress,
488
- ),
489
- ),
490
- )
491
- for (const localToken of allSortedTokens) {
492
- const key = getTokenKey(
493
- localToken.chainId || 0,
494
- localToken.contractAddress || zeroAddress,
495
- )
496
- if (
497
- !apiTokenKeys.has(key) &&
498
- (localToken.chainId || 0) === filterByChainId
499
- ) {
500
- mergedTokens.push(localToken)
501
- }
502
- }
503
-
504
- return mergedTokens
505
- }
506
-
507
- // Filter to only show specific tokens for QR code and exchange modes
508
- const filteredTokens = supportedTokens.filter((token: any) => {
509
- const symbol = token.symbol.toUpperCase()
510
- return STANDARD_TOKENS.includes(symbol as any)
511
- })
512
-
513
- // Convert SupportedToken to Token format and add price data
514
- const tokensWithPrices: Token[] = filteredTokens.map(
515
- (token: Token): Token => {
516
- // Find price data for this token
517
- const priceData = supportedTokenPrices?.find(
518
- (p: any) =>
519
- p.token.tokenAddress?.toLowerCase() ===
520
- (token.contractAddress || zeroAddress).toLowerCase() &&
521
- Number(p.token.chainId) === Number(token.chainId),
522
- )
523
-
524
- const priceUsd = priceData?.priceUsd
525
-
526
- // Format price fields if price exists
527
- const priceFields = priceUsd ? formatPriceFields(priceUsd) : undefined
528
-
529
- // Return Token with price data
530
- return {
531
- ...token,
532
- // No balance info for QR code and exchange modes
533
- ...(priceFields && {
534
- priceUsd: priceFields.priceUsd,
535
- priceUsdFormatted: priceFields.priceUsdFormatted,
536
- priceUsdDisplay: priceFields.priceUsdDisplay,
537
- }),
538
- isSufficientBalance: true, // Always true for QR code and exchange modes
539
- }
540
- },
541
- )
542
-
543
- // Sort by price (highest first) since volume is not available
544
- return tokensWithPrices.sort((a, b) => {
545
- return (b.priceUsd || 0) - (a.priceUsd || 0)
546
- })
547
- }
548
-
549
- // If allSupportedTokens is true and chain filter is active, use chain-filtered tokens
550
- if (
551
- allSupportedTokens &&
552
- shouldUseApiSearch &&
553
- filterByChainId !== null &&
554
- chainFilteredApiTokens.length > 0
555
- ) {
556
- // Merge chain-filtered tokens with local tokens (prefer local tokens with balances)
557
- const localTokensMap = new Map<string, Token>()
558
- for (const tokenItem of allSortedTokens) {
559
- const contractAddress = tokenItem.contractAddress || zeroAddress
560
- const key = getTokenKey(tokenItem.chainId || 0, contractAddress)
561
- localTokensMap.set(key, tokenItem)
562
- }
563
-
564
- const mergedTokens: Token[] = chainFilteredApiTokens.map(
565
- (apiToken: Token) => {
566
- const contractAddress = apiToken.contractAddress || zeroAddress
567
- const key = getTokenKey(apiToken.chainId || 0, contractAddress)
568
- const localToken = localTokensMap.get(key)
569
-
570
- // If local token exists and has balance, use it; otherwise use API token
571
- return localToken && (localToken.balanceUsd || 0) > 0
572
- ? localToken
573
- : apiToken
574
- },
575
- )
576
-
577
- // Add any local tokens that weren't in API results
578
- const apiTokenKeys = new Set(
579
- mergedTokens.map((token) =>
580
- getTokenKey(token.chainId || 0, token.contractAddress || zeroAddress),
581
- ),
582
- )
583
- for (const localToken of allSortedTokens) {
584
- const key = getTokenKey(
585
- localToken.chainId || 0,
586
- localToken.contractAddress || zeroAddress,
587
- )
588
- if (
589
- !apiTokenKeys.has(key) &&
590
- (localToken.chainId || 0) === filterByChainId
591
- ) {
592
- mergedTokens.push(localToken)
593
- }
594
- }
595
-
596
- return mergedTokens
597
- }
598
-
599
- // Default behavior: use account-specific tokens (already Token[]). Chain
600
- // filtering is applied in useTokenBalances with fail-open fallback.
601
- return allSortedTokens
602
- }, [
603
- allSortedTokens,
604
- fundMethod,
605
- supportedTokens,
606
- supportedTokenPrices,
607
- shouldUseApiSearch,
608
- filterByChainId,
609
- chainFilteredApiTokens,
610
- allSupportedTokens,
611
- ])
612
-
613
- useEffect(() => {
614
- if (onError && balanceError) {
615
- onError(balanceError)
616
- }
617
- }, [balanceError, onError])
618
-
619
- const handleTokenSelect = (token: Token) => {
620
- const isNative = token.isNativeToken ?? false
621
- const decimals = token.decimals
622
- if (!decimals) {
623
- logger.console.warn(
624
- "[trails-sdk] [useTokenList] Missing decimals for token:",
625
- {
626
- token: token,
627
- chainId: token.chainId,
628
- isNative,
629
- },
630
- )
631
- onError("Decimals not found [useTokenList]")
632
- return
633
- }
634
-
635
- setSelectedToken(token)
636
- const canContinue =
637
- (!targetAmountUsd || (targetAmountUsd && hasSufficientBalanceUsd)) &&
638
- (token.isSufficientBalance ?? true)
639
-
640
- if (!canContinue) {
641
- logger.console.warn("[trails-sdk] Cannot continue with token selection", {
642
- token: token,
643
- targetAmountUsd,
644
- hasSufficientBalanceUsd,
645
- isSufficientBalance: token.isSufficientBalance,
646
- })
647
- }
648
-
649
- onContinue(token)
650
- }
651
-
652
- const isTokenSelected = (token: Token): boolean => {
653
- if (!selectedToken) return false
654
-
655
- const isNative = token.isNativeToken ?? false
656
- const selectedIsNative = selectedToken.isNativeToken ?? false
657
- return (
658
- (selectedToken.chainId || 0) === (token.chainId || 0) &&
659
- (isNative
660
- ? selectedIsNative
661
- : addressEqual(selectedToken.contractAddress, token.contractAddress))
662
- )
663
- }
664
-
665
- // Map API search results to Token format
666
- // Only used for exchange/qr-code modes
667
- const apiSearchTokens = useMemo(() => {
668
- if (!shouldUseApiSearch || !searchTokensResult?.tokens?.length) {
669
- return []
670
- }
671
-
672
- return searchTokensResult.tokens
673
- .filter((tokenInfo: ApiTokenInfo) => {
674
- if (!isValidDecimals(tokenInfo.decimals)) {
675
- logger.console.warn(
676
- "[trails-sdk] Skipping token with invalid decimals:",
677
- {
678
- symbol: tokenInfo.symbol,
679
- address: tokenInfo.address,
680
- decimals: tokenInfo.decimals,
681
- },
682
- )
683
- return false
684
- }
685
- return true
686
- })
687
- .map((tokenInfo: ApiTokenInfo) =>
688
- convertApiTokenToToken(tokenInfo, getTokenImageUrl),
689
- )
690
- }, [searchTokensResult, getTokenImageUrl, shouldUseApiSearch])
691
-
692
- // Convert custom token info to Token format
693
- const customTokenAsTokenBalance = useMemo(() => {
694
- if (!customTokenInfo || !customTokenChainId) return null
695
-
696
- const chainInfo = getChainInfo(customTokenChainId)
697
- const validatedDecimals = validateDecimals(customTokenInfo.decimals)
698
-
699
- return {
700
- symbol: customTokenInfo.symbol,
701
- name: customTokenInfo.name,
702
- decimals: validatedDecimals,
703
- contractAddress: customTokenInfo.contractAddress,
704
- chainId: customTokenChainId,
705
- chainName: chainInfo?.name || `Chain ${customTokenChainId}`,
706
- imageUrl: getTokenImageUrl({
707
- chainId: customTokenChainId,
708
- contractAddress: customTokenInfo.contractAddress,
709
- symbol: customTokenInfo.symbol,
710
- }),
711
- isCustomToken: true,
712
- } as Token
713
- }, [customTokenInfo, customTokenChainId, getTokenImageUrl])
714
-
715
- const filteredTokens = useMemo(() => {
716
- // If searching by address and getTokenList returned no results, return custom token if available
717
- if (
718
- shouldUseApiSearch &&
719
- isSearchQueryAddress &&
720
- hasNoSearchResults &&
721
- customTokenAsTokenBalance
722
- ) {
723
- return [customTokenAsTokenBalance]
724
- }
725
-
726
- // sortedTokens is already Token[] from useTokenBalances
727
- // Only use API search results for exchange/qr-code modes
728
- if (
729
- shouldUseApiSearch &&
730
- trimmedSearchQuery &&
731
- apiSearchTokens.length > 0
732
- ) {
733
- // Create a map of local tokens by chainId and contractAddress for quick lookup
734
- const localTokensMap = new Map<string, Token>()
735
- for (const tokenItem of sortedTokens) {
736
- const contractAddress = tokenItem.contractAddress || zeroAddress
737
- const key = getTokenKey(tokenItem.chainId || 0, contractAddress)
738
- localTokensMap.set(key, tokenItem)
739
- }
740
-
741
- // Merge API results with local tokens (prefer local tokens with balances)
742
- const mergedTokens: Token[] = apiSearchTokens.map((apiToken: Token) => {
743
- const contractAddress = apiToken.contractAddress || zeroAddress
744
- const key = getTokenKey(apiToken.chainId || 0, contractAddress)
745
- const localToken = localTokensMap.get(key)
746
-
747
- // If local token exists and has balance, use it; otherwise use API token
748
- return localToken && (localToken.balanceUsd || 0) > 0
749
- ? localToken
750
- : apiToken
751
- })
752
-
753
- // Add any local tokens that weren't in API results but match the search
754
- const apiTokenKeys = new Set(
755
- mergedTokens.map((token) => {
756
- const contractAddress = token.contractAddress || zeroAddress
757
- return getTokenKey(token.chainId || 0, contractAddress)
758
- }),
759
- )
760
-
761
- const queryLower = trimmedSearchQuery.toLowerCase()
762
- for (const tokenItem of sortedTokens) {
763
- const contractAddress = tokenItem.contractAddress || zeroAddress
764
- const key = getTokenKey(tokenItem.chainId || 0, contractAddress)
765
-
766
- if (!apiTokenKeys.has(key)) {
767
- // Check if token matches search query locally
768
- const tokenSymbol = (tokenItem.symbol || "").toLowerCase()
769
- const tokenName = (tokenItem.name || "").toLowerCase()
770
-
771
- if (
772
- tokenSymbol.includes(queryLower) ||
773
- tokenName.includes(queryLower) ||
774
- normalizeAddress(contractAddress).includes(queryLower)
775
- ) {
776
- mergedTokens.push(tokenItem)
777
- }
778
- }
779
- }
780
-
781
- return mergedTokens
782
- }
783
-
784
- // Fallback to local filtering if no API results or not using API search
785
- if (!trimmedSearchQuery) {
786
- return sortedTokens
787
- }
788
-
789
- const queryLower = trimmedSearchQuery.toLowerCase()
790
- const queryParts = queryLower.split(/\s+/).filter((part) => part.length > 0)
791
-
792
- const matchingTokens = sortedTokens.filter((token: Token) => {
793
- const chainInfo = getChainInfo(token.chainId || 0)
794
- const chainName = chainInfo?.name || ""
795
- const chainNameLower = chainName.toLowerCase()
796
-
797
- const tokenSymbol = (token.symbol || "???").toLowerCase()
798
- const tokenName = (token.name || "Unknown Token").toLowerCase()
799
- const contractAddress = (
800
- token.contractAddress || zeroAddress
801
- ).toLowerCase()
802
-
803
- // If multiple query parts, check if they match chain + token combination
804
- if (queryParts.length > 1) {
805
- const matchesChain = queryParts.some((part) =>
806
- chainNameLower.includes(part),
807
- )
808
- const matchesToken = queryParts.some(
809
- (part) =>
810
- tokenSymbol.includes(part) ||
811
- tokenName.includes(part) ||
812
- contractAddress.includes(part),
813
- )
814
- return matchesChain && matchesToken
815
- }
816
-
817
- // Single query part - match against any field
818
- return queryParts.some(
819
- (part) =>
820
- tokenSymbol.includes(part) ||
821
- tokenName.includes(part) ||
822
- chainNameLower.includes(part) ||
823
- contractAddress.includes(part),
824
- )
825
- })
826
-
827
- // Sort by relevance for balance tokens too
828
- return matchingTokens.sort((a: Token, b: Token) => {
829
- const aChainInfo = getChainInfo(a.chainId || 0)
830
- const bChainInfo = getChainInfo(b.chainId || 0)
831
- const aChainName = aChainInfo?.name?.toLowerCase() || ""
832
- const bChainName = bChainInfo?.name?.toLowerCase() || ""
833
-
834
- const aTokenSymbol = (a.symbol || "???").toLowerCase()
835
- const bTokenSymbol = (b.symbol || "???").toLowerCase()
836
-
837
- const aTokenName = (a.name || "Unknown Token").toLowerCase()
838
- const bTokenName = (b.name || "Unknown Token").toLowerCase()
839
-
840
- // Calculate relevance scores using helper function
841
- const aScore = calculateSearchRelevanceScore(
842
- aTokenSymbol,
843
- aTokenName,
844
- aChainName,
845
- queryParts,
846
- )
847
- const bScore = calculateSearchRelevanceScore(
848
- bTokenSymbol,
849
- bTokenName,
850
- bChainName,
851
- queryParts,
852
- )
853
-
854
- return bScore - aScore // Higher score first
855
- })
856
- }, [
857
- sortedTokens,
858
- trimmedSearchQuery,
859
- apiSearchTokens,
860
- shouldUseApiSearch,
861
- isSearchQueryAddress,
862
- hasNoSearchResults,
863
- customTokenAsTokenBalance,
864
- ])
865
-
866
- const filteredTokensFormatted = useMemo(() => {
867
- // Get base formatted tokens - filteredTokens is already Token[]
868
- const baseFormattedTokens = filteredTokens
869
- .map((token: Token): Token | null => {
870
- const isNative = token.isNativeToken ?? false
871
- const chainInfo = getChainInfo(token.chainId || 0)
872
- const decimals = token.decimals
873
- if (!decimals) {
874
- logger.console.warn(
875
- "[trails-sdk] Missing decimals for token, skipping:",
876
- {
877
- token: token,
878
- chainId: token.chainId,
879
- isNative,
880
- },
881
- )
882
- return null // Return null to filter out tokens without decimals
883
- }
884
-
885
- let isSufficientBalance = token.isSufficientBalance ?? true
886
- if (targetAmountUsd) {
887
- isSufficientBalance = (token.balanceUsd ?? 0) >= targetAmountUsd
888
- }
889
- const chainName = token.chainName || chainInfo?.name || ""
890
-
891
- // Format price fields if not already formatted
892
- const priceFields = token.priceUsdFormatted
893
- ? undefined
894
- : token.priceUsd
895
- ? formatPriceFields(token.priceUsd)
896
- : undefined
897
-
898
- // Return Token with all formatting fields set
899
- return {
900
- ...token,
901
- balanceDisplay: token.balanceDisplay || token.balanceFormatted,
902
- priceUsdFormatted:
903
- token.priceUsdFormatted || priceFields?.priceUsdFormatted,
904
- priceUsdDisplay:
905
- token.priceUsdDisplay || priceFields?.priceUsdDisplay,
906
- balanceUsdDisplay:
907
- token.balanceUsdDisplay || token.balanceUsdFormatted,
908
- isSufficientBalance,
909
- chainName,
910
- }
911
- })
912
- .filter(Boolean) as Token[] // Filter out null values for tokens without decimals
913
-
914
- // If allSupportedTokens is true, combine with supported tokens
915
- if (allSupportedTokens) {
916
- // Create a set of existing token keys for quick lookup
917
- const existingTokenKeys = new Set(
918
- baseFormattedTokens.map(
919
- (token) =>
920
- `${token.chainId}-${normalizeAddress(token.contractAddress)}`,
921
- ),
922
- )
923
-
924
- // Add supported tokens that don't exist in the base list
925
- const additionalSupportedTokens: Token[] = supportedTokens
926
- .filter((supportedToken) => {
927
- const key = `${supportedToken.chainId || 0}-${normalizeAddress(supportedToken.contractAddress)}`
928
- return !existingTokenKeys.has(key)
929
- })
930
- .map((supportedToken): Token => {
931
- const chainInfo = getChainInfo(supportedToken.chainId || 0)
932
- const chainName =
933
- chainInfo?.name || `Chain ${supportedToken.chainId || 0}`
934
-
935
- // Find price data for this supported token
936
- const priceData = supportedTokenPrices?.find(
937
- (p: any) =>
938
- p.token.tokenAddress?.toLowerCase() ===
939
- (supportedToken.contractAddress || zeroAddress).toLowerCase() &&
940
- Number(p.token.chainId) === Number(supportedToken.chainId),
941
- )
942
-
943
- // Format price fields if price exists
944
- const priceFields = priceData?.priceUsd
945
- ? formatPriceFields(priceData.priceUsd)
946
- : undefined
947
-
948
- return {
949
- symbol: supportedToken.symbol,
950
- name: supportedToken.name,
951
- decimals: supportedToken.decimals,
952
- contractAddress: supportedToken.contractAddress,
953
- chainId: supportedToken.chainId,
954
- chainName: chainName,
955
- imageUrl: supportedToken.imageUrl || "",
956
- ...(priceFields && {
957
- priceUsd: priceFields.priceUsd,
958
- priceUsdFormatted: priceFields.priceUsdFormatted,
959
- priceUsdDisplay: priceFields.priceUsdDisplay,
960
- }),
961
- isSufficientBalance: true,
962
- }
963
- })
964
- .sort((a, b) => {
965
- // Sort supported tokens by price (highest first) since volume is not available
966
- return (b.priceUsd || 0) - (a.priceUsd || 0)
967
- })
968
-
969
- // Combine lists with base tokens taking precedence
970
- const combinedTokens = [
971
- ...baseFormattedTokens,
972
- ...additionalSupportedTokens,
973
- ]
974
-
975
- // Apply search filtering to combined tokens when allSupportedTokens is true
976
- if (searchQuery.trim()) {
977
- const query = searchQuery.toLowerCase().trim()
978
- const queryParts = query.split(/\s+/).filter((part) => part.length > 0)
979
-
980
- const filteredTokens = combinedTokens.filter((token: Token) => {
981
- const chainName = token.chainName?.toLowerCase() || ""
982
- const tokenSymbol = token.symbol?.toLowerCase() || ""
983
- const tokenName = token.name?.toLowerCase() || ""
984
- const contractAddress = token.contractAddress?.toLowerCase() || ""
985
-
986
- // If multiple query parts, check if they match chain + token combination
987
- if (queryParts.length > 1) {
988
- const matchesChain = queryParts.some((part) =>
989
- chainName.includes(part),
990
- )
991
- const matchesToken = queryParts.some(
992
- (part) =>
993
- tokenSymbol.includes(part) ||
994
- tokenName.includes(part) ||
995
- contractAddress.includes(part),
996
- )
997
- return matchesChain && matchesToken
998
- }
999
-
1000
- // Single query part - match against any field
1001
- return queryParts.some(
1002
- (part) =>
1003
- tokenSymbol.includes(part) ||
1004
- tokenName.includes(part) ||
1005
- chainName.includes(part) ||
1006
- contractAddress.includes(part),
1007
- )
1008
- })
1009
-
1010
- // Sort filtered tokens by relevance
1011
- return filteredTokens.sort((a, b) => {
1012
- const aChainName = a.chainName?.toLowerCase() || ""
1013
- const aTokenSymbol = a.symbol?.toLowerCase() || ""
1014
- const aTokenName = a.name?.toLowerCase() || ""
1015
- const bChainName = b.chainName?.toLowerCase() || ""
1016
- const bTokenSymbol = b.symbol?.toLowerCase() || ""
1017
- const bTokenName = b.name?.toLowerCase() || ""
1018
-
1019
- // Calculate relevance scores using helper function
1020
- const aScore = calculateSearchRelevanceScore(
1021
- aTokenSymbol,
1022
- aTokenName,
1023
- aChainName,
1024
- queryParts,
1025
- )
1026
- const bScore = calculateSearchRelevanceScore(
1027
- bTokenSymbol,
1028
- bTokenName,
1029
- bChainName,
1030
- queryParts,
1031
- )
1032
-
1033
- // If scores are equal, prefer tokens with balances
1034
- if (aScore === bScore) {
1035
- const aHasBalance = a.balance && a.balance !== ""
1036
- const bHasBalance = b.balance && b.balance !== ""
1037
- if (aHasBalance && !bHasBalance) return -1
1038
- if (!aHasBalance && bHasBalance) return 1
1039
- }
1040
-
1041
- return bScore - aScore // Higher score first
1042
- })
1043
- }
1044
-
1045
- return combinedTokens
1046
- }
1047
-
1048
- return baseFormattedTokens
1049
- }, [
1050
- filteredTokens,
1051
- targetAmountUsd,
1052
- allSupportedTokens,
1053
- supportedTokens,
1054
- supportedTokenPrices,
1055
- searchQuery,
1056
- ])
1057
-
1058
- const showInsufficientBalance = useMemo(() => {
1059
- return (
1060
- (totalBalanceUsd &&
1061
- targetAmountUsd &&
1062
- !hasSufficientBalanceUsd &&
1063
- !isLoadingHasSufficientBalanceUsd &&
1064
- !hasSufficientBalanceUsdError) ||
1065
- (filteredTokensFormatted?.length > 0 &&
1066
- !filteredTokensFormatted.some((token) => token.isSufficientBalance))
1067
- )
1068
- }, [
1069
- targetAmountUsd,
1070
- hasSufficientBalanceUsd,
1071
- isLoadingHasSufficientBalanceUsd,
1072
- hasSufficientBalanceUsdError,
1073
- filteredTokensFormatted,
1074
- totalBalanceUsd,
1075
- ])
1076
-
1077
- // isSearching: true when user is typing (debounce pending) or API is fetching
1078
- const isSearching = isSearchPending || isLoadingSearchTokens
1079
-
1080
- return {
1081
- selectedToken,
1082
- searchQuery,
1083
- handleTokenSelect,
1084
- filteredTokens,
1085
- isLoadingSortedTokens: isLoadingSortedTokens || isLoadingSearchTokens,
1086
- isLoadingSearchTokens,
1087
- isSearching,
1088
- balanceError,
1089
- showContinueButton,
1090
- isTokenSelected,
1091
- setSearchQuery,
1092
- filteredTokensFormatted,
1093
- totalBalanceUsd,
1094
- totalBalanceUsdFormatted,
1095
- isLoadingTotalBalanceUsd,
1096
- showInsufficientBalance,
1097
- isLoadingTokens,
1098
- }
1099
- }