0xtrails 0.6.6 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/dist/aave.d.ts +10 -2
  2. package/dist/aave.d.ts.map +1 -1
  3. package/dist/analytics.d.ts +26 -0
  4. package/dist/analytics.d.ts.map +1 -1
  5. package/dist/{ccip-CbJrlK-L.js → ccip-fConRNoG.js} +21 -21
  6. package/dist/chains.d.ts +23 -8
  7. package/dist/chains.d.ts.map +1 -1
  8. package/dist/constants.d.ts +5 -5
  9. package/dist/constants.d.ts.map +1 -1
  10. package/dist/customTokens.d.ts +12 -0
  11. package/dist/customTokens.d.ts.map +1 -0
  12. package/dist/decoders.d.ts +2 -2
  13. package/dist/decoders.d.ts.map +1 -1
  14. package/dist/error.d.ts.map +1 -1
  15. package/dist/fees.d.ts +37 -2
  16. package/dist/fees.d.ts.map +1 -1
  17. package/dist/gasless.d.ts +15 -36
  18. package/dist/gasless.d.ts.map +1 -1
  19. package/dist/{index-w7_dK4c5.js → index-BbajxCG_.js} +59269 -77146
  20. package/dist/index.d.ts +8 -6
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +828 -359
  23. package/dist/indexerClient.d.ts.map +1 -1
  24. package/dist/intentReceiptMonitor.d.ts +1 -1
  25. package/dist/intentReceiptMonitor.d.ts.map +1 -1
  26. package/dist/intentReceiptPoller.d.ts +1 -1
  27. package/dist/intentReceiptPoller.d.ts.map +1 -1
  28. package/dist/intents.d.ts +3 -2
  29. package/dist/intents.d.ts.map +1 -1
  30. package/dist/mode.d.ts +1 -1
  31. package/dist/mode.d.ts.map +1 -1
  32. package/dist/mutations.d.ts +2 -2
  33. package/dist/mutations.d.ts.map +1 -1
  34. package/dist/prepareSend.d.ts +2 -2
  35. package/dist/prepareSend.d.ts.map +1 -1
  36. package/dist/prices.d.ts +1 -1
  37. package/dist/prices.d.ts.map +1 -1
  38. package/dist/sequenceWallet.d.ts +2 -2
  39. package/dist/sequenceWallet.d.ts.map +1 -1
  40. package/dist/time.d.ts +6 -0
  41. package/dist/time.d.ts.map +1 -1
  42. package/dist/tokenBalances.d.ts +40 -25
  43. package/dist/tokenBalances.d.ts.map +1 -1
  44. package/dist/tokens.d.ts +54 -14
  45. package/dist/tokens.d.ts.map +1 -1
  46. package/dist/trailsClient.d.ts +1 -1
  47. package/dist/trailsClient.d.ts.map +1 -1
  48. package/dist/trailsRouter.d.ts +2 -1
  49. package/dist/trailsRouter.d.ts.map +1 -1
  50. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +3 -2
  51. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
  52. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +2 -1
  53. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
  54. package/dist/transactionIntent/execution/transactionState.d.ts +1 -1
  55. package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -1
  56. package/dist/transactionIntent/handlers/crossChain.d.ts +5 -3
  57. package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -1
  58. package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +5 -3
  59. package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -1
  60. package/dist/transactionIntent/quote/feeExtractors.d.ts +1 -6
  61. package/dist/transactionIntent/quote/feeExtractors.d.ts.map +1 -1
  62. package/dist/transactionIntent/quote/normalizeQuote.d.ts +4 -2
  63. package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
  64. package/dist/transactionIntent/quote/quoteHelpers.d.ts +1 -1
  65. package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -1
  66. package/dist/transactionIntent/types.d.ts +28 -5
  67. package/dist/transactionIntent/types.d.ts.map +1 -1
  68. package/dist/transactionIntent/utils/testnetHelpers.d.ts +0 -1
  69. package/dist/transactionIntent/utils/testnetHelpers.d.ts.map +1 -1
  70. package/dist/transactionIntent/validators.d.ts +0 -2
  71. package/dist/transactionIntent/validators.d.ts.map +1 -1
  72. package/dist/transactions.d.ts +2 -2
  73. package/dist/transactions.d.ts.map +1 -1
  74. package/dist/utils.d.ts +7 -0
  75. package/dist/utils.d.ts.map +1 -1
  76. package/dist/wallets.d.ts +1 -0
  77. package/dist/wallets.d.ts.map +1 -1
  78. package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
  79. package/dist/widget/components/AddressWalletIcon.d.ts +6 -0
  80. package/dist/widget/components/AddressWalletIcon.d.ts.map +1 -0
  81. package/dist/widget/components/ChainFilterDropdown.d.ts +2 -6
  82. package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
  83. package/dist/widget/components/ChainImage.d.ts.map +1 -1
  84. package/dist/widget/components/ChainList.d.ts +0 -5
  85. package/dist/widget/components/ChainList.d.ts.map +1 -1
  86. package/dist/widget/components/ClassicSwap.d.ts +6 -6
  87. package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
  88. package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
  89. package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
  90. package/dist/widget/components/DebugMenu.d.ts +1 -1
  91. package/dist/widget/components/DebugMenu.d.ts.map +1 -1
  92. package/dist/widget/components/DebugScreensList.d.ts.map +1 -1
  93. package/dist/widget/components/DepositTracker.d.ts.map +1 -1
  94. package/dist/widget/components/Earn.d.ts +5 -5
  95. package/dist/widget/components/Earn.d.ts.map +1 -1
  96. package/dist/widget/components/FeeOption.d.ts +1 -1
  97. package/dist/widget/components/FeeOption.d.ts.map +1 -1
  98. package/dist/widget/components/FeeOptions.d.ts +2 -2
  99. package/dist/widget/components/FeeOptions.d.ts.map +1 -1
  100. package/dist/widget/components/Footer.d.ts +1 -1
  101. package/dist/widget/components/Footer.d.ts.map +1 -1
  102. package/dist/widget/components/Fund.d.ts +5 -5
  103. package/dist/widget/components/Fund.d.ts.map +1 -1
  104. package/dist/widget/components/FundMethods.d.ts +0 -1
  105. package/dist/widget/components/FundMethods.d.ts.map +1 -1
  106. package/dist/widget/components/FundSwap.d.ts +6 -6
  107. package/dist/widget/components/FundSwap.d.ts.map +1 -1
  108. package/dist/widget/components/HookModalContent.d.ts +8 -0
  109. package/dist/widget/components/HookModalContent.d.ts.map +1 -0
  110. package/dist/widget/components/OriginSelectionAmount.d.ts +11 -0
  111. package/dist/widget/components/OriginSelectionAmount.d.ts.map +1 -0
  112. package/dist/widget/components/Pay.d.ts +5 -5
  113. package/dist/widget/components/Pay.d.ts.map +1 -1
  114. package/dist/widget/components/PoolDeposit.d.ts +5 -5
  115. package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
  116. package/dist/widget/components/PoolWithdraw.d.ts +3 -3
  117. package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
  118. package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
  119. package/dist/widget/components/Receipt.d.ts +2 -1
  120. package/dist/widget/components/Receipt.d.ts.map +1 -1
  121. package/dist/widget/components/RecentTokens.d.ts +4 -4
  122. package/dist/widget/components/RecentTokens.d.ts.map +1 -1
  123. package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -1
  124. package/dist/widget/components/ShadowPortal.d.ts +6 -0
  125. package/dist/widget/components/ShadowPortal.d.ts.map +1 -0
  126. package/dist/widget/components/Swap.d.ts +6 -6
  127. package/dist/widget/components/Swap.d.ts.map +1 -1
  128. package/dist/widget/components/ThemeProvider.d.ts +1 -1
  129. package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
  130. package/dist/widget/components/TokenList.d.ts +3 -4
  131. package/dist/widget/components/TokenList.d.ts.map +1 -1
  132. package/dist/widget/components/TokenSelector.d.ts +3 -4
  133. package/dist/widget/components/TokenSelector.d.ts.map +1 -1
  134. package/dist/widget/components/Tooltip.d.ts +6 -1
  135. package/dist/widget/components/Tooltip.d.ts.map +1 -1
  136. package/dist/widget/components/TrailsHookModal.d.ts +10 -0
  137. package/dist/widget/components/TrailsHookModal.d.ts.map +1 -0
  138. package/dist/widget/components/WaasFeeOptions.d.ts +3 -0
  139. package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
  140. package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
  141. package/dist/widget/components/WalletConnect.d.ts.map +1 -1
  142. package/dist/widget/components/WidgetProviders.d.ts +14 -0
  143. package/dist/widget/components/WidgetProviders.d.ts.map +1 -0
  144. package/dist/widget/css/compiled.css +1 -1
  145. package/dist/widget/hooks/useAddressWalletIcon.d.ts +10 -0
  146. package/dist/widget/hooks/useAddressWalletIcon.d.ts.map +1 -0
  147. package/dist/widget/hooks/useBalanceVisible.d.ts +1 -1
  148. package/dist/widget/hooks/useBalanceVisible.d.ts.map +1 -1
  149. package/dist/widget/hooks/useChainFilter.d.ts +1 -1
  150. package/dist/widget/hooks/useChainFilter.d.ts.map +1 -1
  151. package/dist/widget/hooks/useCheckout.d.ts +13 -1
  152. package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
  153. package/dist/widget/hooks/useConnector.d.ts +4 -0
  154. package/dist/widget/hooks/useConnector.d.ts.map +1 -0
  155. package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
  156. package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
  157. package/dist/widget/hooks/useCustomTokenFetch.d.ts +19 -0
  158. package/dist/widget/hooks/useCustomTokenFetch.d.ts.map +1 -0
  159. package/dist/widget/hooks/useCustomTokenSearch.d.ts +20 -0
  160. package/dist/widget/hooks/useCustomTokenSearch.d.ts.map +1 -0
  161. package/dist/widget/hooks/useDebounce.d.ts +10 -0
  162. package/dist/widget/hooks/useDebounce.d.ts.map +1 -0
  163. package/dist/widget/hooks/useDebugScreens.d.ts +7 -2
  164. package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
  165. package/dist/widget/hooks/useDefaultTokenSelection.d.ts +3 -19
  166. package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
  167. package/dist/widget/hooks/useDestinationSelectedToken.d.ts +1 -14
  168. package/dist/widget/hooks/useDestinationSelectedToken.d.ts.map +1 -1
  169. package/dist/widget/hooks/useEarnPool.d.ts +1 -1
  170. package/dist/widget/hooks/useEarnPool.d.ts.map +1 -1
  171. package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
  172. package/dist/widget/hooks/useIsMobile.d.ts +5 -0
  173. package/dist/widget/hooks/useIsMobile.d.ts.map +1 -0
  174. package/dist/widget/hooks/useMode.d.ts +2 -2
  175. package/dist/widget/hooks/useMode.d.ts.map +1 -1
  176. package/dist/widget/hooks/useOriginSelectedToken.d.ts +2 -15
  177. package/dist/widget/hooks/useOriginSelectedToken.d.ts.map +1 -1
  178. package/dist/widget/hooks/usePayMessage.d.ts.map +1 -1
  179. package/dist/widget/hooks/usePriceImpactWarning.d.ts +1 -1
  180. package/dist/widget/hooks/usePriceImpactWarning.d.ts.map +1 -1
  181. package/dist/widget/hooks/useQuote.d.ts +173 -4
  182. package/dist/widget/hooks/useQuote.d.ts.map +1 -1
  183. package/dist/widget/hooks/useRecentTokens.d.ts +3 -3
  184. package/dist/widget/hooks/useRecentTokens.d.ts.map +1 -1
  185. package/dist/widget/hooks/useRecipients.d.ts +1 -1
  186. package/dist/widget/hooks/useRecipients.d.ts.map +1 -1
  187. package/dist/widget/hooks/useSelectedFeeOption.d.ts +2 -2
  188. package/dist/widget/hooks/useSelectedFeeOption.d.ts.map +1 -1
  189. package/dist/widget/hooks/useSelectedFundMethod.d.ts +1 -1
  190. package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -1
  191. package/dist/widget/hooks/useSelectedRecipient.d.ts +1 -1
  192. package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -1
  193. package/dist/widget/hooks/useSendForm.d.ts +9 -31
  194. package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
  195. package/dist/widget/hooks/useSwapAmount.d.ts +1 -1
  196. package/dist/widget/hooks/useSwapAmount.d.ts.map +1 -1
  197. package/dist/widget/hooks/useTheme.d.ts +1 -1
  198. package/dist/widget/hooks/useTheme.d.ts.map +1 -1
  199. package/dist/widget/hooks/useTokenList.d.ts +7 -31
  200. package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
  201. package/dist/widget/hooks/useTrailsSendTransaction.d.ts +83 -0
  202. package/dist/widget/hooks/useTrailsSendTransaction.d.ts.map +1 -0
  203. package/dist/widget/hooks/useWalletConnectUri.d.ts +11 -0
  204. package/dist/widget/hooks/useWalletConnectUri.d.ts.map +1 -0
  205. package/dist/widget/hooks/useWidgetProps.d.ts +5 -0
  206. package/dist/widget/hooks/useWidgetProps.d.ts.map +1 -1
  207. package/dist/widget/index.d.ts +2 -0
  208. package/dist/widget/index.d.ts.map +1 -1
  209. package/dist/widget/index.js +8 -5
  210. package/dist/widget/providers/TrailsModalProvider.d.ts +65 -0
  211. package/dist/widget/providers/TrailsModalProvider.d.ts.map +1 -0
  212. package/dist/widget/providers/TrailsProvider.d.ts +1 -1
  213. package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
  214. package/dist/widget/types.d.ts +11 -18
  215. package/dist/widget/types.d.ts.map +1 -1
  216. package/dist/widget/widget.d.ts +20 -11
  217. package/dist/widget/widget.d.ts.map +1 -1
  218. package/package.json +45 -49
  219. package/src/aave.ts +387 -138
  220. package/src/analytics.ts +208 -2
  221. package/src/chains.ts +65 -64
  222. package/src/constants.ts +18 -14
  223. package/src/customTokens.ts +151 -0
  224. package/src/decoders.ts +4 -7
  225. package/src/error.ts +7 -3
  226. package/src/fees.ts +239 -125
  227. package/src/gasless.ts +54 -108
  228. package/src/index.ts +29 -9
  229. package/src/indexerClient.ts +2 -0
  230. package/src/intentReceiptMonitor.ts +1 -4
  231. package/src/intentReceiptPoller.ts +2 -2
  232. package/src/intents.ts +16 -5
  233. package/src/mode.ts +1 -1
  234. package/src/mutations.ts +7 -3
  235. package/src/prepareSend.ts +19 -14
  236. package/src/prices.ts +1 -1
  237. package/src/sequenceWallet.ts +2 -2
  238. package/src/time.ts +28 -0
  239. package/src/tokenBalances.ts +348 -153
  240. package/src/tokens.ts +393 -142
  241. package/src/trailsClient.ts +1 -1
  242. package/src/trailsRouter.ts +4 -5
  243. package/src/transactionIntent/deposits/depositOrchestrator.ts +6 -2
  244. package/src/transactionIntent/deposits/gaslessDeposit.ts +13 -7
  245. package/src/transactionIntent/deposits/standardDeposit.ts +1 -1
  246. package/src/transactionIntent/execution/transactionState.ts +1 -1
  247. package/src/transactionIntent/handlers/crossChain.ts +75 -37
  248. package/src/transactionIntent/handlers/sameChainSameToken.ts +66 -20
  249. package/src/transactionIntent/quote/feeExtractors.ts +1 -29
  250. package/src/transactionIntent/quote/normalizeQuote.ts +99 -7
  251. package/src/transactionIntent/quote/quoteHelpers.ts +1 -1
  252. package/src/transactionIntent/types.ts +31 -6
  253. package/src/transactionIntent/utils/testnetHelpers.ts +0 -5
  254. package/src/transactionIntent/validators.ts +0 -30
  255. package/src/transactions.ts +3 -3
  256. package/src/utils.ts +18 -0
  257. package/src/wallets.ts +32 -10
  258. package/src/widget/compiled.css +1 -1
  259. package/src/widget/components/AccountIntentTransactionHistory.tsx +2 -1
  260. package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +2 -2
  261. package/src/widget/components/AddressWalletIcon.tsx +29 -0
  262. package/src/widget/components/ChainFilterDropdown.tsx +2 -8
  263. package/src/widget/components/ChainImage.tsx +8 -5
  264. package/src/widget/components/ChainList.tsx +6 -8
  265. package/src/widget/components/ClassicSwap.tsx +93 -85
  266. package/src/widget/components/ConnectWallet.tsx +1 -2
  267. package/src/widget/components/ConnectedWallets.tsx +17 -4
  268. package/src/widget/components/DebugMenu.tsx +2 -2
  269. package/src/widget/components/DebugScreensList.tsx +0 -1
  270. package/src/widget/components/DepositTracker.tsx +20 -34
  271. package/src/widget/components/Earn.tsx +7 -6
  272. package/src/widget/components/FeeOption.tsx +4 -4
  273. package/src/widget/components/FeeOptions.tsx +19 -39
  274. package/src/widget/components/Footer.tsx +1 -1
  275. package/src/widget/components/Fund.tsx +23 -119
  276. package/src/widget/components/FundMethods.tsx +9 -6
  277. package/src/widget/components/FundSwap.tsx +6 -5
  278. package/src/widget/components/FundingMethodSelectorButton.tsx +2 -2
  279. package/src/widget/components/HookModalContent.tsx +306 -0
  280. package/src/widget/components/Modal.tsx +1 -1
  281. package/src/widget/components/OriginSelectionAmount.tsx +135 -0
  282. package/src/widget/components/Pay.tsx +66 -124
  283. package/src/widget/components/PoolDeposit.tsx +11 -55
  284. package/src/widget/components/PoolWithdraw.tsx +3 -3
  285. package/src/widget/components/QuoteDetails.tsx +473 -728
  286. package/src/widget/components/Receipt.tsx +74 -7
  287. package/src/widget/components/RecentTokens.tsx +8 -8
  288. package/src/widget/components/RecipientSelectorButton.tsx +4 -2
  289. package/src/widget/components/ScreenHeader.tsx +2 -2
  290. package/src/widget/components/SearchInputField.tsx +1 -1
  291. package/src/widget/components/ShadowPortal.tsx +58 -0
  292. package/src/widget/components/Swap.tsx +6 -5
  293. package/src/widget/components/ThemeProvider.tsx +1 -1
  294. package/src/widget/components/TokenList.tsx +3 -4
  295. package/src/widget/components/TokenSelector.tsx +211 -80
  296. package/src/widget/components/Tooltip.tsx +18 -7
  297. package/src/widget/components/TrailsHookModal.tsx +118 -0
  298. package/src/widget/components/WaasFeeOptions.tsx +333 -138
  299. package/src/widget/components/WalletConfirmation.tsx +7 -2
  300. package/src/widget/components/WalletConnect.tsx +197 -235
  301. package/src/widget/components/WidgetProviders.tsx +75 -0
  302. package/src/widget/hooks/useAddressWalletIcon.ts +53 -0
  303. package/src/widget/hooks/useBalanceVisible.tsx +1 -1
  304. package/src/widget/hooks/useChainFilter.tsx +1 -1
  305. package/src/widget/hooks/useCheckout.ts +13 -1
  306. package/src/widget/hooks/useConnector.tsx +18 -0
  307. package/src/widget/hooks/useCurrentScreen.tsx +3 -3
  308. package/src/widget/hooks/useCustomTokenFetch.tsx +72 -0
  309. package/src/widget/hooks/useCustomTokenSearch.tsx +402 -0
  310. package/src/widget/hooks/useDebounce.ts +25 -0
  311. package/src/widget/hooks/useDebugScreens.ts +26 -10
  312. package/src/widget/hooks/useDefaultTokenSelection.tsx +99 -143
  313. package/src/widget/hooks/useDestinationSelectedToken.tsx +1 -14
  314. package/src/widget/hooks/useEarnPool.tsx +1 -1
  315. package/src/widget/hooks/useIntentTransactionHistory.ts +20 -11
  316. package/src/widget/hooks/useIsMobile.tsx +50 -0
  317. package/src/widget/hooks/useMode.ts +2 -3
  318. package/src/widget/hooks/useOriginSelectedToken.tsx +2 -15
  319. package/src/widget/hooks/usePayMessage.tsx +31 -11
  320. package/src/widget/hooks/usePriceImpactWarning.ts +1 -1
  321. package/src/widget/hooks/useQuote.ts +189 -6
  322. package/src/widget/hooks/useRecentTokens.ts +6 -6
  323. package/src/widget/hooks/useRecipients.ts +1 -1
  324. package/src/widget/hooks/useSelectedFeeOption.tsx +2 -2
  325. package/src/widget/hooks/useSelectedFundMethod.tsx +1 -1
  326. package/src/widget/hooks/useSelectedRecipient.tsx +1 -1
  327. package/src/widget/hooks/useSendForm.ts +328 -152
  328. package/src/widget/hooks/useSwapAmount.tsx +1 -1
  329. package/src/widget/hooks/useTheme.tsx +1 -1
  330. package/src/widget/hooks/useTokenList.ts +672 -400
  331. package/src/widget/hooks/useTrailsSendTransaction.ts +949 -0
  332. package/src/widget/hooks/useWalletConnectUri.tsx +228 -0
  333. package/src/widget/hooks/useWidgetProps.tsx +3 -1
  334. package/src/widget/index.tsx +12 -0
  335. package/src/widget/providers/TrailsModalProvider.tsx +195 -0
  336. package/src/widget/providers/TrailsProvider.tsx +9 -3
  337. package/src/widget/types.ts +12 -20
  338. package/src/widget/widget.tsx +598 -385
  339. package/dist/cctp.d.ts +0 -3
  340. package/dist/cctp.d.ts.map +0 -1
  341. package/dist/lifi.d.ts +0 -4
  342. package/dist/lifi.d.ts.map +0 -1
  343. package/dist/meshconnect.d.ts +0 -171
  344. package/dist/meshconnect.d.ts.map +0 -1
  345. package/dist/relaySdk.d.ts +0 -87
  346. package/dist/relaySdk.d.ts.map +0 -1
  347. package/dist/widget/components/MeshConnectExchanges.d.ts +0 -7
  348. package/dist/widget/components/MeshConnectExchanges.d.ts.map +0 -1
  349. package/dist/widget/components/MeshConnectFlow.d.ts +0 -13
  350. package/dist/widget/components/MeshConnectFlow.d.ts.map +0 -1
  351. package/dist/widget/components/MeshConnectIframe.d.ts +0 -15
  352. package/dist/widget/components/MeshConnectIframe.d.ts.map +0 -1
  353. package/dist/widget/components/Receive.d.ts +0 -12
  354. package/dist/widget/components/Receive.d.ts.map +0 -1
  355. package/dist/widget/hooks/useSelectedMeshExchange.d.ts +0 -14
  356. package/dist/widget/hooks/useSelectedMeshExchange.d.ts.map +0 -1
  357. package/src/cctp.ts +0 -54
  358. package/src/lifi.ts +0 -108
  359. package/src/meshconnect.ts +0 -531
  360. package/src/relaySdk.ts +0 -703
  361. package/src/widget/components/MeshConnectExchanges.tsx +0 -290
  362. package/src/widget/components/MeshConnectFlow.tsx +0 -90
  363. package/src/widget/components/MeshConnectIframe.tsx +0 -500
  364. package/src/widget/components/Receive.tsx +0 -175
  365. package/src/widget/hooks/useSelectedMeshExchange.tsx +0 -46
package/src/tokens.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { useQuery } from "@tanstack/react-query"
2
- import { zeroAddress, erc20Abi } from "viem"
2
+ import { erc20Abi, zeroAddress } from "viem"
3
3
  import {
4
4
  getChainInfo,
5
- getSupportedChains,
6
5
  getChainRpcClient,
6
+ getSupportedSequenceChains,
7
7
  } from "./chains.js"
8
8
  import {
9
9
  arbitrum,
@@ -17,8 +17,8 @@ import {
17
17
  unichain,
18
18
  worldchain,
19
19
  bsc,
20
+ monad,
20
21
  } from "viem/chains"
21
- import { getRelaySupportedTokens, type Chain } from "./relaySdk.js"
22
22
  import { useReadContracts } from "wagmi"
23
23
  import { useMemo } from "react"
24
24
  import { logger } from "./logger.js"
@@ -26,16 +26,112 @@ import { isNativeToken } from "./utils.js"
26
26
  import { somnia } from "./customChains.js"
27
27
  import { PROD_SEQUENCE_METADATA_URL } from "./constants.js"
28
28
  import { useTrails } from "./widget/providers/TrailsProvider.js"
29
+ import { useCustomTokens } from "./customTokens.js"
30
+ import { getTrailsClient } from "./trailsClient.js"
31
+ import { formatBalanceFields, formatPriceFields } from "./tokenBalances.js"
29
32
 
30
- export type SupportedToken = {
31
- id: string
33
+ // ApiTokenInfo type from trails-api (internal use only)
34
+ interface ApiTokenInfo {
35
+ chainId: number
36
+ address: string
37
+ name: string
38
+ symbol: string
39
+ decimals: number
40
+ supportsBridging: boolean
41
+ logoUri?: string
42
+ }
43
+
44
+ /**
45
+ * Unified token type for the Trails SDK.
46
+ * This type replaces all previous token type variations (SupportedToken, TokenBalanceExtended, etc.)
47
+ */
48
+ export type Token = {
49
+ // Required properties
32
50
  symbol: string
33
51
  name: string
34
- contractAddress: string
35
52
  decimals: number
36
- chainId: number
37
- chainName: string
38
- imageUrl: string
53
+ contractAddress: string // Use zeroAddress for native tokens
54
+
55
+ // Optional properties
56
+ tokenId?: string // For NFTs or specific token IDs if applicable
57
+ chainId?: number
58
+ chainName?: string
59
+ imageUrl?: string
60
+ isCustomToken?: boolean
61
+ isSufficientBalance?: boolean
62
+ isNativeToken?: boolean
63
+
64
+ // Balance fields (raw → formatted → display)
65
+ balance?: string // Raw big number string (e.g., "1000000000000000000")
66
+ balanceFormatted?: string // Formatted number without commas (e.g., "1.0")
67
+ balanceDisplay?: string // Formatted number with commas (e.g., "1,000.00")
68
+
69
+ // USD Balance fields
70
+ balanceUsd?: number // Raw number (e.g., 1000.50)
71
+ balanceUsdFormatted?: string // Formatted number without commas or currency symbol (e.g., "1000.50")
72
+ balanceUsdDisplay?: string // Formatted number with commas and currency symbol (e.g., "$1,000.50")
73
+
74
+ // Price fields (raw → formatted → display)
75
+ priceUsd?: number // Raw number (e.g., 1.50)
76
+ priceUsdFormatted?: string // Formatted number without commas or currency symbol (e.g., "1.50")
77
+ priceUsdDisplay?: string // Formatted number with commas and currency symbol (e.g., "$1.50")
78
+ }
79
+
80
+ // ============================================================================
81
+ // Conversion Helper Functions
82
+ // ============================================================================
83
+
84
+ /**
85
+ * Converts ApiTokenInfo (from trails-api) to Token
86
+ */
87
+ export function convertApiTokenInfoToToken(
88
+ tokenInfo: ApiTokenInfo,
89
+ options?: {
90
+ balance?: string
91
+ priceUsd?: number
92
+ },
93
+ ): Token {
94
+ const chainInfo = getChainInfo(tokenInfo.chainId)
95
+ const isNative = tokenInfo.address === zeroAddress || !tokenInfo.address
96
+
97
+ const result: Token = {
98
+ symbol: tokenInfo.symbol,
99
+ name: tokenInfo.name,
100
+ decimals: tokenInfo.decimals,
101
+ contractAddress: tokenInfo.address,
102
+ tokenId: `${tokenInfo.symbol}-${chainInfo?.name || `chain-${tokenInfo.chainId}`}`, // Generate tokenId
103
+ chainId: tokenInfo.chainId,
104
+ chainName: chainInfo?.name || `Chain ${tokenInfo.chainId}`,
105
+ imageUrl:
106
+ tokenInfo.logoUri ||
107
+ getTokenImageUrl({
108
+ chainId: tokenInfo.chainId,
109
+ contractAddress: tokenInfo.address,
110
+ symbol: tokenInfo.symbol,
111
+ }),
112
+ isNativeToken: isNative,
113
+ }
114
+
115
+ // Format balance if provided
116
+ if (options?.balance) {
117
+ const balanceFields = formatBalanceFields(
118
+ options.balance,
119
+ tokenInfo.decimals,
120
+ )
121
+ result.balance = balanceFields.balance
122
+ result.balanceFormatted = balanceFields.balanceFormatted
123
+ result.balanceDisplay = balanceFields.balanceDisplay
124
+ }
125
+
126
+ // Format price if provided
127
+ if (options?.priceUsd !== undefined) {
128
+ const priceFields = formatPriceFields(options.priceUsd)
129
+ result.priceUsd = priceFields.priceUsd
130
+ result.priceUsdFormatted = priceFields.priceUsdFormatted
131
+ result.priceUsdDisplay = priceFields.priceUsdDisplay
132
+ }
133
+
134
+ return result
39
135
  }
40
136
 
41
137
  export const commonTokenImages: Record<string, string> = {
@@ -58,6 +154,10 @@ export const commonTokenImages: Record<string, string> = {
58
154
  ANIME:
59
155
  "https://assets.coingecko.com/coins/images/53575/large/anime.jpg?1736748703",
60
156
  AVAX: "https://assets.sequence.info/images/tokens/large/43114/0x0000000000000000000000000000000000000000.webp",
157
+ MON: "https://assets.sequence.info/images/tokens/large/143/0x0000000000000000000000000000000000000000.webp",
158
+ USDT0:
159
+ "https://assets.coingecko.com/coins/images/53705/standard/usdt0.jpg?1737086183",
160
+ AUSD: "https://assets.coingecko.com/coins/images/39284/standard/Circle_Agora_White_on_Olive_1080px.png?1722961274",
61
161
  }
62
162
 
63
163
  const cacheVersion = "01"
@@ -76,15 +176,18 @@ interface TokenImageCacheEntry {
76
176
  const TOKEN_INFO_CACHE_KEY = `trails-sdk:token-info-cache:${cacheVersion}`
77
177
  const TOKEN_INFO_CACHE_EXPIRY = 24 * 60 * 60 * 1000 // 24 hours
78
178
 
179
+ // Cache entry matches Token structure (without optional fields)
79
180
  interface TokenInfoCacheEntry {
80
- id: string
181
+ tokenId?: string
81
182
  symbol: string
82
183
  name: string
83
184
  contractAddress: string
84
185
  decimals: number
85
186
  chainId: number
86
- chainName: string
87
- imageUrl: string
187
+ chainName?: string
188
+ imageUrl?: string
189
+ isNativeToken?: boolean
190
+ isCustomToken?: boolean
88
191
  timestamp: number
89
192
  }
90
193
 
@@ -115,31 +218,37 @@ function getTokenInfoCache(): Record<string, TokenInfoCacheEntry> {
115
218
  }
116
219
  }
117
220
 
118
- function setTokenInfoCache(
119
- key: string,
120
- tokenInfo: {
121
- id: string
122
- symbol: string
123
- name: string
124
- contractAddress: string
125
- decimals: number
126
- chainId: number
127
- chainName: string
128
- imageUrl: string
129
- },
130
- ): void {
221
+ function setTokenInfoCache(key: string, tokenInfo: Token): void {
131
222
  if (typeof window === "undefined") return
132
223
 
133
224
  try {
134
225
  const cache = getTokenInfoCache()
135
- cache[key] = {
136
- ...tokenInfo,
226
+ // Ensure chainId is required for cache entry
227
+ if (!tokenInfo.chainId) {
228
+ logger.console.warn(
229
+ "[trails-sdk] Cannot cache token without chainId:",
230
+ tokenInfo,
231
+ )
232
+ return
233
+ }
234
+ const cacheEntry: TokenInfoCacheEntry = {
235
+ tokenId: tokenInfo.tokenId,
236
+ symbol: tokenInfo.symbol,
237
+ name: tokenInfo.name,
238
+ contractAddress: tokenInfo.contractAddress,
239
+ decimals: tokenInfo.decimals,
240
+ chainId: tokenInfo.chainId,
241
+ chainName: tokenInfo.chainName,
242
+ imageUrl: tokenInfo.imageUrl,
243
+ isNativeToken: tokenInfo.isNativeToken,
244
+ isCustomToken: tokenInfo.isCustomToken,
137
245
  timestamp: Date.now(),
138
246
  }
247
+ cache[key] = cacheEntry
139
248
  localStorage.setItem(TOKEN_INFO_CACHE_KEY, JSON.stringify(cache))
140
249
 
141
250
  // Also update in-memory cache
142
- tokenInfoCache.set(key, cache[key])
251
+ tokenInfoCache.set(key, cacheEntry)
143
252
  } catch (error) {
144
253
  logger.console.warn("[trails-sdk] Failed to cache token info:", error)
145
254
  }
@@ -148,13 +257,25 @@ function setTokenInfoCache(
148
257
  function getCachedTokenInfo(
149
258
  chainId: number,
150
259
  contractAddress: string,
151
- ): TokenInfoCacheEntry | null {
260
+ ): Token | null {
152
261
  const key = `${chainId}:${contractAddress.toLowerCase()}`
153
262
 
154
263
  // Check in-memory cache first
155
264
  const memoryEntry = tokenInfoCache.get(key)
156
265
  if (memoryEntry) {
157
- return memoryEntry
266
+ // Convert cache entry to Token
267
+ return {
268
+ symbol: memoryEntry.symbol,
269
+ name: memoryEntry.name,
270
+ decimals: memoryEntry.decimals,
271
+ contractAddress: memoryEntry.contractAddress,
272
+ tokenId: memoryEntry.tokenId,
273
+ chainId: memoryEntry.chainId,
274
+ chainName: memoryEntry.chainName,
275
+ imageUrl: memoryEntry.imageUrl,
276
+ isNativeToken: memoryEntry.isNativeToken,
277
+ isCustomToken: memoryEntry.isCustomToken,
278
+ }
158
279
  }
159
280
 
160
281
  // Check localStorage cache
@@ -163,7 +284,19 @@ function getCachedTokenInfo(
163
284
  if (cachedEntry) {
164
285
  // Update in-memory cache
165
286
  tokenInfoCache.set(key, cachedEntry)
166
- return cachedEntry
287
+ // Convert cache entry to Token
288
+ return {
289
+ symbol: cachedEntry.symbol,
290
+ name: cachedEntry.name,
291
+ decimals: cachedEntry.decimals,
292
+ contractAddress: cachedEntry.contractAddress,
293
+ tokenId: cachedEntry.tokenId,
294
+ chainId: cachedEntry.chainId,
295
+ chainName: cachedEntry.chainName,
296
+ imageUrl: cachedEntry.imageUrl,
297
+ isNativeToken: cachedEntry.isNativeToken,
298
+ isCustomToken: cachedEntry.isCustomToken,
299
+ }
167
300
  }
168
301
 
169
302
  return null
@@ -214,7 +347,7 @@ const PRIORITY_TOKENS = [
214
347
  ]
215
348
 
216
349
  // Sort function for tokens with the specified priority order
217
- function sortTokens(tokens: SupportedToken[]): SupportedToken[] {
350
+ function sortTokens(tokens: Token[]): Token[] {
218
351
  return tokens.sort((a, b) => {
219
352
  // 1. Priority tokens first (ETH, USDC, USDT, DAI)
220
353
  const aPriority = PRIORITY_TOKENS.indexOf(a.symbol)
@@ -243,7 +376,9 @@ function sortTokens(tokens: SupportedToken[]): SupportedToken[] {
243
376
  }
244
377
 
245
378
  // 4. If symbols are the same, sort by chainName
246
- return a.chainName.localeCompare(b.chainName)
379
+ const aChainName = a.chainName || ""
380
+ const bChainName = b.chainName || ""
381
+ return aChainName.localeCompare(bChainName)
247
382
  })
248
383
  }
249
384
 
@@ -258,17 +393,67 @@ export function getCachedTokenImageUrl(
258
393
  return cachedEntry?.imageUrl || ""
259
394
  }
260
395
 
261
- export async function getAllTokens(): Promise<SupportedToken[]> {
262
- const relayTokens = (await getRelaySupportedTokens()) as SupportedToken[]
263
- return relayTokens
264
- }
396
+ export async function getSupportedTokens(config: {
397
+ trailsApiKey: string
398
+ trailsApiUrl: string
399
+ }): Promise<Token[]> {
400
+ // Get chainIds from getSupportedSequenceChains
401
+ const sequenceChains = await getSupportedSequenceChains()
402
+ const chainIds = sequenceChains.map((chain) => chain.id)
403
+
404
+ // Get trails client using provided config
405
+ const trailsClient = getTrailsClient({
406
+ apiKey: config.trailsApiKey || "",
407
+ hostname: config.trailsApiUrl,
408
+ })
409
+
410
+ // Fetch tokens from trails-api using getTokenList
411
+ // This is the new endpoint that replaces getFeaturedTokens
412
+ // It uses go-tokendirectory to fetch efficiently and cache data from token-directory
413
+ // includeAllListed: true returns all tokens in the index (except external) even if not featured
414
+ // Featured tokens are always included and sorted at the top
415
+ let apiTokens: Token[] = []
416
+ try {
417
+ if (config.trailsApiKey && trailsClient) {
418
+ // Use getTokenList to get tokens for the specified chains
419
+ // includeAllListed: true includes all tokens in the index, not just featured
420
+ // The API applies limit per chain, and lists are sorted, normalized, and deduped
421
+ // When filtering by a single chain, use limit of 100, otherwise use 30 per chain
422
+ // Type assertion needed because TrailsClient extends TrailsApi which has these methods
423
+ const limit = chainIds.length === 1 ? 100 : 30
424
+ const tokenListResponse = await trailsClient.getTokenList({
425
+ chainIds,
426
+ includeAllListed: true,
427
+ limit, // Limit per chain - 100 for single chain, 30 for multiple chains
428
+ })
265
429
 
266
- export async function getSupportedTokens(): Promise<SupportedToken[]> {
267
- const tokens = await getAllTokens()
268
- for (const token of tokens) {
430
+ // The API already handles sorting (featured first, then alphabetically) and deduplication
431
+ // Map ApiTokenInfo from API to Token format using conversion helper
432
+ apiTokens = (tokenListResponse.tokens || []).map((tokenInfo: any) => {
433
+ const chainInfo = getChainInfo(tokenInfo.chainId)
434
+ const tokenId = `${tokenInfo.symbol}-${chainInfo?.name || `chain-${tokenInfo.chainId}`}`
435
+ const trailsToken = convertApiTokenInfoToToken(tokenInfo, {
436
+ // No balance or price data from getTokenList
437
+ })
438
+ // Set tokenId for consistency
439
+ trailsToken.tokenId = tokenId
440
+ return trailsToken
441
+ })
442
+ }
443
+ } catch (error) {
444
+ logger.console.warn(
445
+ "[trails-sdk] Error fetching tokens from trails-api:",
446
+ error,
447
+ )
448
+ // Continue with empty apiTokens - will fall back to commonTokens
449
+ apiTokens = []
450
+ }
451
+
452
+ // Ensure imageUrl is set for all tokens
453
+ for (const token of apiTokens) {
269
454
  if (!token.imageUrl) {
270
455
  token.imageUrl = getTokenImageUrl({
271
- chainId: token.chainId,
456
+ chainId: token.chainId || 0,
272
457
  contractAddress: token.contractAddress,
273
458
  symbol: token.symbol,
274
459
  })
@@ -276,7 +461,7 @@ export async function getSupportedTokens(): Promise<SupportedToken[]> {
276
461
 
277
462
  // Use getTokenImageUrl directly (synchronous)
278
463
  const imageUrl = getTokenImageUrl({
279
- chainId: token.chainId,
464
+ chainId: token.chainId || 0,
280
465
  contractAddress: token.contractAddress,
281
466
  symbol: token.symbol,
282
467
  })
@@ -285,46 +470,34 @@ export async function getSupportedTokens(): Promise<SupportedToken[]> {
285
470
  }
286
471
  }
287
472
 
288
- const additionalTokens: SupportedToken[] = []
473
+ // Add common tokens that don't exist in API tokens
474
+ const additionalTokens: Token[] = []
289
475
  for (const commonToken of commonTokens) {
290
476
  const contractAddress = commonToken.contractAddress
291
- const exists = tokens.some(
477
+ const exists = apiTokens.some(
292
478
  (t) =>
293
479
  t.chainId === commonToken.chainId &&
294
480
  t.contractAddress.toLowerCase() === contractAddress.toLowerCase(),
295
481
  )
296
482
  if (!exists) {
483
+ // commonTokens is now Token[], so we can use it directly
297
484
  additionalTokens.push(commonToken)
298
485
  }
299
486
  }
300
487
 
301
- let supportedChains: Chain[] = []
302
- try {
303
- supportedChains = await getSupportedChains({ quoteProvider: "relay" })
304
- } catch (error) {
305
- logger.console.error("[trails-sdk] Error getting supported chains:", error)
306
- // Fallback: include all chains that have tokens
307
- supportedChains = []
308
- }
488
+ const allTokens = [...apiTokens, ...additionalTokens]
309
489
 
310
- const allTokens = [...tokens, ...additionalTokens]
490
+ // Filter to only include tokens from supported sequence chains
311
491
  const supportedChainTokens = allTokens.filter((token) => {
312
492
  // Always include Etherlink tokens
313
493
  if (token.chainId === etherlink.id) {
314
494
  return true
315
495
  }
316
- // If we have supported chains, filter by them
317
- if (supportedChains.length > 0) {
318
- return supportedChains.some((chain) => chain.id === token.chainId)
319
- }
320
- // Fallback: include tokens from chains that are in both relay tokens and common tokens
321
- const relayChainIds = tokens.map((t) => t.chainId)
322
- const commonChainIds = commonTokens.map((t) => t.chainId)
323
- const supportedChainIds = [
324
- ...new Set([...relayChainIds, ...commonChainIds]),
325
- ]
326
- return supportedChainIds.includes(token.chainId)
496
+ // Filter by sequence chains
497
+ return token.chainId && chainIds.includes(token.chainId)
327
498
  })
499
+
500
+ // Remove duplicates
328
501
  const uniqueTokens = supportedChainTokens.filter(
329
502
  (token, index, self) =>
330
503
  index ===
@@ -337,30 +510,64 @@ export async function getSupportedTokens(): Promise<SupportedToken[]> {
337
510
  )
338
511
 
339
512
  // Sort tokens according to priority order
340
- const sortedTokens = sortTokens(uniqueTokens as SupportedToken[])
513
+ const sortedTokens = sortTokens(uniqueTokens)
341
514
 
342
515
  return sortedTokens
343
516
  }
344
517
 
345
518
  export function useSupportedTokens({ chainId }: { chainId?: number } = {}): {
346
- supportedTokens: SupportedToken[]
519
+ supportedTokens: Token[]
347
520
  isLoadingTokens: boolean
348
521
  } {
522
+ const { customTokens } = useCustomTokens()
523
+ const trailsConfig = useTrails()
349
524
  const { data: supportedTokens = [], isLoading: isLoadingTokens } = useQuery({
350
- queryKey: ["supportedTokens"],
351
- queryFn: getSupportedTokens,
525
+ queryKey: [
526
+ "supportedTokens",
527
+ trailsConfig.trailsApiUrl,
528
+ trailsConfig.trailsApiKey,
529
+ ],
530
+ queryFn: () =>
531
+ getSupportedTokens({
532
+ trailsApiKey: trailsConfig.trailsApiKey,
533
+ trailsApiUrl: trailsConfig.trailsApiUrl,
534
+ }),
352
535
  staleTime: 60 * 60 * 1000, // 1 hour - tokens rarely change
353
536
  gcTime: 24 * 60 * 60 * 1000, // 24 hours - keep in cache for a full day
354
537
  refetchOnWindowFocus: false, // Don't refetch when window regains focus
355
538
  refetchOnReconnect: false, // Don't refetch on network reconnect
356
539
  })
357
540
 
541
+ // Merge custom tokens with supported tokens
542
+ // Only add custom tokens that don't already exist in supported tokens
543
+ const mergedTokens = useMemo(() => {
544
+ const tokenMap = new Map<string, Token>()
545
+
546
+ // Add regular supported tokens first
547
+ supportedTokens.forEach((token) => {
548
+ const key = `${token.chainId}-${token.contractAddress.toLowerCase()}`
549
+ tokenMap.set(key, token)
550
+ })
551
+
552
+ // Only add custom tokens that don't already exist in supported tokens
553
+ // customTokens is already Token[]
554
+ customTokens.forEach((token) => {
555
+ const key = `${token.chainId || 0}-${token.contractAddress.toLowerCase()}`
556
+ // Only add if it doesn't already exist (supported tokens take precedence)
557
+ if (!tokenMap.has(key)) {
558
+ tokenMap.set(key, token)
559
+ }
560
+ })
561
+
562
+ return Array.from(tokenMap.values())
563
+ }, [supportedTokens, customTokens])
564
+
358
565
  const filteredTokens = useMemo(() => {
359
566
  if (!chainId) {
360
- return supportedTokens
567
+ return mergedTokens
361
568
  }
362
- return supportedTokens.filter((token) => token.chainId === chainId)
363
- }, [supportedTokens, chainId])
569
+ return mergedTokens.filter((token) => token.chainId === chainId)
570
+ }, [mergedTokens, chainId])
364
571
 
365
572
  return {
366
573
  supportedTokens: filteredTokens || [],
@@ -424,30 +631,22 @@ export function getFormatttedTokenName(
424
631
  export async function getTokenInfo(
425
632
  chainId: number,
426
633
  contractAddress: string,
427
- ): Promise<SupportedToken | null> {
634
+ config: { trailsApiKey: string; trailsApiUrl: string },
635
+ ): Promise<Token | null> {
428
636
  const normalizedAddress = contractAddress.toLowerCase()
429
637
 
430
638
  // Check cache first
431
639
  const cachedInfo = getCachedTokenInfo(chainId, normalizedAddress)
432
640
  if (cachedInfo) {
433
- return {
434
- id: cachedInfo.id,
435
- symbol: cachedInfo.symbol,
436
- name: cachedInfo.name,
437
- contractAddress: cachedInfo.contractAddress,
438
- decimals: cachedInfo.decimals,
439
- chainId: cachedInfo.chainId,
440
- chainName: cachedInfo.chainName,
441
- imageUrl: cachedInfo.imageUrl,
442
- }
641
+ return cachedInfo
443
642
  }
444
643
 
445
644
  // Check if it's a native token
446
645
  const chainInfo = getChainInfo(chainId)
447
646
  if (normalizedAddress === zeroAddress.toLowerCase()) {
448
647
  const decimals = chainInfo?.nativeCurrency.decimals ?? 18
449
- const nativeInfo: SupportedToken = {
450
- id: `${chainInfo?.nativeCurrency.symbol || "ETH"}-${chainInfo?.name || "ethereum"}`,
648
+ const nativeToken: Token = {
649
+ tokenId: `${chainInfo?.nativeCurrency.symbol || "ETH"}-${chainInfo?.name || "ethereum"}`,
451
650
  symbol: chainInfo?.nativeCurrency.symbol || "ETH",
452
651
  name: chainInfo?.nativeCurrency.name || "Ethereum",
453
652
  contractAddress: zeroAddress,
@@ -459,16 +658,17 @@ export async function getTokenInfo(
459
658
  contractAddress: zeroAddress,
460
659
  symbol: chainInfo?.nativeCurrency.symbol || "ETH",
461
660
  }),
661
+ isNativeToken: true,
462
662
  }
463
663
 
464
664
  // Cache the native token info
465
- setTokenInfoCache(`${chainId}:${normalizedAddress}`, nativeInfo)
665
+ setTokenInfoCache(`${chainId}:${normalizedAddress}`, nativeToken)
466
666
 
467
- return nativeInfo
667
+ return nativeToken
468
668
  }
469
669
 
470
670
  // Look in supported tokens
471
- const tokens = await getSupportedTokens()
671
+ const tokens = await getSupportedTokens(config)
472
672
  const token = tokens.find(
473
673
  (t) =>
474
674
  t.chainId === chainId &&
@@ -515,8 +715,8 @@ export async function getTokenInfo(
515
715
  ])
516
716
 
517
717
  // Create token info from on-chain data
518
- const onChainTokenInfo: SupportedToken = {
519
- id: `${symbol}-${chainInfo.name}`,
718
+ const onChainToken: Token = {
719
+ tokenId: `${symbol}-${chainInfo.name}`,
520
720
  name: name,
521
721
  symbol: symbol,
522
722
  decimals: decimals,
@@ -531,13 +731,14 @@ export async function getTokenInfo(
531
731
  }
532
732
 
533
733
  // Cache the on-chain token info
534
- setTokenInfoCache(`${chainId}:${normalizedAddress}`, onChainTokenInfo)
734
+ setTokenInfoCache(`${chainId}:${normalizedAddress}`, onChainToken)
535
735
 
536
736
  logger.console.log(
537
737
  "[trails-sdk] Fetched token info on-chain:",
538
- onChainTokenInfo,
738
+ onChainToken,
539
739
  )
540
- return onChainTokenInfo
740
+
741
+ return onChainToken
541
742
  } catch (error) {
542
743
  logger.console.error(
543
744
  "[trails-sdk] Error fetching on-chain token info:",
@@ -553,7 +754,11 @@ const HYPHENATED_SYMBOL_MAP: Record<string, string> = {
553
754
  "BNB-USD": "USDT",
554
755
  }
555
756
 
556
- export async function getTokenAddress(chainId: number, tokenSymbol: string) {
757
+ export async function getTokenAddress(
758
+ chainId: number,
759
+ tokenSymbol: string,
760
+ config: { trailsApiKey: string; trailsApiUrl: string },
761
+ ) {
557
762
  const chainInfo = getChainInfo(chainId)
558
763
  // Normalize token symbol: trim whitespace and convert to uppercase for comparison
559
764
  const normalizedTokenSymbol = tokenSymbol.trim().toUpperCase()
@@ -563,7 +768,7 @@ export async function getTokenAddress(chainId: number, tokenSymbol: string) {
563
768
  return zeroAddress
564
769
  }
565
770
 
566
- const tokens = await getSupportedTokens()
771
+ const tokens = await getSupportedTokens(config)
567
772
 
568
773
  // First try exact match (normalized)
569
774
  let token = tokens.find(
@@ -602,10 +807,16 @@ export function useTokenAddress({
602
807
  chainId,
603
808
  tokenSymbol,
604
809
  }: UseTokenAddressProps) {
810
+ const trailsConfig = useTrails()
605
811
  const { data: tokenAddress } = useQuery({
606
812
  queryKey: ["tokenAddress", chainId, tokenSymbol],
607
813
  queryFn: () =>
608
- chainId && tokenSymbol ? getTokenAddress(chainId, tokenSymbol) : null,
814
+ chainId && tokenSymbol
815
+ ? getTokenAddress(chainId, tokenSymbol, {
816
+ trailsApiKey: trailsConfig.trailsApiKey,
817
+ trailsApiUrl: trailsConfig.trailsApiUrl,
818
+ })
819
+ : null,
609
820
  enabled: !!chainId && !!tokenSymbol,
610
821
  staleTime: 60 * 60 * 1000, // 1 hour - token addresses rarely change
611
822
  gcTime: 24 * 60 * 60 * 1000, // 24 hours - keep in cache for a full day
@@ -784,7 +995,7 @@ export function useTokenInfo({
784
995
  address: string
785
996
  chainId?: number
786
997
  }): {
787
- tokenInfo: Partial<SupportedToken> | null
998
+ tokenInfo: Token | null
788
999
  isLoading: boolean
789
1000
  error: Error | null
790
1001
  } {
@@ -828,8 +1039,8 @@ export function useTokenInfo({
828
1039
  const nativeName = chainInfo?.nativeCurrency.name || "Ethereum"
829
1040
  const decimals = chainInfo?.nativeCurrency.decimals ?? 18
830
1041
 
831
- return {
832
- id: `${nativeSymbol}-${chainInfo?.name || ""}`,
1042
+ const nativeToken: Token = {
1043
+ tokenId: `${nativeSymbol}-${chainInfo?.name || ""}`,
833
1044
  name: nativeName,
834
1045
  symbol: nativeSymbol,
835
1046
  decimals,
@@ -841,27 +1052,24 @@ export function useTokenInfo({
841
1052
  contractAddress: zeroAddress,
842
1053
  symbol: nativeSymbol,
843
1054
  }),
1055
+ isNativeToken: true,
844
1056
  }
1057
+
1058
+ // Cache the native token
1059
+ setTokenInfoCache(`${chainId}:${address.toLowerCase()}`, nativeToken)
1060
+
1061
+ return nativeToken
845
1062
  }
846
1063
 
847
- // If we have cached info, use it
1064
+ // If we have cached info, use it directly (already Token)
848
1065
  if (cachedInfo) {
849
- return {
850
- id: cachedInfo.id,
851
- name: cachedInfo.name,
852
- symbol: cachedInfo.symbol,
853
- decimals: cachedInfo.decimals,
854
- chainId: cachedInfo.chainId,
855
- contractAddress: cachedInfo.contractAddress,
856
- chainName: cachedInfo.chainName,
857
- imageUrl: cachedInfo.imageUrl,
858
- }
1066
+ return cachedInfo
859
1067
  }
860
1068
 
861
1069
  // If we have blockchain data, use it and cache it
862
1070
  if (symbol?.result && name?.result && decimals?.result != null) {
863
- const tokenInfo: SupportedToken = {
864
- id: symbol.result,
1071
+ const onChainToken: Token = {
1072
+ tokenId: `${symbol.result}-${chainInfo?.name || ""}`,
865
1073
  name: name.result,
866
1074
  symbol: symbol.result,
867
1075
  decimals: decimals.result,
@@ -875,10 +1083,10 @@ export function useTokenInfo({
875
1083
  }),
876
1084
  }
877
1085
 
878
- // Cache the result
879
- setTokenInfoCache(`${chainId}:${address.toLowerCase()}`, tokenInfo)
1086
+ // Cache the result as Token
1087
+ setTokenInfoCache(`${chainId}:${address.toLowerCase()}`, onChainToken)
880
1088
 
881
- return tokenInfo
1089
+ return onChainToken
882
1090
  }
883
1091
 
884
1092
  return null
@@ -929,16 +1137,18 @@ export const tokenImageSymbolMap: Record<string, string> = {
929
1137
  BAT: "BAT",
930
1138
  ARB: "ARB",
931
1139
  LINK: "LINK",
1140
+ MON: "MON",
1141
+ WMON: "MON",
932
1142
 
933
1143
  // vault tokens
934
1144
  aBasUSDC: "USDC",
935
1145
  steakUSDC: "USDC",
936
1146
  }
937
1147
 
938
- export const commonTokens: SupportedToken[] = [
1148
+ export const commonTokens: Token[] = [
939
1149
  // Native tokens
940
1150
  {
941
- id: "ETH-ethereum",
1151
+ tokenId: "ETH-ethereum",
942
1152
  symbol: "ETH",
943
1153
  name: "Ethereum",
944
1154
  contractAddress: "0x0000000000000000000000000000000000000000",
@@ -946,9 +1156,10 @@ export const commonTokens: SupportedToken[] = [
946
1156
  chainId: mainnet.id,
947
1157
  chainName: mainnet.name,
948
1158
  imageUrl: commonTokenImages.ETH!,
1159
+ isNativeToken: true,
949
1160
  },
950
1161
  {
951
- id: "ETH-arbitrum",
1162
+ tokenId: "ETH-arbitrum",
952
1163
  symbol: "ETH",
953
1164
  name: "ETH Arbitrum",
954
1165
  contractAddress: "0x0000000000000000000000000000000000000000",
@@ -956,9 +1167,10 @@ export const commonTokens: SupportedToken[] = [
956
1167
  chainId: arbitrum.id,
957
1168
  chainName: arbitrum.name,
958
1169
  imageUrl: commonTokenImages.ETH!,
1170
+ isNativeToken: true,
959
1171
  },
960
1172
  {
961
- id: "ETH-optimism",
1173
+ tokenId: "ETH-optimism",
962
1174
  symbol: "ETH",
963
1175
  name: "ETH Optimism",
964
1176
  contractAddress: "0x0000000000000000000000000000000000000000",
@@ -966,9 +1178,10 @@ export const commonTokens: SupportedToken[] = [
966
1178
  chainId: optimism.id,
967
1179
  chainName: optimism.name,
968
1180
  imageUrl: commonTokenImages.ETH!,
1181
+ isNativeToken: true,
969
1182
  },
970
1183
  {
971
- id: "ETH-base",
1184
+ tokenId: "ETH-base",
972
1185
  symbol: "ETH",
973
1186
  name: "ETH Base",
974
1187
  contractAddress: "0x0000000000000000000000000000000000000000",
@@ -976,9 +1189,10 @@ export const commonTokens: SupportedToken[] = [
976
1189
  chainId: base.id,
977
1190
  chainName: base.name,
978
1191
  imageUrl: commonTokenImages.ETH!,
1192
+ isNativeToken: true,
979
1193
  },
980
1194
  {
981
- id: "POL-polygon",
1195
+ tokenId: "POL-polygon",
982
1196
  symbol: "POL",
983
1197
  name: "Polygon",
984
1198
  contractAddress: "0x0000000000000000000000000000000000000000",
@@ -986,11 +1200,12 @@ export const commonTokens: SupportedToken[] = [
986
1200
  chainId: polygon.id,
987
1201
  chainName: polygon.name,
988
1202
  imageUrl: commonTokenImages.POL!,
1203
+ isNativeToken: true,
989
1204
  },
990
1205
 
991
1206
  // USDC
992
1207
  {
993
- id: "USDC-ethereum",
1208
+ tokenId: "USDC-ethereum",
994
1209
  symbol: "USDC",
995
1210
  name: "USDC",
996
1211
  contractAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
@@ -1000,7 +1215,7 @@ export const commonTokens: SupportedToken[] = [
1000
1215
  imageUrl: commonTokenImages.USDC!,
1001
1216
  },
1002
1217
  {
1003
- id: "USDC-arbitrum",
1218
+ tokenId: "USDC-arbitrum",
1004
1219
  symbol: "USDC",
1005
1220
  name: "USDC Arbitrum",
1006
1221
  contractAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
@@ -1010,7 +1225,7 @@ export const commonTokens: SupportedToken[] = [
1010
1225
  imageUrl: commonTokenImages.USDC!,
1011
1226
  },
1012
1227
  {
1013
- id: "USDC-avalanche",
1228
+ tokenId: "USDC-avalanche",
1014
1229
  symbol: "USDC",
1015
1230
  name: "USDC Avalanche",
1016
1231
  contractAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
@@ -1020,7 +1235,7 @@ export const commonTokens: SupportedToken[] = [
1020
1235
  imageUrl: commonTokenImages.USDC!,
1021
1236
  },
1022
1237
  {
1023
- id: "USDC-base",
1238
+ tokenId: "USDC-base",
1024
1239
  symbol: "USDC",
1025
1240
  name: "USDC Base",
1026
1241
  contractAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
@@ -1030,7 +1245,7 @@ export const commonTokens: SupportedToken[] = [
1030
1245
  imageUrl: commonTokenImages.USDC!,
1031
1246
  },
1032
1247
  {
1033
- id: "USDC-linea",
1248
+ tokenId: "USDC-linea",
1034
1249
  symbol: "USDC",
1035
1250
  name: "USDC Linea",
1036
1251
  contractAddress: "0x176211869cA2b568f2A7D4EE941E073a821EE1ff",
@@ -1040,7 +1255,7 @@ export const commonTokens: SupportedToken[] = [
1040
1255
  imageUrl: commonTokenImages.USDC!,
1041
1256
  },
1042
1257
  {
1043
- id: "USDC-optimism",
1258
+ tokenId: "USDC-optimism",
1044
1259
  symbol: "USDC",
1045
1260
  name: "USDC Optimism",
1046
1261
  contractAddress: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
@@ -1050,7 +1265,7 @@ export const commonTokens: SupportedToken[] = [
1050
1265
  imageUrl: commonTokenImages.USDC!,
1051
1266
  },
1052
1267
  {
1053
- id: "USDC-polygon",
1268
+ tokenId: "USDC-polygon",
1054
1269
  symbol: "USDC",
1055
1270
  name: "USDC Polygon",
1056
1271
  contractAddress: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
@@ -1060,7 +1275,7 @@ export const commonTokens: SupportedToken[] = [
1060
1275
  imageUrl: commonTokenImages.USDC!,
1061
1276
  },
1062
1277
  {
1063
- id: "USDC-unichain",
1278
+ tokenId: "USDC-unichain",
1064
1279
  symbol: "USDC",
1065
1280
  name: "USDC Unichain",
1066
1281
  contractAddress: "0x078D782b760474a361dDA0AF3839290b0EF57AD6",
@@ -1070,7 +1285,7 @@ export const commonTokens: SupportedToken[] = [
1070
1285
  imageUrl: commonTokenImages.USDC!,
1071
1286
  },
1072
1287
  {
1073
- id: "USDC-worldchain",
1288
+ tokenId: "USDC-worldchain",
1074
1289
  symbol: "USDC",
1075
1290
  name: "USDC WorldChain",
1076
1291
  contractAddress: "0x79A02482A880bCe3F13E09da970dC34dB4cD24D1",
@@ -1082,7 +1297,7 @@ export const commonTokens: SupportedToken[] = [
1082
1297
 
1083
1298
  // Basic Attention Token
1084
1299
  {
1085
- id: "BAT-ethereum",
1300
+ tokenId: "BAT-ethereum",
1086
1301
  symbol: "BAT",
1087
1302
  name: "Basic Attention Token",
1088
1303
  contractAddress: "0x0D8775F648430679A709E98d2b0Cb6250d2887EF",
@@ -1092,7 +1307,7 @@ export const commonTokens: SupportedToken[] = [
1092
1307
  imageUrl: commonTokenImages.BAT!,
1093
1308
  },
1094
1309
  {
1095
- id: "BAT-polygon",
1310
+ tokenId: "BAT-polygon",
1096
1311
  symbol: "BAT",
1097
1312
  name: "Basic Attention Token",
1098
1313
  contractAddress: "0x3Cef98bb43d732E2F285eE605a8158cDE967D219",
@@ -1102,7 +1317,7 @@ export const commonTokens: SupportedToken[] = [
1102
1317
  imageUrl: commonTokenImages.BAT!,
1103
1318
  },
1104
1319
  {
1105
- id: "BAT-avalanche",
1320
+ tokenId: "BAT-avalanche",
1106
1321
  symbol: "BAT",
1107
1322
  name: "Basic Attention Token",
1108
1323
  contractAddress: "0x98443B96EA4b0858FDF3219Cd13e98C7A4690588",
@@ -1114,7 +1329,7 @@ export const commonTokens: SupportedToken[] = [
1114
1329
 
1115
1330
  // ARB
1116
1331
  {
1117
- id: "ARB-arbitrum",
1332
+ tokenId: "ARB-arbitrum",
1118
1333
  symbol: "ARB",
1119
1334
  name: "Arbitrum",
1120
1335
  contractAddress: "0x912CE59144191C1204E64559FE8253a0e49E6548",
@@ -1126,7 +1341,7 @@ export const commonTokens: SupportedToken[] = [
1126
1341
 
1127
1342
  // Chainlink
1128
1343
  {
1129
- id: "LINK-ethereum",
1344
+ tokenId: "LINK-ethereum",
1130
1345
  symbol: "LINK",
1131
1346
  name: "Chainlink",
1132
1347
  contractAddress: "0x514910771AF9Ca656af840dff83E8264EcF986CA",
@@ -1138,7 +1353,7 @@ export const commonTokens: SupportedToken[] = [
1138
1353
 
1139
1354
  // Etherlink tokens
1140
1355
  {
1141
- id: "XTZ-etherlink",
1356
+ tokenId: "XTZ-etherlink",
1142
1357
  symbol: "XTZ",
1143
1358
  name: "Tezos",
1144
1359
  contractAddress: "0x0000000000000000000000000000000000000000",
@@ -1146,9 +1361,10 @@ export const commonTokens: SupportedToken[] = [
1146
1361
  chainId: etherlink.id,
1147
1362
  chainName: etherlink.name,
1148
1363
  imageUrl: commonTokenImages.XTZ as string,
1364
+ isNativeToken: true,
1149
1365
  },
1150
1366
  {
1151
- id: "WXTZ-etherlink",
1367
+ tokenId: "WXTZ-etherlink",
1152
1368
  symbol: "WXTZ",
1153
1369
  name: "Wrapped XTZ",
1154
1370
  contractAddress: "0xc9B53AB2679f573e480d01e0f49e2B5CFB7a3EAb",
@@ -1158,7 +1374,7 @@ export const commonTokens: SupportedToken[] = [
1158
1374
  imageUrl: commonTokenImages.WXTZ as string,
1159
1375
  },
1160
1376
  {
1161
- id: "USDC-etherlink",
1377
+ tokenId: "USDC-etherlink",
1162
1378
  symbol: "USDC",
1163
1379
  name: "USD Coin",
1164
1380
  contractAddress: "0x796Ea11Fa2dD751eD01b53C372fFDB4AAa8f00F9",
@@ -1168,7 +1384,7 @@ export const commonTokens: SupportedToken[] = [
1168
1384
  imageUrl: commonTokenImages.USDC as string,
1169
1385
  },
1170
1386
  {
1171
- id: "WETH-etherlink",
1387
+ tokenId: "WETH-etherlink",
1172
1388
  symbol: "WETH",
1173
1389
  name: "Wrapped ETH",
1174
1390
  contractAddress: "0xfc24f770F94edBca6D6f885E12d4317320BcB401",
@@ -1178,7 +1394,7 @@ export const commonTokens: SupportedToken[] = [
1178
1394
  imageUrl: commonTokenImages.WETH as string,
1179
1395
  },
1180
1396
  {
1181
- id: "USDT-etherlink",
1397
+ tokenId: "USDT-etherlink",
1182
1398
  symbol: "USDT",
1183
1399
  name: "Bridged USDT",
1184
1400
  contractAddress: "0x2C03058C8AFC06713be23e58D2febC8337dbfE6A",
@@ -1188,7 +1404,7 @@ export const commonTokens: SupportedToken[] = [
1188
1404
  imageUrl: commonTokenImages.USDT as string,
1189
1405
  },
1190
1406
  {
1191
- id: "USDT-bsc",
1407
+ tokenId: "USDT-bsc",
1192
1408
  symbol: "USDT",
1193
1409
  name: "Tether USD",
1194
1410
  contractAddress: "0x55d398326f99059ff775485246999027b3197955",
@@ -1198,7 +1414,7 @@ export const commonTokens: SupportedToken[] = [
1198
1414
  imageUrl: commonTokenImages.USDT as string,
1199
1415
  },
1200
1416
  {
1201
- id: "BNB-bsc",
1417
+ tokenId: "BNB-bsc",
1202
1418
  symbol: "BNB",
1203
1419
  name: "BNB",
1204
1420
  contractAddress: "0x0000000000000000000000000000000000000000",
@@ -1206,11 +1422,12 @@ export const commonTokens: SupportedToken[] = [
1206
1422
  chainId: bsc.id,
1207
1423
  chainName: bsc.name,
1208
1424
  imageUrl: commonTokenImages.BNB as string,
1425
+ isNativeToken: true,
1209
1426
  },
1210
1427
 
1211
1428
  // Somnia
1212
1429
  {
1213
- id: "SOMI-somnia",
1430
+ tokenId: "SOMI-somnia",
1214
1431
  symbol: "SOMI",
1215
1432
  name: "Somnia",
1216
1433
  contractAddress: "0x0000000000000000000000000000000000000000",
@@ -1218,6 +1435,40 @@ export const commonTokens: SupportedToken[] = [
1218
1435
  chainId: somnia.id,
1219
1436
  chainName: somnia.name,
1220
1437
  imageUrl: commonTokenImages.SOMI as string,
1438
+ isNativeToken: true,
1439
+ },
1440
+
1441
+ // Monad
1442
+ {
1443
+ tokenId: "MON-monad",
1444
+ symbol: "MON",
1445
+ name: "Monad",
1446
+ contractAddress: "0x0000000000000000000000000000000000000000",
1447
+ decimals: 18,
1448
+ chainId: monad.id,
1449
+ chainName: monad.name,
1450
+ imageUrl: commonTokenImages.MONAD as string,
1451
+ isNativeToken: true,
1452
+ },
1453
+ {
1454
+ tokenId: "WMON-monad",
1455
+ symbol: "WMON",
1456
+ name: "Wrapped MON",
1457
+ contractAddress: "0x3bd359c1119da7da1d913d1c4d2b7c461115433a",
1458
+ decimals: 18,
1459
+ chainId: monad.id,
1460
+ chainName: monad.name,
1461
+ imageUrl: commonTokenImages.MON as string,
1462
+ },
1463
+ {
1464
+ tokenId: "USDC-monad",
1465
+ symbol: "USDC",
1466
+ name: "USDC",
1467
+ contractAddress: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603",
1468
+ decimals: 6,
1469
+ chainId: monad.id,
1470
+ chainName: monad.name,
1471
+ imageUrl: commonTokenImages.USDC as string,
1221
1472
  },
1222
1473
  ]
1223
1474