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/dist/index.js CHANGED
@@ -1,421 +1,435 @@
1
- import { l as r, u as v, t as ue, a as de, b as ge, I as me, g as A, c as pe, d as $, e as fe, f as Ce, h as _, i as Ee, T as ye, p as he, j as J, k as ke, m as w } from "./index-w7_dK4c5.js";
2
- import { n as Be, S as Fe, a0 as Qe, Z as $e, a2 as _e, U as Je, x as Ge, y as Ke, z as je, a1 as We, G as ze, D as Ve, s as Xe, w as Ye, Y as Ze, X as et, V as tt, H as nt, J as ot, o as st, _ as rt, v as it, W as at, q as ct, O as lt, $ as ut, R as dt, C as gt, A as mt, B as pt, K as ft, E as Ct, Q as Et, L as yt, M as ht, F as kt, r as St, N as bt, P as wt } from "./index-w7_dK4c5.js";
3
- import { useQuery as K, useMutation as j } from "@tanstack/react-query";
4
- import { useIndexerGatewayClient as Se } from "@0xsequence/hooks";
5
- import { useIndexerGatewayClient as At } from "@0xsequence/hooks";
6
- import { useRef as be } from "react";
7
- import { zeroAddress as T, erc20Abi as we } from "viem";
8
- const G = 150, Ne = (c, e) => {
9
- const t = K({
10
- queryKey: ["waitIntentReceipt", c],
1
+ import { l as o, u as dt, t as Ht, T as vt, a as Lt, b as qt, g as B, I as bt, c as Et, d as ht, e as pt, f as yt, h as lt, i as It, j, p as St, k as G, m as Nt, n as ft, o as Bt, q as mt, r as Ct } from "./index-BbajxCG_.js";
2
+ import { s as ee, ab as ne, ag as oe, ak as se, aj as re, ad as ie, ai as ae, U as ce, L as le, M as de, N as ue, a5 as ge, ah as fe, a6 as me, a8 as Te, a9 as ke, a7 as he, W as Ce, R as Ae, H as Ee, K as pe, ac as ye, X as Ie, w as Se, v as we, D as Ue, z as De, A as xe, C as Pe, B as Re, x as Oe, y as He, E as ve, ae as Le, J as qe, F as be, a0 as Ne, af as Be, aa as Fe, Q as Me, O as Qe, P as We, Y as $e, S as _e, a2 as je, Z as Ge, _ as Je, V as Ke, G as Xe, a3 as ze, $ as Ve, a4 as Ye, a1 as Ze } from "./index-BbajxCG_.js";
3
+ import { useQuery as wt, useMutation as Tt } from "@tanstack/react-query";
4
+ import { useRef as Ut, useCallback as ct } from "react";
5
+ import { useWalletClient as Ft, useAccount as Mt, useChainId as Qt } from "wagmi";
6
+ import { zeroAddress as R, erc20Abi as Dt } from "viem";
7
+ import { useIndexerGatewayClient as xt } from "@0xsequence/hooks";
8
+ import { useIndexerGatewayClient as en } from "@0xsequence/hooks";
9
+ const At = 150, zt = (d, n) => {
10
+ const s = wt({
11
+ queryKey: ["waitIntentReceipt", d],
11
12
  queryFn: async () => {
12
- if (!c)
13
+ if (!d)
13
14
  throw new Error("Intent ID is required for monitoring");
14
- r.console.log(
15
- `[trails-sdk] 🔍 Monitoring intent receipt for ${c}`
15
+ o.console.log(
16
+ `[trails-sdk] 🔍 Monitoring intent receipt for ${d}`
16
17
  );
17
- const o = await e.waitIntentReceipt({
18
- intentId: c
18
+ const a = await n.waitIntentReceipt({
19
+ intentId: d
19
20
  });
20
- return r.console.log(
21
- `[trails-sdk] 📊 Intent ${c} status: ${o.intentReceipt.status}, done: ${o.done}`
22
- ), o;
21
+ return o.console.log(
22
+ `[trails-sdk] 📊 Intent ${d} status: ${a.intentReceipt.status}, done: ${a.done}`
23
+ ), a;
23
24
  },
24
- enabled: !!c,
25
+ enabled: !!d,
25
26
  refetchIntervalInBackground: !0,
26
- refetchInterval: (o) => {
27
- const s = o.state.data;
28
- return s && s.done ? (r.console.log(
29
- `[trails-sdk] ✅ Intent monitoring complete for ${c}`
30
- ), !1) : G;
27
+ refetchInterval: (a) => {
28
+ const c = a.state.data;
29
+ return c && c.done ? (o.console.log(
30
+ `[trails-sdk] ✅ Intent monitoring complete for ${d}`
31
+ ), !1) : At;
31
32
  },
32
- retry: (o, s) => o >= 30 ? (r.console.error(
33
- `[trails-sdk] ❌ Giving up on intent ${c} after 30 failed API attempts:`,
34
- s
33
+ retry: (a, c) => a >= 30 ? (o.console.error(
34
+ `[trails-sdk] ❌ Giving up on intent ${d} after 30 failed API attempts:`,
35
+ c
35
36
  ), !1) : !0
36
37
  });
37
38
  return {
38
- intentReceipt: t.data?.intentReceipt ?? null,
39
- done: t.data?.done ?? !1,
40
- isLoading: t.isLoading,
41
- isError: t.isError,
42
- error: t.error
39
+ intentReceipt: s.data?.intentReceipt ?? null,
40
+ done: s.data?.done ?? !1,
41
+ isLoading: s.isLoading,
42
+ isError: s.isError,
43
+ error: s.error
43
44
  };
44
45
  };
45
- function Te() {
46
- const c = v();
47
- return j({
48
- mutationFn: async (e) => {
49
- r.console.log("[trails-sdk] useCommitIntent: Starting commit", {
50
- intentId: e.intentId,
51
- originIntentAddress: e.originIntentAddress
46
+ function Pt() {
47
+ const d = dt();
48
+ return Tt({
49
+ mutationFn: async (n) => {
50
+ o.console.log("[trails-sdk] useCommitIntent: Starting commit", {
51
+ intentId: n.intentId,
52
+ originIntentAddress: n.originIntentAddress
52
53
  });
53
- const t = e.quoteRequest.originChainId.toString(), o = e.quoteRequest.destinationChainId.toString();
54
+ const s = n.quoteRequest.originChainId.toString(), a = n.quoteRequest.destinationChainId.toString();
54
55
  try {
55
- ue({
56
- intentAddress: e.originIntentAddress,
57
- userAddress: e.ownerAddress,
58
- originChainId: t ? Number(t) : void 0,
59
- destinationChainId: o ? Number(o) : void 0
56
+ Ht({
57
+ intentAddress: n.originIntentAddress,
58
+ userAddress: n.ownerAddress,
59
+ originChainId: s ? Number(s) : void 0,
60
+ destinationChainId: a ? Number(a) : void 0
60
61
  });
61
- const s = await c.commitIntent({ intent: e });
62
- return r.console.log("[trails-sdk] useCommitIntent: Commit successful", {
63
- intentId: e.intentId,
64
- response: s
65
- }), de({
66
- intentAddress: e.originIntentAddress,
67
- userAddress: e.ownerAddress,
68
- originChainId: t ? Number(t) : void 0,
69
- destinationChainId: o ? Number(o) : void 0
70
- }), s;
71
- } catch (s) {
72
- throw ge({
73
- error: A(s),
74
- userAddress: e.ownerAddress,
75
- intentAddress: e.originIntentAddress,
76
- originChainId: t ? Number(t) : void 0,
77
- destinationChainId: o ? Number(o) : void 0
78
- }), s;
62
+ const c = await d.commitIntent({
63
+ intent: n,
64
+ trailsContracts: vt
65
+ });
66
+ return o.console.log("[trails-sdk] useCommitIntent: Commit successful", {
67
+ intentId: n.intentId,
68
+ response: c
69
+ }), Lt({
70
+ intentAddress: n.originIntentAddress,
71
+ userAddress: n.ownerAddress,
72
+ originChainId: s ? Number(s) : void 0,
73
+ destinationChainId: a ? Number(a) : void 0
74
+ }), c;
75
+ } catch (c) {
76
+ throw qt({
77
+ error: B(c),
78
+ userAddress: n.ownerAddress,
79
+ intentAddress: n.originIntentAddress,
80
+ originChainId: s ? Number(s) : void 0,
81
+ destinationChainId: a ? Number(a) : void 0
82
+ }), c;
79
83
  }
80
84
  }
81
85
  });
82
86
  }
83
- function Ae() {
84
- const c = v();
85
- return j({
87
+ function Rt() {
88
+ const d = dt();
89
+ return Tt({
86
90
  mutationFn: async ({
87
- intentId: e,
88
- depositTransactionHash: t,
89
- depositSignature: o
91
+ intentId: n,
92
+ depositTransactionHash: s,
93
+ depositSignature: a
90
94
  }) => {
91
- if (r.console.log("[trails-sdk] useExecuteIntent: Starting execution", {
92
- intentId: e,
93
- depositTransactionHash: t,
94
- hasDepositSignature: !!o
95
- }), !t && !o)
95
+ if (o.console.log("[trails-sdk] useExecuteIntent: Starting execution", {
96
+ intentId: n,
97
+ depositTransactionHash: s,
98
+ hasDepositSignature: !!a
99
+ }), !s && !a)
96
100
  throw new Error(
97
101
  "[trails-sdk] Either depositTransactionHash or depositSignature must be provided"
98
102
  );
99
- let s;
103
+ let c;
100
104
  try {
101
- s = await c.executeIntent({
102
- intentId: e,
103
- depositTransactionHash: t,
104
- depositSignature: o
105
+ c = await d.executeIntent({
106
+ intentId: n,
107
+ depositTransactionHash: s,
108
+ depositSignature: a
105
109
  });
106
- } catch (l) {
107
- if (r.console.error(
110
+ } catch (T) {
111
+ if (o.console.error(
108
112
  "[trails-sdk] useExecuteIntent: Error executing intent",
109
113
  {
110
- intentId: e,
111
- error: l,
112
- errorJSON: JSON.stringify(l, null, 2)
114
+ intentId: n,
115
+ error: T,
116
+ errorJSON: JSON.stringify(T, null, 2)
113
117
  }
114
- ), l instanceof Error && l?.message?.includes("status=SUCCEEDED") || l instanceof Error && l?.cause?.message?.includes("status=SUCCEEDED") || l instanceof Error && JSON.stringify(l).includes("status=SUCCEEDED") || l instanceof me && l?.cause?.toString().includes("status=SUCCEEDED") || JSON.stringify(l).includes("status=SUCCEEDED"))
115
- return r.console.error(
118
+ ), T instanceof Error && T?.message?.includes("status=SUCCEEDED") || T instanceof Error && T?.cause?.message?.includes("status=SUCCEEDED") || T instanceof Error && JSON.stringify(T).includes("status=SUCCEEDED") || T instanceof bt && T?.cause?.toString().includes("status=SUCCEEDED") || JSON.stringify(T).includes("status=SUCCEEDED"))
119
+ return o.console.error(
116
120
  "[trails-sdk] useExecuteIntent: Intent already succeeded, treating as success",
117
- { intentId: e }
121
+ { intentId: n }
118
122
  ), {
119
- intentId: e,
123
+ intentId: n,
120
124
  intentStatus: "SUCCEEDED"
121
125
  };
122
- throw r.console.error(
126
+ throw o.console.error(
123
127
  "[trails-sdk] useExecuteIntent did not throw IntentStatusError and is not a SUCCEEDED intent",
124
128
  {
125
- intentId: e,
126
- error: l,
127
- errorJSON: JSON.stringify(l, null, 2)
129
+ intentId: n,
130
+ error: T,
131
+ errorJSON: JSON.stringify(T, null, 2)
128
132
  }
129
- ), l;
133
+ ), T;
130
134
  }
131
- return r.console.log(
135
+ return o.console.log(
132
136
  "[trails-sdk] useExecuteIntent: Execution successful",
133
137
  {
134
- intentId: e,
135
- response: s
138
+ intentId: n,
139
+ response: c
136
140
  }
137
- ), s;
141
+ ), c;
138
142
  }
139
143
  });
140
144
  }
141
- function Pe({
142
- walletClient: c,
143
- fromTokenAddress: e,
144
- fromChainId: t,
145
- toTokenAddress: o,
146
- toChainId: s,
147
- swapAmount: l,
148
- tradeType: I,
149
- toRecipient: p,
150
- toCalldata: U,
151
- slippageTolerance: D,
152
- onStatusUpdate: W,
153
- checkoutOnHandlers: z,
154
- quoteProvider: R,
155
- paymasterUrl: V,
156
- selectedFeeOption: x,
157
- nodeGatewayEnv: q,
158
- abortSignal: L,
159
- apiKey: X,
145
+ function Vt({
146
+ walletClient: d,
147
+ fromTokenAddress: n,
148
+ fromChainId: s,
149
+ toTokenAddress: a,
150
+ toChainId: c,
151
+ swapAmount: T,
152
+ tradeType: Z,
153
+ toRecipient: v,
154
+ toCalldata: tt,
155
+ slippageTolerance: J,
156
+ onStatusUpdate: K,
157
+ checkoutOnHandlers: X,
158
+ quoteProvider: F,
159
+ paymasterUrl: M,
160
+ selectedFeeOption: et,
161
+ nodeGatewayEnv: nt,
162
+ abortSignal: ot,
163
+ apiKey: z,
160
164
  isSmartWallet: O
161
165
  } = {}) {
162
- q && (globalThis.__testNodeGatewayEnv = q);
163
- const g = be(new AbortController()), Y = L ? (() => {
164
- const u = new AbortController();
165
- return L.addEventListener("abort", () => {
166
- u.abort(), g.current?.abort();
167
- }), g.current?.signal.addEventListener("abort", () => {
168
- u.abort();
169
- }), u.signal;
170
- })() : g.current.signal, { trailsApiKey: N, trailsApiUrl: Z, sequenceIndexerUrl: ee } = pe(), te = N, m = v({
171
- apiKey: N,
172
- hostname: Z
173
- }), S = Se(), P = $(t ?? void 0), M = $(s ?? void 0), { supportedTokens: f } = fe(), ne = Te(), oe = Ae(), { data: H, isLoading: se, error: B, refetch: re } = K({
166
+ nt && (globalThis.__testNodeGatewayEnv = nt);
167
+ const H = Ut(new AbortController()), ut = ot ? (() => {
168
+ const f = new AbortController();
169
+ return ot.addEventListener("abort", () => {
170
+ f.abort(), H.current?.abort();
171
+ }), H.current?.signal.addEventListener("abort", () => {
172
+ f.abort();
173
+ }), f.signal;
174
+ })() : H.current.signal, { trailsApiKey: Q, trailsApiUrl: p, sequenceIndexerUrl: st } = Et(), y = Q, P = dt({
175
+ apiKey: Q,
176
+ hostname: p
177
+ }), V = xt(), Y = ht(s ?? void 0), t = ht(c ?? void 0), { supportedTokens: r } = pt(), u = Pt(), k = Rt(), { data: g, isLoading: I, error: U, refetch: D } = wt({
174
178
  queryKey: [
175
179
  "prepareSend",
176
- e,
177
- t,
178
- o,
180
+ n,
179
181
  s,
180
- l?.toString(),
181
- p,
182
- U,
183
- I,
184
- D,
185
- R,
186
- X,
182
+ a,
183
+ c,
184
+ T?.toString(),
185
+ v,
186
+ tt,
187
+ Z,
188
+ J,
189
+ F,
190
+ z,
187
191
  O
188
192
  ],
189
193
  queryFn: async () => {
190
194
  try {
191
- if (g.current.signal.aborted && (r.console.log(
195
+ if (H.current.signal.aborted && (o.console.log(
192
196
  "[trails-sdk] Resetting aborted controller for new query"
193
- ), g.current = new AbortController()), !c || !m || !e || !o || !l || !p || !t || !s || !S)
197
+ ), H.current = new AbortController()), !d || !P || !n || !a || !T || !v || !s || !c || !V)
194
198
  return null;
195
- let u = [];
199
+ let f = [];
196
200
  try {
197
- u = (await Ce({
198
- account: c.account.address,
199
- indexerGatewayClient: S,
200
- trailsClient: m
201
+ f = (await yt({
202
+ account: d.account.address,
203
+ indexerGatewayClient: V,
204
+ trailsClient: P
201
205
  })).balances;
202
- } catch (n) {
203
- const a = A(n), d = a.includes("Cross-Origin") || a.includes("CORS") || a.includes("Same Origin Policy"), k = a.includes("fetch failed") || a.includes("network");
204
- if (d || k)
205
- r.console.warn(
206
+ } catch (i) {
207
+ const m = B(i), x = m.includes("Cross-Origin") || m.includes("CORS") || m.includes("Same Origin Policy"), _ = m.includes("fetch failed") || m.includes("network");
208
+ if (x || _)
209
+ o.console.warn(
206
210
  "[trails-sdk] [useQuote] Network or CORS error fetching balances, proceeding with quote using zero balance:",
207
211
  {
208
- error: a,
209
- account: c.account.address
212
+ error: m,
213
+ account: d.account.address
210
214
  }
211
- ), u = [];
215
+ ), f = [];
212
216
  else
213
- throw n;
217
+ throw i;
214
218
  }
215
- const ie = u.find(
216
- (n) => n.chainId === t && (n.contractAddress?.toLowerCase() === e.toLowerCase() || !n.contractAddress && e === T)
219
+ const E = f.find(
220
+ (i) => i.chainId === s && (i.contractAddress?.toLowerCase() === n.toLowerCase() || !i.contractAddress && n === R)
217
221
  )?.balance ?? "0";
218
- let b = 0;
222
+ let A = 0;
219
223
  try {
220
- const a = _(t)?.nativeCurrency?.symbol ?? "";
221
- a && (b = (await Ee(m, {
222
- tokenSymbol: a,
223
- tokenAddress: T,
224
- chainId: t
225
- }))?.priceUsd ?? 0, r.console.log(
224
+ const m = lt(s)?.nativeCurrency?.symbol ?? "";
225
+ m && (A = (await It(P, {
226
+ tokenSymbol: m,
227
+ tokenAddress: R,
228
+ chainId: s
229
+ }))?.priceUsd ?? 0, o.console.log(
226
230
  "[trails-sdk] [useQuote] Origin native token price:",
227
231
  {
228
- chainId: t,
229
- symbol: a,
230
- priceUsd: b
232
+ chainId: s,
233
+ symbol: m,
234
+ priceUsd: A
231
235
  }
232
236
  ));
233
- } catch (n) {
234
- r.console.error(
237
+ } catch (i) {
238
+ o.console.error(
235
239
  "[trails-sdk] [useQuote] Error getting origin native token price:",
236
- n
240
+ i
237
241
  );
238
242
  }
239
- const F = async (n, a) => {
243
+ const L = async (i, m) => {
240
244
  try {
241
- const d = a === t ? P : a === s ? M : null;
242
- if (!d)
243
- return r.console.warn(
244
- `[trails-sdk] No RPC client available for chain ${a}`
245
+ const x = m === s ? Y : m === c ? t : null;
246
+ if (!x)
247
+ return o.console.warn(
248
+ `[trails-sdk] No RPC client available for chain ${m}`
245
249
  ), null;
246
- if (n.toLowerCase() === T.toLowerCase())
247
- return _(a)?.nativeCurrency.decimals ?? 18;
248
- const k = await d.readContract({
249
- address: n,
250
- abi: we,
250
+ if (i.toLowerCase() === R.toLowerCase())
251
+ return lt(m)?.nativeCurrency.decimals ?? 18;
252
+ const _ = await x.readContract({
253
+ address: i,
254
+ abi: Dt,
251
255
  functionName: "decimals"
252
256
  });
253
- return r.console.log(
254
- `[trails-sdk] Fetched decimals on-chain for token ${n} on chain ${a}: ${k}`
255
- ), k;
256
- } catch (d) {
257
- return r.console.error(
258
- `[trails-sdk] Error fetching decimals on-chain for token ${n} on chain ${a}:`,
259
- d
257
+ return o.console.log(
258
+ `[trails-sdk] Fetched decimals on-chain for token ${i} on chain ${m}: ${_}`
259
+ ), _;
260
+ } catch (x) {
261
+ return o.console.error(
262
+ `[trails-sdk] Error fetching decimals on-chain for token ${i} on chain ${m}:`,
263
+ x
260
264
  ), null;
261
265
  }
262
- }, C = f?.find(
263
- (n) => n.contractAddress?.toLowerCase() === e?.toLowerCase() && n.chainId === t
264
- ), E = f?.find(
265
- (n) => n.contractAddress?.toLowerCase() === o?.toLowerCase() && n.chainId === s
266
+ }, S = r?.find(
267
+ (i) => i.contractAddress?.toLowerCase() === n?.toLowerCase() && i.chainId === s
268
+ ), w = r?.find(
269
+ (i) => i.contractAddress?.toLowerCase() === a?.toLowerCase() && i.chainId === c
266
270
  );
267
- let y = C?.decimals;
268
- if (!y && e && t) {
269
- r.console.warn(
271
+ let q = S?.decimals;
272
+ if (!q && n && s) {
273
+ o.console.warn(
270
274
  "[trails-sdk] [useQuote] Source token decimals not found in token list, fetching on-chain:",
271
275
  {
272
- originToken: C,
273
- fromTokenAddress: e,
274
- fromChainId: t
276
+ originToken: S,
277
+ fromTokenAddress: n,
278
+ fromChainId: s
275
279
  }
276
280
  );
277
- const n = await F(
278
- e,
279
- t
281
+ const i = await L(
282
+ n,
283
+ s
280
284
  );
281
- n !== null && (y = n);
285
+ i !== null && (q = i);
282
286
  }
283
- if (!y)
284
- throw r.console.error(
287
+ if (!q)
288
+ throw o.console.error(
285
289
  "[trails-sdk] [useQuote] Source token decimals not found:",
286
290
  {
287
- originToken: C,
288
- fromTokenAddress: e,
289
- fromChainId: t
291
+ originToken: S,
292
+ fromTokenAddress: n,
293
+ fromChainId: s
290
294
  }
291
295
  ), new Error("Source token decimals not found");
292
- let h = E?.decimals;
293
- if (!h && o && s) {
294
- r.console.warn(
296
+ let b = w?.decimals;
297
+ if (!b && a && c) {
298
+ o.console.warn(
295
299
  "[trails-sdk] Destination token decimals not found in token list, fetching on-chain:",
296
300
  {
297
- destinationToken: E,
298
- toTokenAddress: o,
299
- toChainId: s
301
+ destinationToken: w,
302
+ toTokenAddress: a,
303
+ toChainId: c
300
304
  }
301
305
  );
302
- const n = await F(
303
- o,
304
- s
306
+ const i = await L(
307
+ a,
308
+ c
305
309
  );
306
- n !== null && (h = n);
310
+ i !== null && (b = i);
307
311
  }
308
- if (!h)
309
- throw r.console.error(
312
+ if (!b)
313
+ throw o.console.error(
310
314
  "[trails-sdk] Destination token decimals not found:",
311
315
  {
312
- destinationToken: E,
313
- toTokenAddress: o,
314
- toChainId: s
316
+ destinationToken: w,
317
+ toTokenAddress: a,
318
+ toChainId: c
315
319
  }
316
320
  ), new Error("Destination token decimals not found");
317
- const ae = E?.symbol ?? "", ce = C?.symbol ?? "", Q = {
318
- account: c.account,
319
- originTokenAddress: e,
320
- originChainId: t,
321
- originTokenBalance: ie,
322
- destinationChainId: s,
323
- recipient: p,
324
- destinationTokenAddress: o,
325
- swapAmount: l.toString(),
326
- tradeType: I ?? ye.EXACT_OUTPUT,
327
- originTokenSymbol: ce,
328
- destinationTokenSymbol: ae,
329
- destinationCalldata: U,
330
- client: c,
331
- trailsClient: m,
332
- sourceTokenDecimals: y,
333
- destinationTokenDecimals: h,
321
+ const rt = w?.symbol ?? "", it = S?.symbol ?? "", W = {
322
+ account: d.account,
323
+ originTokenAddress: n,
324
+ originChainId: s,
325
+ originTokenBalance: E,
326
+ destinationChainId: c,
327
+ recipient: v,
328
+ destinationTokenAddress: a,
329
+ swapAmount: T.toString(),
330
+ tradeType: Z ?? j.EXACT_OUTPUT,
331
+ originTokenSymbol: it,
332
+ destinationTokenSymbol: rt,
333
+ destinationCalldata: tt,
334
+ client: d,
335
+ trailsClient: P,
336
+ sourceTokenDecimals: q,
337
+ destinationTokenDecimals: b,
334
338
  fee: "0",
335
339
  dryMode: !1,
336
- onTransactionStateChange: W ?? (() => {
340
+ onTransactionStateChange: K ?? (() => {
337
341
  }),
338
- slippageTolerance: D?.toString(),
339
- quoteProvider: R,
340
- paymasterUrl: V,
341
- selectedFeeOption: x ?? null,
342
- abortSignal: Y,
343
- originNativeTokenPriceUsd: b,
344
- commitIntentFn: ne.mutateAsync,
345
- executeIntentFn: oe.mutateAsync,
346
- checkoutOnHandlers: z,
347
- sequenceIndexerUrl: ee,
348
- sequenceProjectAccessKey: te,
349
- originPublicClient: P ?? void 0,
350
- destinationPublicClient: M ?? void 0,
351
- isSmartWallet: O ?? void 0
342
+ slippageTolerance: J?.toString(),
343
+ quoteProvider: F,
344
+ paymasterUrl: M,
345
+ selectedFeeOption: et ?? null,
346
+ abortSignal: ut,
347
+ originNativeTokenPriceUsd: A,
348
+ commitIntentFn: u.mutateAsync,
349
+ executeIntentFn: k.mutateAsync,
350
+ checkoutOnHandlers: X,
351
+ sequenceIndexerUrl: st,
352
+ sequenceProjectAccessKey: y,
353
+ originPublicClient: Y ?? void 0,
354
+ destinationPublicClient: t ?? void 0,
355
+ isSmartWallet: O ?? void 0,
356
+ trailsApiKey: Q,
357
+ trailsApiUrl: p
352
358
  };
353
- r.console.log("[trails-sdk] options", Q);
354
- const { quote: i, send: le } = await he(Q);
359
+ o.console.log("[trails-sdk] options", W);
360
+ const { quote: l, send: at } = await St(W);
355
361
  return {
356
362
  quote: {
357
- fromAmount: i.originAmount,
358
- toAmount: i.destinationAmount,
359
- fromAmountMin: i.originAmountMin,
360
- toAmountMin: i.destinationAmountMin,
361
- originToken: i.originToken,
362
- destinationToken: i.destinationToken,
363
- originChain: i.originChain,
364
- destinationChain: i.destinationChain,
365
- fees: i.fees,
366
- priceImpact: i.priceImpact,
367
- completionEstimateSeconds: i.completionEstimateSeconds,
368
- slippageTolerance: i.slippageTolerance,
369
- transactionStates: i.transactionStates,
370
- originTokenRate: i.originTokenRate,
371
- destinationTokenRate: i.destinationTokenRate,
372
- quoteProvider: i.quoteProvider,
373
- fromAmountUsdDisplay: i.originAmountUsdDisplay ?? void 0,
374
- toAmountUsdDisplay: i.destinationAmountUsdDisplay ?? void 0,
375
- gasCostUsd: i.gasCostUsd ?? void 0,
376
- gasCostUsdDisplay: i.gasCostUsdDisplay ?? void 0,
377
- gasCost: i.gasCost ?? void 0,
378
- gasCostFormatted: i.gasCostFormatted ?? void 0
363
+ fromAmount: l.originAmount,
364
+ toAmount: l.destinationAmount,
365
+ fromAmountMin: l.originAmountMin,
366
+ toAmountMin: l.destinationAmountMin,
367
+ originToken: l.originToken,
368
+ destinationToken: l.destinationToken,
369
+ originChain: l.originChain,
370
+ destinationChain: l.destinationChain,
371
+ fees: l.fees,
372
+ priceImpact: l.priceImpact,
373
+ priceImpactUsd: l.priceImpactUsd ?? void 0,
374
+ priceImpactUsdDisplay: l.priceImpactUsdDisplay ?? void 0,
375
+ completionEstimateSeconds: l.completionEstimateSeconds,
376
+ slippageTolerance: l.slippageTolerance,
377
+ transactionStates: l.transactionStates,
378
+ originTokenRate: l.originTokenRate,
379
+ destinationTokenRate: l.destinationTokenRate,
380
+ quoteProvider: l.quoteProvider,
381
+ fromAmountUsdDisplay: l.originAmountUsdDisplay ?? void 0,
382
+ toAmountUsdDisplay: l.destinationAmountUsdDisplay ?? void 0,
383
+ gasCostUsd: l.gasCostUsd ?? void 0,
384
+ gasCostUsdDisplay: l.gasCostUsdDisplay ?? void 0,
385
+ gasCost: l.gasCost ?? void 0,
386
+ gasCostFormatted: l.gasCostFormatted ?? void 0,
387
+ totalFeesUsd: l.grandTotalUsd ?? void 0,
388
+ totalFeesUsdDisplay: l.grandTotalUsdDisplay ?? void 0,
389
+ totalGasUsd: l.totalGasUsd ?? void 0,
390
+ totalGasUsdDisplay: l.totalGasUsdDisplay ?? void 0,
391
+ allProviderFeesUsd: l.allProviderFeesUsd ?? void 0,
392
+ allProviderFeesUsdDisplay: l.allProviderFeesUsdDisplay ?? void 0
379
393
  },
380
394
  swap: async () => {
381
395
  const {
382
- depositUserTxnReceipt: n,
383
- destinationIntentTransaction: a,
384
- totalCompletionSeconds: d
385
- } = await le({
386
- selectedFeeOption: x ?? null
396
+ depositUserTxnReceipt: i,
397
+ destinationIntentTransaction: m,
398
+ totalCompletionSeconds: x
399
+ } = await at({
400
+ selectedFeeOption: et ?? null
387
401
  });
388
402
  return {
389
403
  originTransaction: {
390
- transactionHash: n?.transactionHash,
391
- explorerUrl: J({
392
- txHash: n?.transactionHash,
393
- chainId: t
404
+ transactionHash: i?.transactionHash,
405
+ explorerUrl: G({
406
+ txHash: i?.transactionHash,
407
+ chainId: s
394
408
  }),
395
- receipt: n
409
+ receipt: i
396
410
  },
397
411
  destinationTransaction: {
398
- transactionHash: a?.txnHash,
399
- explorerUrl: J({
400
- txHash: a?.txnHash,
401
- chainId: s
412
+ transactionHash: m?.txnHash,
413
+ explorerUrl: G({
414
+ txHash: m?.txnHash,
415
+ chainId: c
402
416
  }),
403
- receipt: a
417
+ receipt: m
404
418
  },
405
- totalCompletionSeconds: d
419
+ totalCompletionSeconds: x
406
420
  };
407
421
  }
408
422
  };
409
- } catch (u) {
410
- throw r.console.error(
423
+ } catch (f) {
424
+ throw o.console.error(
411
425
  "[trails-sdk] [useQuote] Error getting quote:",
412
- u
413
- ), A(u);
426
+ f
427
+ ), B(f);
414
428
  }
415
429
  },
416
430
  // Prevent unnecessary refetching
417
- enabled: !!(c && m && e && o && l && p && t && s && S && // !isLoadingTokens &&
418
- f && f.length > 0),
431
+ enabled: !!(d && P && n && a && T && v && s && c && V && // !isLoadingTokens &&
432
+ r && r.length > 0),
419
433
  staleTime: 30 * 1e3,
420
434
  // Consider data fresh for 30 seconds
421
435
  refetchOnWindowFocus: !1,
@@ -430,74 +444,529 @@ function Pe({
430
444
  // Refetch when network reconnects
431
445
  });
432
446
  return {
433
- quote: H?.quote || null,
434
- swap: H?.swap || null,
435
- isLoadingQuote: se,
436
- quoteError: B,
437
- quoteErrorPrettified: ke(B),
438
- refetchQuote: () => re(),
447
+ quote: g?.quote || null,
448
+ swap: g?.swap || null,
449
+ isLoadingQuote: I,
450
+ quoteError: U,
451
+ quoteErrorPrettified: Nt(U),
452
+ refetchQuote: () => D(),
439
453
  abort: () => {
440
- r.console.log("[trails-sdk] useQuote abort() called"), r.console.log(
454
+ o.console.log("[trails-sdk] useQuote abort() called"), o.console.log(
441
455
  "[trails-sdk] Active operations before abort:",
442
- w.getAll()
443
- ), g.current.abort(), w.abortAll(), r.console.log(
456
+ ft.getAll()
457
+ ), H.current.abort(), ft.abortAll(), o.console.log(
444
458
  "[trails-sdk] Abort completed, active operations:",
445
- w.getAll()
459
+ ft.getAll()
460
+ );
461
+ }
462
+ };
463
+ }
464
+ function Yt(d) {
465
+ const { data: n } = Ft(), { chainId: s } = Mt(), a = Qt(), c = dt(), { trailsApiKey: T, sequenceIndexerUrl: Z } = Et(), {
466
+ openModal: v,
467
+ setPendingSelection: tt,
468
+ setHostTransactionState: J,
469
+ setHostTransactionQuote: K,
470
+ setHostTransactionStates: X,
471
+ setHostTransactionTimestamp: F,
472
+ hostTransactionState: M,
473
+ setReceiptActionButtonText: et,
474
+ setOnReceiptAction: nt,
475
+ retryTransactionRef: ot
476
+ } = Bt(), z = xt(), { supportedTokens: O } = pt(), H = Pt(), ut = Rt(), Q = Ut(null), p = ct(
477
+ (t) => {
478
+ J((r) => ({
479
+ status: t.status ?? r.status,
480
+ details: t.details === null ? void 0 : t.details ? { ...r.details, ...t.details } : r.details,
481
+ error: t.error === null ? void 0 : t.error !== void 0 ? t.error : r.error,
482
+ result: t.result === null ? void 0 : t.result ? { ...r.result, ...t.result } : r.result,
483
+ retryEnabled: t.retryEnabled !== void 0 ? t.retryEnabled : r.retryEnabled
484
+ }));
485
+ },
486
+ [J]
487
+ ), st = async (t, r, u) => {
488
+ if (o.console.log(
489
+ "[trails-sdk] [useTrailsSendTransaction] Executing transaction",
490
+ { variables: t, originSelection: r }
491
+ ), !n || !n.account)
492
+ throw new Error(
493
+ "Wallet client not available. Please connect your wallet."
494
+ );
495
+ if (!t.to)
496
+ throw new Error("Transaction 'to' address is required.");
497
+ let k, g, I;
498
+ if (r)
499
+ k = r.fromTokenAddress, g = r.fromChainId, I = r.fromAmount;
500
+ else if (t.fromTokenAddress && t.fromChainId && t.fromAmount)
501
+ k = t.fromTokenAddress, g = t.fromChainId, I = t.fromAmount;
502
+ else if (t.to && t.value !== void 0) {
503
+ const e = s || a;
504
+ if (!e)
505
+ throw new Error("Chain ID not available. Please connect your wallet.");
506
+ g = e, k = R, I = t.value.toString();
507
+ } else
508
+ throw new Error(
509
+ "Origin token parameters are required. Please provide 'value' (native token), or 'fromTokenAddress'/'fromChainId'/'fromAmount' (ERC20 token), or select via modal."
510
+ );
511
+ const U = s || a;
512
+ if (!U)
513
+ throw new Error("Chain ID not available. Please connect your wallet.");
514
+ let D, f, C, E;
515
+ if (t.tokenAddress && t.tokenAmount)
516
+ D = t.tokenAddress, f = O?.find(
517
+ (h) => h.contractAddress?.toLowerCase() === t.tokenAddress?.toLowerCase()
518
+ )?.chainId ?? U, C = t.tokenAmount, E = t.to;
519
+ else if (t.to && t.value !== void 0)
520
+ D = R, f = U, C = t.value.toString(), E = t.to;
521
+ else
522
+ throw new Error(
523
+ "Either 'value' or 'tokenAddress'/'tokenAmount' must be provided."
524
+ );
525
+ const A = t.tokenAddress && t.tokenAmount ? j.EXACT_OUTPUT : j.EXACT_INPUT;
526
+ if (A === j.EXACT_INPUT && !I)
527
+ throw new Error(
528
+ "Origin amount is required for this transaction. Please provide 'value' or 'fromAmount'."
529
+ );
530
+ const L = A === j.EXACT_OUTPUT ? C : I;
531
+ let S = [];
532
+ try {
533
+ S = (await yt({
534
+ account: n.account.address,
535
+ indexerGatewayClient: z,
536
+ trailsClient: c
537
+ })).balances;
538
+ } catch (e) {
539
+ o.console.warn(
540
+ "[trails-sdk] [useTrailsSendTransaction] Error fetching balances, proceeding with zero balance",
541
+ e
542
+ ), S = [];
543
+ }
544
+ const q = S.find(
545
+ (e) => e.chainId === g && (e.contractAddress?.toLowerCase() === k?.toLowerCase() || !e.contractAddress && k === R)
546
+ )?.balance ?? "0";
547
+ let b = 0;
548
+ try {
549
+ const h = lt(g)?.nativeCurrency?.symbol ?? "";
550
+ h && (b = (await It(c, {
551
+ tokenSymbol: h,
552
+ tokenAddress: R,
553
+ chainId: g
554
+ }))?.priceUsd ?? 0);
555
+ } catch (e) {
556
+ o.console.warn(
557
+ "[trails-sdk] [useTrailsSendTransaction] Error getting native token price",
558
+ e
559
+ );
560
+ }
561
+ const rt = O?.find(
562
+ (e) => e.contractAddress?.toLowerCase() === k?.toLowerCase() && e.chainId === g
563
+ ), it = O?.find(
564
+ (e) => e.contractAddress?.toLowerCase() === D?.toLowerCase() && e.chainId === f
565
+ ), { getChainRpcClient: W } = await import("./index-BbajxCG_.js").then((e) => e.aJ), l = W(g), at = W(f), gt = async (e, h) => {
566
+ try {
567
+ const N = h === g ? l : h === f ? at : W(h);
568
+ return N ? e.toLowerCase() === R.toLowerCase() ? lt(h)?.nativeCurrency.decimals ?? 18 : await N.readContract({
569
+ address: e,
570
+ abi: Dt,
571
+ functionName: "decimals"
572
+ }) : null;
573
+ } catch (N) {
574
+ return o.console.error(
575
+ `[trails-sdk] Error fetching decimals on-chain for token ${e} on chain ${h}:`,
576
+ N
577
+ ), null;
578
+ }
579
+ };
580
+ let $ = rt?.decimals;
581
+ if (!$ && k) {
582
+ const e = await gt(
583
+ k,
584
+ g
585
+ );
586
+ e !== null && ($ = e);
587
+ }
588
+ $ || ($ = 18);
589
+ let i = it?.decimals;
590
+ if (!i && D) {
591
+ const e = await gt(
592
+ D,
593
+ f
446
594
  );
595
+ e !== null && (i = e);
447
596
  }
597
+ i || (i = 18);
598
+ const m = it?.symbol ?? "", x = rt?.symbol ?? "", _ = (e) => {
599
+ u?.trackInWidget && X(e), d?.onStatusUpdate?.(e);
600
+ }, { send: kt, quote: Ot } = await St({
601
+ account: n.account,
602
+ originTokenAddress: k,
603
+ originChainId: g,
604
+ originTokenBalance: q,
605
+ destinationChainId: f,
606
+ recipient: E,
607
+ destinationTokenAddress: D,
608
+ swapAmount: L,
609
+ tradeType: A,
610
+ originTokenSymbol: x,
611
+ destinationTokenSymbol: m,
612
+ fee: "0",
613
+ client: n,
614
+ dryMode: !1,
615
+ trailsClient: c,
616
+ destinationCalldata: t.data ? t.data.toString() : void 0,
617
+ onTransactionStateChange: _,
618
+ sourceTokenDecimals: $,
619
+ destinationTokenDecimals: i,
620
+ paymasterUrl: d?.paymasterUrl,
621
+ slippageTolerance: d?.slippageTolerance?.toString(),
622
+ originNativeTokenPriceUsd: b,
623
+ quoteProvider: d?.quoteProvider,
624
+ commitIntentFn: H.mutateAsync,
625
+ executeIntentFn: ut.mutateAsync,
626
+ checkoutOnHandlers: d?.checkoutOnHandlers,
627
+ sequenceIndexerUrl: Z,
628
+ sequenceProjectAccessKey: T,
629
+ originPublicClient: l ?? void 0,
630
+ destinationPublicClient: at ?? void 0,
631
+ isSmartWallet: d?.isSmartWallet ?? void 0
632
+ });
633
+ u?.trackInWidget && (K(Ot ?? null), M.details || p({
634
+ details: {
635
+ to: E,
636
+ tokenAddress: D,
637
+ tokenAmount: A === j.EXACT_OUTPUT ? C : void 0,
638
+ toChainId: f,
639
+ data: t.data
640
+ }
641
+ }), (!M.status || M.status === "idle") && F(Date.now()));
642
+ try {
643
+ u?.trackInWidget && p({ retryEnabled: !1 });
644
+ const {
645
+ depositUserTxnReceipt: e,
646
+ destinationIntentTransaction: h,
647
+ totalCompletionSeconds: N
648
+ } = await kt({
649
+ selectedFeeOption: null,
650
+ // Transition to "pending" when wallet signature is complete
651
+ onOriginSend: () => {
652
+ u?.trackInWidget && p({ status: "pending", error: null });
653
+ }
654
+ });
655
+ return u?.trackInWidget && p({
656
+ status: "success",
657
+ result: {
658
+ originTxHash: e?.transactionHash,
659
+ originExplorerUrl: e?.transactionHash ? G({
660
+ txHash: e.transactionHash,
661
+ chainId: g
662
+ }) : void 0,
663
+ destinationTxHash: h?.txnHash,
664
+ destinationExplorerUrl: h?.txnHash ? G({
665
+ txHash: h.txnHash,
666
+ chainId: f
667
+ }) : void 0
668
+ }
669
+ }), {
670
+ originTransaction: {
671
+ transactionHash: e?.transactionHash,
672
+ explorerUrl: G({
673
+ txHash: e?.transactionHash,
674
+ chainId: g
675
+ }),
676
+ receipt: e
677
+ },
678
+ destinationTransaction: {
679
+ transactionHash: h?.txnHash,
680
+ explorerUrl: G({
681
+ txHash: h?.txnHash,
682
+ chainId: f
683
+ }),
684
+ receipt: h
685
+ },
686
+ totalCompletionSeconds: N
687
+ };
688
+ } catch (e) {
689
+ if (u?.trackInWidget) {
690
+ const h = mt(e);
691
+ p(h ? {
692
+ status: "confirmation",
693
+ error: null,
694
+ retryEnabled: !0
695
+ } : {
696
+ status: "error",
697
+ error: B(e),
698
+ retryEnabled: !1
699
+ });
700
+ }
701
+ throw e;
702
+ }
703
+ }, y = Tt({
704
+ mutationFn: async (t) => {
705
+ o.console.log(
706
+ "[trails-sdk] [useTrailsSendTransaction] Starting transaction",
707
+ t
708
+ ), et(
709
+ d?.receiptActionButtonText ?? "Transact Again"
710
+ ), nt(d?.onReceiptAction ?? null);
711
+ const r = t.value !== void 0, u = t.fromTokenAddress !== void 0 && t.fromChainId !== void 0, k = r || u;
712
+ let g;
713
+ if (t.tokenAddress && O) {
714
+ const C = O.find(
715
+ (E) => E.contractAddress?.toLowerCase() === t.tokenAddress?.toLowerCase()
716
+ );
717
+ C && (g = C.chainId);
718
+ }
719
+ g || (g = s || a);
720
+ let I = !0, U = !0;
721
+ if (n?.account)
722
+ try {
723
+ if (k) {
724
+ let C, E, A;
725
+ t.value !== void 0 ? (C = R, E = s || a || 1, A = t.value.toString()) : t.fromTokenAddress && t.fromChainId && (C = t.fromTokenAddress, E = t.fromChainId, A = t.fromAmount), C && E && A && A !== "0" && (I = await Ct({
726
+ account: n.account.address,
727
+ token: C,
728
+ amount: A,
729
+ chainId: E,
730
+ indexerGatewayClient: z,
731
+ trailsClient: c
732
+ }), o.console.log(
733
+ "[trails-sdk] [useTrailsSendTransaction] Origin token balance check:",
734
+ {
735
+ tokenAddress: C,
736
+ amount: A,
737
+ chainId: E,
738
+ hasSufficientBalance: I
739
+ }
740
+ ));
741
+ }
742
+ I && t.tokenAddress && t.tokenAmount && (U = await Ct({
743
+ account: n.account.address,
744
+ token: t.tokenAddress,
745
+ amount: t.tokenAmount,
746
+ chainId: g,
747
+ indexerGatewayClient: z,
748
+ trailsClient: c
749
+ }), o.console.log(
750
+ "[trails-sdk] [useTrailsSendTransaction] Destination token balance check:",
751
+ {
752
+ tokenAddress: t.tokenAddress,
753
+ tokenAmount: t.tokenAmount,
754
+ chainId: g,
755
+ hasSufficientBalance: U
756
+ }
757
+ ));
758
+ } catch (C) {
759
+ o.console.warn(
760
+ "[trails-sdk] [useTrailsSendTransaction] Error checking balances, defaulting to origin selection:",
761
+ C
762
+ ), I = !1, U = !1;
763
+ }
764
+ const D = !k || !I || !U;
765
+ if (o.console.log(
766
+ "[trails-sdk] [useTrailsSendTransaction] Origin selection decision:",
767
+ {
768
+ hasOriginParams: k,
769
+ hasSufficientOriginBalance: I,
770
+ hasSufficientDestinationTokenBalance: U,
771
+ needsOriginSelection: D
772
+ }
773
+ ), D) {
774
+ const C = !(t.tokenAddress && t.tokenAmount), E = {
775
+ to: t.to,
776
+ tokenAddress: t.tokenAddress,
777
+ tokenAmount: t.tokenAmount,
778
+ toChainId: g,
779
+ data: t.data
780
+ };
781
+ return p({
782
+ status: "awaiting-origin",
783
+ details: E,
784
+ error: null,
785
+ result: null
786
+ }), K(null), X([]), F(Date.now()), new Promise((A, L) => {
787
+ tt({
788
+ resolve: async (S) => {
789
+ try {
790
+ p({ status: "confirmation" });
791
+ const w = await st(t, S, {
792
+ trackInWidget: !0
793
+ });
794
+ A(w);
795
+ } catch (w) {
796
+ mt(w) || p({
797
+ status: "error",
798
+ error: B(w)
799
+ }), L(w);
800
+ }
801
+ },
802
+ reject: (S) => {
803
+ const w = S instanceof Error ? S : new Error(String(S));
804
+ p({
805
+ status: "error",
806
+ error: B(w)
807
+ }), L(w);
808
+ },
809
+ requireAmountInput: C
810
+ }), setTimeout(() => {
811
+ o.console.log(
812
+ "[trails-sdk] [useTrailsSendTransaction] Calling openModal()"
813
+ ), v();
814
+ }, 0);
815
+ });
816
+ }
817
+ const f = {
818
+ to: t.to,
819
+ tokenAddress: t.tokenAddress,
820
+ tokenAmount: t.tokenAmount,
821
+ toChainId: g,
822
+ data: t.data
823
+ };
824
+ return p({
825
+ status: "confirmation",
826
+ details: f,
827
+ error: null,
828
+ result: null
829
+ }), K(null), X([]), F(Date.now()), v(), st(t, void 0, { trackInWidget: !0 });
830
+ },
831
+ onSuccess: (t, r) => {
832
+ o.console.log(
833
+ "[trails-sdk] [useTrailsSendTransaction] Transaction successful",
834
+ { data: t, variables: r }
835
+ ), d?.onSuccess?.(t, r);
836
+ },
837
+ onError: (t, r) => {
838
+ o.console.error(
839
+ "[trails-sdk] [useTrailsSendTransaction] Transaction error",
840
+ { error: t, variables: r }
841
+ );
842
+ const u = B(t), k = mt(t);
843
+ M.status !== "idle" && !k && p({
844
+ status: "error",
845
+ error: u
846
+ }), d?.onError?.(new Error(u), r);
847
+ },
848
+ onSettled: (t, r, u) => {
849
+ o.console.log(
850
+ "[trails-sdk] [useTrailsSendTransaction] Transaction settled",
851
+ { data: t, error: r, variables: u }
852
+ ), d?.onSettled?.(t, r, u);
853
+ }
854
+ }), P = ct(
855
+ (t, r) => {
856
+ y.mutate(t, {
857
+ onSuccess: (u) => {
858
+ r?.onSuccess?.(u);
859
+ },
860
+ onError: (u) => {
861
+ r?.onError?.(u);
862
+ },
863
+ onSettled: (u, k) => {
864
+ r?.onSettled?.(u, k);
865
+ }
866
+ });
867
+ },
868
+ [y]
869
+ ), V = ct(
870
+ async (t, r) => y.mutateAsync(t, {
871
+ onSuccess: (u) => {
872
+ r?.onSuccess?.(u);
873
+ },
874
+ onError: (u) => {
875
+ r?.onError?.(u);
876
+ },
877
+ onSettled: (u, k) => {
878
+ r?.onSettled?.(u, k);
879
+ }
880
+ }),
881
+ [y]
882
+ ), Y = ct(() => {
883
+ Q.current && P(Q.current);
884
+ }, [P]);
885
+ return ot.current = Y, {
886
+ sendTransaction: P,
887
+ sendTransactionAsync: V,
888
+ retry: Y,
889
+ data: y.data,
890
+ error: y.error,
891
+ isPending: y.isPending,
892
+ isSuccess: y.isSuccess,
893
+ isError: y.isError,
894
+ isIdle: y.isIdle,
895
+ status: y.status,
896
+ reset: y.reset,
897
+ variables: y.variables
448
898
  };
449
899
  }
450
900
  export {
451
- Be as InsufficientBalanceError,
452
- Fe as TRAILS_ROUTER_PLACEHOLDER_AMOUNT,
453
- ye as TradeType,
454
- Qe as TrailsClient,
455
- $e as TrailsProvider,
456
- _e as TrailsWidget,
457
- Je as UserRejectionError,
458
- Ge as calculateIntentAddress,
459
- Ke as calculateOriginAndDestinationIntentAddresses,
460
- je as commitIntent,
461
- We as createModalController,
462
- ze as getAccountTotalBalanceUsd,
463
- Ve as getAccountTransactionHistory,
464
- Xe as getAllChains,
465
- _ as getChainInfo,
466
- Ye as getChainRpcClient,
467
- Ze as getCommitHash,
468
- et as getDebug,
469
- tt as getERC20TransferData,
470
- nt as getHasSufficientBalanceToken,
471
- ot as getHasSufficientBalanceUsd,
472
- st as getIsUserRejectionError,
473
- rt as getMinLogLevel,
474
- it as getRpcUrl,
475
- at as getSlippageTolerance,
476
- ct as getSupportedChains,
477
- lt as getSupportedTokens,
478
- ut as getTrailsClient,
479
- dt as getTxTimeDiff,
480
- r as logger,
481
- gt as pollIntentReceipt,
482
- he as prepareSend,
483
- mt as quoteIntent,
484
- pt as sendOriginTransaction,
485
- ft as useAccountTotalBalanceUsd,
486
- Ct as useAccountTransactionHistory,
487
- $ as useChainRpcClient,
488
- Te as useCommitIntent,
489
- Ae as useExecuteIntent,
490
- Et as useGetTokenImageUrl,
491
- yt as useHasSufficientBalanceToken,
492
- ht as useHasSufficientBalanceUsd,
493
- At as useIndexerGatewayClient,
494
- Ne as useIntentReceiptMonitor,
495
- kt as useIntentTransactionHistory,
496
- Pe as useQuote,
497
- St as useSupportedChains,
498
- fe as useSupportedTokens,
499
- bt as useTokenBalances,
500
- wt as useTokenList,
501
- pe as useTrails,
502
- v as useTrailsClient
901
+ ee as InsufficientBalanceError,
902
+ ne as TRAILS_ROUTER_PLACEHOLDER_AMOUNT,
903
+ j as TradeType,
904
+ oe as TrailsClient,
905
+ se as TrailsHookModal,
906
+ re as TrailsModalProvider,
907
+ ie as TrailsProvider,
908
+ ae as TrailsWidget,
909
+ ce as UserRejectionError,
910
+ le as calculateIntentAddress,
911
+ de as calculateOriginAndDestinationIntentAddresses,
912
+ ue as commitIntent,
913
+ ge as convertApiTokenInfoToToken,
914
+ fe as createModalController,
915
+ me as formatBalanceFields,
916
+ Te as formatPriceFields,
917
+ ke as formatUsdAmountFormatted,
918
+ he as formatUsdFields,
919
+ Ce as getAccountTotalBalanceUsd,
920
+ Ae as getAccountTransactionHistory,
921
+ Ee as getAllChains,
922
+ lt as getChainInfo,
923
+ pe as getChainRpcClient,
924
+ ye as getERC20TransferData,
925
+ Ct as getHasSufficientBalanceToken,
926
+ Ie as getHasSufficientBalanceUsd,
927
+ Se as getIsApiError,
928
+ we as getIsBalanceTooLowError,
929
+ Ue as getIsInsufficientLiquidityError,
930
+ De as getIsNoAvailableQuoteError,
931
+ xe as getIsQuoteFailedError,
932
+ Pe as getIsQuoteInputError,
933
+ Re as getIsQuoteTokenError,
934
+ Oe as getIsRateLimitedError,
935
+ He as getIsRequiredAmountNotMetError,
936
+ mt as getIsUserRejectionError,
937
+ ve as getIsWalletAlreadyConnectedError,
938
+ Le as getMinLogLevel,
939
+ Nt as getPrettifiedErrorMessage,
940
+ qe as getRpcUrl,
941
+ be as getSupportedChains,
942
+ Ne as getSupportedTokens,
943
+ Be as getTrailsClient,
944
+ Fe as getTxTimeDiff,
945
+ o as logger,
946
+ Me as pollIntentReceipt,
947
+ St as prepareSend,
948
+ Qe as quoteIntent,
949
+ We as sendOriginTransaction,
950
+ $e as useAccountTotalBalanceUsd,
951
+ _e as useAccountTransactionHistory,
952
+ ht as useChainRpcClient,
953
+ Pt as useCommitIntent,
954
+ Rt as useExecuteIntent,
955
+ je as useGetTokenImageUrl,
956
+ Ge as useHasSufficientBalanceToken,
957
+ Je as useHasSufficientBalanceUsd,
958
+ en as useIndexerGatewayClient,
959
+ zt as useIntentReceiptMonitor,
960
+ Ke as useIntentTransactionHistory,
961
+ Vt as useQuote,
962
+ Xe as useSupportedChains,
963
+ pt as useSupportedTokens,
964
+ ze as useTokenAddress,
965
+ Ve as useTokenBalances,
966
+ Ye as useTokenInfo,
967
+ Ze as useTokenList,
968
+ Et as useTrails,
969
+ dt as useTrailsClient,
970
+ Bt as useTrailsModal,
971
+ Yt as useTrailsSendTransaction
503
972
  };