@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.
- 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 +83 -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 +15 -18
- 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,97 +0,0 @@
|
|
|
1
|
-
import { type Page } from '@0xsequence/indexer';
|
|
2
|
-
import type { HooksOptions } from '../../types/hooks.js';
|
|
3
|
-
interface GetTransactionHistoryArgs {
|
|
4
|
-
accountAddresses: string[];
|
|
5
|
-
contractAddresses?: string[];
|
|
6
|
-
tokenId?: string;
|
|
7
|
-
page?: Page;
|
|
8
|
-
}
|
|
9
|
-
export interface UseGetTransactionHistoryArgs extends GetTransactionHistoryArgs {
|
|
10
|
-
chainId: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Hook to fetch and paginate through transaction history for a given account and chain.
|
|
14
|
-
*
|
|
15
|
-
* This hook provides methods to fetch transaction history with support for infinite scrolling.
|
|
16
|
-
* It can filter transactions by contract address and token ID, making it useful for both
|
|
17
|
-
* general account history and specific asset history views.
|
|
18
|
-
*
|
|
19
|
-
* @see {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useGetTransactionHistory} for more detailed documentation.
|
|
20
|
-
*
|
|
21
|
-
* @param args - Configuration object for the transaction history query {@link GetTransactionHistoryArgs}
|
|
22
|
-
*
|
|
23
|
-
* @returns A hook that returns the transaction history for a given account and chain. {@link UseGetTransactionHistoryReturnType}
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```tsx
|
|
27
|
-
* import { useGetTransactionHistory } from '@0xsequence/hooks'
|
|
28
|
-
*
|
|
29
|
-
* const TransactionList = () => {
|
|
30
|
-
* const {
|
|
31
|
-
* data,
|
|
32
|
-
* fetchNextPage,
|
|
33
|
-
* hasNextPage,
|
|
34
|
-
* isLoading,
|
|
35
|
-
* isFetchingNextPage
|
|
36
|
-
* } = useGetTransactionHistory({
|
|
37
|
-
* chainId: 1,
|
|
38
|
-
* accountAddresses: ['0x123...'],
|
|
39
|
-
* // Optional filters:
|
|
40
|
-
* // contractAddresses: ['0x456...'],
|
|
41
|
-
* // tokenId: '1'
|
|
42
|
-
* })
|
|
43
|
-
*
|
|
44
|
-
* if (isLoading) return <div>Loading...</div>
|
|
45
|
-
*
|
|
46
|
-
* return (
|
|
47
|
-
* <div>
|
|
48
|
-
* {data?.pages.map(page =>
|
|
49
|
-
* page.transactions.map(tx => (
|
|
50
|
-
* <div key={tx.txnHash}>
|
|
51
|
-
* Transaction: {tx.txnHash}
|
|
52
|
-
* Block: {tx.blockNumber}
|
|
53
|
-
* Time: {tx.timestamp}
|
|
54
|
-
* </div>
|
|
55
|
-
* ))
|
|
56
|
-
* )}
|
|
57
|
-
*
|
|
58
|
-
* {hasNextPage && (
|
|
59
|
-
* <button
|
|
60
|
-
* onClick={() => fetchNextPage()}
|
|
61
|
-
* disabled={isFetchingNextPage}
|
|
62
|
-
* >
|
|
63
|
-
* {isFetchingNextPage ? 'Loading more...' : 'Load more'}
|
|
64
|
-
* </button>
|
|
65
|
-
* )}
|
|
66
|
-
* </div>
|
|
67
|
-
* )
|
|
68
|
-
* }
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
export declare const useGetTransactionHistory: (args: UseGetTransactionHistoryArgs, options?: HooksOptions) => import("@tanstack/react-query").UseInfiniteQueryResult<import("@tanstack/react-query").InfiniteData<{
|
|
72
|
-
transactions: {
|
|
73
|
-
transfers: {
|
|
74
|
-
from: `0x${string}`;
|
|
75
|
-
to: `0x${string}`;
|
|
76
|
-
transferType: import("@0xsequence/indexer").TxnTransferType;
|
|
77
|
-
contractAddress: string;
|
|
78
|
-
contractType: import("@0xsequence/indexer").ContractType;
|
|
79
|
-
tokenIds?: Array<string>;
|
|
80
|
-
amounts: Array<string>;
|
|
81
|
-
logIndex: number;
|
|
82
|
-
contractInfo?: import("@0xsequence/indexer").ContractInfo;
|
|
83
|
-
tokenMetadata?: {
|
|
84
|
-
[key: string]: import("@0xsequence/indexer").TokenMetadata;
|
|
85
|
-
};
|
|
86
|
-
}[] | undefined;
|
|
87
|
-
txnHash: string;
|
|
88
|
-
blockNumber: number;
|
|
89
|
-
blockHash: string;
|
|
90
|
-
chainId: number;
|
|
91
|
-
metaTxnID?: string;
|
|
92
|
-
timestamp: string;
|
|
93
|
-
}[];
|
|
94
|
-
page: Page;
|
|
95
|
-
}, unknown>, Error>;
|
|
96
|
-
export {};
|
|
97
|
-
//# sourceMappingURL=useGetTransactionHistory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGetTransactionHistory.d.ts","sourceRoot":"","sources":["../../../../src/hooks/Indexer/useGetTransactionHistory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAKhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAIxD,UAAU,yBAAyB;IACjC,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ;AAED,MAAM,WAAW,4BAA6B,SAAQ,yBAAyB;IAC7E,OAAO,EAAE,MAAM,CAAA;CAChB;AAqDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,eAAO,MAAM,wBAAwB,GAAI,MAAM,4BAA4B,EAAE,UAAU,YAAY;;;;;;;;;;;;;;;;;;;;;;;;mBAmBlG,CAAA"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useGetTransactionHistory = void 0;
|
|
4
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
5
|
-
const viem_1 = require("viem");
|
|
6
|
-
const constants_js_1 = require("../../constants.js");
|
|
7
|
-
const useIndexerClient_js_1 = require("./useIndexerClient.js");
|
|
8
|
-
/**
|
|
9
|
-
* Return type for the useGetTransactionHistory hook.
|
|
10
|
-
*
|
|
11
|
-
* @property data - The paginated transaction history data
|
|
12
|
-
* @property data.pages - Array of page results, each containing:
|
|
13
|
-
* - transactions: Array of transaction objects with:
|
|
14
|
-
* - txnHash: Transaction hash
|
|
15
|
-
* - blockNumber: Block number where transaction was mined
|
|
16
|
-
* - blockHash: Hash of the block
|
|
17
|
-
* - chainId: Chain ID where transaction occurred
|
|
18
|
-
* - metaTxnID: Optional meta transaction ID
|
|
19
|
-
* - transfers: Optional array of transaction transfers
|
|
20
|
-
* - timestamp: Transaction timestamp
|
|
21
|
-
* - page: Pagination information:
|
|
22
|
-
* - after: Cursor for the next page
|
|
23
|
-
* - more: Whether more results exist in the next page
|
|
24
|
-
* - pageSize: Number of results per page
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
const getTransactionHistory = async (indexerClient, { accountAddresses, contractAddresses, tokenId, page }) => {
|
|
28
|
-
const res = await indexerClient.getTransactionHistory({
|
|
29
|
-
includeMetadata: true,
|
|
30
|
-
page,
|
|
31
|
-
filter: {
|
|
32
|
-
accountAddresses,
|
|
33
|
-
contractAddresses,
|
|
34
|
-
tokenID: tokenId
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const transactions = res.transactions.map(transaction => {
|
|
38
|
-
return {
|
|
39
|
-
...transaction,
|
|
40
|
-
transfers: transaction.transfers?.map(transfer => ({
|
|
41
|
-
...transfer,
|
|
42
|
-
from: (0, viem_1.getAddress)(transfer.from),
|
|
43
|
-
to: (0, viem_1.getAddress)(transfer.to)
|
|
44
|
-
}))
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
return {
|
|
48
|
-
...res,
|
|
49
|
-
transactions
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Hook to fetch and paginate through transaction history for a given account and chain.
|
|
54
|
-
*
|
|
55
|
-
* This hook provides methods to fetch transaction history with support for infinite scrolling.
|
|
56
|
-
* It can filter transactions by contract address and token ID, making it useful for both
|
|
57
|
-
* general account history and specific asset history views.
|
|
58
|
-
*
|
|
59
|
-
* @see {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useGetTransactionHistory} for more detailed documentation.
|
|
60
|
-
*
|
|
61
|
-
* @param args - Configuration object for the transaction history query {@link GetTransactionHistoryArgs}
|
|
62
|
-
*
|
|
63
|
-
* @returns A hook that returns the transaction history for a given account and chain. {@link UseGetTransactionHistoryReturnType}
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```tsx
|
|
67
|
-
* import { useGetTransactionHistory } from '@0xsequence/hooks'
|
|
68
|
-
*
|
|
69
|
-
* const TransactionList = () => {
|
|
70
|
-
* const {
|
|
71
|
-
* data,
|
|
72
|
-
* fetchNextPage,
|
|
73
|
-
* hasNextPage,
|
|
74
|
-
* isLoading,
|
|
75
|
-
* isFetchingNextPage
|
|
76
|
-
* } = useGetTransactionHistory({
|
|
77
|
-
* chainId: 1,
|
|
78
|
-
* accountAddresses: ['0x123...'],
|
|
79
|
-
* // Optional filters:
|
|
80
|
-
* // contractAddresses: ['0x456...'],
|
|
81
|
-
* // tokenId: '1'
|
|
82
|
-
* })
|
|
83
|
-
*
|
|
84
|
-
* if (isLoading) return <div>Loading...</div>
|
|
85
|
-
*
|
|
86
|
-
* return (
|
|
87
|
-
* <div>
|
|
88
|
-
* {data?.pages.map(page =>
|
|
89
|
-
* page.transactions.map(tx => (
|
|
90
|
-
* <div key={tx.txnHash}>
|
|
91
|
-
* Transaction: {tx.txnHash}
|
|
92
|
-
* Block: {tx.blockNumber}
|
|
93
|
-
* Time: {tx.timestamp}
|
|
94
|
-
* </div>
|
|
95
|
-
* ))
|
|
96
|
-
* )}
|
|
97
|
-
*
|
|
98
|
-
* {hasNextPage && (
|
|
99
|
-
* <button
|
|
100
|
-
* onClick={() => fetchNextPage()}
|
|
101
|
-
* disabled={isFetchingNextPage}
|
|
102
|
-
* >
|
|
103
|
-
* {isFetchingNextPage ? 'Loading more...' : 'Load more'}
|
|
104
|
-
* </button>
|
|
105
|
-
* )}
|
|
106
|
-
* </div>
|
|
107
|
-
* )
|
|
108
|
-
* }
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
const useGetTransactionHistory = (args, options) => {
|
|
112
|
-
const indexerClient = (0, useIndexerClient_js_1.useIndexerClient)(args.chainId);
|
|
113
|
-
return (0, react_query_1.useInfiniteQuery)({
|
|
114
|
-
queryKey: [constants_js_1.QUERY_KEYS.useGetTransactionHistory, args, options],
|
|
115
|
-
queryFn: ({ pageParam }) => {
|
|
116
|
-
return getTransactionHistory(indexerClient, {
|
|
117
|
-
...args,
|
|
118
|
-
page: pageParam
|
|
119
|
-
});
|
|
120
|
-
},
|
|
121
|
-
getNextPageParam: ({ page }) => {
|
|
122
|
-
return page?.more ? page : undefined;
|
|
123
|
-
},
|
|
124
|
-
initialPageParam: { ...args?.page },
|
|
125
|
-
retry: options?.retry ?? false,
|
|
126
|
-
staleTime: constants_js_1.time.oneSecond * 30,
|
|
127
|
-
enabled: !!args.chainId && args.accountAddresses.length > 0 && !options?.disabled
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
exports.useGetTransactionHistory = useGetTransactionHistory;
|
|
131
|
-
//# sourceMappingURL=useGetTransactionHistory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGetTransactionHistory.js","sourceRoot":"","sources":["../../../../src/hooks/Indexer/useGetTransactionHistory.ts"],"names":[],"mappings":";;;AACA,uDAAwD;AACxD,+BAAiC;AAEjC,qDAAqD;AAGrD,+DAAwD;AAaxD;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,qBAAqB,GAAG,KAAK,EACjC,aAA8B,EAC9B,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAA6B,EACjF,EAAE;IACF,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,qBAAqB,CAAC;QACpD,eAAe,EAAE,IAAI;QACrB,IAAI;QACJ,MAAM,EAAE;YACN,gBAAgB;YAChB,iBAAiB;YACjB,OAAO,EAAE,OAAO;SACjB;KACF,CAAC,CAAA;IAEF,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;QACtD,OAAO;YACL,GAAG,WAAW;YACd,SAAS,EAAE,WAAW,CAAC,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;gBACjD,GAAG,QAAQ;gBACX,IAAI,EAAE,IAAA,iBAAU,EAAC,QAAQ,CAAC,IAAI,CAAC;gBAC/B,EAAE,EAAE,IAAA,iBAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;aAC5B,CAAC,CAAC;SACJ,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO;QACL,GAAG,GAAG;QACN,YAAY;KACb,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACI,MAAM,wBAAwB,GAAG,CAAC,IAAkC,EAAE,OAAsB,EAAE,EAAE;IACrG,MAAM,aAAa,GAAG,IAAA,sCAAgB,EAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAEpD,OAAO,IAAA,8BAAgB,EAAC;QACtB,QAAQ,EAAE,CAAC,yBAAU,CAAC,wBAAwB,EAAE,IAAI,EAAE,OAAO,CAAC;QAC9D,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;YACzB,OAAO,qBAAqB,CAAC,aAAa,EAAE;gBAC1C,GAAG,IAAI;gBACP,IAAI,EAAE,SAAS;aAChB,CAAC,CAAA;QACJ,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,KAAK;QAC9B,SAAS,EAAE,mBAAI,CAAC,SAAS,GAAG,EAAE;QAC9B,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ;KAClF,CAAC,CAAA;AACJ,CAAC,CAAA;AAnBY,QAAA,wBAAwB,4BAmBpC"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { Transaction } from '@0xsequence/indexer';
|
|
2
|
-
import type { HooksOptions } from '../../types/hooks.js';
|
|
3
|
-
export interface GetTransactionHistorySummaryArgs {
|
|
4
|
-
accountAddresses: string[];
|
|
5
|
-
chainIds: number[];
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* A hook that retrieves a comprehensive transaction history summary across multiple chains for a given account address.
|
|
9
|
-
* The transactions are ordered by timestamp (newest first) and include detailed transfer information.
|
|
10
|
-
*
|
|
11
|
-
* Implementation details:
|
|
12
|
-
* - Uses Promise.all with an array of indexer clients to fetch transactions from all specified chains in parallel
|
|
13
|
-
* - Flattens and sorts the combined results by timestamp
|
|
14
|
-
* - Normalizes all addresses in transfer objects using viem's getAddress
|
|
15
|
-
*
|
|
16
|
-
* @param getTransactionHistorySummaryArgs - Configuration object for the transaction history query
|
|
17
|
-
* @param getTransactionHistorySummaryArgs.accountAddress - The account address to fetch transactions for
|
|
18
|
-
* @param getTransactionHistorySummaryArgs.chainIds - Array of chain IDs to fetch transactions from. Each chain ID will be queried in parallel.
|
|
19
|
-
* @param options - Optional configuration for the hook behavior
|
|
20
|
-
* @param options.disabled - If true, disables the query
|
|
21
|
-
* @param options.retry - If false, retries failed requests
|
|
22
|
-
*
|
|
23
|
-
* @returns A React Query result object containing:
|
|
24
|
-
* - data: Array of Transaction objects combined from all specified chains, each containing:
|
|
25
|
-
* - txnHash: Transaction hash
|
|
26
|
-
* - chainId: Chain ID where transaction occurred
|
|
27
|
-
* - timestamp: Transaction timestamp
|
|
28
|
-
* - transfers: Array of transfer objects with normalized addresses
|
|
29
|
-
* - blockNumber: Block number where transaction was mined
|
|
30
|
-
* - blockHash: Hash of the block
|
|
31
|
-
* - metaTxnID: Optional meta transaction ID
|
|
32
|
-
* - Other standard React Query properties (isLoading, isError, etc.)
|
|
33
|
-
*
|
|
34
|
-
* @see {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useGetTransactionHistorySummary} for more detailed documentation.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```tsx
|
|
38
|
-
* import { useGetTransactionHistorySummary } from '@0xsequence/hooks'
|
|
39
|
-
* import { useConnection } from 'wagmi'
|
|
40
|
-
*
|
|
41
|
-
* // Basic usage in a component
|
|
42
|
-
* const TransactionHistory = () => {
|
|
43
|
-
* const { address: accountAddress } = useConnection()
|
|
44
|
-
* const {
|
|
45
|
-
* data: transactionHistory = [],
|
|
46
|
-
* isLoading: isLoadingTransactionHistory
|
|
47
|
-
* } = useGetTransactionHistorySummary({
|
|
48
|
-
* accountAddress: accountAddress || '',
|
|
49
|
-
* chainIds: [1, 137]
|
|
50
|
-
* })
|
|
51
|
-
*
|
|
52
|
-
* return (
|
|
53
|
-
* <div>
|
|
54
|
-
* {transactionHistory.map(tx => (
|
|
55
|
-
* <div key={tx.txnHash}>
|
|
56
|
-
* Transaction: {tx.txnHash}
|
|
57
|
-
* Chain: {tx.chainId}
|
|
58
|
-
* Time: {tx.timestamp}
|
|
59
|
-
* </div>
|
|
60
|
-
* ))}
|
|
61
|
-
* </div>
|
|
62
|
-
* )
|
|
63
|
-
* }
|
|
64
|
-
* ```
|
|
65
|
-
*
|
|
66
|
-
* @remarks
|
|
67
|
-
* - The hook uses the Sequence Indexer service to fetch transaction data
|
|
68
|
-
* - Creates a separate indexer client for each chain ID and fetches from all in parallel
|
|
69
|
-
* - Transactions from all chains are combined and sorted by timestamp (newest first)
|
|
70
|
-
* - All addresses in transfer objects are normalized using viem's getAddress
|
|
71
|
-
* - The query is enabled only when chainIds array is not empty and accountAddress is provided
|
|
72
|
-
* - The query result is cached for 30 seconds (staleTime)
|
|
73
|
-
* - The query automatically refetches when the component is mounted
|
|
74
|
-
*/
|
|
75
|
-
export declare const useGetTransactionHistorySummary: (getTransactionHistorySummaryArgs: GetTransactionHistorySummaryArgs, options?: HooksOptions) => import("@tanstack/react-query").UseQueryResult<Transaction[], Error>;
|
|
76
|
-
//# sourceMappingURL=useGetTransactionHistorySummary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGetTransactionHistorySummary.d.ts","sourceRoot":"","sources":["../../../../src/hooks/Indexer/useGetTransactionHistorySummary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAKvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAIxD,MAAM,WAAW,gCAAgC;IAC/C,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAoCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,eAAO,MAAM,+BAA+B,GAC1C,kCAAkC,gCAAgC,EAClE,UAAU,YAAY,yEAiBvB,CAAA"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useGetTransactionHistorySummary = void 0;
|
|
4
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
5
|
-
const viem_1 = require("viem");
|
|
6
|
-
const constants_js_1 = require("../../constants.js");
|
|
7
|
-
const useIndexerClient_js_1 = require("./useIndexerClient.js");
|
|
8
|
-
const getTransactionHistorySummary = async (indexerClients, { accountAddresses }) => {
|
|
9
|
-
const histories = await Promise.all(Array.from(indexerClients.values()).map(indexerClient => indexerClient.getTransactionHistory({
|
|
10
|
-
filter: {
|
|
11
|
-
accountAddresses
|
|
12
|
-
},
|
|
13
|
-
includeMetadata: true
|
|
14
|
-
})));
|
|
15
|
-
const unorderedTransactions = histories.map(history => history.transactions).flat();
|
|
16
|
-
const orderedTransactions = unorderedTransactions.sort((a, b) => {
|
|
17
|
-
const firstDate = new Date(a.timestamp).getTime();
|
|
18
|
-
const secondDate = new Date(b.timestamp).getTime();
|
|
19
|
-
return secondDate - firstDate;
|
|
20
|
-
});
|
|
21
|
-
const transactions = orderedTransactions.map(transaction => ({
|
|
22
|
-
...transaction,
|
|
23
|
-
transfers: transaction.transfers?.map(transfer => ({
|
|
24
|
-
...transfer,
|
|
25
|
-
from: (0, viem_1.getAddress)(transfer.from),
|
|
26
|
-
to: (0, viem_1.getAddress)(transfer.to)
|
|
27
|
-
}))
|
|
28
|
-
}));
|
|
29
|
-
return transactions;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* A hook that retrieves a comprehensive transaction history summary across multiple chains for a given account address.
|
|
33
|
-
* The transactions are ordered by timestamp (newest first) and include detailed transfer information.
|
|
34
|
-
*
|
|
35
|
-
* Implementation details:
|
|
36
|
-
* - Uses Promise.all with an array of indexer clients to fetch transactions from all specified chains in parallel
|
|
37
|
-
* - Flattens and sorts the combined results by timestamp
|
|
38
|
-
* - Normalizes all addresses in transfer objects using viem's getAddress
|
|
39
|
-
*
|
|
40
|
-
* @param getTransactionHistorySummaryArgs - Configuration object for the transaction history query
|
|
41
|
-
* @param getTransactionHistorySummaryArgs.accountAddress - The account address to fetch transactions for
|
|
42
|
-
* @param getTransactionHistorySummaryArgs.chainIds - Array of chain IDs to fetch transactions from. Each chain ID will be queried in parallel.
|
|
43
|
-
* @param options - Optional configuration for the hook behavior
|
|
44
|
-
* @param options.disabled - If true, disables the query
|
|
45
|
-
* @param options.retry - If false, retries failed requests
|
|
46
|
-
*
|
|
47
|
-
* @returns A React Query result object containing:
|
|
48
|
-
* - data: Array of Transaction objects combined from all specified chains, each containing:
|
|
49
|
-
* - txnHash: Transaction hash
|
|
50
|
-
* - chainId: Chain ID where transaction occurred
|
|
51
|
-
* - timestamp: Transaction timestamp
|
|
52
|
-
* - transfers: Array of transfer objects with normalized addresses
|
|
53
|
-
* - blockNumber: Block number where transaction was mined
|
|
54
|
-
* - blockHash: Hash of the block
|
|
55
|
-
* - metaTxnID: Optional meta transaction ID
|
|
56
|
-
* - Other standard React Query properties (isLoading, isError, etc.)
|
|
57
|
-
*
|
|
58
|
-
* @see {@link https://docs.sequence.xyz/sdk/web/hooks-sdk/hooks/useGetTransactionHistorySummary} for more detailed documentation.
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```tsx
|
|
62
|
-
* import { useGetTransactionHistorySummary } from '@0xsequence/hooks'
|
|
63
|
-
* import { useConnection } from 'wagmi'
|
|
64
|
-
*
|
|
65
|
-
* // Basic usage in a component
|
|
66
|
-
* const TransactionHistory = () => {
|
|
67
|
-
* const { address: accountAddress } = useConnection()
|
|
68
|
-
* const {
|
|
69
|
-
* data: transactionHistory = [],
|
|
70
|
-
* isLoading: isLoadingTransactionHistory
|
|
71
|
-
* } = useGetTransactionHistorySummary({
|
|
72
|
-
* accountAddress: accountAddress || '',
|
|
73
|
-
* chainIds: [1, 137]
|
|
74
|
-
* })
|
|
75
|
-
*
|
|
76
|
-
* return (
|
|
77
|
-
* <div>
|
|
78
|
-
* {transactionHistory.map(tx => (
|
|
79
|
-
* <div key={tx.txnHash}>
|
|
80
|
-
* Transaction: {tx.txnHash}
|
|
81
|
-
* Chain: {tx.chainId}
|
|
82
|
-
* Time: {tx.timestamp}
|
|
83
|
-
* </div>
|
|
84
|
-
* ))}
|
|
85
|
-
* </div>
|
|
86
|
-
* )
|
|
87
|
-
* }
|
|
88
|
-
* ```
|
|
89
|
-
*
|
|
90
|
-
* @remarks
|
|
91
|
-
* - The hook uses the Sequence Indexer service to fetch transaction data
|
|
92
|
-
* - Creates a separate indexer client for each chain ID and fetches from all in parallel
|
|
93
|
-
* - Transactions from all chains are combined and sorted by timestamp (newest first)
|
|
94
|
-
* - All addresses in transfer objects are normalized using viem's getAddress
|
|
95
|
-
* - The query is enabled only when chainIds array is not empty and accountAddress is provided
|
|
96
|
-
* - The query result is cached for 30 seconds (staleTime)
|
|
97
|
-
* - The query automatically refetches when the component is mounted
|
|
98
|
-
*/
|
|
99
|
-
const useGetTransactionHistorySummary = (getTransactionHistorySummaryArgs, options) => {
|
|
100
|
-
const indexerClients = (0, useIndexerClient_js_1.useIndexerClients)(getTransactionHistorySummaryArgs.chainIds);
|
|
101
|
-
return (0, react_query_1.useQuery)({
|
|
102
|
-
queryKey: [constants_js_1.QUERY_KEYS.useGetTransactionHistorySummary, getTransactionHistorySummaryArgs, options],
|
|
103
|
-
queryFn: async () => {
|
|
104
|
-
return await getTransactionHistorySummary(indexerClients, getTransactionHistorySummaryArgs);
|
|
105
|
-
},
|
|
106
|
-
retry: options?.retry ?? false,
|
|
107
|
-
staleTime: constants_js_1.time.oneSecond * 30,
|
|
108
|
-
refetchOnMount: true,
|
|
109
|
-
enabled: getTransactionHistorySummaryArgs.chainIds.length > 0 &&
|
|
110
|
-
getTransactionHistorySummaryArgs.accountAddresses.length > 0 &&
|
|
111
|
-
!options?.disabled
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
exports.useGetTransactionHistorySummary = useGetTransactionHistorySummary;
|
|
115
|
-
//# sourceMappingURL=useGetTransactionHistorySummary.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGetTransactionHistorySummary.js","sourceRoot":"","sources":["../../../../src/hooks/Indexer/useGetTransactionHistorySummary.ts"],"names":[],"mappings":";;;AACA,uDAAgD;AAChD,+BAAiC;AAEjC,qDAAqD;AAGrD,+DAAyD;AAOzD,MAAM,4BAA4B,GAAG,KAAK,EACxC,cAA4C,EAC5C,EAAE,gBAAgB,EAAoC,EAC9B,EAAE;IAC1B,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CACjC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CACtD,aAAa,CAAC,qBAAqB,CAAC;QAClC,MAAM,EAAE;YACN,gBAAgB;SACjB;QACD,eAAe,EAAE,IAAI;KACtB,CAAC,CACH,CACF,CAAA;IAED,MAAM,qBAAqB,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,CAAA;IACnF,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC9D,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAA;QACjD,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAA;QAClD,OAAO,UAAU,GAAG,SAAS,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,MAAM,YAAY,GAAG,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAC3D,GAAG,WAAW;QACd,SAAS,EAAE,WAAW,CAAC,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YACjD,GAAG,QAAQ;YACX,IAAI,EAAE,IAAA,iBAAU,EAAC,QAAQ,CAAC,IAAI,CAAC;YAC/B,EAAE,EAAE,IAAA,iBAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;SAC5B,CAAC,CAAC;KACJ,CAAC,CAAC,CAAA;IAEH,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACI,MAAM,+BAA+B,GAAG,CAC7C,gCAAkE,EAClE,OAAsB,EACtB,EAAE;IACF,MAAM,cAAc,GAAG,IAAA,uCAAiB,EAAC,gCAAgC,CAAC,QAAQ,CAAC,CAAA;IAEnF,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,yBAAU,CAAC,+BAA+B,EAAE,gCAAgC,EAAE,OAAO,CAAC;QACjG,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,OAAO,MAAM,4BAA4B,CAAC,cAAc,EAAE,gCAAgC,CAAC,CAAA;QAC7F,CAAC;QACD,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,KAAK;QAC9B,SAAS,EAAE,mBAAI,CAAC,SAAS,GAAG,EAAE;QAC9B,cAAc,EAAE,IAAI;QACpB,OAAO,EACL,gCAAgC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;YACpD,gCAAgC,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC;YAC5D,CAAC,OAAO,EAAE,QAAQ;KACrB,CAAC,CAAA;AACJ,CAAC,CAAA;AAnBY,QAAA,+BAA+B,mCAmB3C"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { SequenceIndexer } from '@0xsequence/indexer';
|
|
2
|
-
import { ChainId } from '@0xsequence/network';
|
|
3
|
-
/**
|
|
4
|
-
* Hook that creates and manages a Sequence Indexer client for a specific chain.
|
|
5
|
-
*
|
|
6
|
-
* This hook maintains a cached indexer client for the specified chain ID,
|
|
7
|
-
* initializing it with the appropriate indexer URL based on the network
|
|
8
|
-
* and environment configuration.
|
|
9
|
-
*
|
|
10
|
-
* Implementation details:
|
|
11
|
-
* - Creates a new SequenceIndexer instance for the specified chain ID if it doesn't exist
|
|
12
|
-
* - Caches the client in a Map to avoid recreating it unnecessarily
|
|
13
|
-
* - Uses projectAccessKey for authentication
|
|
14
|
-
* - Constructs appropriate indexer URL based on network and environment
|
|
15
|
-
*
|
|
16
|
-
* @param chainId - The chain ID to create an indexer client for
|
|
17
|
-
* @returns A SequenceIndexer instance for the specified chain
|
|
18
|
-
*
|
|
19
|
-
* @throws Error if an indexer client cannot be created for the specified chain ID
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* const TokenBalanceChecker = () => {
|
|
24
|
-
* const chainId = useChainId()
|
|
25
|
-
* const indexerClient = useIndexerClient(chainId)
|
|
26
|
-
* const { address } = useConnection()
|
|
27
|
-
*
|
|
28
|
-
* const checkBalance = async () => {
|
|
29
|
-
* // Get native token balance
|
|
30
|
-
* const nativeBalance = await indexerClient.getNativeTokenBalance({
|
|
31
|
-
* accountAddress: address
|
|
32
|
-
* })
|
|
33
|
-
*
|
|
34
|
-
* // Get token balances
|
|
35
|
-
* const tokenBalances = await indexerClient.getTokenBalancesSummary({
|
|
36
|
-
* filter: {
|
|
37
|
-
* accountAddresses: [address],
|
|
38
|
-
* contractStatus: ContractVerificationStatus.ALL,
|
|
39
|
-
* omitNativeBalances: true
|
|
40
|
-
* }
|
|
41
|
-
* })
|
|
42
|
-
* }
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @remarks
|
|
47
|
-
* - The client is memoized based on projectAccessKey to prevent recreation
|
|
48
|
-
* - The client is initialized only once per chain ID
|
|
49
|
-
* - The environment configuration determines the indexer URL for the network
|
|
50
|
-
* - Throws an error if the chain ID is not supported or client creation fails
|
|
51
|
-
* - Used internally by useIndexerClients to manage multiple chain clients
|
|
52
|
-
*/
|
|
53
|
-
export declare const useIndexerClient: (chainId: ChainId) => SequenceIndexer;
|
|
54
|
-
/**
|
|
55
|
-
* Hook that creates and manages Sequence Indexer clients for multiple chains.
|
|
56
|
-
*
|
|
57
|
-
* This hook maintains a map of indexer clients, one for each specified chain ID.
|
|
58
|
-
* Each client is initialized with the appropriate indexer URL based on the network
|
|
59
|
-
* and environment configuration.
|
|
60
|
-
*
|
|
61
|
-
* Implementation details:
|
|
62
|
-
* - Creates a new SequenceIndexer instance for each unique chain ID
|
|
63
|
-
* - Caches clients in a Map to avoid recreating them unnecessarily
|
|
64
|
-
* - Uses projectAccessKey for authentication
|
|
65
|
-
* - Constructs appropriate indexer URLs based on network and environment
|
|
66
|
-
*
|
|
67
|
-
* @param chainIds - Array of chain IDs to create indexer clients for
|
|
68
|
-
* @returns A Map where keys are chain IDs and values are the corresponding SequenceIndexer instances
|
|
69
|
-
*
|
|
70
|
-
* @throws Error if an indexer client cannot be created for any of the specified chain IDs
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```typescript
|
|
75
|
-
* const TransactionFetcher = () => {
|
|
76
|
-
* // Get indexer clients for Ethereum mainnet and Polygon
|
|
77
|
-
* const indexerClients = useIndexerClients([1, 137])
|
|
78
|
-
*
|
|
79
|
-
* // Use the clients to fetch data
|
|
80
|
-
* const fetchData = async () => {
|
|
81
|
-
* // Get Ethereum client
|
|
82
|
-
* const ethClient = indexerClients.get(1)
|
|
83
|
-
* // Get Polygon client
|
|
84
|
-
* const polygonClient = indexerClients.get(137)
|
|
85
|
-
*
|
|
86
|
-
* // Make parallel requests
|
|
87
|
-
* const [ethData, polygonData] = await Promise.all([
|
|
88
|
-
* ethClient.getTransactionHistory(...),
|
|
89
|
-
* polygonClient.getTransactionHistory(...)
|
|
90
|
-
* ])
|
|
91
|
-
* }
|
|
92
|
-
* }
|
|
93
|
-
* ```
|
|
94
|
-
*
|
|
95
|
-
* @remarks
|
|
96
|
-
* - The clients are memoized based on projectAccessKey to prevent recreation
|
|
97
|
-
* - Each client is initialized only once per chain ID
|
|
98
|
-
* - The environment configuration determines the indexer URL for each network
|
|
99
|
-
* - Throws an error if a chain ID is not supported or client creation fails
|
|
100
|
-
*/
|
|
101
|
-
export declare const useIndexerClients: (chainIds: number[]) => Map<ChainId, SequenceIndexer>;
|
|
102
|
-
//# sourceMappingURL=useIndexerClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIndexerClient.d.ts","sourceRoot":"","sources":["../../../../src/hooks/Indexer/useIndexerClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAY,MAAM,qBAAqB,CAAA;AAOvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,OAAO,oBAqBhD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,EAAE,kCA2BnD,CAAA"}
|