@0xsequence/hooks 5.2.1 → 5.2.3

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 (58) hide show
  1. package/README.md +0 -15
  2. package/dist/cjs/constants.d.ts +1 -1
  3. package/dist/cjs/constants.js +2 -2
  4. package/dist/cjs/constants.js.map +1 -1
  5. package/dist/cjs/hooks/Combination/useGetSwapQuote.d.ts +32 -22
  6. package/dist/cjs/hooks/Combination/useGetSwapQuote.d.ts.map +1 -1
  7. package/dist/cjs/hooks/Combination/useGetSwapQuote.js +46 -38
  8. package/dist/cjs/hooks/Combination/useGetSwapQuote.js.map +1 -1
  9. package/dist/cjs/hooks/Combination/useGetSwapRoutes.d.ts +61 -0
  10. package/dist/cjs/hooks/Combination/useGetSwapRoutes.d.ts.map +1 -0
  11. package/dist/cjs/hooks/Combination/useGetSwapRoutes.js +79 -0
  12. package/dist/cjs/hooks/Combination/useGetSwapRoutes.js.map +1 -0
  13. package/dist/cjs/index.d.ts +1 -1
  14. package/dist/cjs/index.d.ts.map +1 -1
  15. package/dist/cjs/index.js +3 -4
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/tests/Combination/useGetSwapQuote.test.js +32 -13
  18. package/dist/cjs/tests/Combination/useGetSwapQuote.test.js.map +1 -1
  19. package/dist/cjs/tests/handlers.d.ts.map +1 -1
  20. package/dist/cjs/tests/handlers.js +9 -45
  21. package/dist/cjs/tests/handlers.js.map +1 -1
  22. package/dist/esm/constants.d.ts +1 -1
  23. package/dist/esm/constants.js +2 -2
  24. package/dist/esm/constants.js.map +1 -1
  25. package/dist/esm/hooks/Combination/useGetSwapQuote.d.ts +32 -22
  26. package/dist/esm/hooks/Combination/useGetSwapQuote.d.ts.map +1 -1
  27. package/dist/esm/hooks/Combination/useGetSwapQuote.js +46 -38
  28. package/dist/esm/hooks/Combination/useGetSwapQuote.js.map +1 -1
  29. package/dist/esm/hooks/Combination/useGetSwapRoutes.d.ts +61 -0
  30. package/dist/esm/hooks/Combination/useGetSwapRoutes.d.ts.map +1 -0
  31. package/dist/esm/hooks/Combination/useGetSwapRoutes.js +75 -0
  32. package/dist/esm/hooks/Combination/useGetSwapRoutes.js.map +1 -0
  33. package/dist/esm/index.d.ts +1 -1
  34. package/dist/esm/index.d.ts.map +1 -1
  35. package/dist/esm/index.js +1 -2
  36. package/dist/esm/index.js.map +1 -1
  37. package/dist/esm/tests/Combination/useGetSwapQuote.test.js +32 -13
  38. package/dist/esm/tests/Combination/useGetSwapQuote.test.js.map +1 -1
  39. package/dist/esm/tests/handlers.d.ts.map +1 -1
  40. package/dist/esm/tests/handlers.js +9 -45
  41. package/dist/esm/tests/handlers.js.map +1 -1
  42. package/package.json +17 -17
  43. package/dist/cjs/hooks/Combination/useGetSwapPrices.d.ts +0 -92
  44. package/dist/cjs/hooks/Combination/useGetSwapPrices.d.ts.map +0 -1
  45. package/dist/cjs/hooks/Combination/useGetSwapPrices.js +0 -177
  46. package/dist/cjs/hooks/Combination/useGetSwapPrices.js.map +0 -1
  47. package/dist/cjs/tests/Combination/useGetSwapPrices.test.d.ts +0 -2
  48. package/dist/cjs/tests/Combination/useGetSwapPrices.test.d.ts.map +0 -1
  49. package/dist/cjs/tests/Combination/useGetSwapPrices.test.js +0 -37
  50. package/dist/cjs/tests/Combination/useGetSwapPrices.test.js.map +0 -1
  51. package/dist/esm/hooks/Combination/useGetSwapPrices.d.ts +0 -92
  52. package/dist/esm/hooks/Combination/useGetSwapPrices.d.ts.map +0 -1
  53. package/dist/esm/hooks/Combination/useGetSwapPrices.js +0 -173
  54. package/dist/esm/hooks/Combination/useGetSwapPrices.js.map +0 -1
  55. package/dist/esm/tests/Combination/useGetSwapPrices.test.d.ts +0 -2
  56. package/dist/esm/tests/Combination/useGetSwapPrices.test.d.ts.map +0 -1
  57. package/dist/esm/tests/Combination/useGetSwapPrices.test.js +0 -35
  58. package/dist/esm/tests/Combination/useGetSwapPrices.test.js.map +0 -1
@@ -1,173 +0,0 @@
1
- import { findSupportedNetwork } from '@0xsequence/network';
2
- import { useQuery } from '@tanstack/react-query';
3
- import { NATIVE_TOKEN_ADDRESS_0X_SWAP, QUERY_KEYS, time, ZERO_ADDRESS } from '../../constants';
4
- import { compareAddress } from '../../utils/helpers';
5
- import { useAPIClient } from '../API/useAPIClient';
6
- import { useIndexerGatewayClient } from '../IndexerGateway/useIndexerGatewayClient';
7
- import { useMetadataClient } from '../Metadata/useMetadataClient';
8
- const getSwapPrices = async (apiClient, metadataClient, indexerGatewayClient, args) => {
9
- if (!args.chainId || !args.userAddress || !args.buyCurrencyAddress || !args.buyAmount || args.buyAmount === '0') {
10
- return [];
11
- }
12
- const network = findSupportedNetwork(args.chainId);
13
- const { withContractInfo, ...swapPricesArgs } = args;
14
- const isNativeTokenInArgs = compareAddress(args.buyCurrencyAddress, NATIVE_TOKEN_ADDRESS_0X_SWAP) || compareAddress(args.buyCurrencyAddress, ZERO_ADDRESS);
15
- const res = await apiClient.getSwapPermit2Prices({
16
- ...swapPricesArgs,
17
- buyCurrencyAddress: isNativeTokenInArgs ? NATIVE_TOKEN_ADDRESS_0X_SWAP : args.buyCurrencyAddress
18
- });
19
- if (res.swapPermit2Prices === null) {
20
- return [];
21
- }
22
- const currencyInfoMap = new Map();
23
- if (withContractInfo) {
24
- res?.swapPermit2Prices.forEach(price => {
25
- const { currencyAddress } = price;
26
- const isNativeToken = compareAddress(currencyAddress, NATIVE_TOKEN_ADDRESS_0X_SWAP || ZERO_ADDRESS);
27
- if (currencyAddress && !currencyInfoMap.has(currencyAddress)) {
28
- const getNativeTokenInfo = () => new Promise(resolve => {
29
- resolve({
30
- ...network?.nativeToken,
31
- logoURI: network?.logoURI || '',
32
- address: NATIVE_TOKEN_ADDRESS_0X_SWAP
33
- });
34
- });
35
- currencyInfoMap.set(currencyAddress, isNativeToken
36
- ? getNativeTokenInfo()
37
- : metadataClient
38
- .getContractInfo({
39
- chainID: String(args.chainId),
40
- contractAddress: currencyAddress
41
- })
42
- .then(data => ({ ...data.contractInfo }))
43
- .catch(error => {
44
- console.error(`Failed to fetch contract info for ${currencyAddress}:`, error);
45
- return undefined;
46
- }));
47
- }
48
- });
49
- }
50
- const currencyBalanceInfoMap = new Map();
51
- res?.swapPermit2Prices.forEach(price => {
52
- const { currencyAddress } = price;
53
- const isNativeToken = compareAddress(currencyAddress, NATIVE_TOKEN_ADDRESS_0X_SWAP || ZERO_ADDRESS);
54
- if (currencyAddress && !currencyBalanceInfoMap.has(currencyAddress)) {
55
- const tokenBalance = indexerGatewayClient
56
- .getTokenBalancesSummary({
57
- chainIds: [args.chainId],
58
- filter: {
59
- accountAddresses: [args.userAddress],
60
- contractWhitelist: [currencyAddress],
61
- omitNativeBalances: false
62
- }
63
- })
64
- .then(res => {
65
- if (isNativeToken) {
66
- return {
67
- balance: res.nativeBalances[0].results[0].balance
68
- };
69
- }
70
- else {
71
- return {
72
- balance: res.balances[0].results[0].balance
73
- };
74
- }
75
- })
76
- .catch(error => {
77
- console.error(`Failed to fetch balance for ${currencyAddress}:`, error);
78
- return { balance: '0' };
79
- });
80
- currencyBalanceInfoMap.set(currencyAddress, tokenBalance);
81
- }
82
- });
83
- return Promise.all(res?.swapPermit2Prices.map(async (price) => {
84
- const { currencyAddress: rawCurrencyAddress } = price;
85
- const currencyAddress = compareAddress(rawCurrencyAddress, NATIVE_TOKEN_ADDRESS_0X_SWAP)
86
- ? NATIVE_TOKEN_ADDRESS_0X_SWAP
87
- : rawCurrencyAddress;
88
- return {
89
- price: {
90
- ...price,
91
- currencyAddress
92
- },
93
- info: await currencyInfoMap.get(currencyAddress),
94
- balance: (await currencyBalanceInfoMap.get(currencyAddress)) || { balance: '0' }
95
- };
96
- }) || []);
97
- };
98
- /**
99
- * Hook to fetch available swap prices for a given currency pair.
100
- *
101
- * This hook provides functionality to:
102
- * - Get swap prices for a specified currency and amount
103
- * - Fetch token information and balances for available swap options
104
- * - Support both native tokens and ERC20 tokens
105
- * - Handle currency conversions and price formatting
106
- *
107
- * The hook automatically handles:
108
- * - Native token address normalization (between 0x0 and 0xEEE...)
109
- * - Contract information fetching (name, symbol, decimals, etc.)
110
- * - Error handling for failed API calls or balance fetches
111
- *
112
- * @see {@link https://docs.sequence.xyz/sdk/web/hooks/useGetSwapPrices} for more detailed documentation.
113
- *
114
- * @param args - Configuration object for the swap prices query {@link UseGetSwapPricesArgs}
115
- * @param options - Optional configuration for the hook behavior {@link HooksOptions}
116
- *
117
- * @returns A React Query result object containing:
118
- * - data: Array of {@link SwapPricesWithCurrencyInfo} objects
119
- * - isLoading: Whether the query is in progress
120
- * - isError: Whether an error occurred
121
- * - error: Any error that occurred
122
- * - Other standard React Query properties
123
- *
124
- * @example
125
- * ```tsx
126
- * import { useGetSwapPrices } from '@0xsequence/hooks'
127
- *
128
- * function SwapComponent() {
129
- * const { data: swapPrices, isLoading } = useGetSwapPrices({
130
- * userAddress: '0x123...',
131
- * buyCurrencyAddress: '0x456...',
132
- * buyAmount: '1000000000000000000', // 1 token in base units
133
- * chainId: 1,
134
- * withContractInfo: true
135
- * })
136
- *
137
- * if (isLoading) return <div>Loading...</div>
138
- *
139
- * return (
140
- * <div>
141
- * {swapPrices?.map(swap => (
142
- * <div key={swap.info?.address}>
143
- * Token: {swap.info?.symbol}
144
- * Price: {swap.price.price}
145
- * Balance: {swap.balance.balance}
146
- * </div>
147
- * ))}
148
- * </div>
149
- * )
150
- * }
151
- * ```
152
- */
153
- export const useGetSwapPrices = (args, options) => {
154
- const apiClient = useAPIClient();
155
- const metadataClient = useMetadataClient();
156
- const indexerGatewayClient = useIndexerGatewayClient();
157
- const enabled = !!args.chainId &&
158
- !!args.userAddress &&
159
- !!args.buyCurrencyAddress &&
160
- !!args.buyAmount &&
161
- args.buyAmount !== '0' &&
162
- !options?.disabled;
163
- return useQuery({
164
- queryKey: [QUERY_KEYS.useGetSwapPrices, args, options],
165
- queryFn: () => getSwapPrices(apiClient, metadataClient, indexerGatewayClient, args),
166
- retry: options?.retry ?? true,
167
- // We must keep a long staletime to avoid the list of quotes being refreshed while the user is doing the transactions
168
- // Instead, we will invalidate the query manually
169
- staleTime: time.oneHour,
170
- enabled
171
- });
172
- };
173
- //# sourceMappingURL=useGetSwapPrices.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGetSwapPrices.js","sourceRoot":"","sources":["../../../../src/hooks/Combination/useGetSwapPrices.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,4BAA4B,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9F,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAA;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAoCjE,MAAM,aAAa,GAAG,KAAK,EACzB,SAA4B,EAC5B,cAAgC,EAChC,oBAA4C,EAC5C,IAA0B,EACa,EAAE;IACzC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,KAAK,GAAG,EAAE,CAAC;QAChH,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,OAAO,GAAG,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAElD,MAAM,EAAE,gBAAgB,EAAE,GAAG,cAAc,EAAE,GAAG,IAAI,CAAA;IAEpD,MAAM,mBAAmB,GACvB,cAAc,CAAC,IAAI,CAAC,kBAAkB,EAAE,4BAA4B,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,kBAAkB,EAAE,YAAY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AI,CAAC,SAAS;QAChB,IAAI,CAAC,SAAS,KAAK,GAAG;QACtB,CAAC,OAAO,EAAE,QAAQ,CAAA;IAEpB,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,CAAC,UAAU,CAAC,gBAAgB,EAAE,IAAI,EAAE,OAAO,CAAC;QACtD,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,cAAc,EAAE,oBAAoB,EAAE,IAAI,CAAC;QACnF,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;QAC7B,qHAAqH;QACrH,iDAAiD;QACjD,SAAS,EAAE,IAAI,CAAC,OAAO;QACvB,OAAO;KACR,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=useGetSwapPrices.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGetSwapPrices.test.d.ts","sourceRoot":"","sources":["../../../../src/tests/Combination/useGetSwapPrices.test.ts"],"names":[],"mappings":""}
@@ -1,35 +0,0 @@
1
- import { renderHook, waitFor } from '@testing-library/react';
2
- import { HttpResponse, http } from 'msw';
3
- import { describe, expect, it } from 'vitest';
4
- import { ACCOUNT_ADDRESS, NATIVE_TOKEN_ADDRESS_0X_SWAP } from '../../constants';
5
- import { useGetSwapPrices } from '../../hooks/Combination/useGetSwapPrices';
6
- import { createWrapper } from '../createWrapper';
7
- import { server } from '../setup';
8
- const getSwapPricesArgs = {
9
- userAddress: ACCOUNT_ADDRESS,
10
- buyCurrencyAddress: NATIVE_TOKEN_ADDRESS_0X_SWAP,
11
- chainId: 1,
12
- buyAmount: '20000',
13
- withContractInfo: true
14
- };
15
- describe('useGetSwapPrices', () => {
16
- it('should return data with a balance', async () => {
17
- const { result } = renderHook(() => useGetSwapPrices(getSwapPricesArgs), {
18
- wrapper: createWrapper()
19
- });
20
- await waitFor(() => expect(result.current.isSuccess).toBe(true));
21
- expect(result.current.data).toBeDefined();
22
- const value = BigInt(result.current.data[0].balance.balance || 0);
23
- expect(value).toBeGreaterThan(0);
24
- });
25
- it('should return error when fetching data fails', async () => {
26
- server.use(http.post('*', () => {
27
- return HttpResponse.error();
28
- }));
29
- const { result } = renderHook(() => useGetSwapPrices(getSwapPricesArgs, { retry: false }), {
30
- wrapper: createWrapper()
31
- });
32
- await waitFor(() => expect(result.current.isError).toBe(true));
33
- });
34
- });
35
- //# sourceMappingURL=useGetSwapPrices.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGetSwapPrices.test.js","sourceRoot":"","sources":["../../../../src/tests/Combination/useGetSwapPrices.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,eAAe,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAA;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAA;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,MAAM,iBAAiB,GAAG;IACxB,WAAW,EAAE,eAAe;IAC5B,kBAAkB,EAAE,4BAA4B;IAChD,OAAO,EAAE,CAAC;IACV,SAAS,EAAE,OAAO;IAClB,gBAAgB,EAAE,IAAI;CACvB,CAAA;AAED,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,EAAE;YACvE,OAAO,EAAE,aAAa,EAAE;SACzB,CAAC,CAAA;QAE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