@0xsequence/hooks 6.0.0-beta.4 → 6.0.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 (249) hide show
  1. package/LICENSE +1 -1
  2. package/dist/esm/contexts/ConfigContext.d.ts +2 -0
  3. package/dist/esm/contexts/ConfigContext.d.ts.map +1 -1
  4. package/dist/esm/contexts/ConfigContext.js +2 -0
  5. package/dist/esm/contexts/ConfigContext.js.map +1 -1
  6. package/dist/esm/hooks/Indexer/useGetTransactionHistory.d.ts +2 -0
  7. package/dist/esm/hooks/Indexer/useGetTransactionHistory.d.ts.map +1 -1
  8. package/dist/esm/hooks/Indexer/useIndexerClient.d.ts +2 -2
  9. package/dist/esm/hooks/Indexer/useIndexerClient.d.ts.map +1 -1
  10. package/dist/esm/hooks/Indexer/useIndexerClient.js +1 -1
  11. package/dist/esm/hooks/Indexer/useIndexerClient.js.map +1 -1
  12. package/dist/esm/hooks/IndexerGateway/useGetNativeTokenBalance.d.ts +2 -1
  13. package/dist/esm/hooks/IndexerGateway/useGetNativeTokenBalance.d.ts.map +1 -1
  14. package/dist/esm/hooks/IndexerGateway/useGetNativeTokenBalance.js.map +1 -1
  15. package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesByContract.d.ts +2 -1
  16. package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesByContract.d.ts.map +1 -1
  17. package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesByContract.js.map +1 -1
  18. package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesDetails.d.ts +2 -1
  19. package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesDetails.d.ts.map +1 -1
  20. package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesDetails.js.map +1 -1
  21. package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesSummary.d.ts +2 -1
  22. package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesSummary.d.ts.map +1 -1
  23. package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesSummary.js.map +1 -1
  24. package/dist/esm/hooks/Metadata/useGetContractInfo.d.ts.map +1 -1
  25. package/dist/esm/hooks/Metadata/useGetContractInfo.js +1 -1
  26. package/dist/esm/hooks/Metadata/useGetContractInfo.js.map +1 -1
  27. package/dist/esm/hooks/useNetwork.d.ts +1 -1
  28. package/dist/esm/hooks/useNetwork.d.ts.map +1 -1
  29. package/dist/esm/hooks/useNetwork.js +1 -1
  30. package/dist/esm/hooks/useNetwork.js.map +1 -1
  31. package/dist/esm/index.d.ts +4 -4
  32. package/dist/esm/index.d.ts.map +1 -1
  33. package/dist/esm/index.js.map +1 -1
  34. package/dist/esm/tests/IndexerGateway/useGetTokenBalancesByContract.test.js.map +1 -1
  35. package/dist/esm/tests/IndexerGateway/useGetTokenBalancesDetails.test.js.map +1 -1
  36. package/dist/esm/tests/IndexerGateway/useGetTokenBalancesSummary.test.js.map +1 -1
  37. package/dist/esm/utils/helpers.d.ts.map +1 -1
  38. package/dist/esm/utils/helpers.js +2 -0
  39. package/dist/esm/utils/helpers.js.map +1 -1
  40. package/dist/esm/utils/networks.d.ts +83 -0
  41. package/dist/esm/utils/networks.d.ts.map +1 -0
  42. package/dist/esm/utils/networks.js +52 -0
  43. package/dist/esm/utils/networks.js.map +1 -0
  44. package/package.json +15 -18
  45. package/dist/cjs/constants.d.ts +0 -29
  46. package/dist/cjs/constants.d.ts.map +0 -1
  47. package/dist/cjs/constants.js +0 -33
  48. package/dist/cjs/constants.js.map +0 -1
  49. package/dist/cjs/contexts/ConfigContext.d.ts +0 -27
  50. package/dist/cjs/contexts/ConfigContext.d.ts.map +0 -1
  51. package/dist/cjs/contexts/ConfigContext.js +0 -30
  52. package/dist/cjs/contexts/ConfigContext.js.map +0 -1
  53. package/dist/cjs/hooks/API/useAPIClient.d.ts +0 -39
  54. package/dist/cjs/hooks/API/useAPIClient.d.ts.map +0 -1
  55. package/dist/cjs/hooks/API/useAPIClient.js +0 -51
  56. package/dist/cjs/hooks/API/useAPIClient.js.map +0 -1
  57. package/dist/cjs/hooks/API/useGetCoinPrices.d.ts +0 -49
  58. package/dist/cjs/hooks/API/useGetCoinPrices.d.ts.map +0 -1
  59. package/dist/cjs/hooks/API/useGetCoinPrices.js +0 -78
  60. package/dist/cjs/hooks/API/useGetCoinPrices.js.map +0 -1
  61. package/dist/cjs/hooks/API/useGetCollectiblePrices.d.ts +0 -54
  62. package/dist/cjs/hooks/API/useGetCollectiblePrices.d.ts.map +0 -1
  63. package/dist/cjs/hooks/API/useGetCollectiblePrices.js +0 -83
  64. package/dist/cjs/hooks/API/useGetCollectiblePrices.js.map +0 -1
  65. package/dist/cjs/hooks/API/useGetExchangeRate.d.ts +0 -42
  66. package/dist/cjs/hooks/API/useGetExchangeRate.d.ts.map +0 -1
  67. package/dist/cjs/hooks/API/useGetExchangeRate.js +0 -63
  68. package/dist/cjs/hooks/API/useGetExchangeRate.js.map +0 -1
  69. package/dist/cjs/hooks/API/useGetWaasStatus.d.ts +0 -48
  70. package/dist/cjs/hooks/API/useGetWaasStatus.d.ts.map +0 -1
  71. package/dist/cjs/hooks/API/useGetWaasStatus.js +0 -49
  72. package/dist/cjs/hooks/API/useGetWaasStatus.js.map +0 -1
  73. package/dist/cjs/hooks/Builder/useDetectContractVersion.d.ts +0 -30
  74. package/dist/cjs/hooks/Builder/useDetectContractVersion.d.ts.map +0 -1
  75. package/dist/cjs/hooks/Builder/useDetectContractVersion.js +0 -26
  76. package/dist/cjs/hooks/Builder/useDetectContractVersion.js.map +0 -1
  77. package/dist/cjs/hooks/Combination/useGetSwapQuote.d.ts +0 -97
  78. package/dist/cjs/hooks/Combination/useGetSwapQuote.d.ts.map +0 -1
  79. package/dist/cjs/hooks/Combination/useGetSwapQuote.js +0 -123
  80. package/dist/cjs/hooks/Combination/useGetSwapQuote.js.map +0 -1
  81. package/dist/cjs/hooks/Combination/useGetSwapRoutes.d.ts +0 -61
  82. package/dist/cjs/hooks/Combination/useGetSwapRoutes.d.ts.map +0 -1
  83. package/dist/cjs/hooks/Combination/useGetSwapRoutes.js +0 -83
  84. package/dist/cjs/hooks/Combination/useGetSwapRoutes.js.map +0 -1
  85. package/dist/cjs/hooks/Indexer/useGetTransactionHistory.d.ts +0 -97
  86. package/dist/cjs/hooks/Indexer/useGetTransactionHistory.d.ts.map +0 -1
  87. package/dist/cjs/hooks/Indexer/useGetTransactionHistory.js +0 -131
  88. package/dist/cjs/hooks/Indexer/useGetTransactionHistory.js.map +0 -1
  89. package/dist/cjs/hooks/Indexer/useGetTransactionHistorySummary.d.ts +0 -76
  90. package/dist/cjs/hooks/Indexer/useGetTransactionHistorySummary.d.ts.map +0 -1
  91. package/dist/cjs/hooks/Indexer/useGetTransactionHistorySummary.js +0 -115
  92. package/dist/cjs/hooks/Indexer/useGetTransactionHistorySummary.js.map +0 -1
  93. package/dist/cjs/hooks/Indexer/useIndexerClient.d.ts +0 -102
  94. package/dist/cjs/hooks/Indexer/useIndexerClient.d.ts.map +0 -1
  95. package/dist/cjs/hooks/Indexer/useIndexerClient.js +0 -145
  96. package/dist/cjs/hooks/Indexer/useIndexerClient.js.map +0 -1
  97. package/dist/cjs/hooks/IndexerGateway/useGetNativeTokenBalance.d.ts +0 -35
  98. package/dist/cjs/hooks/IndexerGateway/useGetNativeTokenBalance.d.ts.map +0 -1
  99. package/dist/cjs/hooks/IndexerGateway/useGetNativeTokenBalance.js +0 -55
  100. package/dist/cjs/hooks/IndexerGateway/useGetNativeTokenBalance.js.map +0 -1
  101. package/dist/cjs/hooks/IndexerGateway/useGetSingleTokenBalance.d.ts +0 -50
  102. package/dist/cjs/hooks/IndexerGateway/useGetSingleTokenBalance.d.ts.map +0 -1
  103. package/dist/cjs/hooks/IndexerGateway/useGetSingleTokenBalance.js +0 -88
  104. package/dist/cjs/hooks/IndexerGateway/useGetSingleTokenBalance.js.map +0 -1
  105. package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesByContract.d.ts +0 -61
  106. package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesByContract.d.ts.map +0 -1
  107. package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesByContract.js +0 -85
  108. package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesByContract.js.map +0 -1
  109. package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesDetails.d.ts +0 -99
  110. package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesDetails.d.ts.map +0 -1
  111. package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesDetails.js +0 -136
  112. package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesDetails.js.map +0 -1
  113. package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesSummary.d.ts +0 -74
  114. package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesSummary.d.ts.map +0 -1
  115. package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesSummary.js +0 -111
  116. package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesSummary.js.map +0 -1
  117. package/dist/cjs/hooks/IndexerGateway/useIndexerGatewayClient.d.ts +0 -29
  118. package/dist/cjs/hooks/IndexerGateway/useIndexerGatewayClient.d.ts.map +0 -1
  119. package/dist/cjs/hooks/IndexerGateway/useIndexerGatewayClient.js +0 -41
  120. package/dist/cjs/hooks/IndexerGateway/useIndexerGatewayClient.js.map +0 -1
  121. package/dist/cjs/hooks/Metadata/useGetContractInfo.d.ts +0 -68
  122. package/dist/cjs/hooks/Metadata/useGetContractInfo.d.ts.map +0 -1
  123. package/dist/cjs/hooks/Metadata/useGetContractInfo.js +0 -96
  124. package/dist/cjs/hooks/Metadata/useGetContractInfo.js.map +0 -1
  125. package/dist/cjs/hooks/Metadata/useGetMultipleContractsInfo.d.ts +0 -95
  126. package/dist/cjs/hooks/Metadata/useGetMultipleContractsInfo.d.ts.map +0 -1
  127. package/dist/cjs/hooks/Metadata/useGetMultipleContractsInfo.js +0 -118
  128. package/dist/cjs/hooks/Metadata/useGetMultipleContractsInfo.js.map +0 -1
  129. package/dist/cjs/hooks/Metadata/useGetTokenMetadata.d.ts +0 -89
  130. package/dist/cjs/hooks/Metadata/useGetTokenMetadata.d.ts.map +0 -1
  131. package/dist/cjs/hooks/Metadata/useGetTokenMetadata.js +0 -123
  132. package/dist/cjs/hooks/Metadata/useGetTokenMetadata.js.map +0 -1
  133. package/dist/cjs/hooks/Metadata/useMetadataClient.d.ts +0 -39
  134. package/dist/cjs/hooks/Metadata/useMetadataClient.d.ts.map +0 -1
  135. package/dist/cjs/hooks/Metadata/useMetadataClient.js +0 -51
  136. package/dist/cjs/hooks/Metadata/useMetadataClient.js.map +0 -1
  137. package/dist/cjs/hooks/useClearCachedBalances.d.ts +0 -4
  138. package/dist/cjs/hooks/useClearCachedBalances.d.ts.map +0 -1
  139. package/dist/cjs/hooks/useClearCachedBalances.js +0 -17
  140. package/dist/cjs/hooks/useClearCachedBalances.js.map +0 -1
  141. package/dist/cjs/hooks/useClipboard.d.ts +0 -6
  142. package/dist/cjs/hooks/useClipboard.d.ts.map +0 -1
  143. package/dist/cjs/hooks/useClipboard.js +0 -34
  144. package/dist/cjs/hooks/useClipboard.js.map +0 -1
  145. package/dist/cjs/hooks/useConfig.d.ts +0 -47
  146. package/dist/cjs/hooks/useConfig.d.ts.map +0 -1
  147. package/dist/cjs/hooks/useConfig.js +0 -59
  148. package/dist/cjs/hooks/useConfig.js.map +0 -1
  149. package/dist/cjs/hooks/useNetwork.d.ts +0 -2
  150. package/dist/cjs/hooks/useNetwork.d.ts.map +0 -1
  151. package/dist/cjs/hooks/useNetwork.js +0 -9
  152. package/dist/cjs/hooks/useNetwork.js.map +0 -1
  153. package/dist/cjs/index.d.ts +0 -27
  154. package/dist/cjs/index.d.ts.map +0 -1
  155. package/dist/cjs/index.js +0 -67
  156. package/dist/cjs/index.js.map +0 -1
  157. package/dist/cjs/package.json +0 -1
  158. package/dist/cjs/tests/API/useGetCoinPrices.test.d.ts +0 -2
  159. package/dist/cjs/tests/API/useGetCoinPrices.test.d.ts.map +0 -1
  160. package/dist/cjs/tests/API/useGetCoinPrices.test.js +0 -36
  161. package/dist/cjs/tests/API/useGetCoinPrices.test.js.map +0 -1
  162. package/dist/cjs/tests/API/useGetCollectiblePrices.test.d.ts +0 -2
  163. package/dist/cjs/tests/API/useGetCollectiblePrices.test.d.ts.map +0 -1
  164. package/dist/cjs/tests/API/useGetCollectiblePrices.test.js +0 -36
  165. package/dist/cjs/tests/API/useGetCollectiblePrices.test.js.map +0 -1
  166. package/dist/cjs/tests/API/useGetExchangeRate.test.d.ts +0 -2
  167. package/dist/cjs/tests/API/useGetExchangeRate.test.d.ts.map +0 -1
  168. package/dist/cjs/tests/API/useGetExchangeRate.test.js +0 -29
  169. package/dist/cjs/tests/API/useGetExchangeRate.test.js.map +0 -1
  170. package/dist/cjs/tests/Combination/useGetSwapQuote.test.d.ts +0 -2
  171. package/dist/cjs/tests/Combination/useGetSwapQuote.test.d.ts.map +0 -1
  172. package/dist/cjs/tests/Combination/useGetSwapQuote.test.js +0 -57
  173. package/dist/cjs/tests/Combination/useGetSwapQuote.test.js.map +0 -1
  174. package/dist/cjs/tests/Indexer/useGetTransactionHistory.test.d.ts +0 -2
  175. package/dist/cjs/tests/Indexer/useGetTransactionHistory.test.d.ts.map +0 -1
  176. package/dist/cjs/tests/Indexer/useGetTransactionHistory.test.js +0 -35
  177. package/dist/cjs/tests/Indexer/useGetTransactionHistory.test.js.map +0 -1
  178. package/dist/cjs/tests/Indexer/useGetTransactionHistorySummary.test.d.ts +0 -2
  179. package/dist/cjs/tests/Indexer/useGetTransactionHistorySummary.test.d.ts.map +0 -1
  180. package/dist/cjs/tests/Indexer/useGetTransactionHistorySummary.test.js +0 -34
  181. package/dist/cjs/tests/Indexer/useGetTransactionHistorySummary.test.js.map +0 -1
  182. package/dist/cjs/tests/IndexerGateway/useGetNativeTokenBalance.test.d.ts +0 -2
  183. package/dist/cjs/tests/IndexerGateway/useGetNativeTokenBalance.test.d.ts.map +0 -1
  184. package/dist/cjs/tests/IndexerGateway/useGetNativeTokenBalance.test.js +0 -34
  185. package/dist/cjs/tests/IndexerGateway/useGetNativeTokenBalance.test.js.map +0 -1
  186. package/dist/cjs/tests/IndexerGateway/useGetSingleTokenBalanceSummary.test.d.ts +0 -2
  187. package/dist/cjs/tests/IndexerGateway/useGetSingleTokenBalanceSummary.test.d.ts.map +0 -1
  188. package/dist/cjs/tests/IndexerGateway/useGetSingleTokenBalanceSummary.test.js +0 -35
  189. package/dist/cjs/tests/IndexerGateway/useGetSingleTokenBalanceSummary.test.js.map +0 -1
  190. package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesByContract.test.d.ts +0 -2
  191. package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesByContract.test.d.ts.map +0 -1
  192. package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesByContract.test.js +0 -38
  193. package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesByContract.test.js.map +0 -1
  194. package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesDetails.test.d.ts +0 -2
  195. package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesDetails.test.d.ts.map +0 -1
  196. package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesDetails.test.js +0 -38
  197. package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesDetails.test.js.map +0 -1
  198. package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesSummary.test.d.ts +0 -2
  199. package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesSummary.test.d.ts.map +0 -1
  200. package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesSummary.test.js +0 -38
  201. package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesSummary.test.js.map +0 -1
  202. package/dist/cjs/tests/Metadata/useGetContractInfo.test.d.ts +0 -2
  203. package/dist/cjs/tests/Metadata/useGetContractInfo.test.d.ts.map +0 -1
  204. package/dist/cjs/tests/Metadata/useGetContractInfo.test.js +0 -33
  205. package/dist/cjs/tests/Metadata/useGetContractInfo.test.js.map +0 -1
  206. package/dist/cjs/tests/Metadata/useGetMultipleContractsInfo.test.d.ts +0 -2
  207. package/dist/cjs/tests/Metadata/useGetMultipleContractsInfo.test.d.ts.map +0 -1
  208. package/dist/cjs/tests/Metadata/useGetMultipleContractsInfo.test.js +0 -39
  209. package/dist/cjs/tests/Metadata/useGetMultipleContractsInfo.test.js.map +0 -1
  210. package/dist/cjs/tests/Metadata/useGetTokenMetadata.test.d.ts +0 -2
  211. package/dist/cjs/tests/Metadata/useGetTokenMetadata.test.d.ts.map +0 -1
  212. package/dist/cjs/tests/Metadata/useGetTokenMetadata.test.js +0 -34
  213. package/dist/cjs/tests/Metadata/useGetTokenMetadata.test.js.map +0 -1
  214. package/dist/cjs/tests/createWrapper.d.ts +0 -7
  215. package/dist/cjs/tests/createWrapper.d.ts.map +0 -1
  216. package/dist/cjs/tests/createWrapper.js +0 -29
  217. package/dist/cjs/tests/createWrapper.js.map +0 -1
  218. package/dist/cjs/tests/fixtures/nativeTokenBalance.d.ts +0 -7
  219. package/dist/cjs/tests/fixtures/nativeTokenBalance.d.ts.map +0 -1
  220. package/dist/cjs/tests/fixtures/nativeTokenBalance.js +0 -10
  221. package/dist/cjs/tests/fixtures/nativeTokenBalance.js.map +0 -1
  222. package/dist/cjs/tests/handlers.d.ts +0 -2
  223. package/dist/cjs/tests/handlers.d.ts.map +0 -1
  224. package/dist/cjs/tests/handlers.js +0 -274
  225. package/dist/cjs/tests/handlers.js.map +0 -1
  226. package/dist/cjs/tests/setup.d.ts +0 -3
  227. package/dist/cjs/tests/setup.d.ts.map +0 -1
  228. package/dist/cjs/tests/setup.js +0 -16
  229. package/dist/cjs/tests/setup.js.map +0 -1
  230. package/dist/cjs/tests/simple.test.d.ts +0 -2
  231. package/dist/cjs/tests/simple.test.d.ts.map +0 -1
  232. package/dist/cjs/tests/simple.test.js +0 -64
  233. package/dist/cjs/tests/simple.test.js.map +0 -1
  234. package/dist/cjs/tests/useConfig.test.d.ts +0 -2
  235. package/dist/cjs/tests/useConfig.test.d.ts.map +0 -1
  236. package/dist/cjs/tests/useConfig.test.js +0 -15
  237. package/dist/cjs/tests/useConfig.test.js.map +0 -1
  238. package/dist/cjs/types/hooks.d.ts +0 -5
  239. package/dist/cjs/types/hooks.d.ts.map +0 -1
  240. package/dist/cjs/types/hooks.js +0 -3
  241. package/dist/cjs/types/hooks.js.map +0 -1
  242. package/dist/cjs/utils/envstring.d.ts +0 -2
  243. package/dist/cjs/utils/envstring.d.ts.map +0 -1
  244. package/dist/cjs/utils/envstring.js +0 -10
  245. package/dist/cjs/utils/envstring.js.map +0 -1
  246. package/dist/cjs/utils/helpers.d.ts +0 -12
  247. package/dist/cjs/utils/helpers.d.ts.map +0 -1
  248. package/dist/cjs/utils/helpers.js +0 -66
  249. package/dist/cjs/utils/helpers.js.map +0 -1
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useGetExchangeRate = void 0;
4
- const react_query_1 = require("@tanstack/react-query");
5
- const constants_js_1 = require("../../constants.js");
6
- const useAPIClient_js_1 = require("./useAPIClient.js");
7
- /**
8
- * Hook to fetch current exchange rates from USD to other currencies.
9
- *
10
- * This hook uses React Query to fetch and cache exchange rates from the Sequence API.
11
- * Rates are automatically refreshed every 10 minutes to ensure they stay current.
12
- * Used throughout the wallet widget and checkout components to display fiat values
13
- * for tokens and NFTs.
14
- *
15
- * @see {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useGetExchangeRate} for more detailed documentation.
16
- *
17
- * @param toCurrency - The target currency code (e.g., 'EUR', 'GBP', 'JPY').
18
- * If 'USD' is provided, returns 1 as the conversion rate.
19
- *
20
- * @param options - Optional configuration options:
21
- * - retry: Whether to retry failed requests (defaults to false)
22
- * - disabled: Whether to disable the query
23
- *
24
- * @returns React Query result object containing:
25
- * - data: The exchange rate value from USD to the target currency
26
- * - isLoading: Whether the initial request is in progress
27
- * - error: Any error that occurred
28
- * - isError: Whether an error occurred
29
- * - isSuccess: Whether the request was successful
30
- *
31
- * @example
32
- * ```tsx
33
- * const { data: rate = 1, isLoading } = useGetExchangeRate('EUR')
34
- *
35
- * // Convert USD amount to EUR
36
- * const usdAmount = 100
37
- * const eurAmount = usdAmount * rate
38
- *
39
- * if (isLoading) {
40
- * return <div>Loading rates...</div>
41
- * }
42
- *
43
- * console.log(`${usdAmount} USD = ${eurAmount} EUR`)
44
- * ```
45
- */
46
- const useGetExchangeRate = (toCurrency, options) => {
47
- const apiClient = (0, useAPIClient_js_1.useAPIClient)();
48
- return (0, react_query_1.useQuery)({
49
- queryKey: [constants_js_1.QUERY_KEYS.useGetExchangeRate, toCurrency, options],
50
- queryFn: async () => {
51
- if (toCurrency === 'USD') {
52
- return 1;
53
- }
54
- const res = await apiClient.getExchangeRate({ toCurrency });
55
- return res.exchangeRate.value;
56
- },
57
- retry: options?.retry ?? false,
58
- staleTime: constants_js_1.time.oneMinute * 10,
59
- enabled: !!toCurrency && !options?.disabled
60
- });
61
- };
62
- exports.useGetExchangeRate = useGetExchangeRate;
63
- //# sourceMappingURL=useGetExchangeRate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGetExchangeRate.js","sourceRoot":"","sources":["../../../../src/hooks/API/useGetExchangeRate.ts"],"names":[],"mappings":";;;AAAA,uDAAgD;AAEhD,qDAAqD;AAGrD,uDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACI,MAAM,kBAAkB,GAAG,CAAC,UAAkB,EAAE,OAAsB,EAAE,EAAE;IAC/E,MAAM,SAAS,GAAG,IAAA,8BAAY,GAAE,CAAA;IAEhC,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,yBAAU,CAAC,kBAAkB,EAAE,UAAU,EAAE,OAAO,CAAC;QAC9D,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;gBACzB,OAAO,CAAC,CAAA;YACV,CAAC;YAED,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,eAAe,CAAC,EAAE,UAAU,EAAE,CAAC,CAAA;YAE3D,OAAO,GAAG,CAAC,YAAY,CAAC,KAAK,CAAA;QAC/B,CAAC;QACD,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,KAAK;QAC9B,SAAS,EAAE,mBAAI,CAAC,SAAS,GAAG,EAAE;QAC9B,OAAO,EAAE,CAAC,CAAC,UAAU,IAAI,CAAC,OAAO,EAAE,QAAQ;KAC5C,CAAC,CAAA;AACJ,CAAC,CAAA;AAlBY,QAAA,kBAAkB,sBAkB9B"}
@@ -1,48 +0,0 @@
1
- import { type UseQueryResult } from '@tanstack/react-query';
2
- export type WaasErrorStatusResponse = {
3
- status: number;
4
- error: number;
5
- code: string;
6
- msg: string;
7
- };
8
- export type WaasSuccessStatusResponse = {
9
- healthOK: boolean;
10
- pcr0: string;
11
- startTime: string;
12
- uptime: string;
13
- ver: string;
14
- };
15
- export type WaasStatusResponse = {
16
- successResponse: WaasSuccessStatusResponse | undefined;
17
- errorResponse: WaasErrorStatusResponse | undefined;
18
- };
19
- /**
20
- * React hook to fetch the current WAAS (Wallet as a Service) status from the backend API.
21
- *
22
- * @returns {UseQueryResult<WaasStatusResponse, Error>} The react-query result object containing:
23
- * - data: The WAAS status response
24
- * - successResponse: The WAAS status response if the request is successful
25
- * - errorResponse: The WAAS status response if the request is not successful
26
- * - error: Any error encountered during fetch
27
- * - isLoading: Boolean indicating if the request is in progress
28
- * - isSuccess, isError, refetch, etc.
29
- *
30
- * An error will be thrown only if the endpoint is not reachable or has an unhandled error.
31
- *
32
- * @example
33
- * ```tsx
34
- * import { useGetWaasStatus } from '@0xsequence/hooks'
35
- *
36
- * const MyComponent = () => {
37
- * const { data, isLoading, error } = useGetWaasStatus()
38
- *
39
- * if (isLoading) return <div>Loading...</div>
40
- * if (error) return <div>Error: {error.message}</div>
41
- * if (!data) return <div>No status available</div>
42
- *
43
- * return <div>Status: {data.successResponse?.healthOK ? 'OK' : data.errorResponse?.msg}</div>
44
- * }
45
- * ```
46
- */
47
- export declare const useGetWaasStatus: () => UseQueryResult<WaasStatusResponse, Error>;
48
- //# sourceMappingURL=useGetWaasStatus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGetWaasStatus.d.ts","sourceRoot":"","sources":["../../../../src/hooks/API/useGetWaasStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAIrE,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,EAAE,yBAAyB,GAAG,SAAS,CAAA;IACtD,aAAa,EAAE,uBAAuB,GAAG,SAAS,CAAA;CACnD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,gBAAgB,QAAO,cAAc,CAAC,kBAAkB,EAAE,KAAK,CAa3E,CAAA"}
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useGetWaasStatus = void 0;
4
- const react_query_1 = require("@tanstack/react-query");
5
- const constants_js_1 = require("../../constants.js");
6
- /**
7
- * React hook to fetch the current WAAS (Wallet as a Service) status from the backend API.
8
- *
9
- * @returns {UseQueryResult<WaasStatusResponse, Error>} The react-query result object containing:
10
- * - data: The WAAS status response
11
- * - successResponse: The WAAS status response if the request is successful
12
- * - errorResponse: The WAAS status response if the request is not successful
13
- * - error: Any error encountered during fetch
14
- * - isLoading: Boolean indicating if the request is in progress
15
- * - isSuccess, isError, refetch, etc.
16
- *
17
- * An error will be thrown only if the endpoint is not reachable or has an unhandled error.
18
- *
19
- * @example
20
- * ```tsx
21
- * import { useGetWaasStatus } from '@0xsequence/hooks'
22
- *
23
- * const MyComponent = () => {
24
- * const { data, isLoading, error } = useGetWaasStatus()
25
- *
26
- * if (isLoading) return <div>Loading...</div>
27
- * if (error) return <div>Error: {error.message}</div>
28
- * if (!data) return <div>No status available</div>
29
- *
30
- * return <div>Status: {data.successResponse?.healthOK ? 'OK' : data.errorResponse?.msg}</div>
31
- * }
32
- * ```
33
- */
34
- const useGetWaasStatus = () => {
35
- return (0, react_query_1.useQuery)({
36
- queryKey: ['waasStatus'],
37
- queryFn: async () => {
38
- const res = await fetch(constants_js_1.WAAS_STATUS_URL);
39
- const data = await res.json();
40
- return {
41
- successResponse: data.healthOK ? data : undefined,
42
- errorResponse: data.error ? data : undefined
43
- };
44
- },
45
- retry: false
46
- });
47
- };
48
- exports.useGetWaasStatus = useGetWaasStatus;
49
- //# sourceMappingURL=useGetWaasStatus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGetWaasStatus.js","sourceRoot":"","sources":["../../../../src/hooks/API/useGetWaasStatus.ts"],"names":[],"mappings":";;;AAAA,uDAAqE;AAErE,qDAAoD;AAsBpD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACI,MAAM,gBAAgB,GAAG,GAA8C,EAAE;IAC9E,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,YAAY,CAAC;QACxB,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,8BAAe,CAAC,CAAA;YACxC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;YAC7B,OAAO;gBACL,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAE,IAAkC,CAAC,CAAC,CAAC,SAAS;gBAChF,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAE,IAAgC,CAAC,CAAC,CAAC,SAAS;aAC1E,CAAA;QACH,CAAC;QACD,KAAK,EAAE,KAAK;KACb,CAAC,CAAA;AACJ,CAAC,CAAA;AAbY,QAAA,gBAAgB,oBAa5B"}
@@ -1,30 +0,0 @@
1
- import type { HooksOptions } from '../../types/hooks.js';
2
- /**
3
- * Hook to fetch the version of a contract.
4
- *
5
- * This hook uses React Query to fetch and cache the version of a contract.
6
- *
7
- *
8
- * @param args - The arguments for the hook:
9
- * - address: The address of the contract
10
- * - chainId: The chain id of the contract
11
- *
12
- * @param options - Optional configuration options:
13
- * - retry: Whether to retry failed requests (defaults to false)
14
- * - disabled: Whether to disable the query
15
- *
16
- * @returns React Query result object containing:
17
- * - data: The version of the contract
18
- * - isLoading: Whether the initial request is in progress
19
- * - error: Any error that occurred
20
- * - isError: Whether an error occurred
21
- * - isSuccess: Whether the request was successful
22
- *
23
- */
24
- interface DetectContractVersionArgs {
25
- contractAddress: string;
26
- chainId: number;
27
- }
28
- export declare const useDetectContractVersion: (args: DetectContractVersionArgs, options?: HooksOptions) => import("@tanstack/react-query").UseQueryResult<any, Error>;
29
- export {};
30
- //# sourceMappingURL=useDetectContractVersion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDetectContractVersion.d.ts","sourceRoot":"","sources":["../../../../src/hooks/Builder/useDetectContractVersion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAGxD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,UAAU,yBAAyB;IACjC,eAAe,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,eAAO,MAAM,wBAAwB,GAAI,MAAM,yBAAyB,EAAE,UAAU,YAAY,+DAkB/F,CAAA"}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useDetectContractVersion = void 0;
4
- const react_query_1 = require("@tanstack/react-query");
5
- const constants_js_1 = require("../../constants.js");
6
- const useConfig_js_1 = require("../useConfig.js");
7
- const useDetectContractVersion = (args, options) => {
8
- const { projectAccessKey, env } = (0, useConfig_js_1.useConfig)();
9
- return (0, react_query_1.useQuery)({
10
- queryKey: [constants_js_1.QUERY_KEYS.useDetectContractVersion, args.contractAddress, args.chainId, options],
11
- queryFn: async () => {
12
- const res = await fetch(`${env.builderUrl}/rpc/ContractLibrary/DetectContractVersion`, {
13
- method: 'POST',
14
- headers: { 'Content-Type': 'application/json', 'X-Access-Key': projectAccessKey },
15
- body: JSON.stringify({ address: args.contractAddress, chainId: args.chainId })
16
- });
17
- const data = await res.json();
18
- return data;
19
- },
20
- retry: options?.retry ?? false,
21
- staleTime: constants_js_1.time.oneMinute * 60,
22
- enabled: !!args.contractAddress && !!args.chainId && !options?.disabled
23
- });
24
- };
25
- exports.useDetectContractVersion = useDetectContractVersion;
26
- //# sourceMappingURL=useDetectContractVersion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDetectContractVersion.js","sourceRoot":"","sources":["../../../../src/hooks/Builder/useDetectContractVersion.ts"],"names":[],"mappings":";;;AAAA,uDAAgD;AAEhD,qDAAqD;AAErD,kDAA2C;AA8BpC,MAAM,wBAAwB,GAAG,CAAC,IAA+B,EAAE,OAAsB,EAAE,EAAE;IAClG,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG,IAAA,wBAAS,GAAE,CAAA;IAE7C,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,yBAAU,CAAC,wBAAwB,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC;QAC5F,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,GAAG,CAAC,UAAU,4CAA4C,EAAE;gBACrF,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,gBAAgB,EAAE;gBACjF,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;aAC/E,CAAC,CAAA;YACF,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;YAC7B,OAAO,IAAI,CAAA;QACb,CAAC;QACD,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,KAAK;QAC9B,SAAS,EAAE,mBAAI,CAAC,SAAS,GAAG,EAAE;QAC9B,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,QAAQ;KACxE,CAAC,CAAA;AACJ,CAAC,CAAA;AAlBY,QAAA,wBAAwB,4BAkBpC"}
@@ -1,97 +0,0 @@
1
- import type { GetLifiSwapQuoteRequest } from '@0xsequence/api';
2
- import type { HooksOptions } from '../../types/hooks.js';
3
- /**
4
- * Hook to fetch a swap quote for exchanging between two currencies.
5
- *
6
- * This hook provides functionality to:
7
- * - Get a quote for swapping between two currencies (native or ERC20)
8
- * - Fetch necessary approval data for ERC20 tokens
9
- * - Generate transaction data for executing the swap
10
- *
11
- * The hook automatically handles:
12
- * - Native token address normalization (between 0x0 and 0xEEE...)
13
- * - Approval data generation for ERC20 tokens when needed
14
- * - Transaction data generation for the swap
15
- * - Error handling for failed API calls
16
- *
17
- * Go to {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useGetSwapQuote} for more detailed documentation.
18
- *
19
- * @param getSwapQuoteArgs - Configuration object for the swap quote query:
20
- * - params: The parameters for the swap quote query
21
- * - walletAddress: The address of the user's wallet
22
- * - fromTokenAddress: The address of the currency to sell
23
- * - toTokenAddress: The address of the currency to buy
24
- * - fromTokenAmount?: The amount of currency to sell (optional)
25
- * - toTokenAmount?: The amount of currency to buy (optional)
26
- * - includeApprove: Whether to include approval data for ERC20 tokens
27
- * - slippageBps: The slippage percentage for the swap
28
- *
29
- * @param options - Optional configuration for the hook behavior:
30
- * - disabled: Whether to disable the query
31
- * - retry: Whether to retry failed queries
32
- * - Other standard React Query options
33
- *
34
- * @returns A React Query result object containing:
35
- * - data: The swap quote data including:
36
- * - quote: The swap quote data including:
37
- * - currencyAddress: The address of the currency being swapped
38
- * - currencyBalance: The user's balance of the currency
39
- * - price: The price for the swap
40
- * - maxPrice: The maximum price (including slippage)
41
- * - to: The target contract address for the swap
42
- * - transactionData: The calldata for the swap transaction
43
- * - transactionValue: The value to send with the transaction (for native tokens)
44
- * - approveData: The approval transaction data (if needed)
45
- * - amount: The amount of currency to buy
46
- * - amountMin: The minimum amount of currency to buy
47
- * - isLoading: Whether the query is in progress
48
- * - isError: Whether an error occurred
49
- * - error: Any error that occurred
50
- * - Other standard React Query properties
51
- *
52
- * @see {@link https://docs.sequence.xyz/sdk/web/hooks/useGetSwapQuote} for more detailed documentation.
53
- *
54
- * @example
55
- * ```tsx
56
- * import { useGetSwapQuote } from '@0xsequence/hooks'
57
- *
58
- * function SwapComponent() {
59
- * const { data: swapQuote, isLoading } = useGetSwapQuote({
60
- * params: {
61
- * walletAddress: '0x123...',
62
- * fromTokenAddress: '0x456...',
63
- * toTokenAddress: '0x789...',
64
- * fromTokenAmount: '1000000000000000000', // 1 token in base units
65
- * includeApprove: true,
66
- * slippageBps: 150,
67
- * chainId: 1
68
- * }
69
- * })
70
- *
71
- * if (isLoading) return <div>Loading...</div>
72
- *
73
- * return (
74
- * <div>
75
- * <div>Price: {swapQuote?.price}</div>
76
- * <div>Max Price: {swapQuote?.maxPrice}</div>
77
- * <button onClick={() => executeSwap(swapQuote)}>
78
- * Swap Tokens
79
- * </button>
80
- * </div>
81
- * )
82
- * }
83
- * ```
84
- */
85
- export declare const useGetSwapQuote: (getSwapQuoteArgs: GetLifiSwapQuoteRequest, options?: HooksOptions) => import("@tanstack/react-query").UseQueryResult<{
86
- currencyAddress: string;
87
- currencyBalance: string;
88
- price: string;
89
- maxPrice: string;
90
- to: string;
91
- transactionData: string;
92
- transactionValue: string;
93
- approveData: string;
94
- amount: string;
95
- amountMin: string;
96
- }, Error>;
97
- //# sourceMappingURL=useGetSwapQuote.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGetSwapQuote.d.ts","sourceRoot":"","sources":["../../../../src/hooks/Combination/useGetSwapQuote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAI9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAIxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFG;AACH,eAAO,MAAM,eAAe,GAAI,kBAAkB,uBAAuB,EAAE,UAAU,YAAY;;;;;;;;;;;SAkChG,CAAA"}
@@ -1,123 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useGetSwapQuote = void 0;
4
- const react_query_1 = require("@tanstack/react-query");
5
- const constants_js_1 = require("../../constants.js");
6
- const helpers_js_1 = require("../../utils/helpers.js");
7
- const useAPIClient_js_1 = require("../API/useAPIClient.js");
8
- /**
9
- * Hook to fetch a swap quote for exchanging between two currencies.
10
- *
11
- * This hook provides functionality to:
12
- * - Get a quote for swapping between two currencies (native or ERC20)
13
- * - Fetch necessary approval data for ERC20 tokens
14
- * - Generate transaction data for executing the swap
15
- *
16
- * The hook automatically handles:
17
- * - Native token address normalization (between 0x0 and 0xEEE...)
18
- * - Approval data generation for ERC20 tokens when needed
19
- * - Transaction data generation for the swap
20
- * - Error handling for failed API calls
21
- *
22
- * Go to {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useGetSwapQuote} for more detailed documentation.
23
- *
24
- * @param getSwapQuoteArgs - Configuration object for the swap quote query:
25
- * - params: The parameters for the swap quote query
26
- * - walletAddress: The address of the user's wallet
27
- * - fromTokenAddress: The address of the currency to sell
28
- * - toTokenAddress: The address of the currency to buy
29
- * - fromTokenAmount?: The amount of currency to sell (optional)
30
- * - toTokenAmount?: The amount of currency to buy (optional)
31
- * - includeApprove: Whether to include approval data for ERC20 tokens
32
- * - slippageBps: The slippage percentage for the swap
33
- *
34
- * @param options - Optional configuration for the hook behavior:
35
- * - disabled: Whether to disable the query
36
- * - retry: Whether to retry failed queries
37
- * - Other standard React Query options
38
- *
39
- * @returns A React Query result object containing:
40
- * - data: The swap quote data including:
41
- * - quote: The swap quote data including:
42
- * - currencyAddress: The address of the currency being swapped
43
- * - currencyBalance: The user's balance of the currency
44
- * - price: The price for the swap
45
- * - maxPrice: The maximum price (including slippage)
46
- * - to: The target contract address for the swap
47
- * - transactionData: The calldata for the swap transaction
48
- * - transactionValue: The value to send with the transaction (for native tokens)
49
- * - approveData: The approval transaction data (if needed)
50
- * - amount: The amount of currency to buy
51
- * - amountMin: The minimum amount of currency to buy
52
- * - isLoading: Whether the query is in progress
53
- * - isError: Whether an error occurred
54
- * - error: Any error that occurred
55
- * - Other standard React Query properties
56
- *
57
- * @see {@link https://docs.sequence.xyz/sdk/web/hooks/useGetSwapQuote} for more detailed documentation.
58
- *
59
- * @example
60
- * ```tsx
61
- * import { useGetSwapQuote } from '@0xsequence/hooks'
62
- *
63
- * function SwapComponent() {
64
- * const { data: swapQuote, isLoading } = useGetSwapQuote({
65
- * params: {
66
- * walletAddress: '0x123...',
67
- * fromTokenAddress: '0x456...',
68
- * toTokenAddress: '0x789...',
69
- * fromTokenAmount: '1000000000000000000', // 1 token in base units
70
- * includeApprove: true,
71
- * slippageBps: 150,
72
- * chainId: 1
73
- * }
74
- * })
75
- *
76
- * if (isLoading) return <div>Loading...</div>
77
- *
78
- * return (
79
- * <div>
80
- * <div>Price: {swapQuote?.price}</div>
81
- * <div>Max Price: {swapQuote?.maxPrice}</div>
82
- * <button onClick={() => executeSwap(swapQuote)}>
83
- * Swap Tokens
84
- * </button>
85
- * </div>
86
- * )
87
- * }
88
- * ```
89
- */
90
- const useGetSwapQuote = (getSwapQuoteArgs, options) => {
91
- const apiClient = (0, useAPIClient_js_1.useAPIClient)();
92
- return (0, react_query_1.useQuery)({
93
- queryKey: [constants_js_1.QUERY_KEYS.useGetSwapQuote, getSwapQuoteArgs, options],
94
- queryFn: async () => {
95
- const res = await apiClient.getLifiSwapQuote({
96
- params: {
97
- ...getSwapQuoteArgs.params,
98
- toTokenAddress: (0, helpers_js_1.compareAddress)(getSwapQuoteArgs.params.toTokenAddress, constants_js_1.ZERO_ADDRESS)
99
- ? constants_js_1.ZERO_ADDRESS
100
- : getSwapQuoteArgs.params.toTokenAddress,
101
- fromTokenAddress: (0, helpers_js_1.compareAddress)(getSwapQuoteArgs.params.fromTokenAddress, constants_js_1.ZERO_ADDRESS)
102
- ? constants_js_1.ZERO_ADDRESS
103
- : getSwapQuoteArgs.params.fromTokenAddress
104
- }
105
- });
106
- return {
107
- ...res.quote,
108
- currencyAddress: (0, helpers_js_1.compareAddress)(res.quote.currencyAddress, constants_js_1.ZERO_ADDRESS) ? constants_js_1.ZERO_ADDRESS : res.quote.currencyAddress
109
- };
110
- },
111
- retry: options?.retry ?? false,
112
- staleTime: constants_js_1.time.oneMinute * 1,
113
- enabled: !options?.disabled &&
114
- !!getSwapQuoteArgs.params.walletAddress &&
115
- !!getSwapQuoteArgs.params.fromTokenAddress &&
116
- !!getSwapQuoteArgs.params.toTokenAddress &&
117
- getSwapQuoteArgs.params.fromTokenAmount !== '0' &&
118
- !!getSwapQuoteArgs.params.chainId &&
119
- !!getSwapQuoteArgs.params.includeApprove
120
- });
121
- };
122
- exports.useGetSwapQuote = useGetSwapQuote;
123
- //# sourceMappingURL=useGetSwapQuote.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGetSwapQuote.js","sourceRoot":"","sources":["../../../../src/hooks/Combination/useGetSwapQuote.ts"],"names":[],"mappings":";;;AACA,uDAAgD;AAEhD,qDAAmE;AAEnE,uDAAuD;AACvD,4DAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFG;AACI,MAAM,eAAe,GAAG,CAAC,gBAAyC,EAAE,OAAsB,EAAE,EAAE;IACnG,MAAM,SAAS,GAAG,IAAA,8BAAY,GAAE,CAAA;IAEhC,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,yBAAU,CAAC,eAAe,EAAE,gBAAgB,EAAE,OAAO,CAAC;QACjE,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,gBAAgB,CAAC;gBAC3C,MAAM,EAAE;oBACN,GAAG,gBAAgB,CAAC,MAAM;oBAC1B,cAAc,EAAE,IAAA,2BAAc,EAAC,gBAAgB,CAAC,MAAM,CAAC,cAAc,EAAE,2BAAY,CAAC;wBAClF,CAAC,CAAC,2BAAY;wBACd,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,cAAc;oBAC1C,gBAAgB,EAAE,IAAA,2BAAc,EAAC,gBAAgB,CAAC,MAAM,CAAC,gBAAgB,EAAE,2BAAY,CAAC;wBACtF,CAAC,CAAC,2BAAY;wBACd,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,gBAAgB;iBAC7C;aACF,CAAC,CAAA;YAEF,OAAO;gBACL,GAAG,GAAG,CAAC,KAAK;gBACZ,eAAe,EAAE,IAAA,2BAAc,EAAC,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,2BAAY,CAAC,CAAC,CAAC,CAAC,2BAAY,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe;aACpH,CAAA;QACH,CAAC;QACD,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,KAAK;QAC9B,SAAS,EAAE,mBAAI,CAAC,SAAS,GAAG,CAAC;QAC7B,OAAO,EACL,CAAC,OAAO,EAAE,QAAQ;YAClB,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,aAAa;YACvC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,gBAAgB;YAC1C,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,cAAc;YACxC,gBAAgB,CAAC,MAAM,CAAC,eAAe,KAAK,GAAG;YAC/C,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO;YACjC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,cAAc;KAC3C,CAAC,CAAA;AACJ,CAAC,CAAA;AAlCY,QAAA,eAAe,mBAkC3B"}
@@ -1,61 +0,0 @@
1
- import { type LifiSwapRoute } from '@0xsequence/api';
2
- import type { HooksOptions } from '../../types/hooks.js';
3
- /**
4
- * Arguments for the useGetSwapRoutes hook
5
- *
6
- * @property walletAddress - The address of the user's wallet
7
- * @property toTokenAddress - The address of the currency to buy
8
- * @property chainId - The chain ID where the swap will occur
9
- * @property toTokenAmount - The amount of the currency to buy
10
- */
11
- export interface UseGetSwapRoutesArgs {
12
- walletAddress: string;
13
- toTokenAddress: string;
14
- chainId: number;
15
- toTokenAmount: string;
16
- }
17
- /**
18
- * Hook to fetch available swap routes for a given token.
19
- *
20
- * This hook uses React Query to fetch and cache swap routes from the Sequence API.
21
- * Stale time is set to one hour by default
22
- *
23
- * @see {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useGetSwapRoutes} for more detailed documentation.
24
- *
25
- * @param args - Arguments for fetching swap routes:
26
- * - walletAddress: The address of the user's wallet
27
- * - toTokenAddress: The address of the token to buy
28
- * - chainId: The chain ID where the swap will occur
29
- * - toTokenAmount: The amount of the token to buy
30
- *
31
- * @param options - Optional configuration options:
32
- * - retry: Whether to retry failed requests (defaults to false)
33
- * - disabled: Whether to disable the query
34
- *
35
- * @returns React Query result object containing:
36
- * - data: Array of available swap routes when available
37
- * - isLoading: Whether the initial request is in progress
38
- * - error: Any error that occurred
39
- * - isError: Whether an error occurred
40
- * - isSuccess: Whether the request was successful
41
- *
42
- * @example
43
- * ```tsx
44
- * const { data: routes, isLoading, error } = useGetSwapRoutes({
45
- * walletAddress: '0x123...',
46
- * toTokenAddress: '0x456...',
47
- * chainId: 1,
48
- * toTokenAmount: '1000000000000000000' // 1 ETH in wei
49
- * })
50
- *
51
- * if (isLoading) {
52
- * return <div>Loading swap routes...</div>
53
- * }
54
- *
55
- * if (routes?.length) {
56
- * console.log('Best route:', routes[0])
57
- * }
58
- * ```
59
- */
60
- export declare const useGetSwapRoutes: (args: UseGetSwapRoutesArgs, options?: HooksOptions) => import("@tanstack/react-query").UseQueryResult<LifiSwapRoute[], Error>;
61
- //# sourceMappingURL=useGetSwapRoutes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGetSwapRoutes.d.ts","sourceRoot":"","sources":["../../../../src/hooks/Combination/useGetSwapRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgD,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAIlG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAGxD;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;CACtB;AA+BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,oBAAoB,EAAE,UAAU,YAAY,2EAclF,CAAA"}
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useGetSwapRoutes = void 0;
4
- const api_1 = require("@0xsequence/api");
5
- const react_query_1 = require("@tanstack/react-query");
6
- const constants_js_1 = require("../../constants.js");
7
- const useAPIClient_js_1 = require("../API/useAPIClient.js");
8
- const getSwapRoutes = async (apiClient, args) => {
9
- if (!args.chainId || !args.toTokenAddress) {
10
- return [];
11
- }
12
- const res = await apiClient.getLifiSwapRoutes({
13
- params: {
14
- direction: api_1.GetLifiSwapRouteDirection.to,
15
- chainId: args.chainId,
16
- walletAddress: args.walletAddress,
17
- tokenAddress: args.toTokenAddress,
18
- tokenAmount: args.toTokenAmount
19
- }
20
- });
21
- if (res.routes.length === 0) {
22
- return [];
23
- }
24
- return res.routes;
25
- };
26
- /**
27
- * Hook to fetch available swap routes for a given token.
28
- *
29
- * This hook uses React Query to fetch and cache swap routes from the Sequence API.
30
- * Stale time is set to one hour by default
31
- *
32
- * @see {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useGetSwapRoutes} for more detailed documentation.
33
- *
34
- * @param args - Arguments for fetching swap routes:
35
- * - walletAddress: The address of the user's wallet
36
- * - toTokenAddress: The address of the token to buy
37
- * - chainId: The chain ID where the swap will occur
38
- * - toTokenAmount: The amount of the token to buy
39
- *
40
- * @param options - Optional configuration options:
41
- * - retry: Whether to retry failed requests (defaults to false)
42
- * - disabled: Whether to disable the query
43
- *
44
- * @returns React Query result object containing:
45
- * - data: Array of available swap routes when available
46
- * - isLoading: Whether the initial request is in progress
47
- * - error: Any error that occurred
48
- * - isError: Whether an error occurred
49
- * - isSuccess: Whether the request was successful
50
- *
51
- * @example
52
- * ```tsx
53
- * const { data: routes, isLoading, error } = useGetSwapRoutes({
54
- * walletAddress: '0x123...',
55
- * toTokenAddress: '0x456...',
56
- * chainId: 1,
57
- * toTokenAmount: '1000000000000000000' // 1 ETH in wei
58
- * })
59
- *
60
- * if (isLoading) {
61
- * return <div>Loading swap routes...</div>
62
- * }
63
- *
64
- * if (routes?.length) {
65
- * console.log('Best route:', routes[0])
66
- * }
67
- * ```
68
- */
69
- const useGetSwapRoutes = (args, options) => {
70
- const apiClient = (0, useAPIClient_js_1.useAPIClient)();
71
- const enabled = !!args.chainId && !!args.toTokenAddress && !options?.disabled;
72
- return (0, react_query_1.useQuery)({
73
- queryKey: [constants_js_1.QUERY_KEYS.useGetSwapRoutes, args, options],
74
- queryFn: () => getSwapRoutes(apiClient, args),
75
- retry: options?.retry ?? false,
76
- // We must keep a long staletime to avoid the list of quotes being refreshed while the user is doing the transactions
77
- // Instead, we will invalidate the query manually
78
- staleTime: constants_js_1.time.oneHour,
79
- enabled
80
- });
81
- };
82
- exports.useGetSwapRoutes = useGetSwapRoutes;
83
- //# sourceMappingURL=useGetSwapRoutes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGetSwapRoutes.js","sourceRoot":"","sources":["../../../../src/hooks/Combination/useGetSwapRoutes.ts"],"names":[],"mappings":";;;AAAA,yCAAkG;AAClG,uDAAgD;AAEhD,qDAAqD;AAErD,4DAAqD;AAwBrD,MAAM,aAAa,GAAG,KAAK,EAAE,SAA4B,EAAE,IAAuB,EAA4B,EAAE;IAC9G,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;QAC1C,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,iBAAiB,CAAC;QAC5C,MAAM,EAAE;YACN,SAAS,EAAE,+BAAyB,CAAC,EAAE;YACvC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,YAAY,EAAE,IAAI,CAAC,cAAc;YACjC,WAAW,EAAE,IAAI,CAAC,aAAa;SAChC;KACF,CAAC,CAAA;IAEF,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAA;IACX,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,CAAA;AACnB,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAA0B,EAAE,OAAsB,EAAE,EAAE;IACrF,MAAM,SAAS,GAAG,IAAA,8BAAY,GAAE,CAAA;IAEhC,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAA;IAE7E,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,yBAAU,CAAC,gBAAgB,EAAE,IAAI,EAAE,OAAO,CAAC;QACtD,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC;QAC7C,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,KAAK;QAC9B,qHAAqH;QACrH,iDAAiD;QACjD,SAAS,EAAE,mBAAI,CAAC,OAAO;QACvB,OAAO;KACR,CAAC,CAAA;AACJ,CAAC,CAAA;AAdY,QAAA,gBAAgB,oBAc5B"}