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
@@ -11,11 +11,6 @@ import type { CheckoutOnHandlers } from "../../widget/hooks/useCheckout.js"
11
11
  import { logger } from "../../logger.js"
12
12
  import { sendOriginTransaction } from "../../intents.js"
13
13
  import { getIsCustomCalldata } from "../../contractUtils.js"
14
- import {
15
- fetchCachedGasLimit,
16
- createGasEstimationParams,
17
- } from "../../useGasEstimation.js"
18
- import { queryClient as defaultQueryClient } from "../../query/client.js"
19
14
  import type { QueryClient } from "@tanstack/react-query"
20
15
  import { attemptSwitchChain } from "../../chainSwitch.js"
21
16
  import { requestWithTimeout } from "../../utils.js"
@@ -44,7 +39,6 @@ import { ensureErc20Approval } from "../utils/erc20Approval.js"
44
39
  * (executePassthrough in intentHandler.ts) is used instead.
45
40
  */
46
41
  export async function attemptStandardDeposit({
47
- queryClient: paramQueryClient,
48
42
  originTokenAddress,
49
43
  depositAmount,
50
44
  onOriginSend,
@@ -173,25 +167,6 @@ export async function attemptStandardDeposit({
173
167
  })
174
168
  }
175
169
 
176
- const effectiveQueryClient = paramQueryClient ?? defaultQueryClient
177
-
178
- const gasLimit = await fetchCachedGasLimit(
179
- effectiveQueryClient,
180
- publicClient,
181
- createGasEstimationParams(
182
- account.address,
183
- originCallParamsBase.to,
184
- originCallParamsBase.data,
185
- BigInt(originCallParamsBase.value),
186
- ),
187
- "standard-deposit",
188
- )
189
-
190
- const originCallParams = {
191
- ...originCallParamsBase,
192
- gasLimit,
193
- }
194
-
195
170
  await attemptSwitchChain({
196
171
  walletClient,
197
172
  desiredChainId: originChainId,
@@ -248,10 +223,10 @@ export async function attemptStandardDeposit({
248
223
 
249
224
  // Add the origin call
250
225
  calls.push({
251
- to: originCallParams.to as `0x${string}`,
252
- data: originCallParams.data as `0x${string}`,
253
- value: originCallParams.value
254
- ? `0x${BigInt(originCallParams.value).toString(16)}`
226
+ to: originCallParamsBase.to as `0x${string}`,
227
+ data: originCallParamsBase.data as `0x${string}`,
228
+ value: originCallParamsBase.value
229
+ ? `0x${BigInt(originCallParamsBase.value).toString(16)}`
255
230
  : "0x0",
256
231
  })
257
232
 
@@ -403,7 +378,7 @@ export async function attemptStandardDeposit({
403
378
  txHash = await sendOriginTransaction(
404
379
  account,
405
380
  walletClient,
406
- originCallParams as any,
381
+ originCallParamsBase as any,
407
382
  {
408
383
  depositTokenAmountUsd: depositAmountUsd?.toString(),
409
384
  },
@@ -48,7 +48,7 @@ import {
48
48
  import { updatePersistentToast } from "../../toast.js"
49
49
  import { formatRawAmount, rawAmountToNumber } from "../../utils/format.js"
50
50
  import { invalidateTokenBalancesCache } from "../../query/balance.queries.js"
51
- import { calcAmountUsdPrice } from "../../prices.js"
51
+ import { calcAmountUsdPrice } from "../../utils/format.js"
52
52
  import { checkAccountBalance } from "../utils/balanceChecker.js"
53
53
  import { queryClient as defaultQueryClient } from "../../query/client.js"
54
54
  import {
@@ -78,7 +78,10 @@ import {
78
78
  updateTransactionStateWithDecodedEvents,
79
79
  } from "../helpers/transactionStateHelpers.js"
80
80
  import { isSameChain, isSameToken } from "../validators.js"
81
- import { isSyntheticTransactionHash } from "../../transactions.js"
81
+ import {
82
+ isSyntheticTransactionHash,
83
+ isDisplayableTransactionHash,
84
+ } from "../../transactions.js"
82
85
 
83
86
  /**
84
87
  * Parameters for the unified intent handler.
@@ -588,20 +591,25 @@ async function executeIntent(
588
591
  // Set up transaction state tracking
589
592
  publishTransactionStates(localTransactionStates)
590
593
 
591
- if (!intent.intentProtocolVersion) {
594
+ const rawIntentProtocol = (intent as { intentProtocol?: string })
595
+ .intentProtocol
596
+
597
+ if (!rawIntentProtocol) {
592
598
  logger.console.log(
593
599
  "[trails-sdk] [intent-protocol] Intent protocol version not found in response, defaulting to v1",
594
600
  )
595
601
  }
596
- const intentProtocolVersion =
597
- intent.intentProtocolVersion ?? IntentProtocolVersion.v1
602
+ const intentProtocol =
603
+ rawIntentProtocol === "v1.5"
604
+ ? IntentProtocolVersion.v1_5
605
+ : IntentProtocolVersion.v1
598
606
 
599
607
  logger.console.log(
600
608
  "[trails-sdk] [intent-protocol] === Intent Protocol Version ===",
601
609
  {
602
- version: intentProtocolVersion,
603
- isV1: intentProtocolVersion === IntentProtocolVersion.v1,
604
- isV1_5: intentProtocolVersion === IntentProtocolVersion.v1_5,
610
+ version: intentProtocol,
611
+ isV1: intentProtocol === IntentProtocolVersion.v1,
612
+ isV1_5: intentProtocol === IntentProtocolVersion.v1_5,
605
613
  intentId: intent.intentId,
606
614
  fundMethod,
607
615
  },
@@ -718,7 +726,7 @@ async function executeIntent(
718
726
  isSameChainSameToken,
719
727
  destinationCalldata,
720
728
  depositTransaction: intent.depositTransaction,
721
- intentProtocolVersion,
729
+ intentProtocol,
722
730
  })
723
731
 
724
732
  // Update state and call executeIntent
@@ -788,11 +796,17 @@ async function executeIntent(
788
796
  )
789
797
 
790
798
  if (receipt.depositTransaction?.status === "SUCCEEDED") {
799
+ const existingHash = localTransactionStates[0].transactionHash
800
+ const existingExplorerUrl =
801
+ localTransactionStates[0].explorerUrl
802
+ const hasClientSideHash =
803
+ isDisplayableTransactionHash(existingHash)
804
+
791
805
  localTransactionStates[0] = {
792
806
  ...localTransactionStates[0],
793
807
  state: "confirmed",
794
- transactionHash: "",
795
- explorerUrl: "",
808
+ transactionHash: hasClientSideHash ? existingHash : "",
809
+ explorerUrl: hasClientSideHash ? existingExplorerUrl : "",
796
810
  txnMinedAt:
797
811
  receipt.depositTransaction?.txnMinedAt || undefined,
798
812
  }
@@ -1406,7 +1420,10 @@ export async function handleIntent(
1406
1420
  tokenAddress: originTokenAddress,
1407
1421
  depositAmount: depositAmount,
1408
1422
  publicClient: effectivePublicClient,
1409
- knownBalance: originTokenBalance,
1423
+ knownBalance:
1424
+ originTokenBalance && originTokenBalance !== "0"
1425
+ ? originTokenBalance
1426
+ : undefined,
1410
1427
  decimals: originTokenDecimals,
1411
1428
  })
1412
1429
  : Promise.resolve({ hasEnoughBalance: true }),
@@ -233,13 +233,16 @@ export function applyIntentReceiptToTransactionStates(params: {
233
233
  return
234
234
  }
235
235
 
236
- const displayableHash = isDisplayableTransactionHash(txnHash) ? txnHash : ""
236
+ const hasNewDisplayableHash = isDisplayableTransactionHash(txnHash)
237
+ const displayableHash = hasNewDisplayableHash
238
+ ? txnHash
239
+ : targetState.transactionHash || ""
237
240
  const nextExplorerUrl = displayableHash
238
241
  ? getExplorerUrl({
239
242
  txHash: displayableHash,
240
243
  chainId: targetState.chainId,
241
244
  })
242
- : ""
245
+ : targetState.explorerUrl || ""
243
246
 
244
247
  const stateChanged =
245
248
  targetState.state !== mappedState ||
@@ -405,18 +405,24 @@ export async function getNormalizedQuoteObject({
405
405
  totalProviderFeesUsdDisplay: "$0.00",
406
406
  }
407
407
 
408
- if (!intent?.intentProtocolVersion) {
408
+ const rawIntentProtocol = (
409
+ intent as { intentProtocol?: string } | null | undefined
410
+ )?.intentProtocol
411
+
412
+ if (!rawIntentProtocol) {
409
413
  logger.console.log(
410
414
  "[trails-sdk] [intent-protocol] Intent protocol version not in API response, defaulting to v1",
411
415
  )
412
416
  }
413
- const intentProtocolVersion =
414
- intent?.intentProtocolVersion ?? IntentProtocolVersion.v1
417
+ const intentProtocol =
418
+ rawIntentProtocol === "v1.5"
419
+ ? IntentProtocolVersion.v1_5
420
+ : IntentProtocolVersion.v1
415
421
 
416
422
  logger.console.log(
417
423
  "[trails-sdk] [intent-protocol] Quote normalized with version",
418
424
  {
419
- intentProtocolVersion,
425
+ intentProtocol,
420
426
  intentId: intent?.intentId,
421
427
  },
422
428
  )
@@ -430,7 +436,7 @@ export async function getNormalizedQuoteObject({
430
436
  })
431
437
 
432
438
  return {
433
- intentProtocolVersion,
439
+ intentProtocol,
434
440
  originDepositAddress: originDepositAddress || "",
435
441
  destinationDepositAddress: destinationDepositAddress || "",
436
442
  destinationAddress: destinationAddress || "",
@@ -130,7 +130,7 @@ export type PrepareSendFees = {
130
130
  }
131
131
 
132
132
  export type PrepareSendQuote = {
133
- intentProtocolVersion: IntentProtocolVersion
133
+ intentProtocol: IntentProtocolVersion
134
134
  originDepositAddress: string
135
135
  destinationDepositAddress: string
136
136
  destinationAddress: string
@@ -289,7 +289,8 @@ export type IntentTransaction = {
289
289
  intentId?: string
290
290
  metaTxnId?: string
291
291
  txnHash?: string
292
- executionStatus?: string
292
+ intentStatus?: string // Top-level intent status returned by Trails API history
293
+ executionStatus?: string // Derived transaction-level status used for detailed progress states
293
294
  originChainId?: number
294
295
  destinationChainId?: number
295
296
  originTokenAddress?: string
@@ -306,6 +307,9 @@ export type IntentTransaction = {
306
307
  depositTransactionStatus?: string // Deposit transaction status from API
307
308
  originTransactionStatus?: string // Origin transaction status from API
308
309
  destinationTransactionStatus?: string // Destination transaction status from API
310
+ refundTransactionHash?: string // Refund transaction hash from API
311
+ refundTransactionStatus?: string // Refund transaction status from API
312
+ refundTransactionChainId?: number // Refund transaction chain ID from API
309
313
  // Enriched token information
310
314
  originToken?: {
311
315
  symbol: string
@@ -1,6 +1,8 @@
1
1
  import type { NativeTokenBalance, TokenBalance } from "@0xsequence/indexer"
2
2
  import { formatUnits, zeroAddress } from "viem"
3
3
  import { logger } from "../logger.js"
4
+ import { parseLocaleNumber } from "../localeUtils.js"
5
+ import { isNonNegativeNumber, isValidNumber } from "./validation.js"
4
6
  import { forexRateStore } from "../widget/utils/forexRateStore.js"
5
7
 
6
8
  // ============================================================================
@@ -18,6 +20,7 @@ export type Price = {
18
20
 
19
21
  /** Cap used across all USD formatters to prevent display issues */
20
22
  const MAX_DISPLAY_VALUE = 100_000_000_000_000
23
+ const MAX_SUPPORTED_TOKEN_DECIMALS = 255
21
24
 
22
25
  // navigator.language provides the browser's UI language (e.g., 'es-ES', 'en-US')
23
26
  // Currently hardcoded to en-US until entire app is updated with locale display values
@@ -80,7 +83,11 @@ function parseRawBalance(
80
83
  return null
81
84
  }
82
85
 
83
- if (!Number.isInteger(decimals) || decimals < 0 || decimals > 18) {
86
+ if (
87
+ !Number.isInteger(decimals) ||
88
+ decimals < 0 ||
89
+ decimals > MAX_SUPPORTED_TOKEN_DECIMALS
90
+ ) {
84
91
  throw new Error("Invalid decimals")
85
92
  }
86
93
 
@@ -539,3 +546,80 @@ export function formatPriceFields(price: number | string | null | undefined): {
539
546
  priceUsdDisplay: usdFields.balanceUsdDisplay,
540
547
  }
541
548
  }
549
+
550
+ export function normalizeNumber(
551
+ number: number | string | null | undefined,
552
+ ): number {
553
+ if (number === null || number === undefined) {
554
+ return 0
555
+ }
556
+
557
+ // If already a number, return it directly
558
+ if (typeof number === "number") {
559
+ // Validate the number
560
+ if (!isValidNumber(number)) {
561
+ logger.console.error("[trails-sdk] Invalid number value:", number)
562
+ return 0
563
+ }
564
+ return number
565
+ }
566
+
567
+ // Only parse strings that might be locale-formatted
568
+ // This should ideally only be used for user input, not internal calculations
569
+ const normalized = parseLocaleNumber(number)
570
+
571
+ // Return 0 for invalid numbers
572
+ if (!isValidNumber(normalized)) {
573
+ logger.console.error("[trails-sdk] Error normalizing number string:", {
574
+ number,
575
+ normalized,
576
+ })
577
+ return 0
578
+ }
579
+
580
+ return normalized
581
+ }
582
+
583
+ export function calcAmountUsdPrice({
584
+ amount,
585
+ usdPrice,
586
+ }: {
587
+ amount: number | string
588
+ usdPrice: string | number | null | undefined
589
+ }) {
590
+ const sanitizedAmount = normalizeNumber(amount)
591
+ const sanitizedPrice = normalizeNumber(usdPrice)
592
+
593
+ // Validate inputs
594
+ if (!isNonNegativeNumber(sanitizedAmount)) {
595
+ return 0
596
+ }
597
+ if (!isNonNegativeNumber(sanitizedPrice)) {
598
+ return 0
599
+ }
600
+
601
+ const result = sanitizedAmount * sanitizedPrice
602
+
603
+ // Validate result
604
+ if (!isValidNumber(result)) {
605
+ logger.console.error("[trails-sdk] Error calculating amount USD:", {
606
+ sanitizedAmount,
607
+ sanitizedPrice,
608
+ result,
609
+ amount,
610
+ usdPrice,
611
+ })
612
+ return 0
613
+ }
614
+
615
+ return result
616
+ }
617
+
618
+ export function formatTvl(tvl: number): string {
619
+ if (tvl >= 1e9) return `$${(tvl / 1e9).toFixed(1)}B`
620
+ if (tvl >= 1e6) return `$${(tvl / 1e6).toFixed(1)}M`
621
+ if (tvl >= 1e3) return `$${(tvl / 1e3).toFixed(1)}K`
622
+ return `$${tvl.toFixed(0)}`
623
+ }
624
+
625
+ export { isValidInteger, isValidNumeric } from "./validation.js"
@@ -1,4 +1,5 @@
1
1
  import type { Connector } from "wagmi"
2
+ import type { WalletConnector } from "./wallets.js"
2
3
  import {
3
4
  BaseError,
4
5
  formatTransactionRequest,
@@ -202,7 +203,7 @@ export function isSequenceWalletById(walletId: string | undefined): boolean {
202
203
  }
203
204
 
204
205
  export function isWalletConnectConnector(
205
- connector: Connector | undefined,
206
+ connector: Connector | Pick<WalletConnector, "id" | "name"> | undefined,
206
207
  ): boolean {
207
208
  if (!connector) return false
208
209
  const connectorName = connector.name?.toLowerCase() || ""