@0xsequence/hooks 6.0.0-beta.4 → 6.0.1
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.
- package/LICENSE +1 -1
- package/dist/esm/contexts/ConfigContext.d.ts +2 -0
- package/dist/esm/contexts/ConfigContext.d.ts.map +1 -1
- package/dist/esm/contexts/ConfigContext.js +2 -0
- package/dist/esm/contexts/ConfigContext.js.map +1 -1
- package/dist/esm/hooks/Indexer/useGetTransactionHistory.d.ts +2 -0
- package/dist/esm/hooks/Indexer/useGetTransactionHistory.d.ts.map +1 -1
- package/dist/esm/hooks/Indexer/useIndexerClient.d.ts +2 -2
- package/dist/esm/hooks/Indexer/useIndexerClient.d.ts.map +1 -1
- package/dist/esm/hooks/Indexer/useIndexerClient.js +1 -1
- package/dist/esm/hooks/Indexer/useIndexerClient.js.map +1 -1
- package/dist/esm/hooks/IndexerGateway/useGetNativeTokenBalance.d.ts +2 -1
- package/dist/esm/hooks/IndexerGateway/useGetNativeTokenBalance.d.ts.map +1 -1
- package/dist/esm/hooks/IndexerGateway/useGetNativeTokenBalance.js.map +1 -1
- package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesByContract.d.ts +2 -1
- package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesByContract.d.ts.map +1 -1
- package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesByContract.js.map +1 -1
- package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesDetails.d.ts +2 -1
- package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesDetails.d.ts.map +1 -1
- package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesDetails.js.map +1 -1
- package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesSummary.d.ts +2 -1
- package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesSummary.d.ts.map +1 -1
- package/dist/esm/hooks/IndexerGateway/useGetTokenBalancesSummary.js.map +1 -1
- package/dist/esm/hooks/Metadata/useGetContractInfo.d.ts.map +1 -1
- package/dist/esm/hooks/Metadata/useGetContractInfo.js +1 -1
- package/dist/esm/hooks/Metadata/useGetContractInfo.js.map +1 -1
- package/dist/esm/hooks/useNetwork.d.ts +1 -1
- package/dist/esm/hooks/useNetwork.d.ts.map +1 -1
- package/dist/esm/hooks/useNetwork.js +1 -1
- package/dist/esm/hooks/useNetwork.js.map +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tests/IndexerGateway/useGetTokenBalancesByContract.test.js.map +1 -1
- package/dist/esm/tests/IndexerGateway/useGetTokenBalancesDetails.test.js.map +1 -1
- package/dist/esm/tests/IndexerGateway/useGetTokenBalancesSummary.test.js.map +1 -1
- package/dist/esm/utils/helpers.d.ts.map +1 -1
- package/dist/esm/utils/helpers.js +2 -0
- package/dist/esm/utils/helpers.js.map +1 -1
- package/dist/esm/utils/networks.d.ts +84 -0
- package/dist/esm/utils/networks.d.ts.map +1 -0
- package/dist/esm/utils/networks.js +52 -0
- package/dist/esm/utils/networks.js.map +1 -0
- package/package.json +14 -19
- package/dist/cjs/constants.d.ts +0 -29
- package/dist/cjs/constants.d.ts.map +0 -1
- package/dist/cjs/constants.js +0 -33
- package/dist/cjs/constants.js.map +0 -1
- package/dist/cjs/contexts/ConfigContext.d.ts +0 -27
- package/dist/cjs/contexts/ConfigContext.d.ts.map +0 -1
- package/dist/cjs/contexts/ConfigContext.js +0 -30
- package/dist/cjs/contexts/ConfigContext.js.map +0 -1
- package/dist/cjs/hooks/API/useAPIClient.d.ts +0 -39
- package/dist/cjs/hooks/API/useAPIClient.d.ts.map +0 -1
- package/dist/cjs/hooks/API/useAPIClient.js +0 -51
- package/dist/cjs/hooks/API/useAPIClient.js.map +0 -1
- package/dist/cjs/hooks/API/useGetCoinPrices.d.ts +0 -49
- package/dist/cjs/hooks/API/useGetCoinPrices.d.ts.map +0 -1
- package/dist/cjs/hooks/API/useGetCoinPrices.js +0 -78
- package/dist/cjs/hooks/API/useGetCoinPrices.js.map +0 -1
- package/dist/cjs/hooks/API/useGetCollectiblePrices.d.ts +0 -54
- package/dist/cjs/hooks/API/useGetCollectiblePrices.d.ts.map +0 -1
- package/dist/cjs/hooks/API/useGetCollectiblePrices.js +0 -83
- package/dist/cjs/hooks/API/useGetCollectiblePrices.js.map +0 -1
- package/dist/cjs/hooks/API/useGetExchangeRate.d.ts +0 -42
- package/dist/cjs/hooks/API/useGetExchangeRate.d.ts.map +0 -1
- package/dist/cjs/hooks/API/useGetExchangeRate.js +0 -63
- package/dist/cjs/hooks/API/useGetExchangeRate.js.map +0 -1
- package/dist/cjs/hooks/API/useGetWaasStatus.d.ts +0 -48
- package/dist/cjs/hooks/API/useGetWaasStatus.d.ts.map +0 -1
- package/dist/cjs/hooks/API/useGetWaasStatus.js +0 -49
- package/dist/cjs/hooks/API/useGetWaasStatus.js.map +0 -1
- package/dist/cjs/hooks/Builder/useDetectContractVersion.d.ts +0 -30
- package/dist/cjs/hooks/Builder/useDetectContractVersion.d.ts.map +0 -1
- package/dist/cjs/hooks/Builder/useDetectContractVersion.js +0 -26
- package/dist/cjs/hooks/Builder/useDetectContractVersion.js.map +0 -1
- package/dist/cjs/hooks/Combination/useGetSwapQuote.d.ts +0 -97
- package/dist/cjs/hooks/Combination/useGetSwapQuote.d.ts.map +0 -1
- package/dist/cjs/hooks/Combination/useGetSwapQuote.js +0 -123
- package/dist/cjs/hooks/Combination/useGetSwapQuote.js.map +0 -1
- package/dist/cjs/hooks/Combination/useGetSwapRoutes.d.ts +0 -61
- package/dist/cjs/hooks/Combination/useGetSwapRoutes.d.ts.map +0 -1
- package/dist/cjs/hooks/Combination/useGetSwapRoutes.js +0 -83
- package/dist/cjs/hooks/Combination/useGetSwapRoutes.js.map +0 -1
- package/dist/cjs/hooks/Indexer/useGetTransactionHistory.d.ts +0 -97
- package/dist/cjs/hooks/Indexer/useGetTransactionHistory.d.ts.map +0 -1
- package/dist/cjs/hooks/Indexer/useGetTransactionHistory.js +0 -131
- package/dist/cjs/hooks/Indexer/useGetTransactionHistory.js.map +0 -1
- package/dist/cjs/hooks/Indexer/useGetTransactionHistorySummary.d.ts +0 -76
- package/dist/cjs/hooks/Indexer/useGetTransactionHistorySummary.d.ts.map +0 -1
- package/dist/cjs/hooks/Indexer/useGetTransactionHistorySummary.js +0 -115
- package/dist/cjs/hooks/Indexer/useGetTransactionHistorySummary.js.map +0 -1
- package/dist/cjs/hooks/Indexer/useIndexerClient.d.ts +0 -102
- package/dist/cjs/hooks/Indexer/useIndexerClient.d.ts.map +0 -1
- package/dist/cjs/hooks/Indexer/useIndexerClient.js +0 -145
- package/dist/cjs/hooks/Indexer/useIndexerClient.js.map +0 -1
- package/dist/cjs/hooks/IndexerGateway/useGetNativeTokenBalance.d.ts +0 -35
- package/dist/cjs/hooks/IndexerGateway/useGetNativeTokenBalance.d.ts.map +0 -1
- package/dist/cjs/hooks/IndexerGateway/useGetNativeTokenBalance.js +0 -55
- package/dist/cjs/hooks/IndexerGateway/useGetNativeTokenBalance.js.map +0 -1
- package/dist/cjs/hooks/IndexerGateway/useGetSingleTokenBalance.d.ts +0 -50
- package/dist/cjs/hooks/IndexerGateway/useGetSingleTokenBalance.d.ts.map +0 -1
- package/dist/cjs/hooks/IndexerGateway/useGetSingleTokenBalance.js +0 -88
- package/dist/cjs/hooks/IndexerGateway/useGetSingleTokenBalance.js.map +0 -1
- package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesByContract.d.ts +0 -61
- package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesByContract.d.ts.map +0 -1
- package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesByContract.js +0 -85
- package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesByContract.js.map +0 -1
- package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesDetails.d.ts +0 -99
- package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesDetails.d.ts.map +0 -1
- package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesDetails.js +0 -136
- package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesDetails.js.map +0 -1
- package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesSummary.d.ts +0 -74
- package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesSummary.d.ts.map +0 -1
- package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesSummary.js +0 -111
- package/dist/cjs/hooks/IndexerGateway/useGetTokenBalancesSummary.js.map +0 -1
- package/dist/cjs/hooks/IndexerGateway/useIndexerGatewayClient.d.ts +0 -29
- package/dist/cjs/hooks/IndexerGateway/useIndexerGatewayClient.d.ts.map +0 -1
- package/dist/cjs/hooks/IndexerGateway/useIndexerGatewayClient.js +0 -41
- package/dist/cjs/hooks/IndexerGateway/useIndexerGatewayClient.js.map +0 -1
- package/dist/cjs/hooks/Metadata/useGetContractInfo.d.ts +0 -68
- package/dist/cjs/hooks/Metadata/useGetContractInfo.d.ts.map +0 -1
- package/dist/cjs/hooks/Metadata/useGetContractInfo.js +0 -96
- package/dist/cjs/hooks/Metadata/useGetContractInfo.js.map +0 -1
- package/dist/cjs/hooks/Metadata/useGetMultipleContractsInfo.d.ts +0 -95
- package/dist/cjs/hooks/Metadata/useGetMultipleContractsInfo.d.ts.map +0 -1
- package/dist/cjs/hooks/Metadata/useGetMultipleContractsInfo.js +0 -118
- package/dist/cjs/hooks/Metadata/useGetMultipleContractsInfo.js.map +0 -1
- package/dist/cjs/hooks/Metadata/useGetTokenMetadata.d.ts +0 -89
- package/dist/cjs/hooks/Metadata/useGetTokenMetadata.d.ts.map +0 -1
- package/dist/cjs/hooks/Metadata/useGetTokenMetadata.js +0 -123
- package/dist/cjs/hooks/Metadata/useGetTokenMetadata.js.map +0 -1
- package/dist/cjs/hooks/Metadata/useMetadataClient.d.ts +0 -39
- package/dist/cjs/hooks/Metadata/useMetadataClient.d.ts.map +0 -1
- package/dist/cjs/hooks/Metadata/useMetadataClient.js +0 -51
- package/dist/cjs/hooks/Metadata/useMetadataClient.js.map +0 -1
- package/dist/cjs/hooks/useClearCachedBalances.d.ts +0 -4
- package/dist/cjs/hooks/useClearCachedBalances.d.ts.map +0 -1
- package/dist/cjs/hooks/useClearCachedBalances.js +0 -17
- package/dist/cjs/hooks/useClearCachedBalances.js.map +0 -1
- package/dist/cjs/hooks/useClipboard.d.ts +0 -6
- package/dist/cjs/hooks/useClipboard.d.ts.map +0 -1
- package/dist/cjs/hooks/useClipboard.js +0 -34
- package/dist/cjs/hooks/useClipboard.js.map +0 -1
- package/dist/cjs/hooks/useConfig.d.ts +0 -47
- package/dist/cjs/hooks/useConfig.d.ts.map +0 -1
- package/dist/cjs/hooks/useConfig.js +0 -59
- package/dist/cjs/hooks/useConfig.js.map +0 -1
- package/dist/cjs/hooks/useNetwork.d.ts +0 -2
- package/dist/cjs/hooks/useNetwork.d.ts.map +0 -1
- package/dist/cjs/hooks/useNetwork.js +0 -9
- package/dist/cjs/hooks/useNetwork.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -27
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -67
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/tests/API/useGetCoinPrices.test.d.ts +0 -2
- package/dist/cjs/tests/API/useGetCoinPrices.test.d.ts.map +0 -1
- package/dist/cjs/tests/API/useGetCoinPrices.test.js +0 -36
- package/dist/cjs/tests/API/useGetCoinPrices.test.js.map +0 -1
- package/dist/cjs/tests/API/useGetCollectiblePrices.test.d.ts +0 -2
- package/dist/cjs/tests/API/useGetCollectiblePrices.test.d.ts.map +0 -1
- package/dist/cjs/tests/API/useGetCollectiblePrices.test.js +0 -36
- package/dist/cjs/tests/API/useGetCollectiblePrices.test.js.map +0 -1
- package/dist/cjs/tests/API/useGetExchangeRate.test.d.ts +0 -2
- package/dist/cjs/tests/API/useGetExchangeRate.test.d.ts.map +0 -1
- package/dist/cjs/tests/API/useGetExchangeRate.test.js +0 -29
- package/dist/cjs/tests/API/useGetExchangeRate.test.js.map +0 -1
- package/dist/cjs/tests/Combination/useGetSwapQuote.test.d.ts +0 -2
- package/dist/cjs/tests/Combination/useGetSwapQuote.test.d.ts.map +0 -1
- package/dist/cjs/tests/Combination/useGetSwapQuote.test.js +0 -57
- package/dist/cjs/tests/Combination/useGetSwapQuote.test.js.map +0 -1
- package/dist/cjs/tests/Indexer/useGetTransactionHistory.test.d.ts +0 -2
- package/dist/cjs/tests/Indexer/useGetTransactionHistory.test.d.ts.map +0 -1
- package/dist/cjs/tests/Indexer/useGetTransactionHistory.test.js +0 -35
- package/dist/cjs/tests/Indexer/useGetTransactionHistory.test.js.map +0 -1
- package/dist/cjs/tests/Indexer/useGetTransactionHistorySummary.test.d.ts +0 -2
- package/dist/cjs/tests/Indexer/useGetTransactionHistorySummary.test.d.ts.map +0 -1
- package/dist/cjs/tests/Indexer/useGetTransactionHistorySummary.test.js +0 -34
- package/dist/cjs/tests/Indexer/useGetTransactionHistorySummary.test.js.map +0 -1
- package/dist/cjs/tests/IndexerGateway/useGetNativeTokenBalance.test.d.ts +0 -2
- package/dist/cjs/tests/IndexerGateway/useGetNativeTokenBalance.test.d.ts.map +0 -1
- package/dist/cjs/tests/IndexerGateway/useGetNativeTokenBalance.test.js +0 -34
- package/dist/cjs/tests/IndexerGateway/useGetNativeTokenBalance.test.js.map +0 -1
- package/dist/cjs/tests/IndexerGateway/useGetSingleTokenBalanceSummary.test.d.ts +0 -2
- package/dist/cjs/tests/IndexerGateway/useGetSingleTokenBalanceSummary.test.d.ts.map +0 -1
- package/dist/cjs/tests/IndexerGateway/useGetSingleTokenBalanceSummary.test.js +0 -35
- package/dist/cjs/tests/IndexerGateway/useGetSingleTokenBalanceSummary.test.js.map +0 -1
- package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesByContract.test.d.ts +0 -2
- package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesByContract.test.d.ts.map +0 -1
- package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesByContract.test.js +0 -38
- package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesByContract.test.js.map +0 -1
- package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesDetails.test.d.ts +0 -2
- package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesDetails.test.d.ts.map +0 -1
- package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesDetails.test.js +0 -38
- package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesDetails.test.js.map +0 -1
- package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesSummary.test.d.ts +0 -2
- package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesSummary.test.d.ts.map +0 -1
- package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesSummary.test.js +0 -38
- package/dist/cjs/tests/IndexerGateway/useGetTokenBalancesSummary.test.js.map +0 -1
- package/dist/cjs/tests/Metadata/useGetContractInfo.test.d.ts +0 -2
- package/dist/cjs/tests/Metadata/useGetContractInfo.test.d.ts.map +0 -1
- package/dist/cjs/tests/Metadata/useGetContractInfo.test.js +0 -33
- package/dist/cjs/tests/Metadata/useGetContractInfo.test.js.map +0 -1
- package/dist/cjs/tests/Metadata/useGetMultipleContractsInfo.test.d.ts +0 -2
- package/dist/cjs/tests/Metadata/useGetMultipleContractsInfo.test.d.ts.map +0 -1
- package/dist/cjs/tests/Metadata/useGetMultipleContractsInfo.test.js +0 -39
- package/dist/cjs/tests/Metadata/useGetMultipleContractsInfo.test.js.map +0 -1
- package/dist/cjs/tests/Metadata/useGetTokenMetadata.test.d.ts +0 -2
- package/dist/cjs/tests/Metadata/useGetTokenMetadata.test.d.ts.map +0 -1
- package/dist/cjs/tests/Metadata/useGetTokenMetadata.test.js +0 -34
- package/dist/cjs/tests/Metadata/useGetTokenMetadata.test.js.map +0 -1
- package/dist/cjs/tests/createWrapper.d.ts +0 -7
- package/dist/cjs/tests/createWrapper.d.ts.map +0 -1
- package/dist/cjs/tests/createWrapper.js +0 -29
- package/dist/cjs/tests/createWrapper.js.map +0 -1
- package/dist/cjs/tests/fixtures/nativeTokenBalance.d.ts +0 -7
- package/dist/cjs/tests/fixtures/nativeTokenBalance.d.ts.map +0 -1
- package/dist/cjs/tests/fixtures/nativeTokenBalance.js +0 -10
- package/dist/cjs/tests/fixtures/nativeTokenBalance.js.map +0 -1
- package/dist/cjs/tests/handlers.d.ts +0 -2
- package/dist/cjs/tests/handlers.d.ts.map +0 -1
- package/dist/cjs/tests/handlers.js +0 -274
- package/dist/cjs/tests/handlers.js.map +0 -1
- package/dist/cjs/tests/setup.d.ts +0 -3
- package/dist/cjs/tests/setup.d.ts.map +0 -1
- package/dist/cjs/tests/setup.js +0 -16
- package/dist/cjs/tests/setup.js.map +0 -1
- package/dist/cjs/tests/simple.test.d.ts +0 -2
- package/dist/cjs/tests/simple.test.d.ts.map +0 -1
- package/dist/cjs/tests/simple.test.js +0 -64
- package/dist/cjs/tests/simple.test.js.map +0 -1
- package/dist/cjs/tests/useConfig.test.d.ts +0 -2
- package/dist/cjs/tests/useConfig.test.d.ts.map +0 -1
- package/dist/cjs/tests/useConfig.test.js +0 -15
- package/dist/cjs/tests/useConfig.test.js.map +0 -1
- package/dist/cjs/types/hooks.d.ts +0 -5
- package/dist/cjs/types/hooks.d.ts.map +0 -1
- package/dist/cjs/types/hooks.js +0 -3
- package/dist/cjs/types/hooks.js.map +0 -1
- package/dist/cjs/utils/envstring.d.ts +0 -2
- package/dist/cjs/utils/envstring.d.ts.map +0 -1
- package/dist/cjs/utils/envstring.js +0 -10
- package/dist/cjs/utils/envstring.js.map +0 -1
- package/dist/cjs/utils/helpers.d.ts +0 -12
- package/dist/cjs/utils/helpers.d.ts.map +0 -1
- package/dist/cjs/utils/helpers.js +0 -66
- package/dist/cjs/utils/helpers.js.map +0 -1
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useGetTokenBalancesDetails = 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 useIndexerGatewayClient_js_1 = require("./useIndexerGatewayClient.js");
|
|
8
|
-
const getTokenBalancesDetails = async (indexerGatewayClient, args) => {
|
|
9
|
-
try {
|
|
10
|
-
const res = await indexerGatewayClient.getTokenBalancesDetails(args);
|
|
11
|
-
const nativeTokens = res.nativeBalances.flatMap(nativeChainBalance => nativeChainBalance.results.map(nativeTokenBalance => (0, helpers_js_1.createNativeTokenBalance)(nativeChainBalance.chainId, nativeTokenBalance.accountAddress, nativeTokenBalance.balance)));
|
|
12
|
-
const tokens = res.balances.flatMap(chainBalance => chainBalance.results);
|
|
13
|
-
const sortedBalances = (0, helpers_js_1.sortBalancesByType)([...nativeTokens, ...tokens]);
|
|
14
|
-
return {
|
|
15
|
-
balances: [
|
|
16
|
-
...(res.page.after ? [] : [...sortedBalances.nativeTokens]),
|
|
17
|
-
...sortedBalances.erc20Tokens,
|
|
18
|
-
...sortedBalances.collectibles
|
|
19
|
-
],
|
|
20
|
-
page: res.page
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
throw e;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Hook to fetch detailed token balances including individual token metadata.
|
|
29
|
-
*
|
|
30
|
-
* Key differences from other balance hooks:
|
|
31
|
-
* - useGetTokenBalancesSummary: Returns basic token info, faster but less detailed
|
|
32
|
-
* - useGetTokenBalancesByContract: Only fetches specific contracts
|
|
33
|
-
* - useGetSingleTokenBalanceSummary: Fetches a single token balance
|
|
34
|
-
*
|
|
35
|
-
* This hook is best used when you need full token details, especially for NFTs and collectibles
|
|
36
|
-
* where metadata is important (images, attributes, etc).
|
|
37
|
-
* Results are sorted by type: native tokens first, then ERC20s, then collectibles.
|
|
38
|
-
*
|
|
39
|
-
* @param getTokenBalancesDetailsArgs - Arguments for fetching token balances
|
|
40
|
-
* @param getTokenBalancesDetailsArgs.chainIds - Array of chain IDs to fetch balances from
|
|
41
|
-
* @param getTokenBalancesDetailsArgs.filter - Filter criteria for the query
|
|
42
|
-
* @param getTokenBalancesDetailsArgs.filter.accountAddresses - List of account addresses to fetch balances for
|
|
43
|
-
* @param getTokenBalancesDetailsArgs.filter.contractWhitelist - Optional list of contracts to include
|
|
44
|
-
* @param getTokenBalancesDetailsArgs.filter.contractBlacklist - Optional list of contracts to exclude
|
|
45
|
-
* @param getTokenBalancesDetailsArgs.filter.omitNativeBalances - If true, excludes native token balances
|
|
46
|
-
* @param getTokenBalancesDetailsArgs.filter.contractStatus - Optional filter for contract verification status
|
|
47
|
-
* @param options - Optional configuration for the query behavior
|
|
48
|
-
* @param options.hideCollectibles - If true, filters out ERC721 and ERC1155 tokens
|
|
49
|
-
* @param options.disabled - If true, disables the query from automatically running
|
|
50
|
-
* @param options.retry - If true (default), retries failed queries
|
|
51
|
-
*
|
|
52
|
-
* Query configuration:
|
|
53
|
-
* - Marks data as stale after 30 seconds
|
|
54
|
-
* - Retries failed requests by default
|
|
55
|
-
* - Only enabled when account address is present and not explicitly disabled
|
|
56
|
-
*
|
|
57
|
-
* @returns Query result containing an array of TokenBalance objects with detailed information:
|
|
58
|
-
* - `contractType`: Type of the token contract (NATIVE, ERC20, ERC721, ERC1155)
|
|
59
|
-
* - `contractAddress`: Address of the token contract
|
|
60
|
-
* - `accountAddress`: Address of the account holding the tokens
|
|
61
|
-
* - `tokenID`: (for NFTs) ID of the token
|
|
62
|
-
* - `balance`: Token balance as a string
|
|
63
|
-
* - `blockHash`: Hash of the block where this balance was last updated
|
|
64
|
-
* - `blockNumber`: Block number where this balance was last updated
|
|
65
|
-
* - `chainId`: Chain ID where the token exists
|
|
66
|
-
* - `contractInfo`: Additional token contract information including:
|
|
67
|
-
* - `name`: Token name
|
|
68
|
-
* - `symbol`: Token symbol
|
|
69
|
-
* - `decimals`: Number of decimals
|
|
70
|
-
* - `logoURI`: URL of the token logo
|
|
71
|
-
* - `tokenMetadata`: (for NFTs) Detailed token metadata including:
|
|
72
|
-
* - `name`: Token name
|
|
73
|
-
* - `description`: Token description
|
|
74
|
-
* - `image`: Token image URL
|
|
75
|
-
* - `attributes`: Array of token attributes
|
|
76
|
-
*
|
|
77
|
-
* @see {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useGetTokenBalancesDetails} for more detailed documentation.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* ```tsx
|
|
81
|
-
* import { useGetTokenBalancesDetails } from '@0xsequence/hooks'
|
|
82
|
-
*
|
|
83
|
-
* // Fetch all token balances with full details
|
|
84
|
-
* function TokenList() {
|
|
85
|
-
* const { data: tokens } = useGetTokenBalancesDetails({
|
|
86
|
-
* chainIds: [1], // Ethereum mainnet
|
|
87
|
-
* filter: {
|
|
88
|
-
* accountAddresses: ['0x123...'],
|
|
89
|
-
* omitNativeBalances: false,
|
|
90
|
-
* // Optional: only include specific tokens
|
|
91
|
-
* contractWhitelist: ['0x...', '0x...'],
|
|
92
|
-
* // Optional: exclude specific tokens
|
|
93
|
-
* contractBlacklist: ['0x...']
|
|
94
|
-
* }
|
|
95
|
-
* })
|
|
96
|
-
*
|
|
97
|
-
* return tokens?.map(token => (
|
|
98
|
-
* <div key={`${token.chainId}-${token.contractAddress}-${token.tokenID}`}>
|
|
99
|
-
* {token.contractType === 'ERC721' ? (
|
|
100
|
-
* // NFT display with metadata
|
|
101
|
-
* <NFTCard
|
|
102
|
-
* name={token.tokenMetadata?.name}
|
|
103
|
-
* image={token.tokenMetadata?.image}
|
|
104
|
-
* attributes={token.tokenMetadata?.attributes}
|
|
105
|
-
* />
|
|
106
|
-
* ) : (
|
|
107
|
-
* // Regular token display
|
|
108
|
-
* <TokenRow
|
|
109
|
-
* symbol={token.contractInfo?.symbol}
|
|
110
|
-
* balance={token.balance}
|
|
111
|
-
* decimals={token.contractInfo?.decimals}
|
|
112
|
-
* />
|
|
113
|
-
* )}
|
|
114
|
-
* </div>
|
|
115
|
-
* ))
|
|
116
|
-
* }
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
const useGetTokenBalancesDetails = (args, options) => {
|
|
120
|
-
const indexerGatewayClient = (0, useIndexerGatewayClient_js_1.useIndexerGatewayClient)();
|
|
121
|
-
return (0, react_query_1.useInfiniteQuery)({
|
|
122
|
-
queryKey: [constants_js_1.QUERY_KEYS.useGetTokenBalancesDetails, args, options],
|
|
123
|
-
queryFn: ({ pageParam }) => {
|
|
124
|
-
return getTokenBalancesDetails(indexerGatewayClient, { ...args, page: pageParam });
|
|
125
|
-
},
|
|
126
|
-
getNextPageParam: ({ page }) => {
|
|
127
|
-
return page?.more ? page : undefined;
|
|
128
|
-
},
|
|
129
|
-
initialPageParam: { ...args?.page },
|
|
130
|
-
retry: options?.retry ?? true,
|
|
131
|
-
staleTime: constants_js_1.time.oneSecond * 30,
|
|
132
|
-
enabled: args.filter.accountAddresses.length > 0 && !options?.disabled
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
exports.useGetTokenBalancesDetails = useGetTokenBalancesDetails;
|
|
136
|
-
//# sourceMappingURL=useGetTokenBalancesDetails.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGetTokenBalancesDetails.js","sourceRoot":"","sources":["../../../../src/hooks/IndexerGateway/useGetTokenBalancesDetails.ts"],"names":[],"mappings":";;;AACA,uDAAwD;AAExD,qDAAqD;AAErD,uDAAqF;AAErF,6EAAsE;AAEtE,MAAM,uBAAuB,GAAG,KAAK,EACnC,oBAA4C,EAC5C,IAAgD,EAChD,EAAE;IACF,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,oBAAoB,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAA;QAEpE,MAAM,YAAY,GAAmB,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CACnF,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,CAClD,IAAA,qCAAwB,EAAC,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,CAAC,cAAc,EAAE,kBAAkB,CAAC,OAAO,CAAC,CACpH,CACF,CAAA;QAED,MAAM,MAAM,GAAmB,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;QAEzF,MAAM,cAAc,GAAG,IAAA,+BAAkB,EAAC,CAAC,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC,CAAC,CAAA;QAEvE,OAAO;YACL,QAAQ,EAAE;gBACR,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;gBAC3D,GAAG,cAAc,CAAC,WAAW;gBAC7B,GAAG,cAAc,CAAC,YAAY;aAC/B;YACD,IAAI,EAAE,GAAG,CAAC,IAAI;SACf,CAAA;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,CAAC,CAAA;IACT,CAAC;AACH,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACI,MAAM,0BAA0B,GAAG,CAAC,IAAgD,EAAE,OAAsB,EAAE,EAAE;IACrH,MAAM,oBAAoB,GAAG,IAAA,oDAAuB,GAAE,CAAA;IAEtD,OAAO,IAAA,8BAAgB,EAAC;QACtB,QAAQ,EAAE,CAAC,yBAAU,CAAC,0BAA0B,EAAE,IAAI,EAAE,OAAO,CAAC;QAChE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;YACzB,OAAO,uBAAuB,CAAC,oBAAoB,EAAE,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;QACpF,CAAC;QACD,gBAAgB,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;YAC7B,OAAO,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;QACtC,CAAC;QACD,gBAAgB,EAAE,EAAE,GAAG,IAAI,EAAE,IAAI,EAAU;QAC3C,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;QAC7B,SAAS,EAAE,mBAAI,CAAC,SAAS,GAAG,EAAE;QAC9B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ;KACvE,CAAC,CAAA;AACJ,CAAC,CAAA;AAhBY,QAAA,0BAA0B,8BAgBtC"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { type IndexerGateway, type TokenBalance } from '@0xsequence/indexer';
|
|
2
|
-
import type { HooksOptions } from '../../types/hooks.js';
|
|
3
|
-
/**
|
|
4
|
-
* Hook to fetch token balances with summarized contract information.
|
|
5
|
-
* This is a lighter version of useGetTokenBalancesDetails - it returns basic token information
|
|
6
|
-
* without detailed metadata, making it faster and more suitable for token lists and balances display.
|
|
7
|
-
* Results are sorted by type: native tokens first, then ERC20s, then collectibles.
|
|
8
|
-
*
|
|
9
|
-
* @param getTokenBalancesSummaryArgs - Arguments for fetching token balances
|
|
10
|
-
* @param getTokenBalancesSummaryArgs.chainIds - Array of chain IDs to fetch balances from
|
|
11
|
-
* @param getTokenBalancesSummaryArgs.filter - Filter criteria for the query
|
|
12
|
-
* @param getTokenBalancesSummaryArgs.filter.accountAddresses - List of account addresses to fetch balances for
|
|
13
|
-
* @param getTokenBalancesSummaryArgs.filter.contractWhitelist - Optional list of contracts to include
|
|
14
|
-
* @param getTokenBalancesSummaryArgs.filter.contractBlacklist - Optional list of contracts to exclude
|
|
15
|
-
* @param getTokenBalancesSummaryArgs.filter.omitNativeBalances - If true, excludes native token balances
|
|
16
|
-
* @param getTokenBalancesSummaryArgs.filter.contractStatus - Optional filter for contract verification status
|
|
17
|
-
* @param options - Optional configuration for the query behavior
|
|
18
|
-
* @param options.hideCollectibles - If true, filters out ERC721 and ERC1155 tokens
|
|
19
|
-
* @param options.disabled - If true, disables the query from automatically running
|
|
20
|
-
* @param options.retry - If true (default), retries failed queries
|
|
21
|
-
*
|
|
22
|
-
* Query configuration:
|
|
23
|
-
* - Marks data as stale after 30 seconds
|
|
24
|
-
* - Retries failed requests by default
|
|
25
|
-
* - Only enabled when account address is present and not explicitly disabled
|
|
26
|
-
*
|
|
27
|
-
* @returns Query result containing an array of TokenBalance objects with basic information:
|
|
28
|
-
* - `contractType`: Type of the token contract (NATIVE, ERC20, ERC721, ERC1155)
|
|
29
|
-
* - `contractAddress`: Address of the token contract
|
|
30
|
-
* - `accountAddress`: Address of the account holding the tokens
|
|
31
|
-
* - `balance`: Token balance as a string
|
|
32
|
-
* - `chainId`: Chain ID where the token exists
|
|
33
|
-
* - `contractInfo`: Basic token contract information including:
|
|
34
|
-
* - `name`: Token name
|
|
35
|
-
* - `symbol`: Token symbol
|
|
36
|
-
* - `decimals`: Number of decimals
|
|
37
|
-
* - `logoURI`: URL of the token logo
|
|
38
|
-
*
|
|
39
|
-
* @see {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useGetTokenBalancesSummary} for more detailed documentation.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```tsx
|
|
43
|
-
* import { useGetTokenBalancesSummary } from '@0xsequence/hooks'
|
|
44
|
-
*
|
|
45
|
-
* // Fetch token balances for a wallet
|
|
46
|
-
* function TokenBalances() {
|
|
47
|
-
* const { data: tokens } = useGetTokenBalancesSummary({
|
|
48
|
-
* chainIds: [1, 137], // Ethereum and Polygon
|
|
49
|
-
* filter: {
|
|
50
|
-
* accountAddresses: ['0x123...'],
|
|
51
|
-
* omitNativeBalances: false,
|
|
52
|
-
* // Optional: filter specific tokens
|
|
53
|
-
* contractWhitelist: ['0x...', '0x...']
|
|
54
|
-
* }
|
|
55
|
-
* })
|
|
56
|
-
*
|
|
57
|
-
* return tokens?.map(token => (
|
|
58
|
-
* <div key={`${token.chainId}-${token.contractAddress}`}>
|
|
59
|
-
* <TokenRow
|
|
60
|
-
* symbol={token.contractInfo?.symbol}
|
|
61
|
-
* balance={token.balance}
|
|
62
|
-
* decimals={token.contractInfo?.decimals}
|
|
63
|
-
* logoURI={token.contractInfo?.logoURI}
|
|
64
|
-
* />
|
|
65
|
-
* </div>
|
|
66
|
-
* ))
|
|
67
|
-
* }
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
export declare const useGetTokenBalancesSummary: (args: IndexerGateway.GetTokenBalancesSummaryArgs, options?: HooksOptions) => import("@tanstack/react-query").UseInfiniteQueryResult<import("@tanstack/react-query").InfiniteData<{
|
|
71
|
-
balances: TokenBalance[];
|
|
72
|
-
page: IndexerGateway.Page;
|
|
73
|
-
}, unknown>, Error>;
|
|
74
|
-
//# sourceMappingURL=useGetTokenBalancesSummary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGetTokenBalancesSummary.d.ts","sourceRoot":"","sources":["../../../../src/hooks/IndexerGateway/useGetTokenBalancesSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,cAAc,EAAa,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAI/G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAmCxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,eAAO,MAAM,0BAA0B,GAAI,MAAM,cAAc,CAAC,2BAA2B,EAAE,UAAU,YAAY;;;mBAgBlH,CAAA"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useGetTokenBalancesSummary = 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 useIndexerGatewayClient_js_1 = require("./useIndexerGatewayClient.js");
|
|
8
|
-
const getTokenBalancesSummary = async (indexerGatewayClient, args) => {
|
|
9
|
-
try {
|
|
10
|
-
const res = await indexerGatewayClient.getTokenBalancesSummary(args);
|
|
11
|
-
const nativeTokens = res.nativeBalances.flatMap(nativeChainBalance => nativeChainBalance.results.map(nativeTokenBalance => (0, helpers_js_1.createNativeTokenBalance)(nativeChainBalance.chainId, nativeTokenBalance.accountAddress, nativeTokenBalance.balance)));
|
|
12
|
-
const tokens = res.balances.flatMap(chainBalance => chainBalance.results);
|
|
13
|
-
const sortedBalances = (0, helpers_js_1.sortBalancesByType)([...nativeTokens, ...tokens]);
|
|
14
|
-
return {
|
|
15
|
-
balances: [
|
|
16
|
-
...(res.page.after ? [] : [...sortedBalances.nativeTokens]),
|
|
17
|
-
...sortedBalances.erc20Tokens,
|
|
18
|
-
...sortedBalances.collectibles
|
|
19
|
-
],
|
|
20
|
-
page: res.page
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
throw e;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Hook to fetch token balances with summarized contract information.
|
|
29
|
-
* This is a lighter version of useGetTokenBalancesDetails - it returns basic token information
|
|
30
|
-
* without detailed metadata, making it faster and more suitable for token lists and balances display.
|
|
31
|
-
* Results are sorted by type: native tokens first, then ERC20s, then collectibles.
|
|
32
|
-
*
|
|
33
|
-
* @param getTokenBalancesSummaryArgs - Arguments for fetching token balances
|
|
34
|
-
* @param getTokenBalancesSummaryArgs.chainIds - Array of chain IDs to fetch balances from
|
|
35
|
-
* @param getTokenBalancesSummaryArgs.filter - Filter criteria for the query
|
|
36
|
-
* @param getTokenBalancesSummaryArgs.filter.accountAddresses - List of account addresses to fetch balances for
|
|
37
|
-
* @param getTokenBalancesSummaryArgs.filter.contractWhitelist - Optional list of contracts to include
|
|
38
|
-
* @param getTokenBalancesSummaryArgs.filter.contractBlacklist - Optional list of contracts to exclude
|
|
39
|
-
* @param getTokenBalancesSummaryArgs.filter.omitNativeBalances - If true, excludes native token balances
|
|
40
|
-
* @param getTokenBalancesSummaryArgs.filter.contractStatus - Optional filter for contract verification status
|
|
41
|
-
* @param options - Optional configuration for the query behavior
|
|
42
|
-
* @param options.hideCollectibles - If true, filters out ERC721 and ERC1155 tokens
|
|
43
|
-
* @param options.disabled - If true, disables the query from automatically running
|
|
44
|
-
* @param options.retry - If true (default), retries failed queries
|
|
45
|
-
*
|
|
46
|
-
* Query configuration:
|
|
47
|
-
* - Marks data as stale after 30 seconds
|
|
48
|
-
* - Retries failed requests by default
|
|
49
|
-
* - Only enabled when account address is present and not explicitly disabled
|
|
50
|
-
*
|
|
51
|
-
* @returns Query result containing an array of TokenBalance objects with basic information:
|
|
52
|
-
* - `contractType`: Type of the token contract (NATIVE, ERC20, ERC721, ERC1155)
|
|
53
|
-
* - `contractAddress`: Address of the token contract
|
|
54
|
-
* - `accountAddress`: Address of the account holding the tokens
|
|
55
|
-
* - `balance`: Token balance as a string
|
|
56
|
-
* - `chainId`: Chain ID where the token exists
|
|
57
|
-
* - `contractInfo`: Basic token contract information including:
|
|
58
|
-
* - `name`: Token name
|
|
59
|
-
* - `symbol`: Token symbol
|
|
60
|
-
* - `decimals`: Number of decimals
|
|
61
|
-
* - `logoURI`: URL of the token logo
|
|
62
|
-
*
|
|
63
|
-
* @see {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useGetTokenBalancesSummary} for more detailed documentation.
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```tsx
|
|
67
|
-
* import { useGetTokenBalancesSummary } from '@0xsequence/hooks'
|
|
68
|
-
*
|
|
69
|
-
* // Fetch token balances for a wallet
|
|
70
|
-
* function TokenBalances() {
|
|
71
|
-
* const { data: tokens } = useGetTokenBalancesSummary({
|
|
72
|
-
* chainIds: [1, 137], // Ethereum and Polygon
|
|
73
|
-
* filter: {
|
|
74
|
-
* accountAddresses: ['0x123...'],
|
|
75
|
-
* omitNativeBalances: false,
|
|
76
|
-
* // Optional: filter specific tokens
|
|
77
|
-
* contractWhitelist: ['0x...', '0x...']
|
|
78
|
-
* }
|
|
79
|
-
* })
|
|
80
|
-
*
|
|
81
|
-
* return tokens?.map(token => (
|
|
82
|
-
* <div key={`${token.chainId}-${token.contractAddress}`}>
|
|
83
|
-
* <TokenRow
|
|
84
|
-
* symbol={token.contractInfo?.symbol}
|
|
85
|
-
* balance={token.balance}
|
|
86
|
-
* decimals={token.contractInfo?.decimals}
|
|
87
|
-
* logoURI={token.contractInfo?.logoURI}
|
|
88
|
-
* />
|
|
89
|
-
* </div>
|
|
90
|
-
* ))
|
|
91
|
-
* }
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
const useGetTokenBalancesSummary = (args, options) => {
|
|
95
|
-
const indexerGatewayClient = (0, useIndexerGatewayClient_js_1.useIndexerGatewayClient)();
|
|
96
|
-
return (0, react_query_1.useInfiniteQuery)({
|
|
97
|
-
queryKey: [constants_js_1.QUERY_KEYS.useGetTokenBalancesSummary, args, options],
|
|
98
|
-
queryFn: ({ pageParam }) => {
|
|
99
|
-
return getTokenBalancesSummary(indexerGatewayClient, { ...args, page: pageParam });
|
|
100
|
-
},
|
|
101
|
-
getNextPageParam: ({ page }) => {
|
|
102
|
-
return page?.more ? page : undefined;
|
|
103
|
-
},
|
|
104
|
-
initialPageParam: { ...args?.page },
|
|
105
|
-
retry: options?.retry ?? true,
|
|
106
|
-
staleTime: constants_js_1.time.oneSecond * 30,
|
|
107
|
-
enabled: args.filter.accountAddresses.length > 0 && !options?.disabled
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
exports.useGetTokenBalancesSummary = useGetTokenBalancesSummary;
|
|
111
|
-
//# sourceMappingURL=useGetTokenBalancesSummary.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGetTokenBalancesSummary.js","sourceRoot":"","sources":["../../../../src/hooks/IndexerGateway/useGetTokenBalancesSummary.ts"],"names":[],"mappings":";;;AACA,uDAAwD;AAExD,qDAAqD;AAErD,uDAAqF;AAErF,6EAAsE;AAEtE,MAAM,uBAAuB,GAAG,KAAK,EACnC,oBAA4C,EAC5C,IAAgD,EAChD,EAAE;IACF,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,oBAAoB,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAA;QAEpE,MAAM,YAAY,GAAmB,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CACnF,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,CAClD,IAAA,qCAAwB,EAAC,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,CAAC,cAAc,EAAE,kBAAkB,CAAC,OAAO,CAAC,CACpH,CACF,CAAA;QAED,MAAM,MAAM,GAAmB,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;QAEzF,MAAM,cAAc,GAAG,IAAA,+BAAkB,EAAC,CAAC,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC,CAAC,CAAA;QAEvE,OAAO;YACL,QAAQ,EAAE;gBACR,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;gBAC3D,GAAG,cAAc,CAAC,WAAW;gBAC7B,GAAG,cAAc,CAAC,YAAY;aAC/B;YACD,IAAI,EAAE,GAAG,CAAC,IAAI;SACf,CAAA;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,CAAC,CAAA;IACT,CAAC;AACH,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACI,MAAM,0BAA0B,GAAG,CAAC,IAAgD,EAAE,OAAsB,EAAE,EAAE;IACrH,MAAM,oBAAoB,GAAG,IAAA,oDAAuB,GAAE,CAAA;IAEtD,OAAO,IAAA,8BAAgB,EAAC;QACtB,QAAQ,EAAE,CAAC,yBAAU,CAAC,0BAA0B,EAAE,IAAI,EAAE,OAAO,CAAC;QAChE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;YACzB,OAAO,uBAAuB,CAAC,oBAAoB,EAAE,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;QACpF,CAAC;QACD,gBAAgB,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;YAC7B,OAAO,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;QACtC,CAAC;QACD,gBAAgB,EAAE,EAAE,GAAG,IAAI,EAAE,IAAI,EAAU;QAC3C,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;QAC7B,SAAS,EAAE,mBAAI,CAAC,SAAS,GAAG,EAAE;QAC9B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ;KACvE,CAAC,CAAA;AACJ,CAAC,CAAA;AAhBY,QAAA,0BAA0B,8BAgBtC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { SequenceIndexerGateway } from '@0xsequence/indexer';
|
|
2
|
-
/**
|
|
3
|
-
* Hook that provides an indexer gateway client for querying token balances across multiple chains.
|
|
4
|
-
* Unlike the regular indexer client, the gateway client can fetch token data from multiple
|
|
5
|
-
* chains in a single request.
|
|
6
|
-
*
|
|
7
|
-
* @returns A SequenceIndexerGateway instance
|
|
8
|
-
*
|
|
9
|
-
* @see {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useIndexerGatewayClient} for more detailed documentation.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```tsx
|
|
13
|
-
* import { useIndexerGatewayClient } from '@0xsequence/hooks'
|
|
14
|
-
*
|
|
15
|
-
* const TokenBalances = () => {
|
|
16
|
-
* const indexerGatewayClient = useIndexerGatewayClient()
|
|
17
|
-
*
|
|
18
|
-
* // Get balances across multiple chains in one call
|
|
19
|
-
* const { data } = useGetTokenBalancesSummary({
|
|
20
|
-
* filter: {
|
|
21
|
-
* accountAddresses: [address],
|
|
22
|
-
* omitNativeBalances: false
|
|
23
|
-
* }
|
|
24
|
-
* })
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare const useIndexerGatewayClient: () => SequenceIndexerGateway;
|
|
29
|
-
//# sourceMappingURL=useIndexerGatewayClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIndexerGatewayClient.d.ts","sourceRoot":"","sources":["../../../../src/hooks/IndexerGateway/useIndexerGatewayClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAK5D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,uBAAuB,8BAQnC,CAAA"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useIndexerGatewayClient = void 0;
|
|
4
|
-
const indexer_1 = require("@0xsequence/indexer");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const useConfig_js_1 = require("../useConfig.js");
|
|
7
|
-
/**
|
|
8
|
-
* Hook that provides an indexer gateway client for querying token balances across multiple chains.
|
|
9
|
-
* Unlike the regular indexer client, the gateway client can fetch token data from multiple
|
|
10
|
-
* chains in a single request.
|
|
11
|
-
*
|
|
12
|
-
* @returns A SequenceIndexerGateway instance
|
|
13
|
-
*
|
|
14
|
-
* @see {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useIndexerGatewayClient} for more detailed documentation.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```tsx
|
|
18
|
-
* import { useIndexerGatewayClient } from '@0xsequence/hooks'
|
|
19
|
-
*
|
|
20
|
-
* const TokenBalances = () => {
|
|
21
|
-
* const indexerGatewayClient = useIndexerGatewayClient()
|
|
22
|
-
*
|
|
23
|
-
* // Get balances across multiple chains in one call
|
|
24
|
-
* const { data } = useGetTokenBalancesSummary({
|
|
25
|
-
* filter: {
|
|
26
|
-
* accountAddresses: [address],
|
|
27
|
-
* omitNativeBalances: false
|
|
28
|
-
* }
|
|
29
|
-
* })
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
const useIndexerGatewayClient = () => {
|
|
34
|
-
const { env, projectAccessKey, jwt } = (0, useConfig_js_1.useConfig)();
|
|
35
|
-
const indexerGatewayClient = (0, react_1.useMemo)(() => {
|
|
36
|
-
return new indexer_1.SequenceIndexerGateway(env.indexerGatewayUrl, projectAccessKey, jwt);
|
|
37
|
-
}, [projectAccessKey, jwt]);
|
|
38
|
-
return indexerGatewayClient;
|
|
39
|
-
};
|
|
40
|
-
exports.useIndexerGatewayClient = useIndexerGatewayClient;
|
|
41
|
-
//# sourceMappingURL=useIndexerGatewayClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIndexerGatewayClient.js","sourceRoot":"","sources":["../../../../src/hooks/IndexerGateway/useIndexerGatewayClient.ts"],"names":[],"mappings":";;;AAAA,iDAA4D;AAC5D,iCAA+B;AAE/B,kDAA2C;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACI,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG,IAAA,wBAAS,GAAE,CAAA;IAElD,MAAM,oBAAoB,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QACxC,OAAO,IAAI,gCAAsB,CAAC,GAAG,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,GAAG,CAAC,CAAA;IACjF,CAAC,EAAE,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,CAAA;IAE3B,OAAO,oBAAoB,CAAA;AAC7B,CAAC,CAAA;AARY,QAAA,uBAAuB,2BAQnC"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { ContractInfo, GetContractInfoArgs } from '@0xsequence/metadata';
|
|
2
|
-
import { type UseQueryResult } from '@tanstack/react-query';
|
|
3
|
-
import type { HooksOptions } from '../../types/hooks.js';
|
|
4
|
-
/**
|
|
5
|
-
* Hook to fetch contract information.
|
|
6
|
-
* Handles ERC20/ERC721/ERC1155 contracts and native tokens (using ZERO_ADDRESS).
|
|
7
|
-
*
|
|
8
|
-
* For native tokens (like ETH, POL), it enriches the response with network-specific
|
|
9
|
-
* information like the native token symbol and network logo.
|
|
10
|
-
*
|
|
11
|
-
* @see {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useGetContractInfo} for more detailed documentation.
|
|
12
|
-
*
|
|
13
|
-
* @param getContractInfoArgs - Arguments for fetching contract info
|
|
14
|
-
* @param getContractInfoArgs.chainID - Chain ID as string (e.g., "1" for Ethereum mainnet)
|
|
15
|
-
* @param getContractInfoArgs.contractAddress - Contract address or ZERO_ADDRESS for native token
|
|
16
|
-
* @param options - Optional configuration for the query behavior
|
|
17
|
-
* @param options.disabled - If true, disables the query from automatically running
|
|
18
|
-
* @param options.retry - If true, retries failed queries
|
|
19
|
-
*
|
|
20
|
-
* Query configuration:
|
|
21
|
-
* - Marks data as stale after 10 minutes
|
|
22
|
-
* - Retries failed requests by default
|
|
23
|
-
* - Only enabled when chainID and contractAddress are present and not explicitly disabled
|
|
24
|
-
*
|
|
25
|
-
* @returns Query result containing contract information:
|
|
26
|
-
* - `name`: Contract/token name
|
|
27
|
-
* - `symbol`: Token symbol
|
|
28
|
-
* - `decimals`: Token decimals (if applicable)
|
|
29
|
-
* - `logoURI`: URL of the contract/token logo
|
|
30
|
-
* - `type`: Contract type (e.g., "ERC721", "ERC20")
|
|
31
|
-
* - Additional metadata from the contract
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```tsx
|
|
35
|
-
* // Fetch NFT collection info
|
|
36
|
-
* function CollectionDetails() {
|
|
37
|
-
* const { data: contractInfo } = useGetContractInfo({
|
|
38
|
-
* chainID: "1",
|
|
39
|
-
* contractAddress: "0x123..."
|
|
40
|
-
* })
|
|
41
|
-
*
|
|
42
|
-
* return (
|
|
43
|
-
* <div>
|
|
44
|
-
* <img src={contractInfo?.logoURI} />
|
|
45
|
-
* <h1>{contractInfo?.name}</h1>
|
|
46
|
-
* <span>Type: {contractInfo?.type}</span>
|
|
47
|
-
* </div>
|
|
48
|
-
* )
|
|
49
|
-
* }
|
|
50
|
-
*
|
|
51
|
-
* // Used in checkout for displaying collection info
|
|
52
|
-
* function OrderSummaryItem() {
|
|
53
|
-
* const { data: contractInfo } = useGetContractInfo({
|
|
54
|
-
* chainID: String(chainId),
|
|
55
|
-
* contractAddress
|
|
56
|
-
* })
|
|
57
|
-
*
|
|
58
|
-
* return (
|
|
59
|
-
* <div>
|
|
60
|
-
* <TokenImage src={contractInfo?.logoURI} />
|
|
61
|
-
* <Text>{contractInfo?.name || 'Unknown Collection'}</Text>
|
|
62
|
-
* </div>
|
|
63
|
-
* )
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
export declare const useGetContractInfo: (args: GetContractInfoArgs, options?: HooksOptions) => UseQueryResult<ContractInfo>;
|
|
68
|
-
//# sourceMappingURL=useGetContractInfo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGetContractInfo.d.ts","sourceRoot":"","sources":["../../../../src/hooks/Metadata/useGetContractInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE7E,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAGrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAKxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,mBAAmB,EAAE,UAAU,YAAY,KAAG,cAAc,CAAC,YAAY,CAyBjH,CAAA"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useGetContractInfo = void 0;
|
|
4
|
-
const network_1 = require("@0xsequence/network");
|
|
5
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
6
|
-
const constants_js_1 = require("../../constants.js");
|
|
7
|
-
const helpers_js_1 = require("../../utils/helpers.js");
|
|
8
|
-
const useMetadataClient_js_1 = require("./useMetadataClient.js");
|
|
9
|
-
/**
|
|
10
|
-
* Hook to fetch contract information.
|
|
11
|
-
* Handles ERC20/ERC721/ERC1155 contracts and native tokens (using ZERO_ADDRESS).
|
|
12
|
-
*
|
|
13
|
-
* For native tokens (like ETH, POL), it enriches the response with network-specific
|
|
14
|
-
* information like the native token symbol and network logo.
|
|
15
|
-
*
|
|
16
|
-
* @see {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useGetContractInfo} for more detailed documentation.
|
|
17
|
-
*
|
|
18
|
-
* @param getContractInfoArgs - Arguments for fetching contract info
|
|
19
|
-
* @param getContractInfoArgs.chainID - Chain ID as string (e.g., "1" for Ethereum mainnet)
|
|
20
|
-
* @param getContractInfoArgs.contractAddress - Contract address or ZERO_ADDRESS for native token
|
|
21
|
-
* @param options - Optional configuration for the query behavior
|
|
22
|
-
* @param options.disabled - If true, disables the query from automatically running
|
|
23
|
-
* @param options.retry - If true, retries failed queries
|
|
24
|
-
*
|
|
25
|
-
* Query configuration:
|
|
26
|
-
* - Marks data as stale after 10 minutes
|
|
27
|
-
* - Retries failed requests by default
|
|
28
|
-
* - Only enabled when chainID and contractAddress are present and not explicitly disabled
|
|
29
|
-
*
|
|
30
|
-
* @returns Query result containing contract information:
|
|
31
|
-
* - `name`: Contract/token name
|
|
32
|
-
* - `symbol`: Token symbol
|
|
33
|
-
* - `decimals`: Token decimals (if applicable)
|
|
34
|
-
* - `logoURI`: URL of the contract/token logo
|
|
35
|
-
* - `type`: Contract type (e.g., "ERC721", "ERC20")
|
|
36
|
-
* - Additional metadata from the contract
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```tsx
|
|
40
|
-
* // Fetch NFT collection info
|
|
41
|
-
* function CollectionDetails() {
|
|
42
|
-
* const { data: contractInfo } = useGetContractInfo({
|
|
43
|
-
* chainID: "1",
|
|
44
|
-
* contractAddress: "0x123..."
|
|
45
|
-
* })
|
|
46
|
-
*
|
|
47
|
-
* return (
|
|
48
|
-
* <div>
|
|
49
|
-
* <img src={contractInfo?.logoURI} />
|
|
50
|
-
* <h1>{contractInfo?.name}</h1>
|
|
51
|
-
* <span>Type: {contractInfo?.type}</span>
|
|
52
|
-
* </div>
|
|
53
|
-
* )
|
|
54
|
-
* }
|
|
55
|
-
*
|
|
56
|
-
* // Used in checkout for displaying collection info
|
|
57
|
-
* function OrderSummaryItem() {
|
|
58
|
-
* const { data: contractInfo } = useGetContractInfo({
|
|
59
|
-
* chainID: String(chainId),
|
|
60
|
-
* contractAddress
|
|
61
|
-
* })
|
|
62
|
-
*
|
|
63
|
-
* return (
|
|
64
|
-
* <div>
|
|
65
|
-
* <TokenImage src={contractInfo?.logoURI} />
|
|
66
|
-
* <Text>{contractInfo?.name || 'Unknown Collection'}</Text>
|
|
67
|
-
* </div>
|
|
68
|
-
* )
|
|
69
|
-
* }
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
const useGetContractInfo = (args, options) => {
|
|
73
|
-
const metadataClient = (0, useMetadataClient_js_1.useMetadataClient)();
|
|
74
|
-
return (0, react_query_1.useQuery)({
|
|
75
|
-
queryKey: [constants_js_1.QUERY_KEYS.useGetContractInfo, args, options],
|
|
76
|
-
queryFn: async () => {
|
|
77
|
-
const isNativeToken = (0, helpers_js_1.compareAddress)(constants_js_1.ZERO_ADDRESS, args.contractAddress);
|
|
78
|
-
const res = await metadataClient.getContractInfo(args);
|
|
79
|
-
const network = (0, network_1.findSupportedNetwork)(args.chainID);
|
|
80
|
-
return {
|
|
81
|
-
...res.contractInfo,
|
|
82
|
-
...(isNativeToken && network
|
|
83
|
-
? {
|
|
84
|
-
...network.nativeToken,
|
|
85
|
-
logoURI: network.logoURI
|
|
86
|
-
}
|
|
87
|
-
: {})
|
|
88
|
-
};
|
|
89
|
-
},
|
|
90
|
-
retry: options?.retry ?? false,
|
|
91
|
-
staleTime: constants_js_1.time.oneMinute * 10,
|
|
92
|
-
enabled: !!args.chainID && !!args.contractAddress && !options?.disabled
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
exports.useGetContractInfo = useGetContractInfo;
|
|
96
|
-
//# sourceMappingURL=useGetContractInfo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGetContractInfo.js","sourceRoot":"","sources":["../../../../src/hooks/Metadata/useGetContractInfo.ts"],"names":[],"mappings":";;;AACA,iDAA0D;AAC1D,uDAAqE;AAErE,qDAAmE;AAEnE,uDAAuD;AAEvD,iEAA0D;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACI,MAAM,kBAAkB,GAAG,CAAC,IAAyB,EAAE,OAAsB,EAAgC,EAAE;IACpH,MAAM,cAAc,GAAG,IAAA,wCAAiB,GAAE,CAAA;IAE1C,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,yBAAU,CAAC,kBAAkB,EAAE,IAAI,EAAE,OAAO,CAAC;QACxD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,aAAa,GAAG,IAAA,2BAAc,EAAC,2BAAY,EAAE,IAAI,CAAC,eAAe,CAAC,CAAA;YAExE,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;YACtD,MAAM,OAAO,GAAG,IAAA,8BAAoB,EAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAElD,OAAO;gBACL,GAAG,GAAG,CAAC,YAAY;gBACnB,GAAG,CAAC,aAAa,IAAI,OAAO;oBAC1B,CAAC,CAAC;wBACE,GAAG,OAAO,CAAC,WAAW;wBACtB,OAAO,EAAE,OAAO,CAAC,OAAO;qBACzB;oBACH,CAAC,CAAC,EAAE,CAAC;aACR,CAAA;QACH,CAAC;QACD,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,KAAK;QAC9B,SAAS,EAAE,mBAAI,CAAC,SAAS,GAAG,EAAE;QAC9B,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,OAAO,EAAE,QAAQ;KACxE,CAAC,CAAA;AACJ,CAAC,CAAA;AAzBY,QAAA,kBAAkB,sBAyB9B"}
|