0xtrails 0.13.0 → 0.13.2

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 (307) hide show
  1. package/dist/{ccip-Cg9-lJ6K.js → ccip-CT_An6eM.js} +39 -39
  2. package/dist/chains.d.ts +4 -3
  3. package/dist/chains.d.ts.map +1 -1
  4. package/dist/constants.d.ts +1 -0
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/customTokens.d.ts.map +1 -1
  7. package/dist/error.d.ts +1 -0
  8. package/dist/error.d.ts.map +1 -1
  9. package/dist/gasless.d.ts +1 -2
  10. package/dist/gasless.d.ts.map +1 -1
  11. package/dist/{index-DEojZg7b.js → index-RfqL5Foz.js} +56672 -43550
  12. package/dist/index.d.ts +5 -2
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +385 -333
  15. package/dist/intents.d.ts +8 -2
  16. package/dist/intents.d.ts.map +1 -1
  17. package/dist/keyMachineClient.d.ts +9 -0
  18. package/dist/keyMachineClient.d.ts.map +1 -0
  19. package/dist/keymachine/index.d.ts +14 -0
  20. package/dist/keymachine/index.d.ts.map +1 -0
  21. package/dist/keymachine/key-machine.gen.d.ts +461 -0
  22. package/dist/keymachine/key-machine.gen.d.ts.map +1 -0
  23. package/dist/onramp/MeshConnectFlow.d.ts +18 -0
  24. package/dist/onramp/MeshConnectFlow.d.ts.map +1 -0
  25. package/dist/onramp/MeshConnectIframe.d.ts +13 -0
  26. package/dist/onramp/MeshConnectIframe.d.ts.map +1 -0
  27. package/dist/onramp/SendFromExchangeButton.d.ts +16 -0
  28. package/dist/onramp/SendFromExchangeButton.d.ts.map +1 -0
  29. package/dist/onramp/TrailsOnRampProvider.d.ts +31 -0
  30. package/dist/onramp/TrailsOnRampProvider.d.ts.map +1 -0
  31. package/dist/onramp/index.d.ts +13 -0
  32. package/dist/onramp/index.d.ts.map +1 -0
  33. package/dist/onramp/meshconnect.d.ts +30 -0
  34. package/dist/onramp/meshconnect.d.ts.map +1 -0
  35. package/dist/onramp/trailsOnramp.d.ts +24 -0
  36. package/dist/onramp/trailsOnramp.d.ts.map +1 -0
  37. package/dist/onramp-client/index.d.ts +3 -3
  38. package/dist/onramp-client/index.d.ts.map +1 -1
  39. package/dist/paymasterSend.d.ts.map +1 -1
  40. package/dist/prepareSend.d.ts.map +1 -1
  41. package/dist/query/balance.fetchers.d.ts +31 -2
  42. package/dist/query/balance.fetchers.d.ts.map +1 -1
  43. package/dist/query/balance.hooks.d.ts +21 -2
  44. package/dist/query/balance.hooks.d.ts.map +1 -1
  45. package/dist/query/balance.queries.d.ts +18 -1
  46. package/dist/query/balance.queries.d.ts.map +1 -1
  47. package/dist/query/chains.queries.d.ts.map +1 -1
  48. package/dist/query/meld.fetchers.d.ts +1 -1
  49. package/dist/query/meld.fetchers.d.ts.map +1 -1
  50. package/dist/query/meld.hooks.d.ts +3 -3
  51. package/dist/query/meld.hooks.d.ts.map +1 -1
  52. package/dist/query/meld.queries.d.ts +1 -1
  53. package/dist/query/meld.queries.d.ts.map +1 -1
  54. package/dist/query/price.fetchers.d.ts +15 -0
  55. package/dist/query/price.fetchers.d.ts.map +1 -0
  56. package/dist/query/price.hooks.d.ts +352 -0
  57. package/dist/query/price.hooks.d.ts.map +1 -0
  58. package/dist/query/price.queries.d.ts +34 -0
  59. package/dist/query/price.queries.d.ts.map +1 -0
  60. package/dist/query/tokenList.queries.d.ts +54 -0
  61. package/dist/query/tokenList.queries.d.ts.map +1 -0
  62. package/dist/recover.d.ts +6 -4
  63. package/dist/recover.d.ts.map +1 -1
  64. package/dist/tokens.d.ts +13 -0
  65. package/dist/tokens.d.ts.map +1 -1
  66. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +2 -2
  67. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
  68. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +2 -2
  69. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
  70. package/dist/transactionIntent/deposits/standardDeposit.d.ts +1 -1
  71. package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
  72. package/dist/transactionIntent/handlers/intentHandler.d.ts.map +1 -1
  73. package/dist/transactionIntent/helpers/transactionStateHelpers.d.ts.map +1 -1
  74. package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
  75. package/dist/transactionIntent/types.d.ts +1 -1
  76. package/dist/transactionIntent/types.d.ts.map +1 -1
  77. package/dist/transactions.d.ts +4 -0
  78. package/dist/transactions.d.ts.map +1 -1
  79. package/dist/umd/trails.min.js +291 -202
  80. package/dist/utils/format.d.ts +7 -0
  81. package/dist/utils/format.d.ts.map +1 -1
  82. package/dist/walletUtils.d.ts +2 -1
  83. package/dist/walletUtils.d.ts.map +1 -1
  84. package/dist/wallets.d.ts +13 -54
  85. package/dist/wallets.d.ts.map +1 -1
  86. package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
  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/DirectTransfer.d.ts +1 -1
  91. package/dist/widget/components/DirectTransfer.d.ts.map +1 -1
  92. package/dist/widget/components/EarnPools.d.ts.map +1 -1
  93. package/dist/widget/components/ExecutionStatusBadge.d.ts.map +1 -1
  94. package/dist/widget/components/Fund.d.ts.map +1 -1
  95. package/dist/widget/components/FundMethods.d.ts.map +1 -1
  96. package/dist/widget/components/HighPriceImpactBlock.d.ts +7 -0
  97. package/dist/widget/components/HighPriceImpactBlock.d.ts.map +1 -0
  98. package/dist/widget/components/MeldHistory.d.ts.map +1 -1
  99. package/dist/widget/components/MeshExchangeSelection.d.ts +11 -0
  100. package/dist/widget/components/MeshExchangeSelection.d.ts.map +1 -0
  101. package/dist/widget/components/OnrampHistoryRow.d.ts +1 -1
  102. package/dist/widget/components/OnrampHistoryRow.d.ts.map +1 -1
  103. package/dist/widget/components/OnrampProviderConfirmation.d.ts.map +1 -1
  104. package/dist/widget/components/Pay.d.ts.map +1 -1
  105. package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
  106. package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
  107. package/dist/widget/components/QRCodeWalletSelect.d.ts +1 -1
  108. package/dist/widget/components/QRCodeWalletSelect.d.ts.map +1 -1
  109. package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
  110. package/dist/widget/components/Receipt.d.ts.map +1 -1
  111. package/dist/widget/components/Recipients.d.ts.map +1 -1
  112. package/dist/widget/components/RefundWarning.d.ts.map +1 -1
  113. package/dist/widget/components/TokenSelector.d.ts.map +1 -1
  114. package/dist/widget/components/TransactionDetails.d.ts.map +1 -1
  115. package/dist/widget/components/TransactionHistoryItem.d.ts +2 -0
  116. package/dist/widget/components/TransactionHistoryItem.d.ts.map +1 -1
  117. package/dist/widget/components/TransferPendingVertical.d.ts +1 -0
  118. package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
  119. package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
  120. package/dist/widget/components/WalletConnect.d.ts.map +1 -1
  121. package/dist/widget/components/WalletImage.d.ts.map +1 -1
  122. package/dist/widget/components/WalletList.d.ts.map +1 -1
  123. package/dist/widget/components/Withdraw.d.ts.map +1 -1
  124. package/dist/widget/css/compiled.css +1 -1
  125. package/dist/widget/hooks/useAddressWalletIcon.d.ts.map +1 -1
  126. package/dist/widget/hooks/useCombinedHistory.d.ts +6 -5
  127. package/dist/widget/hooks/useCombinedHistory.d.ts.map +1 -1
  128. package/dist/widget/hooks/useCustomTokenSearch.d.ts +6 -1
  129. package/dist/widget/hooks/useCustomTokenSearch.d.ts.map +1 -1
  130. package/dist/widget/hooks/useDefaultDestinationToken.d.ts.map +1 -1
  131. package/dist/widget/hooks/useDefaultOriginToken.d.ts.map +1 -1
  132. package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts +1 -1
  133. package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts.map +1 -1
  134. package/dist/widget/hooks/useGetIntent.d.ts +3 -2
  135. package/dist/widget/hooks/useGetIntent.d.ts.map +1 -1
  136. package/dist/widget/hooks/useIntentReceiptBalances.d.ts +1 -1
  137. package/dist/widget/hooks/useIntentReceiptBalances.d.ts.map +1 -1
  138. package/dist/widget/hooks/useIntentTransactionHistory.d.ts +3 -2
  139. package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
  140. package/dist/widget/hooks/useMeldTransactionHistory.d.ts +1 -1
  141. package/dist/widget/hooks/useMeldTransactionHistory.d.ts.map +1 -1
  142. package/dist/widget/hooks/useMeldTransactionStatus.d.ts +1 -1
  143. package/dist/widget/hooks/useMeldTransactionStatus.d.ts.map +1 -1
  144. package/dist/widget/hooks/useOnRampQuote.d.ts +1 -1
  145. package/dist/widget/hooks/useOnRampQuote.d.ts.map +1 -1
  146. package/dist/widget/hooks/useOnRampTransactionStatus.d.ts +1 -1
  147. package/dist/widget/hooks/useOnRampTransactionStatus.d.ts.map +1 -1
  148. package/dist/widget/hooks/useQuote.d.ts +2 -2
  149. package/dist/widget/hooks/useQuote.d.ts.map +1 -1
  150. package/dist/widget/hooks/useSelectedFundMethod.d.ts +7 -0
  151. package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -1
  152. package/dist/widget/hooks/useSendForm.d.ts +0 -1
  153. package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
  154. package/dist/widget/hooks/useTokenList.d.ts +7 -1
  155. package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
  156. package/dist/widget/hooks/useViewManager.d.ts +1 -1
  157. package/dist/widget/hooks/useViewManager.d.ts.map +1 -1
  158. package/dist/widget/index.js +1 -1
  159. package/dist/widget/providers/TrailsProvider.d.ts +2 -0
  160. package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
  161. package/dist/widget/utils/createWagmiConfig.d.ts +2 -2
  162. package/dist/widget/utils/createWagmiConfig.d.ts.map +1 -1
  163. package/dist/widget/utils/fundMethodSwitchState.d.ts +1 -0
  164. package/dist/widget/utils/fundMethodSwitchState.d.ts.map +1 -1
  165. package/dist/widget/utils/historyFilters.d.ts +13 -0
  166. package/dist/widget/utils/historyFilters.d.ts.map +1 -0
  167. package/dist/widget/utils/meldProviderUtils.d.ts +1 -1
  168. package/dist/widget/utils/meldProviderUtils.d.ts.map +1 -1
  169. package/dist/widget/utils/meshSupportedTokens.d.ts +4 -0
  170. package/dist/widget/utils/meshSupportedTokens.d.ts.map +1 -0
  171. package/dist/widget/utils/onrampConfig.d.ts +11 -0
  172. package/dist/widget/utils/onrampConfig.d.ts.map +1 -0
  173. package/dist/widget/utils/statusLabel.d.ts +2 -0
  174. package/dist/widget/utils/statusLabel.d.ts.map +1 -0
  175. package/dist/widget/utils/trailsOnrampConfig.d.ts +18 -0
  176. package/dist/widget/utils/trailsOnrampConfig.d.ts.map +1 -0
  177. package/dist/widget/widget.d.ts +24 -8
  178. package/dist/widget/widget.d.ts.map +1 -1
  179. package/package.json +9 -7
  180. package/src/chains.ts +26 -9
  181. package/src/constants.ts +2 -0
  182. package/src/customTokens.ts +22 -7
  183. package/src/error.ts +7 -0
  184. package/src/gasless.ts +5 -2
  185. package/src/index.ts +8 -5
  186. package/src/intents.ts +56 -60
  187. package/src/keyMachineClient.ts +29 -0
  188. package/src/keymachine/index.ts +175 -0
  189. package/src/keymachine/key-machine.gen.ts +993 -0
  190. package/src/onramp/MeshConnectFlow.tsx +86 -0
  191. package/src/onramp/MeshConnectIframe.tsx +661 -0
  192. package/src/onramp/SendFromExchangeButton.tsx +81 -0
  193. package/src/onramp/TrailsOnRampProvider.tsx +59 -0
  194. package/src/onramp/index.ts +31 -0
  195. package/src/onramp/meshconnect.ts +277 -0
  196. package/src/onramp/trailsOnramp.tsx +130 -0
  197. package/src/onramp-client/index.ts +4 -6
  198. package/src/paymasterSend.ts +0 -5
  199. package/src/prepareSend.ts +45 -44
  200. package/src/query/balance.fetchers.ts +172 -17
  201. package/src/query/balance.hooks.ts +69 -6
  202. package/src/query/balance.queries.ts +63 -0
  203. package/src/query/chains.queries.ts +1 -6
  204. package/src/query/meld.fetchers.ts +1 -1
  205. package/src/query/meld.hooks.ts +1 -1
  206. package/src/query/meld.queries.ts +1 -1
  207. package/src/query/price.fetchers.ts +53 -0
  208. package/src/query/price.hooks.ts +46 -0
  209. package/src/query/price.queries.ts +364 -0
  210. package/src/query/tokenList.queries.ts +118 -0
  211. package/src/recover.ts +89 -26
  212. package/src/tokens.ts +108 -26
  213. package/src/transactionIntent/deposits/depositOrchestrator.ts +11 -11
  214. package/src/transactionIntent/deposits/gaslessDeposit.ts +38 -39
  215. package/src/transactionIntent/deposits/standardDeposit.ts +5 -30
  216. package/src/transactionIntent/handlers/intentHandler.ts +29 -12
  217. package/src/transactionIntent/helpers/transactionStateHelpers.ts +5 -2
  218. package/src/transactionIntent/quote/normalizeQuote.ts +11 -5
  219. package/src/transactionIntent/types.ts +1 -1
  220. package/src/transactions.ts +5 -1
  221. package/src/utils/format.ts +85 -1
  222. package/src/walletUtils.ts +2 -1
  223. package/src/wallets.ts +184 -380
  224. package/src/widget/compiled.css +1 -1
  225. package/src/widget/components/AccountIntentTransactionHistory.tsx +134 -109
  226. package/src/widget/components/ClassicSwap.tsx +26 -24
  227. package/src/widget/components/ConnectWallet.tsx +4 -2
  228. package/src/widget/components/ConnectedWallets.tsx +2 -5
  229. package/src/widget/components/DirectTransfer.tsx +5 -2
  230. package/src/widget/components/EarnPools.tsx +1 -2
  231. package/src/widget/components/ExecutionStatusBadge.tsx +10 -4
  232. package/src/widget/components/Fund.tsx +169 -110
  233. package/src/widget/components/FundMethods.tsx +5 -9
  234. package/src/widget/components/HighPriceImpactBlock.tsx +44 -0
  235. package/src/widget/components/MeldHistory.tsx +4 -28
  236. package/src/widget/components/MeshExchangeSelection.tsx +218 -0
  237. package/src/widget/components/OnrampHistoryRow.tsx +3 -27
  238. package/src/widget/components/OnrampProviderConfirmation.tsx +0 -25
  239. package/src/widget/components/Pay.tsx +20 -36
  240. package/src/widget/components/PoolDeposit.tsx +14 -24
  241. package/src/widget/components/PoolWithdraw.tsx +1 -63
  242. package/src/widget/components/QRCodeWalletSelect.tsx +5 -2
  243. package/src/widget/components/QuoteDetails.tsx +113 -106
  244. package/src/widget/components/Receipt.tsx +0 -11
  245. package/src/widget/components/Recipients.tsx +2 -1
  246. package/src/widget/components/RefundWarning.tsx +5 -10
  247. package/src/widget/components/ThemeProvider.tsx +4 -4
  248. package/src/widget/components/TokenSelector.tsx +85 -16
  249. package/src/widget/components/TransactionDetails.tsx +46 -0
  250. package/src/widget/components/TransactionHistoryItem.tsx +14 -23
  251. package/src/widget/components/TransferPendingVertical.tsx +17 -11
  252. package/src/widget/components/WaasFeeOptions.tsx +4 -42
  253. package/src/widget/components/WalletConnect.tsx +2 -5
  254. package/src/widget/components/WalletImage.tsx +6 -18
  255. package/src/widget/components/WalletList.tsx +1 -1
  256. package/src/widget/components/Withdraw.tsx +22 -23
  257. package/src/widget/hooks/useAddressWalletIcon.ts +2 -1
  258. package/src/widget/hooks/useAmountUsd.ts +1 -1
  259. package/src/widget/hooks/useCombinedHistory.ts +37 -93
  260. package/src/widget/hooks/useCustomTokenSearch.tsx +63 -33
  261. package/src/widget/hooks/useDefaultDestinationToken.tsx +2 -5
  262. package/src/widget/hooks/useDefaultOriginToken.tsx +2 -5
  263. package/src/widget/hooks/useFiatOnRampCurrencies.ts +1 -1
  264. package/src/widget/hooks/useGetIntent.ts +5 -4
  265. package/src/widget/hooks/useIntentReceiptBalances.ts +3 -3
  266. package/src/widget/hooks/useIntentTransactionHistory.ts +24 -47
  267. package/src/widget/hooks/useMeldTransactionHistory.ts +4 -2
  268. package/src/widget/hooks/useMeldTransactionStatus.ts +13 -11
  269. package/src/widget/hooks/useOnRampQuote.ts +3 -3
  270. package/src/widget/hooks/useOnRampTransactionStatus.ts +8 -6
  271. package/src/widget/hooks/useQuote.ts +56 -48
  272. package/src/widget/hooks/useSelectedFundMethod.tsx +14 -1
  273. package/src/widget/hooks/useSendForm.ts +52 -31
  274. package/src/widget/hooks/useTokenList.ts +209 -140
  275. package/src/widget/hooks/useTrailsSendTransaction.ts +1 -1
  276. package/src/widget/hooks/useViewManager.tsx +1 -0
  277. package/src/widget/providers/TrailsProvider.tsx +5 -0
  278. package/src/widget/styles.ts +1 -1
  279. package/src/widget/utils/createWagmiConfig.ts +7 -2
  280. package/src/widget/utils/fundMethodSwitchState.ts +2 -0
  281. package/src/widget/utils/historyFilters.ts +157 -0
  282. package/src/widget/utils/meldProviderUtils.ts +8 -2
  283. package/src/widget/utils/meshSupportedTokens.ts +28 -0
  284. package/src/widget/utils/onrampConfig.ts +15 -0
  285. package/src/widget/utils/statusLabel.ts +3 -0
  286. package/src/widget/utils/trailsOnrampConfig.ts +39 -0
  287. package/src/widget/widget.tsx +235 -185
  288. package/dist/onramp-client/trails-onramp.gen.d.ts +0 -570
  289. package/dist/onramp-client/trails-onramp.gen.d.ts.map +0 -1
  290. package/dist/prices.d.ts +0 -34
  291. package/dist/prices.d.ts.map +0 -1
  292. package/dist/useGasEstimation.d.ts +0 -34
  293. package/dist/useGasEstimation.d.ts.map +0 -1
  294. package/dist/widget/hooks/useCustomTokenFetch.d.ts +0 -19
  295. package/dist/widget/hooks/useCustomTokenFetch.d.ts.map +0 -1
  296. package/dist/widget/hooks/useTokenWithFreshBalance.d.ts +0 -18
  297. package/dist/widget/hooks/useTokenWithFreshBalance.d.ts.map +0 -1
  298. package/src/onramp-client/trails-onramp.gen.ts +0 -1320
  299. package/src/prices.ts +0 -528
  300. package/src/useGasEstimation.ts +0 -147
  301. package/src/widget/assets/Binance_Icon_Logo.svg +0 -14
  302. package/src/widget/assets/Bitfinex_Icon_Logo.svg +0 -5
  303. package/src/widget/assets/Coinbase_Icon_Logo.svg +0 -1
  304. package/src/widget/assets/WalletConnect-logo-blue-bg.svg +0 -11
  305. package/src/widget/assets/sequence-logo.svg +0 -15
  306. package/src/widget/hooks/useCustomTokenFetch.tsx +0 -74
  307. package/src/widget/hooks/useTokenWithFreshBalance.ts +0 -246
@@ -0,0 +1,81 @@
1
+ import type React from "react"
2
+ import { AlertCircle, ArrowLeftRight, ChevronRight } from "lucide-react"
3
+ import { isMeshEnabled, useTrailsOnRamp } from "./TrailsOnRampProvider.js"
4
+
5
+ export interface SendFromExchangeButtonProps {
6
+ /**
7
+ * Callback to navigate to the onramp screen.
8
+ * The onramp screen will show the exchange list.
9
+ */
10
+ onNavigateToOnramp?: () => void
11
+ }
12
+
13
+ /**
14
+ * Button component for "Send from Exchange" option in FundMethods.
15
+ * Only renders if Mesh onramp is configured and exchanges are configured.
16
+ * Shows an error message if no exchanges are configured.
17
+ * When clicked, navigates directly to the onramp screen which shows the exchange list.
18
+ */
19
+ export const SendFromExchangeButton: React.FC<SendFromExchangeButtonProps> = ({
20
+ onNavigateToOnramp,
21
+ }) => {
22
+ const onRampContext = useTrailsOnRamp()
23
+
24
+ // Check if exchanges are configured
25
+ const hasExchanges =
26
+ onRampContext?.config.mesh?.exchanges &&
27
+ onRampContext.config.mesh.exchanges.length > 0
28
+
29
+ const meshEnabled = isMeshEnabled(onRampContext?.config)
30
+
31
+ if (!meshEnabled) {
32
+ return null
33
+ }
34
+
35
+ // If no exchanges configured, show error message
36
+ if (!hasExchanges) {
37
+ return (
38
+ <>
39
+ {/* Divider between buttons */}
40
+ <div className="border-b border-gray-200 dark:border-gray-700"></div>
41
+
42
+ <div className="px-3 py-4 text-sm">
43
+ <div className="flex items-center gap-3 text-amber-600 dark:text-amber-400">
44
+ <AlertCircle className="w-4 h-4 flex-shrink-0" />
45
+ <div className="flex-1">
46
+ <p className="font-medium">Exchange list not configured</p>
47
+ <p className="text-xs mt-1 text-amber-500 dark:text-amber-500">
48
+ Please configure at least one exchange in the onramp settings.
49
+ </p>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ </>
54
+ )
55
+ }
56
+
57
+ // If no navigation callback provided, don't render button
58
+ if (!onNavigateToOnramp) {
59
+ return null
60
+ }
61
+
62
+ // Render the button - clicking navigates to the onramp screen which shows the exchange list
63
+ return (
64
+ <>
65
+ {/* Divider between buttons */}
66
+ <div className="border-b border-gray-200 dark:border-gray-700"></div>
67
+
68
+ <button
69
+ type="button"
70
+ onClick={onNavigateToOnramp}
71
+ className="w-full text-left px-3 py-4 text-sm flex items-center justify-between cursor-pointer transition-colors trails-text-primary trails-hover-bg"
72
+ >
73
+ <div className="flex items-center gap-3">
74
+ <ArrowLeftRight className="w-4 h-4" />
75
+ <span className="text-sm font-bold">Send from Exchange</span>
76
+ </div>
77
+ <ChevronRight className="w-5 h-5 text-gray-400" />
78
+ </button>
79
+ </>
80
+ )
81
+ }
@@ -0,0 +1,59 @@
1
+ import type React from "react"
2
+ import { createContext, useContext, useMemo } from "react"
3
+
4
+ export interface MeshConfig {
5
+ exchanges?: string[]
6
+ clientId?: string
7
+ environment?: "sandbox" | "production"
8
+ sandbox?: boolean
9
+ sandboxEnabled?: boolean
10
+ productionEnabled?: boolean
11
+ mode?: "sandbox" | "production"
12
+ }
13
+
14
+ export interface TrailsOnRampConfig {
15
+ mesh?: MeshConfig
16
+ environment?: "sandbox" | "production"
17
+ apiKey?: string
18
+ jwt?: string
19
+ hostname?: string
20
+ clientId?: string
21
+ }
22
+
23
+ interface TrailsOnRampContextValue {
24
+ config: TrailsOnRampConfig
25
+ }
26
+
27
+ const TrailsOnRampContext = createContext<TrailsOnRampContextValue | null>(null)
28
+
29
+ export interface TrailsOnRampProviderProps {
30
+ config?: TrailsOnRampConfig
31
+ children: React.ReactNode
32
+ }
33
+
34
+ export function TrailsOnRampProvider({
35
+ config = {},
36
+ children,
37
+ }: TrailsOnRampProviderProps) {
38
+ const value = useMemo<TrailsOnRampContextValue>(() => ({ config }), [config])
39
+
40
+ return (
41
+ <TrailsOnRampContext.Provider value={value}>
42
+ {children}
43
+ </TrailsOnRampContext.Provider>
44
+ )
45
+ }
46
+
47
+ export function useTrailsOnRamp(): TrailsOnRampContextValue | null {
48
+ return useContext(TrailsOnRampContext)
49
+ }
50
+
51
+ export function isMeshEnabled(config?: TrailsOnRampConfig | null): boolean {
52
+ return !!config?.mesh
53
+ }
54
+
55
+ export function getActiveMeshMode(
56
+ config?: TrailsOnRampConfig | null,
57
+ ): "sandbox" | "production" {
58
+ return config?.mesh?.environment ?? "production"
59
+ }
@@ -0,0 +1,31 @@
1
+ export { MeshConnectFlow } from "./MeshConnectFlow.js"
2
+ export type {
3
+ MeshConnectFlowProps,
4
+ SelectedMeshExchange,
5
+ } from "./MeshConnectFlow.js"
6
+ export { MeshConnectIframe } from "./MeshConnectIframe.js"
7
+ export type { MeshConnectProps } from "./MeshConnectIframe.js"
8
+ export { SendFromExchangeButton } from "./SendFromExchangeButton.js"
9
+ export type { SendFromExchangeButtonProps } from "./SendFromExchangeButton.js"
10
+ export {
11
+ SimpleHeader,
12
+ type SimpleHeaderProps,
13
+ } from "../meld/components/SimpleHeader.js"
14
+ export {
15
+ TrailsOnRampProvider,
16
+ getActiveMeshMode,
17
+ isMeshEnabled,
18
+ useTrailsOnRamp,
19
+ } from "./TrailsOnRampProvider.js"
20
+ export type {
21
+ MeshConfig,
22
+ TrailsOnRampConfig,
23
+ TrailsOnRampProviderProps,
24
+ } from "./TrailsOnRampProvider.js"
25
+ export {
26
+ trailsOnramp,
27
+ getTrailsOnrampConfig,
28
+ normalizeTrailsOnrampConfig,
29
+ } from "./trailsOnramp.js"
30
+ export type { OnrampFactory, OnrampWidgetHandlers } from "./trailsOnramp.js"
31
+ export * from "./meshconnect.js"
@@ -0,0 +1,277 @@
1
+ import {
2
+ type CreateMeshLinkTokenRequest,
3
+ type CreateMeshLinkTokenResponse,
4
+ type GetMeshIntegrationsRequest,
5
+ type GetMeshSupportedTokensRequest,
6
+ type GetMeshSupportedTokensResponse,
7
+ type MeshIntegration,
8
+ type MeshSupportedToken,
9
+ TrailsOnrampRpcClient,
10
+ } from "@0xtrails/api/onramp"
11
+ import type { TrailsOnRampConfig } from "./TrailsOnRampProvider.js"
12
+ import { getActiveMeshMode } from "./TrailsOnRampProvider.js"
13
+
14
+ const MESH_INTEGRATIONS_CACHE_TTL_MS = 30_000
15
+ const MESH_LINK_TOKEN_CACHE_TTL_MS = 5_000
16
+
17
+ const meshIntegrationsCache = new Map<
18
+ string,
19
+ { integrations: MeshIntegration[]; expiresAt: number }
20
+ >()
21
+ const meshIntegrationsInFlight = new Map<string, Promise<MeshIntegration[]>>()
22
+ const meshLinkTokenCache = new Map<
23
+ string,
24
+ { response: CreateMeshLinkTokenResponse; expiresAt: number }
25
+ >()
26
+ const meshLinkTokenInFlight = new Map<
27
+ string,
28
+ Promise<CreateMeshLinkTokenResponse>
29
+ >()
30
+ const meshSupportedTokensCache = new Map<
31
+ string,
32
+ { tokens: MeshSupportedToken[]; expiresAt: number }
33
+ >()
34
+ const meshSupportedTokensInFlight = new Map<
35
+ string,
36
+ Promise<MeshSupportedToken[]>
37
+ >()
38
+
39
+ export interface CreateMeshLinkTokenOptions {
40
+ address: string
41
+ symbol: string
42
+ amount: string
43
+ destinationChainId: number | string
44
+ integrationId?: string
45
+ exchangeType?: string
46
+ transactionId?: string
47
+ restrictMultipleAccounts?: boolean
48
+ }
49
+
50
+ function createOnrampClient(
51
+ config?: TrailsOnRampConfig,
52
+ ): TrailsOnrampRpcClient {
53
+ const customFetch = (
54
+ input: RequestInfo,
55
+ init?: RequestInit,
56
+ ): Promise<Response> => {
57
+ const headers: Record<string, string> = {}
58
+
59
+ if (config?.jwt && config.jwt.length > 0) {
60
+ headers.Authorization = `BEARER ${config.jwt}`
61
+ }
62
+
63
+ if (config?.apiKey && config.apiKey.length > 0) {
64
+ headers["X-Access-Key"] = config.apiKey
65
+ }
66
+
67
+ init = init || {}
68
+ init.headers = { ...init.headers, ...headers }
69
+
70
+ return fetch(input, init)
71
+ }
72
+
73
+ return new TrailsOnrampRpcClient(
74
+ config?.hostname && config.hostname.length > 0
75
+ ? config.hostname
76
+ : "https://trails-api.sequence.app",
77
+ customFetch,
78
+ )
79
+ }
80
+
81
+ function getMeshConfigKey(config?: TrailsOnRampConfig): string {
82
+ return JSON.stringify({
83
+ hostname: config?.hostname ?? "",
84
+ apiKey: config?.apiKey ?? "",
85
+ jwt: config?.jwt ?? "",
86
+ environment: getActiveMeshMode(config),
87
+ })
88
+ }
89
+
90
+ export async function getMeshIntegrations(
91
+ config?: TrailsOnRampConfig,
92
+ ): Promise<MeshIntegration[]> {
93
+ const cacheKey = getMeshConfigKey(config)
94
+ const cached = meshIntegrationsCache.get(cacheKey)
95
+
96
+ if (cached && cached.expiresAt > Date.now()) {
97
+ return cached.integrations
98
+ }
99
+
100
+ const inFlight = meshIntegrationsInFlight.get(cacheKey)
101
+ if (inFlight) {
102
+ return inFlight
103
+ }
104
+
105
+ const client = createOnrampClient(config)
106
+ const request: GetMeshIntegrationsRequest = {
107
+ environment: getActiveMeshMode(config),
108
+ }
109
+ const requestPromise = client
110
+ .getMeshIntegrations(request)
111
+ .then((response) => {
112
+ const integrations = response.integrations || []
113
+ meshIntegrationsCache.set(cacheKey, {
114
+ integrations,
115
+ expiresAt: Date.now() + MESH_INTEGRATIONS_CACHE_TTL_MS,
116
+ })
117
+ return integrations
118
+ })
119
+ .finally(() => {
120
+ meshIntegrationsInFlight.delete(cacheKey)
121
+ })
122
+
123
+ meshIntegrationsInFlight.set(cacheKey, requestPromise)
124
+ return requestPromise
125
+ }
126
+
127
+ export async function getMeshIntegrationId(
128
+ exchangeType: string,
129
+ config?: TrailsOnRampConfig,
130
+ ): Promise<string | undefined> {
131
+ const integrations = await getMeshIntegrations(config)
132
+ return integrations.find((integration) => integration.key === exchangeType)
133
+ ?.id
134
+ }
135
+
136
+ export async function getCoinbaseIntegrationId(
137
+ config?: TrailsOnRampConfig,
138
+ ): Promise<string | undefined> {
139
+ return (
140
+ (await getMeshIntegrationId("coinbaseRamp", config)) ??
141
+ getMeshIntegrationId("coinbase", config)
142
+ )
143
+ }
144
+
145
+ export async function getBinanceIntegrationId(
146
+ config?: TrailsOnRampConfig,
147
+ ): Promise<string | undefined> {
148
+ return (
149
+ (await getMeshIntegrationId("binanceInternationalDirect", config)) ??
150
+ getMeshIntegrationId("binanceInternational", config)
151
+ )
152
+ }
153
+
154
+ export async function getBitfinexIntegrationId(
155
+ config?: TrailsOnRampConfig,
156
+ ): Promise<string | undefined> {
157
+ return (
158
+ (await getMeshIntegrationId("bitfinexDirect", config)) ??
159
+ getMeshIntegrationId("bitfinex", config)
160
+ )
161
+ }
162
+
163
+ export async function createMeshLinkToken(
164
+ options: CreateMeshLinkTokenOptions,
165
+ config?: TrailsOnRampConfig,
166
+ ): Promise<CreateMeshLinkTokenResponse> {
167
+ const cacheKey = JSON.stringify({
168
+ config: getMeshConfigKey(config),
169
+ request: {
170
+ address: options.address,
171
+ symbol: options.symbol,
172
+ amount: options.amount,
173
+ destinationChainId: options.destinationChainId.toString(),
174
+ integrationId: options.integrationId ?? "",
175
+ exchangeType: options.exchangeType ?? "",
176
+ restrictMultipleAccounts: options.restrictMultipleAccounts ?? false,
177
+ transactionId: options.transactionId ?? "",
178
+ },
179
+ })
180
+
181
+ const cached = meshLinkTokenCache.get(cacheKey)
182
+ if (cached && cached.expiresAt > Date.now()) {
183
+ return cached.response
184
+ }
185
+
186
+ const inFlight = meshLinkTokenInFlight.get(cacheKey)
187
+ if (inFlight) {
188
+ return inFlight
189
+ }
190
+
191
+ const client = createOnrampClient(config)
192
+ const request: CreateMeshLinkTokenRequest = {
193
+ environment: getActiveMeshMode(config),
194
+ clientId: config?.mesh?.clientId ?? config?.clientId,
195
+ recipientAddress: options.address,
196
+ tokenSymbol: options.symbol,
197
+ destinationChainId: options.destinationChainId.toString(),
198
+ amount: options.amount,
199
+ integrationId: options.integrationId,
200
+ exchangeType: options.exchangeType,
201
+ transactionId: options.transactionId,
202
+ restrictMultipleAccounts: options.restrictMultipleAccounts,
203
+ }
204
+ const requestPromise = client
205
+ .createMeshLinkToken(request)
206
+ .then((response) => {
207
+ meshLinkTokenCache.set(cacheKey, {
208
+ response,
209
+ expiresAt: Date.now() + MESH_LINK_TOKEN_CACHE_TTL_MS,
210
+ })
211
+ return response
212
+ })
213
+ .finally(() => {
214
+ meshLinkTokenInFlight.delete(cacheKey)
215
+ })
216
+
217
+ meshLinkTokenInFlight.set(cacheKey, requestPromise)
218
+ return requestPromise
219
+ }
220
+
221
+ export async function getMeshSupportedTokens(
222
+ request: Omit<GetMeshSupportedTokensRequest, "environment">,
223
+ config?: TrailsOnRampConfig,
224
+ ): Promise<MeshSupportedToken[]> {
225
+ const cacheKey = JSON.stringify({
226
+ config: getMeshConfigKey(config),
227
+ request: {
228
+ integrationId: request.integrationId ?? "",
229
+ exchangeType: request.exchangeType ?? "",
230
+ chainIds: request.chainIds ?? [],
231
+ },
232
+ })
233
+
234
+ const cached = meshSupportedTokensCache.get(cacheKey)
235
+ if (cached && cached.expiresAt > Date.now()) {
236
+ return cached.tokens
237
+ }
238
+
239
+ const inFlight = meshSupportedTokensInFlight.get(cacheKey)
240
+ if (inFlight) {
241
+ return inFlight
242
+ }
243
+
244
+ const client = createOnrampClient(config)
245
+ const fullRequest: GetMeshSupportedTokensRequest = {
246
+ environment: getActiveMeshMode(config),
247
+ integrationId: request.integrationId,
248
+ exchangeType: request.exchangeType,
249
+ chainIds: request.chainIds,
250
+ }
251
+ const requestPromise = client
252
+ .getMeshSupportedTokens(fullRequest)
253
+ .then((response: GetMeshSupportedTokensResponse) => {
254
+ const tokens = response.tokens || []
255
+ meshSupportedTokensCache.set(cacheKey, {
256
+ tokens,
257
+ expiresAt: Date.now() + MESH_INTEGRATIONS_CACHE_TTL_MS,
258
+ })
259
+ return tokens
260
+ })
261
+ .finally(() => {
262
+ meshSupportedTokensInFlight.delete(cacheKey)
263
+ })
264
+
265
+ meshSupportedTokensInFlight.set(cacheKey, requestPromise)
266
+ return requestPromise
267
+ }
268
+
269
+ export default {
270
+ createMeshLinkToken,
271
+ getMeshIntegrations,
272
+ getMeshSupportedTokens,
273
+ getMeshIntegrationId,
274
+ getCoinbaseIntegrationId,
275
+ getBinanceIntegrationId,
276
+ getBitfinexIntegrationId,
277
+ }
@@ -0,0 +1,130 @@
1
+ import type React from "react"
2
+ import { MeshConnectFlow } from "./MeshConnectFlow.js"
3
+ import type { SelectedMeshExchange } from "./MeshConnectFlow.js"
4
+ import {
5
+ TrailsOnRampProvider,
6
+ type TrailsOnRampConfig,
7
+ } from "./TrailsOnRampProvider.js"
8
+
9
+ export interface OnrampWidgetHandlers {
10
+ setCurrentScreen: (screen: string) => void
11
+ onComplete?: (transferData: unknown) => void
12
+ onError?: (error: unknown) => void
13
+ onBack?: () => void
14
+ toTokenSymbol?: string
15
+ toTokenAmount?: string
16
+ toChainId?: number
17
+ toRecipientAddress?: string
18
+ toAmountUsd?: number
19
+ selectedExchange?: SelectedMeshExchange
20
+ apiKey?: string
21
+ hostname?: string
22
+ }
23
+
24
+ export type OnrampFactory = (
25
+ handlers: OnrampWidgetHandlers,
26
+ ) => React.ReactElement
27
+
28
+ type OnrampFactoryWithConfig = OnrampFactory & {
29
+ trailsOnrampConfig?: TrailsOnRampConfig
30
+ }
31
+
32
+ export function normalizeTrailsOnrampConfig(
33
+ config?: TrailsOnRampConfig,
34
+ ): TrailsOnRampConfig | undefined {
35
+ if (!config) {
36
+ return undefined
37
+ }
38
+
39
+ if (!config.mesh) {
40
+ return config
41
+ }
42
+
43
+ return {
44
+ ...config,
45
+ mesh: {
46
+ environment: "production",
47
+ ...config.mesh,
48
+ },
49
+ }
50
+ }
51
+
52
+ export function getTrailsOnrampConfig(
53
+ factory?: OnrampFactory,
54
+ ): TrailsOnRampConfig | undefined {
55
+ return normalizeTrailsOnrampConfig(
56
+ (factory as OnrampFactoryWithConfig | undefined)?.trailsOnrampConfig,
57
+ )
58
+ }
59
+
60
+ export function trailsOnramp(options: {
61
+ config?: TrailsOnRampConfig
62
+ }): OnrampFactory {
63
+ const normalizedConfig = normalizeTrailsOnrampConfig(options.config)
64
+ const factory: OnrampFactoryWithConfig = (handlers: OnrampWidgetHandlers) => {
65
+ const {
66
+ setCurrentScreen,
67
+ onComplete,
68
+ onBack,
69
+ toTokenSymbol,
70
+ toTokenAmount,
71
+ toChainId,
72
+ toRecipientAddress,
73
+ toAmountUsd,
74
+ selectedExchange,
75
+ apiKey,
76
+ hostname,
77
+ } = handlers
78
+
79
+ const handleBack = () => {
80
+ if (onBack) {
81
+ onBack()
82
+ } else {
83
+ setCurrentScreen("home")
84
+ }
85
+ }
86
+
87
+ const handleComplete = (transferData: unknown) => {
88
+ console.log("[onramp] handleComplete called:", {
89
+ hasOnComplete: !!onComplete,
90
+ transferData,
91
+ })
92
+ if (onComplete) {
93
+ try {
94
+ console.log("[onramp] Calling onComplete from widget handlers")
95
+ onComplete(transferData)
96
+ console.log("[onramp] onComplete called successfully")
97
+ } catch (error) {
98
+ console.error("[onramp] Error in onComplete:", error)
99
+ }
100
+ } else {
101
+ console.warn("[onramp] onComplete handler not provided by widget")
102
+ }
103
+ }
104
+
105
+ const configWithApiKey = {
106
+ ...normalizedConfig,
107
+ apiKey: apiKey || normalizedConfig?.apiKey,
108
+ hostname: hostname || normalizedConfig?.hostname,
109
+ }
110
+
111
+ return (
112
+ <TrailsOnRampProvider config={configWithApiKey}>
113
+ <MeshConnectFlow
114
+ onBack={handleBack}
115
+ onComplete={handleComplete}
116
+ toTokenSymbol={toTokenSymbol}
117
+ toTokenAmount={toTokenAmount}
118
+ toChainId={toChainId}
119
+ toRecipientAddress={toRecipientAddress}
120
+ toAmountUsd={toAmountUsd}
121
+ selectedExchange={selectedExchange}
122
+ />
123
+ </TrailsOnRampProvider>
124
+ )
125
+ }
126
+
127
+ factory.trailsOnrampConfig = normalizedConfig
128
+
129
+ return factory
130
+ }
@@ -1,8 +1,6 @@
1
- export * from "./trails-onramp.gen.js"
2
-
3
1
  import type { TrailsApi } from "@0xtrails/api"
4
-
5
- import { TrailsOnramp as BaseTrailsOnramp } from "./trails-onramp.gen.js"
2
+ export type * from "@0xtrails/api/onramp"
3
+ import { TrailsOnrampRpcClient } from "@0xtrails/api/onramp"
6
4
 
7
5
  export interface TrailsOnrampOptions {
8
6
  apiKey?: string
@@ -10,11 +8,11 @@ export interface TrailsOnrampOptions {
10
8
  hostname?: string
11
9
  }
12
10
 
13
- export class TrailsOnramp extends BaseTrailsOnramp {
11
+ export class TrailsOnramp extends TrailsOnrampRpcClient {
14
12
  static fromTrailsApiClient(client: TrailsApi): TrailsOnramp {
15
13
  const hostname = client.getHostname()
16
14
  const fetchFn = client.getFetch()
17
- return new BaseTrailsOnramp(hostname, fetchFn)
15
+ return new TrailsOnrampRpcClient(hostname, fetchFn)
18
16
  }
19
17
 
20
18
  constructor(apiKey: string, options?: TrailsOnrampOptions) {
@@ -10,7 +10,6 @@ import {
10
10
  toHex,
11
11
  zeroAddress,
12
12
  } from "viem"
13
- import { getChainRpcClient } from "./chains.js"
14
13
  import type { UserOperation } from "viem/account-abstraction"
15
14
  import {
16
15
  createBundlerClient,
@@ -193,9 +192,6 @@ export async function getPaymasterGaslessTransaction({
193
192
  recipient: `0x${string}`
194
193
  delegatorSmartAccount: ToSimpleSmartAccountReturnType
195
194
  }): Promise<{ to: string; data: string; value: string }[]> {
196
- // Initialize clients
197
- const publicClient = getChainRpcClient(chain.id)
198
-
199
195
  if (!walletClient.account) {
200
196
  throw new Error("No account found")
201
197
  }
@@ -205,7 +201,6 @@ export async function getPaymasterGaslessTransaction({
205
201
  logger.console.log("[trails-sdk] Transfer amount:", amount.toString())
206
202
 
207
203
  const { signature, deadline } = await getPermitSignature({
208
- publicClient,
209
204
  walletClient,
210
205
  signer: connectedAccount,
211
206
  spender: delegatorSmartAccount.address,