wagmi 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/actions/package.json +5 -0
- package/chains/package.json +5 -0
- package/codegen/package.json +5 -0
- package/connectors/package.json +5 -0
- package/dist/esm/context.js +6 -11
- package/dist/esm/context.js.map +1 -1
- package/dist/esm/errors/base.js +1 -1
- package/dist/esm/errors/base.js.map +1 -1
- package/dist/esm/errors/context.js +3 -1
- package/dist/esm/errors/context.js.map +1 -1
- package/dist/esm/exports/actions.js +2 -1
- package/dist/esm/exports/actions.js.map +1 -1
- package/dist/esm/exports/chains.js +1 -0
- package/dist/esm/exports/chains.js.map +1 -1
- package/dist/esm/exports/codegen.js +12 -0
- package/dist/esm/exports/codegen.js.map +1 -0
- package/dist/esm/exports/connectors.js +1 -0
- package/dist/esm/exports/connectors.js.map +1 -1
- package/dist/esm/exports/index.js +43 -15
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/query.js +1 -0
- package/dist/esm/exports/query.js.map +1 -1
- package/dist/esm/hooks/codegen/createUseReadContract.js +33 -0
- package/dist/esm/hooks/codegen/createUseReadContract.js.map +1 -0
- package/dist/esm/hooks/codegen/createUseSimulateContract.js +33 -0
- package/dist/esm/hooks/codegen/createUseSimulateContract.js.map +1 -0
- package/dist/esm/hooks/codegen/createUseWatchContractEvent.js +32 -0
- package/dist/esm/hooks/codegen/createUseWatchContractEvent.js.map +1 -0
- package/dist/esm/hooks/codegen/createUseWriteContract.js +95 -0
- package/dist/esm/hooks/codegen/createUseWriteContract.js.map +1 -0
- package/dist/esm/hooks/useAccount.js +1 -1
- package/dist/esm/hooks/useAccount.js.map +1 -1
- package/dist/esm/hooks/useAccountEffect.js +10 -3
- package/dist/esm/hooks/useAccountEffect.js.map +1 -1
- package/dist/esm/hooks/useBalance.js +4 -4
- package/dist/esm/hooks/useBalance.js.map +1 -1
- package/dist/esm/hooks/useBlock.js +36 -0
- package/dist/esm/hooks/useBlock.js.map +1 -0
- package/dist/esm/hooks/useBlockNumber.js +6 -8
- package/dist/esm/hooks/useBlockNumber.js.map +1 -1
- package/dist/esm/hooks/useBlockTransactionCount.js +20 -0
- package/dist/esm/hooks/useBlockTransactionCount.js.map +1 -0
- package/dist/esm/hooks/useChainId.js +2 -2
- package/dist/esm/hooks/useChainId.js.map +1 -1
- package/dist/esm/hooks/useClient.js +1 -1
- package/dist/esm/hooks/useClient.js.map +1 -1
- package/dist/esm/hooks/useConfig.js +1 -1
- package/dist/esm/hooks/useConfig.js.map +1 -1
- package/dist/esm/hooks/useConnect.js +12 -2
- package/dist/esm/hooks/useConnect.js.map +1 -1
- package/dist/esm/hooks/useConnections.js +2 -2
- package/dist/esm/hooks/useConnections.js.map +1 -1
- package/dist/esm/hooks/useConnectorClient.js +2 -3
- package/dist/esm/hooks/useConnectorClient.js.map +1 -1
- package/dist/esm/hooks/useConnectors.js +10 -0
- package/dist/esm/hooks/useConnectors.js.map +1 -0
- package/dist/esm/hooks/useDisconnect.js +1 -1
- package/dist/esm/hooks/useDisconnect.js.map +1 -1
- package/dist/esm/hooks/useEnsAddress.js +4 -4
- package/dist/esm/hooks/useEnsAddress.js.map +1 -1
- package/dist/esm/hooks/useEnsAvatar.js +4 -4
- package/dist/esm/hooks/useEnsAvatar.js.map +1 -1
- package/dist/esm/hooks/useEnsName.js +4 -4
- package/dist/esm/hooks/useEnsName.js.map +1 -1
- package/dist/esm/hooks/useEnsResolver.js +4 -4
- package/dist/esm/hooks/useEnsResolver.js.map +1 -1
- package/dist/esm/hooks/useEstimateFeesPerGas.js +4 -4
- package/dist/esm/hooks/useEstimateFeesPerGas.js.map +1 -1
- package/dist/esm/hooks/useEstimateGas.js +3 -3
- package/dist/esm/hooks/useEstimateGas.js.map +1 -1
- package/dist/esm/hooks/useEstimateMaxPriorityFeePerGas.js +19 -0
- package/dist/esm/hooks/useEstimateMaxPriorityFeePerGas.js.map +1 -0
- package/dist/esm/hooks/useFeeHistory.js +20 -0
- package/dist/esm/hooks/useFeeHistory.js.map +1 -0
- package/dist/esm/hooks/useGasPrice.js +20 -0
- package/dist/esm/hooks/useGasPrice.js.map +1 -0
- package/dist/esm/hooks/useInfiniteReadContracts.js +24 -0
- package/dist/esm/hooks/useInfiniteReadContracts.js.map +1 -0
- package/dist/esm/hooks/usePublicClient.js +1 -1
- package/dist/esm/hooks/usePublicClient.js.map +1 -1
- package/dist/esm/hooks/{useContractRead.js → useReadContract.js} +5 -8
- package/dist/esm/hooks/useReadContract.js.map +1 -0
- package/dist/esm/hooks/{useContractReads.js → useReadContracts.js} +7 -9
- package/dist/esm/hooks/useReadContracts.js.map +1 -0
- package/dist/esm/hooks/useReconnect.js +1 -1
- package/dist/esm/hooks/useReconnect.js.map +1 -1
- package/dist/esm/hooks/useSendTransaction.js +1 -1
- package/dist/esm/hooks/useSendTransaction.js.map +1 -1
- package/dist/esm/hooks/useSignMessage.js +1 -1
- package/dist/esm/hooks/useSignMessage.js.map +1 -1
- package/dist/esm/hooks/useSignTypedData.js +1 -1
- package/dist/esm/hooks/useSignTypedData.js.map +1 -1
- package/dist/esm/hooks/{useContractSimulate.js → useSimulateContract.js} +6 -6
- package/dist/esm/hooks/useSimulateContract.js.map +1 -0
- package/dist/esm/hooks/useSwitchAccount.js +1 -1
- package/dist/esm/hooks/useSwitchAccount.js.map +1 -1
- package/dist/esm/hooks/useSwitchChain.js +1 -1
- package/dist/esm/hooks/useSwitchChain.js.map +1 -1
- package/dist/esm/hooks/useToken.js +8 -4
- package/dist/esm/hooks/useToken.js.map +1 -1
- package/dist/esm/hooks/useTransaction.js +8 -4
- package/dist/esm/hooks/useTransaction.js.map +1 -1
- package/dist/esm/hooks/useTransactionCount.js +19 -0
- package/dist/esm/hooks/useTransactionCount.js.map +1 -0
- package/dist/esm/hooks/useVerifyMessage.js +19 -0
- package/dist/esm/hooks/useVerifyMessage.js.map +1 -0
- package/dist/esm/hooks/useVerifyTypedData.js +25 -0
- package/dist/esm/hooks/useVerifyTypedData.js.map +1 -0
- package/dist/esm/hooks/useWaitForTransactionReceipt.js +9 -5
- package/dist/esm/hooks/useWaitForTransactionReceipt.js.map +1 -1
- package/dist/esm/hooks/useWalletClient.js +2 -3
- package/dist/esm/hooks/useWalletClient.js.map +1 -1
- package/dist/esm/hooks/useWatchBlockNumber.js +1 -1
- package/dist/esm/hooks/useWatchBlockNumber.js.map +1 -1
- package/dist/esm/hooks/useWatchBlocks.js +25 -0
- package/dist/esm/hooks/useWatchBlocks.js.map +1 -0
- package/dist/esm/hooks/useWatchContractEvent.js +1 -1
- package/dist/esm/hooks/useWatchContractEvent.js.map +1 -1
- package/dist/esm/hooks/useWatchPendingTransactions.js +1 -1
- package/dist/esm/hooks/useWatchPendingTransactions.js.map +1 -1
- package/dist/esm/hooks/{useContractWrite.js → useWriteContract.js} +5 -5
- package/dist/esm/hooks/useWriteContract.js.map +1 -0
- package/dist/esm/hydrate.js +28 -0
- package/dist/esm/hydrate.js.map +1 -0
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/types/properties.js +3 -1
- package/dist/esm/types/properties.js.map +1 -1
- package/dist/esm/utils/query.js +10 -1
- package/dist/esm/utils/query.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/context.d.ts +6 -7
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/errors/base.d.ts +3 -0
- package/dist/types/errors/base.d.ts.map +1 -1
- package/dist/types/errors/context.d.ts +3 -0
- package/dist/types/errors/context.d.ts.map +1 -1
- package/dist/types/exports/actions.d.ts.map +1 -1
- package/dist/types/exports/chains.d.ts.map +1 -1
- package/dist/types/exports/codegen.d.ts +6 -0
- package/dist/types/exports/codegen.d.ts.map +1 -0
- package/dist/types/exports/connectors.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +33 -10
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/exports/query.d.ts.map +1 -1
- package/dist/types/hooks/codegen/createUseReadContract.d.ts +18 -0
- package/dist/types/hooks/codegen/createUseReadContract.d.ts.map +1 -0
- package/dist/types/hooks/codegen/createUseSimulateContract.d.ts +21 -0
- package/dist/types/hooks/codegen/createUseSimulateContract.d.ts.map +1 -0
- package/dist/types/hooks/codegen/createUseWatchContractEvent.d.ts +14 -0
- package/dist/types/hooks/codegen/createUseWatchContractEvent.d.ts.map +1 -0
- package/dist/types/hooks/codegen/createUseWriteContract.d.ts +27 -0
- package/dist/types/hooks/codegen/createUseWriteContract.d.ts.map +1 -0
- package/dist/types/hooks/useAccount.d.ts +1 -1
- package/dist/types/hooks/useAccount.d.ts.map +1 -1
- package/dist/types/hooks/useAccountEffect.d.ts +2 -2
- package/dist/types/hooks/useAccountEffect.d.ts.map +1 -1
- package/dist/types/hooks/useBalance.d.ts +6 -8
- package/dist/types/hooks/useBalance.d.ts.map +1 -1
- package/dist/types/hooks/useBlock.d.ts +14 -0
- package/dist/types/hooks/useBlock.d.ts.map +1 -0
- package/dist/types/hooks/useBlockNumber.d.ts +8 -9
- package/dist/types/hooks/useBlockNumber.d.ts.map +1 -1
- package/dist/types/hooks/useBlockTransactionCount.d.ts +10 -0
- package/dist/types/hooks/useBlockTransactionCount.d.ts.map +1 -0
- package/dist/types/hooks/useChainId.d.ts +1 -1
- package/dist/types/hooks/useChainId.d.ts.map +1 -1
- package/dist/types/hooks/useClient.d.ts +1 -1
- package/dist/types/hooks/useClient.d.ts.map +1 -1
- package/dist/types/hooks/useConfig.d.ts +1 -1
- package/dist/types/hooks/useConfig.d.ts.map +1 -1
- package/dist/types/hooks/useConnect.d.ts +5 -5
- package/dist/types/hooks/useConnect.d.ts.map +1 -1
- package/dist/types/hooks/useConnections.d.ts +1 -1
- package/dist/types/hooks/useConnections.d.ts.map +1 -1
- package/dist/types/hooks/useConnectorClient.d.ts +4 -4
- package/dist/types/hooks/useConnectorClient.d.ts.map +1 -1
- package/dist/types/hooks/useConnectors.d.ts +7 -0
- package/dist/types/hooks/useConnectors.d.ts.map +1 -0
- package/dist/types/hooks/useDisconnect.d.ts +4 -4
- package/dist/types/hooks/useDisconnect.d.ts.map +1 -1
- package/dist/types/hooks/useEnsAddress.d.ts +6 -8
- package/dist/types/hooks/useEnsAddress.d.ts.map +1 -1
- package/dist/types/hooks/useEnsAvatar.d.ts +6 -8
- package/dist/types/hooks/useEnsAvatar.d.ts.map +1 -1
- package/dist/types/hooks/useEnsName.d.ts +6 -8
- package/dist/types/hooks/useEnsName.d.ts.map +1 -1
- package/dist/types/hooks/useEnsResolver.d.ts +6 -8
- package/dist/types/hooks/useEnsResolver.d.ts.map +1 -1
- package/dist/types/hooks/useEstimateFeesPerGas.d.ts +6 -8
- package/dist/types/hooks/useEstimateFeesPerGas.d.ts.map +1 -1
- package/dist/types/hooks/useEstimateGas.d.ts +6 -8
- package/dist/types/hooks/useEstimateGas.d.ts.map +1 -1
- package/dist/types/hooks/useEstimateMaxPriorityFeePerGas.d.ts +10 -0
- package/dist/types/hooks/useEstimateMaxPriorityFeePerGas.d.ts.map +1 -0
- package/dist/types/hooks/useFeeHistory.d.ts +10 -0
- package/dist/types/hooks/useFeeHistory.d.ts.map +1 -0
- package/dist/types/hooks/useGasPrice.d.ts +10 -0
- package/dist/types/hooks/useGasPrice.d.ts.map +1 -0
- package/dist/types/hooks/useInfiniteReadContracts.d.ts +11 -0
- package/dist/types/hooks/useInfiniteReadContracts.d.ts.map +1 -0
- package/dist/types/hooks/usePublicClient.d.ts +1 -1
- package/dist/types/hooks/usePublicClient.d.ts.map +1 -1
- package/dist/types/hooks/{useContractRead.d.ts → useReadContract.d.ts} +8 -10
- package/dist/types/hooks/useReadContract.d.ts.map +1 -0
- package/dist/types/hooks/useReadContracts.d.ts +11 -0
- package/dist/types/hooks/useReadContracts.d.ts.map +1 -0
- package/dist/types/hooks/useReconnect.d.ts +4 -4
- package/dist/types/hooks/useReconnect.d.ts.map +1 -1
- package/dist/types/hooks/useSendTransaction.d.ts +4 -4
- package/dist/types/hooks/useSendTransaction.d.ts.map +1 -1
- package/dist/types/hooks/useSignMessage.d.ts +4 -4
- package/dist/types/hooks/useSignMessage.d.ts.map +1 -1
- package/dist/types/hooks/useSignTypedData.d.ts +4 -4
- package/dist/types/hooks/useSignTypedData.d.ts.map +1 -1
- package/dist/types/hooks/{useContractSimulate.d.ts → useSimulateContract.d.ts} +8 -10
- package/dist/types/hooks/useSimulateContract.d.ts.map +1 -0
- package/dist/types/hooks/useSwitchAccount.d.ts +4 -4
- package/dist/types/hooks/useSwitchAccount.d.ts.map +1 -1
- package/dist/types/hooks/useSwitchChain.d.ts +4 -4
- package/dist/types/hooks/useSwitchChain.d.ts.map +1 -1
- package/dist/types/hooks/useToken.d.ts +10 -8
- package/dist/types/hooks/useToken.d.ts.map +1 -1
- package/dist/types/hooks/useTransaction.d.ts +6 -8
- package/dist/types/hooks/useTransaction.d.ts.map +1 -1
- package/dist/types/hooks/useTransactionCount.d.ts +11 -0
- package/dist/types/hooks/useTransactionCount.d.ts.map +1 -0
- package/dist/types/hooks/useVerifyMessage.d.ts +11 -0
- package/dist/types/hooks/useVerifyMessage.d.ts.map +1 -0
- package/dist/types/hooks/useVerifyTypedData.d.ts +11 -0
- package/dist/types/hooks/useVerifyTypedData.d.ts.map +1 -0
- package/dist/types/hooks/useWaitForTransactionReceipt.d.ts +6 -8
- package/dist/types/hooks/useWaitForTransactionReceipt.d.ts.map +1 -1
- package/dist/types/hooks/useWalletClient.d.ts +4 -4
- package/dist/types/hooks/useWalletClient.d.ts.map +1 -1
- package/dist/types/hooks/useWatchBlockNumber.d.ts +1 -1
- package/dist/types/hooks/useWatchBlockNumber.d.ts.map +1 -1
- package/dist/types/hooks/useWatchBlocks.d.ts +9 -0
- package/dist/types/hooks/useWatchBlocks.d.ts.map +1 -0
- package/dist/types/hooks/useWatchContractEvent.d.ts +1 -1
- package/dist/types/hooks/useWatchContractEvent.d.ts.map +1 -1
- package/dist/types/hooks/useWatchPendingTransactions.d.ts +1 -1
- package/dist/types/hooks/useWatchPendingTransactions.d.ts.map +1 -1
- package/dist/types/hooks/useWriteContract.d.ts +15 -0
- package/dist/types/hooks/useWriteContract.d.ts.map +1 -0
- package/dist/types/hydrate.d.ts +9 -0
- package/dist/types/hydrate.d.ts.map +1 -0
- package/dist/types/types/properties.d.ts +10 -1
- package/dist/types/types/properties.d.ts.map +1 -1
- package/dist/types/utils/query.d.ts +12 -3
- package/dist/types/utils/query.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +26 -34
- package/query/package.json +5 -0
- package/src/context.ts +15 -14
- package/src/errors/base.ts +2 -1
- package/src/errors/context.ts +6 -1
- package/src/exports/actions.ts +2 -1
- package/src/exports/chains.ts +1 -0
- package/src/exports/codegen.ts +17 -0
- package/src/exports/connectors.ts +1 -0
- package/src/exports/index.ts +135 -37
- package/src/exports/query.ts +1 -0
- package/src/hooks/codegen/createUseReadContract.ts +128 -0
- package/src/hooks/codegen/createUseSimulateContract.ts +121 -0
- package/src/hooks/codegen/createUseWatchContractEvent.ts +98 -0
- package/src/hooks/codegen/createUseWriteContract.ts +290 -0
- package/src/hooks/useAccount.ts +1 -1
- package/src/hooks/useAccountEffect.ts +11 -4
- package/src/hooks/useBalance.ts +14 -21
- package/src/hooks/useBlock.ts +129 -0
- package/src/hooks/useBlockNumber.ts +30 -32
- package/src/hooks/useBlockTransactionCount.ts +65 -0
- package/src/hooks/useChainId.ts +2 -1
- package/src/hooks/useClient.ts +1 -1
- package/src/hooks/useConfig.ts +1 -1
- package/src/hooks/useConnect.ts +21 -6
- package/src/hooks/useConnections.ts +2 -1
- package/src/hooks/useConnectorClient.ts +9 -7
- package/src/hooks/useConnectors.ts +28 -0
- package/src/hooks/useDisconnect.ts +4 -4
- package/src/hooks/useEnsAddress.ts +18 -21
- package/src/hooks/useEnsAvatar.ts +18 -19
- package/src/hooks/useEnsName.ts +14 -21
- package/src/hooks/useEnsResolver.ts +18 -21
- package/src/hooks/useEstimateFeesPerGas.ts +14 -21
- package/src/hooks/useEstimateGas.ts +19 -22
- package/src/hooks/useEstimateMaxPriorityFeePerGas.ts +61 -0
- package/src/hooks/useFeeHistory.ts +62 -0
- package/src/hooks/useGasPrice.ts +60 -0
- package/src/hooks/useInfiniteReadContracts.ts +89 -0
- package/src/hooks/usePublicClient.ts +1 -1
- package/src/hooks/{useContractRead.ts → useReadContract.ts} +22 -25
- package/src/hooks/{useContractReads.ts → useReadContracts.ts} +27 -28
- package/src/hooks/useReconnect.ts +4 -4
- package/src/hooks/useSendTransaction.ts +4 -4
- package/src/hooks/useSignMessage.ts +4 -4
- package/src/hooks/useSignTypedData.ts +4 -4
- package/src/hooks/{useContractSimulate.ts → useSimulateContract.ts} +26 -27
- package/src/hooks/useSwitchAccount.ts +4 -4
- package/src/hooks/useSwitchChain.ts +8 -4
- package/src/hooks/useToken.ts +18 -21
- package/src/hooks/useTransaction.ts +22 -21
- package/src/hooks/useTransactionCount.ts +59 -0
- package/src/hooks/useVerifyMessage.ts +59 -0
- package/src/hooks/useVerifyTypedData.ts +81 -0
- package/src/hooks/useWaitForTransactionReceipt.ts +19 -22
- package/src/hooks/useWalletClient.ts +25 -21
- package/src/hooks/useWatchBlockNumber.ts +1 -1
- package/src/hooks/useWatchBlocks.ts +61 -0
- package/src/hooks/useWatchContractEvent.ts +1 -1
- package/src/hooks/useWatchPendingTransactions.ts +1 -1
- package/src/hooks/{useContractWrite.ts → useWriteContract.ts} +18 -14
- package/src/hydrate.ts +36 -0
- package/src/types/properties.ts +43 -1
- package/src/utils/query.ts +66 -15
- package/src/version.ts +1 -1
- package/dist/esm/hooks/useContractRead.js.map +0 -1
- package/dist/esm/hooks/useContractReads.js.map +0 -1
- package/dist/esm/hooks/useContractSimulate.js.map +0 -1
- package/dist/esm/hooks/useContractWrite.js.map +0 -1
- package/dist/types/hooks/useContractRead.d.ts.map +0 -1
- package/dist/types/hooks/useContractReads.d.ts +0 -13
- package/dist/types/hooks/useContractReads.d.ts.map +0 -1
- package/dist/types/hooks/useContractSimulate.d.ts.map +0 -1
- package/dist/types/hooks/useContractWrite.d.ts +0 -15
- package/dist/types/hooks/useContractWrite.d.ts.map +0 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useQueryClient } from '@tanstack/react-query'
|
|
4
|
+
import {
|
|
5
|
+
type Config,
|
|
6
|
+
type GetBlockErrorType,
|
|
7
|
+
type ResolvedRegister,
|
|
8
|
+
} from '@wagmi/core'
|
|
9
|
+
import {
|
|
10
|
+
type Evaluate,
|
|
11
|
+
type UnionEvaluate,
|
|
12
|
+
type UnionOmit,
|
|
13
|
+
} from '@wagmi/core/internal'
|
|
14
|
+
import {
|
|
15
|
+
type GetBlockData,
|
|
16
|
+
type GetBlockOptions,
|
|
17
|
+
type GetBlockQueryFnData,
|
|
18
|
+
type GetBlockQueryKey,
|
|
19
|
+
getBlockQueryOptions,
|
|
20
|
+
} from '@wagmi/core/query'
|
|
21
|
+
import type { BlockTag } from 'viem'
|
|
22
|
+
|
|
23
|
+
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
24
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
25
|
+
import { useChainId } from './useChainId.js'
|
|
26
|
+
import { useConfig } from './useConfig.js'
|
|
27
|
+
import {
|
|
28
|
+
type UseWatchBlocksParameters,
|
|
29
|
+
useWatchBlocks,
|
|
30
|
+
} from './useWatchBlocks.js'
|
|
31
|
+
|
|
32
|
+
export type UseBlockParameters<
|
|
33
|
+
includeTransactions extends boolean = false,
|
|
34
|
+
blockTag extends BlockTag = 'latest',
|
|
35
|
+
config extends Config = Config,
|
|
36
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
37
|
+
selectData = GetBlockData<includeTransactions, blockTag, config, chainId>,
|
|
38
|
+
> = Evaluate<
|
|
39
|
+
GetBlockOptions<includeTransactions, blockTag, config, chainId> &
|
|
40
|
+
ConfigParameter<config> &
|
|
41
|
+
QueryParameter<
|
|
42
|
+
GetBlockQueryFnData<includeTransactions, blockTag, config, chainId>,
|
|
43
|
+
GetBlockErrorType,
|
|
44
|
+
selectData,
|
|
45
|
+
GetBlockQueryKey<includeTransactions, blockTag, config, chainId>
|
|
46
|
+
> & {
|
|
47
|
+
watch?:
|
|
48
|
+
| boolean
|
|
49
|
+
| UnionEvaluate<
|
|
50
|
+
UnionOmit<
|
|
51
|
+
UseWatchBlocksParameters<
|
|
52
|
+
includeTransactions,
|
|
53
|
+
blockTag,
|
|
54
|
+
config,
|
|
55
|
+
chainId
|
|
56
|
+
>,
|
|
57
|
+
'chainId' | 'config' | 'onBlock' | 'onError'
|
|
58
|
+
>
|
|
59
|
+
>
|
|
60
|
+
| undefined
|
|
61
|
+
}
|
|
62
|
+
>
|
|
63
|
+
|
|
64
|
+
export type UseBlockReturnType<
|
|
65
|
+
includeTransactions extends boolean = false,
|
|
66
|
+
blockTag extends BlockTag = 'latest',
|
|
67
|
+
config extends Config = Config,
|
|
68
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
69
|
+
selectData = GetBlockData<includeTransactions, blockTag, config, chainId>,
|
|
70
|
+
> = UseQueryReturnType<selectData, GetBlockErrorType>
|
|
71
|
+
|
|
72
|
+
/** https://wagmi.sh/react/hooks/useBlock */
|
|
73
|
+
export function useBlock<
|
|
74
|
+
includeTransactions extends boolean = false,
|
|
75
|
+
blockTag extends BlockTag = 'latest',
|
|
76
|
+
config extends Config = ResolvedRegister['config'],
|
|
77
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
78
|
+
selectData = GetBlockData<includeTransactions, blockTag, config, chainId>,
|
|
79
|
+
>(
|
|
80
|
+
parameters: UseBlockParameters<
|
|
81
|
+
includeTransactions,
|
|
82
|
+
blockTag,
|
|
83
|
+
config,
|
|
84
|
+
chainId,
|
|
85
|
+
selectData
|
|
86
|
+
> = {},
|
|
87
|
+
): UseBlockReturnType<
|
|
88
|
+
includeTransactions,
|
|
89
|
+
blockTag,
|
|
90
|
+
config,
|
|
91
|
+
chainId,
|
|
92
|
+
selectData
|
|
93
|
+
> {
|
|
94
|
+
const { query = {}, watch } = parameters
|
|
95
|
+
|
|
96
|
+
const config = useConfig(parameters)
|
|
97
|
+
const queryClient = useQueryClient()
|
|
98
|
+
const configChainId = useChainId()
|
|
99
|
+
const chainId = parameters.chainId ?? configChainId
|
|
100
|
+
|
|
101
|
+
const options = getBlockQueryOptions(config, { chainId })
|
|
102
|
+
const enabled = Boolean(query.enabled ?? true)
|
|
103
|
+
|
|
104
|
+
useWatchBlocks({
|
|
105
|
+
...({
|
|
106
|
+
config: parameters.config,
|
|
107
|
+
chainId: parameters.chainId!,
|
|
108
|
+
...(typeof watch === 'object' ? watch : {}),
|
|
109
|
+
} as UseWatchBlocksParameters),
|
|
110
|
+
enabled: Boolean(
|
|
111
|
+
enabled && (typeof watch === 'object' ? watch.enabled : watch),
|
|
112
|
+
),
|
|
113
|
+
onBlock(block) {
|
|
114
|
+
queryClient.setQueryData(options.queryKey, block)
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
return useQuery({
|
|
119
|
+
...(query as any),
|
|
120
|
+
...options,
|
|
121
|
+
enabled,
|
|
122
|
+
}) as UseBlockReturnType<
|
|
123
|
+
includeTransactions,
|
|
124
|
+
blockTag,
|
|
125
|
+
config,
|
|
126
|
+
chainId,
|
|
127
|
+
selectData
|
|
128
|
+
>
|
|
129
|
+
}
|
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
import { useQueryClient } from '@tanstack/react-query'
|
|
4
4
|
import {
|
|
5
5
|
type Config,
|
|
6
|
-
type
|
|
6
|
+
type GetBlockNumberErrorType,
|
|
7
7
|
type ResolvedRegister,
|
|
8
8
|
} from '@wagmi/core'
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
type Evaluate,
|
|
11
|
+
type UnionEvaluate,
|
|
12
|
+
type UnionOmit,
|
|
13
|
+
} from '@wagmi/core/internal'
|
|
10
14
|
import {
|
|
11
15
|
type GetBlockNumberData,
|
|
12
16
|
type GetBlockNumberOptions,
|
|
@@ -15,12 +19,8 @@ import {
|
|
|
15
19
|
getBlockNumberQueryOptions,
|
|
16
20
|
} from '@wagmi/core/query'
|
|
17
21
|
|
|
18
|
-
import type { ConfigParameter } from '../types/properties.js'
|
|
19
|
-
import {
|
|
20
|
-
type UseQueryParameters,
|
|
21
|
-
type UseQueryReturnType,
|
|
22
|
-
useQuery,
|
|
23
|
-
} from '../utils/query.js'
|
|
22
|
+
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
23
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
24
24
|
import { useChainId } from './useChainId.js'
|
|
25
25
|
import { useConfig } from './useConfig.js'
|
|
26
26
|
import {
|
|
@@ -33,30 +33,30 @@ export type UseBlockNumberParameters<
|
|
|
33
33
|
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
34
34
|
selectData = GetBlockNumberData,
|
|
35
35
|
> = Evaluate<
|
|
36
|
-
GetBlockNumberOptions<config> &
|
|
37
|
-
ConfigParameter<config> &
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
>
|
|
45
|
-
| undefined
|
|
36
|
+
GetBlockNumberOptions<config, chainId> &
|
|
37
|
+
ConfigParameter<config> &
|
|
38
|
+
QueryParameter<
|
|
39
|
+
GetBlockNumberQueryFnData,
|
|
40
|
+
GetBlockNumberErrorType,
|
|
41
|
+
selectData,
|
|
42
|
+
GetBlockNumberQueryKey<config, chainId>
|
|
43
|
+
> & {
|
|
46
44
|
watch?:
|
|
47
45
|
| boolean
|
|
48
|
-
|
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
| UnionEvaluate<
|
|
47
|
+
UnionOmit<
|
|
48
|
+
UseWatchBlockNumberParameters<config, chainId>,
|
|
49
|
+
'chainId' | 'config' | 'onBlockNumber' | 'onError'
|
|
50
|
+
>
|
|
51
51
|
>
|
|
52
52
|
| undefined
|
|
53
53
|
}
|
|
54
54
|
>
|
|
55
55
|
|
|
56
56
|
export type UseBlockNumberReturnType<selectData = GetBlockNumberData> =
|
|
57
|
-
UseQueryReturnType<selectData,
|
|
57
|
+
UseQueryReturnType<selectData, GetBlockNumberErrorType>
|
|
58
58
|
|
|
59
|
-
/** https://
|
|
59
|
+
/** https://wagmi.sh/react/api/hooks/useBlockNumber */
|
|
60
60
|
export function useBlockNumber<
|
|
61
61
|
config extends Config = ResolvedRegister['config'],
|
|
62
62
|
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
@@ -71,27 +71,25 @@ export function useBlockNumber<
|
|
|
71
71
|
const configChainId = useChainId()
|
|
72
72
|
const chainId = parameters.chainId ?? configChainId
|
|
73
73
|
|
|
74
|
-
const
|
|
74
|
+
const options = getBlockNumberQueryOptions(config, {
|
|
75
75
|
...parameters,
|
|
76
76
|
chainId,
|
|
77
77
|
})
|
|
78
78
|
|
|
79
79
|
useWatchBlockNumber({
|
|
80
|
-
...{
|
|
80
|
+
...({
|
|
81
81
|
config: parameters.config,
|
|
82
|
-
chainId: parameters.chainId
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
? (watch as UseWatchBlockNumberParameters)
|
|
86
|
-
: {}),
|
|
82
|
+
chainId: parameters.chainId,
|
|
83
|
+
...(typeof watch === 'object' ? watch : {}),
|
|
84
|
+
} as UseWatchBlockNumberParameters),
|
|
87
85
|
enabled: Boolean(
|
|
88
86
|
(query.enabled ?? true) &&
|
|
89
87
|
(typeof watch === 'object' ? watch.enabled : watch),
|
|
90
88
|
),
|
|
91
89
|
onBlockNumber(blockNumber) {
|
|
92
|
-
queryClient.setQueryData(
|
|
90
|
+
queryClient.setQueryData(options.queryKey, blockNumber)
|
|
93
91
|
},
|
|
94
92
|
})
|
|
95
93
|
|
|
96
|
-
return useQuery({ ...
|
|
94
|
+
return useQuery({ ...query, ...options })
|
|
97
95
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type Config,
|
|
5
|
+
type GetBlockTransactionCountErrorType,
|
|
6
|
+
type ResolvedRegister,
|
|
7
|
+
} from '@wagmi/core'
|
|
8
|
+
import { type UnionEvaluate } from '@wagmi/core/internal'
|
|
9
|
+
import {
|
|
10
|
+
type GetBlockTransactionCountData,
|
|
11
|
+
type GetBlockTransactionCountOptions,
|
|
12
|
+
type GetBlockTransactionCountQueryFnData,
|
|
13
|
+
type GetBlockTransactionCountQueryKey,
|
|
14
|
+
getBlockTransactionCountQueryOptions,
|
|
15
|
+
} from '@wagmi/core/query'
|
|
16
|
+
|
|
17
|
+
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
18
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
19
|
+
import { useChainId } from './useChainId.js'
|
|
20
|
+
import { useConfig } from './useConfig.js'
|
|
21
|
+
|
|
22
|
+
export type UseBlockTransactionCountParameters<
|
|
23
|
+
config extends Config = Config,
|
|
24
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
25
|
+
selectData = GetBlockTransactionCountData,
|
|
26
|
+
> = UnionEvaluate<
|
|
27
|
+
GetBlockTransactionCountOptions<config, chainId> &
|
|
28
|
+
ConfigParameter<config> &
|
|
29
|
+
QueryParameter<
|
|
30
|
+
GetBlockTransactionCountQueryFnData,
|
|
31
|
+
GetBlockTransactionCountErrorType,
|
|
32
|
+
selectData,
|
|
33
|
+
GetBlockTransactionCountQueryKey<config, chainId>
|
|
34
|
+
>
|
|
35
|
+
>
|
|
36
|
+
|
|
37
|
+
export type UseBlockTransactionCountReturnType<
|
|
38
|
+
selectData = GetBlockTransactionCountData,
|
|
39
|
+
> = UseQueryReturnType<selectData, GetBlockTransactionCountErrorType>
|
|
40
|
+
|
|
41
|
+
/** https://wagmi.sh/react/api/hooks/useBlockTransactionCount */
|
|
42
|
+
export function useBlockTransactionCount<
|
|
43
|
+
config extends Config = ResolvedRegister['config'],
|
|
44
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
45
|
+
selectData = GetBlockTransactionCountData,
|
|
46
|
+
>(
|
|
47
|
+
parameters: UseBlockTransactionCountParameters<
|
|
48
|
+
config,
|
|
49
|
+
chainId,
|
|
50
|
+
selectData
|
|
51
|
+
> = {},
|
|
52
|
+
): UseBlockTransactionCountReturnType<selectData> {
|
|
53
|
+
const { query = {} } = parameters
|
|
54
|
+
|
|
55
|
+
const config = useConfig(parameters)
|
|
56
|
+
const configChainId = useChainId()
|
|
57
|
+
const chainId = parameters.chainId ?? configChainId
|
|
58
|
+
|
|
59
|
+
const options = getBlockTransactionCountQueryOptions(config, {
|
|
60
|
+
...parameters,
|
|
61
|
+
chainId,
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
return useQuery({ ...query, ...options })
|
|
65
|
+
}
|
package/src/hooks/useChainId.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type UseChainIdParameters<config extends Config = Config> =
|
|
|
18
18
|
export type UseChainIdReturnType<config extends Config = Config> =
|
|
19
19
|
GetChainIdReturnType<config>
|
|
20
20
|
|
|
21
|
-
/** https://
|
|
21
|
+
/** https://wagmi.sh/react/api/hooks/useChainId */
|
|
22
22
|
export function useChainId<config extends Config = ResolvedRegister['config']>(
|
|
23
23
|
parameters: UseChainIdParameters<config> = {},
|
|
24
24
|
): UseChainIdReturnType<config> {
|
|
@@ -27,5 +27,6 @@ export function useChainId<config extends Config = ResolvedRegister['config']>(
|
|
|
27
27
|
return useSyncExternalStore(
|
|
28
28
|
(onChange) => watchChainId(config, { onChange }),
|
|
29
29
|
() => getChainId(config),
|
|
30
|
+
() => getChainId(config),
|
|
30
31
|
)
|
|
31
32
|
}
|
package/src/hooks/useClient.ts
CHANGED
|
@@ -24,7 +24,7 @@ export type UseClientReturnType<
|
|
|
24
24
|
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
25
25
|
> = GetClientReturnType<config, chainId>
|
|
26
26
|
|
|
27
|
-
/** https://
|
|
27
|
+
/** https://wagmi.sh/react/api/hooks/useClient */
|
|
28
28
|
export function useClient<
|
|
29
29
|
config extends Config = ResolvedRegister['config'],
|
|
30
30
|
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
package/src/hooks/useConfig.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type UseConfigParameters<config extends Config = Config> =
|
|
|
12
12
|
|
|
13
13
|
export type UseConfigReturnType<config extends Config = Config> = config
|
|
14
14
|
|
|
15
|
-
/** https://
|
|
15
|
+
/** https://wagmi.sh/react/api/hooks/useConfig */
|
|
16
16
|
export function useConfig<config extends Config = ResolvedRegister['config']>(
|
|
17
17
|
parameters: UseConfigParameters<config> = {},
|
|
18
18
|
): UseConfigReturnType<config> {
|
package/src/hooks/useConnect.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import { useMutation } from '@tanstack/react-query'
|
|
4
4
|
import {
|
|
5
5
|
type Config,
|
|
6
|
-
type
|
|
6
|
+
type ConnectErrorType,
|
|
7
|
+
type Connector,
|
|
7
8
|
type ResolvedRegister,
|
|
8
9
|
} from '@wagmi/core'
|
|
9
10
|
import type { Evaluate } from '@wagmi/core/internal'
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
type ConnectVariables,
|
|
15
16
|
connectMutationOptions,
|
|
16
17
|
} from '@wagmi/core/query'
|
|
18
|
+
import { useEffect } from 'react'
|
|
17
19
|
|
|
18
20
|
import type { ConfigParameter } from '../types/properties.js'
|
|
19
21
|
import type {
|
|
@@ -21,6 +23,7 @@ import type {
|
|
|
21
23
|
UseMutationReturnType,
|
|
22
24
|
} from '../utils/query.js'
|
|
23
25
|
import { useConfig } from './useConfig.js'
|
|
26
|
+
import { useConnectors } from './useConnectors.js'
|
|
24
27
|
|
|
25
28
|
export type UseConnectParameters<
|
|
26
29
|
config extends Config = Config,
|
|
@@ -30,7 +33,7 @@ export type UseConnectParameters<
|
|
|
30
33
|
mutation?:
|
|
31
34
|
| UseMutationParameters<
|
|
32
35
|
ConnectData<config>,
|
|
33
|
-
|
|
36
|
+
ConnectErrorType,
|
|
34
37
|
ConnectVariables<config>,
|
|
35
38
|
context
|
|
36
39
|
>
|
|
@@ -44,17 +47,17 @@ export type UseConnectReturnType<
|
|
|
44
47
|
> = Evaluate<
|
|
45
48
|
UseMutationReturnType<
|
|
46
49
|
ConnectData<config>,
|
|
47
|
-
|
|
50
|
+
ConnectErrorType,
|
|
48
51
|
ConnectVariables<config>,
|
|
49
52
|
context
|
|
50
53
|
> & {
|
|
51
54
|
connect: ConnectMutate<config, context>
|
|
52
55
|
connectAsync: ConnectMutateAsync<config, context>
|
|
53
|
-
connectors:
|
|
56
|
+
connectors: readonly Connector[]
|
|
54
57
|
}
|
|
55
58
|
>
|
|
56
59
|
|
|
57
|
-
/** https://
|
|
60
|
+
/** https://wagmi.sh/react/api/hooks/useConnect */
|
|
58
61
|
export function useConnect<
|
|
59
62
|
config extends Config = ResolvedRegister['config'],
|
|
60
63
|
context = unknown,
|
|
@@ -64,6 +67,7 @@ export function useConnect<
|
|
|
64
67
|
const { mutation } = parameters
|
|
65
68
|
|
|
66
69
|
const config = useConfig(parameters)
|
|
70
|
+
const connectors = useConnectors({ config })
|
|
67
71
|
|
|
68
72
|
const mutationOptions = connectMutationOptions(config)
|
|
69
73
|
const { mutate, mutateAsync, ...result } = useMutation({
|
|
@@ -71,10 +75,21 @@ export function useConnect<
|
|
|
71
75
|
...mutationOptions,
|
|
72
76
|
})
|
|
73
77
|
|
|
78
|
+
// Reset mutation back to an idle state when the connector disconnects.
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
return config.subscribe(
|
|
81
|
+
({ status }) => status,
|
|
82
|
+
(status, previousStatus) => {
|
|
83
|
+
if (previousStatus === 'connected' && status === 'disconnected')
|
|
84
|
+
result.reset()
|
|
85
|
+
},
|
|
86
|
+
)
|
|
87
|
+
}, [config, result])
|
|
88
|
+
|
|
74
89
|
return {
|
|
75
90
|
...result,
|
|
76
91
|
connect: mutate,
|
|
77
92
|
connectAsync: mutateAsync,
|
|
78
|
-
connectors
|
|
93
|
+
connectors,
|
|
79
94
|
}
|
|
80
95
|
}
|
|
@@ -14,7 +14,7 @@ export type UseConnectionsParameters = ConfigParameter
|
|
|
14
14
|
|
|
15
15
|
export type UseConnectionsReturnType = GetConnectionsReturnType
|
|
16
16
|
|
|
17
|
-
/** https://
|
|
17
|
+
/** https://wagmi.sh/react/api/hooks/useConnections */
|
|
18
18
|
export function useConnections(
|
|
19
19
|
parameters: UseConnectionsParameters = {},
|
|
20
20
|
): UseConnectionsReturnType {
|
|
@@ -23,5 +23,6 @@ export function useConnections(
|
|
|
23
23
|
return useSyncExternalStore(
|
|
24
24
|
(onChange) => watchConnections(config, { onChange }),
|
|
25
25
|
() => getConnections(config),
|
|
26
|
+
() => getConnections(config),
|
|
26
27
|
)
|
|
27
28
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useQueryClient } from '@tanstack/react-query'
|
|
4
4
|
import type {
|
|
5
5
|
Config,
|
|
6
|
-
|
|
6
|
+
GetConnectorClientErrorType,
|
|
7
7
|
ResolvedRegister,
|
|
8
8
|
} from '@wagmi/core'
|
|
9
9
|
import { type Evaluate, type Omit } from '@wagmi/core/internal'
|
|
@@ -38,7 +38,7 @@ export type UseConnectorClientParameters<
|
|
|
38
38
|
Omit<
|
|
39
39
|
UseQueryParameters<
|
|
40
40
|
GetConnectorClientQueryFnData<config, chainId>,
|
|
41
|
-
|
|
41
|
+
GetConnectorClientErrorType,
|
|
42
42
|
selectData,
|
|
43
43
|
GetConnectorClientQueryKey<config, chainId>
|
|
44
44
|
>,
|
|
@@ -53,9 +53,9 @@ export type UseConnectorClientReturnType<
|
|
|
53
53
|
config extends Config = Config,
|
|
54
54
|
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
55
55
|
selectData = GetConnectorClientData<config, chainId>,
|
|
56
|
-
> = UseQueryReturnType<selectData,
|
|
56
|
+
> = UseQueryReturnType<selectData, GetConnectorClientErrorType>
|
|
57
57
|
|
|
58
|
-
/** https://
|
|
58
|
+
/** https://wagmi.sh/react/api/hooks/useConnectorClient */
|
|
59
59
|
export function useConnectorClient<
|
|
60
60
|
config extends Config = ResolvedRegister['config'],
|
|
61
61
|
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
@@ -70,7 +70,10 @@ export function useConnectorClient<
|
|
|
70
70
|
const { address, connector, status } = useAccount()
|
|
71
71
|
const chainId = useChainId()
|
|
72
72
|
|
|
73
|
-
const { queryKey, ...options } = getConnectorClientQueryOptions
|
|
73
|
+
const { queryKey, ...options } = getConnectorClientQueryOptions<
|
|
74
|
+
config,
|
|
75
|
+
chainId
|
|
76
|
+
>(config, {
|
|
74
77
|
...parameters,
|
|
75
78
|
chainId: parameters.chainId ?? chainId,
|
|
76
79
|
connector: parameters.connector ?? connector,
|
|
@@ -85,11 +88,10 @@ export function useConnectorClient<
|
|
|
85
88
|
}, [address, queryClient])
|
|
86
89
|
|
|
87
90
|
return useQuery({
|
|
88
|
-
...options,
|
|
89
91
|
...query,
|
|
92
|
+
...options,
|
|
90
93
|
queryKey,
|
|
91
94
|
enabled,
|
|
92
|
-
gcTime: 0,
|
|
93
95
|
staleTime: Infinity,
|
|
94
96
|
})
|
|
95
97
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type GetConnectorsReturnType,
|
|
5
|
+
getConnectors,
|
|
6
|
+
watchConnectors,
|
|
7
|
+
} from '@wagmi/core'
|
|
8
|
+
import { useSyncExternalStore } from 'react'
|
|
9
|
+
|
|
10
|
+
import type { ConfigParameter } from '../types/properties.js'
|
|
11
|
+
import { useConfig } from './useConfig.js'
|
|
12
|
+
|
|
13
|
+
export type UseConnectorsParameters = ConfigParameter
|
|
14
|
+
|
|
15
|
+
export type UseConnectorsReturnType = GetConnectorsReturnType
|
|
16
|
+
|
|
17
|
+
/** https://wagmi.sh/react/api/hooks/useConnectors */
|
|
18
|
+
export function useConnectors(
|
|
19
|
+
parameters: UseConnectorsParameters = {},
|
|
20
|
+
): UseConnectorsReturnType {
|
|
21
|
+
const config = useConfig(parameters)
|
|
22
|
+
|
|
23
|
+
return useSyncExternalStore(
|
|
24
|
+
(onChange) => watchConnectors(config, { onChange }),
|
|
25
|
+
() => getConnectors(config),
|
|
26
|
+
() => getConnectors(config),
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import { useMutation } from '@tanstack/react-query'
|
|
4
|
-
import { type Connector, type
|
|
4
|
+
import { type Connector, type DisconnectErrorType } from '@wagmi/core'
|
|
5
5
|
import type { Evaluate } from '@wagmi/core/internal'
|
|
6
6
|
import {
|
|
7
7
|
type DisconnectData,
|
|
@@ -24,7 +24,7 @@ export type UseDisconnectParameters<context = unknown> = Evaluate<
|
|
|
24
24
|
mutation?:
|
|
25
25
|
| UseMutationParameters<
|
|
26
26
|
DisconnectData,
|
|
27
|
-
|
|
27
|
+
DisconnectErrorType,
|
|
28
28
|
DisconnectVariables,
|
|
29
29
|
context
|
|
30
30
|
>
|
|
@@ -35,7 +35,7 @@ export type UseDisconnectParameters<context = unknown> = Evaluate<
|
|
|
35
35
|
export type UseDisconnectReturnType<context = unknown> = Evaluate<
|
|
36
36
|
UseMutationReturnType<
|
|
37
37
|
DisconnectData,
|
|
38
|
-
|
|
38
|
+
DisconnectErrorType,
|
|
39
39
|
DisconnectVariables,
|
|
40
40
|
context
|
|
41
41
|
> & {
|
|
@@ -45,7 +45,7 @@ export type UseDisconnectReturnType<context = unknown> = Evaluate<
|
|
|
45
45
|
}
|
|
46
46
|
>
|
|
47
47
|
|
|
48
|
-
/** https://
|
|
48
|
+
/** https://wagmi.sh/react/api/hooks/useDisconnect */
|
|
49
49
|
export function useDisconnect<context = unknown>(
|
|
50
50
|
parameters: UseDisconnectParameters<context> = {},
|
|
51
51
|
): UseDisconnectReturnType<context> {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
Config,
|
|
5
|
+
GetEnsAddressErrorType,
|
|
6
|
+
ResolvedRegister,
|
|
7
|
+
} from '@wagmi/core'
|
|
4
8
|
import { type Evaluate } from '@wagmi/core/internal'
|
|
5
9
|
import {
|
|
6
10
|
type GetEnsAddressData,
|
|
@@ -10,12 +14,8 @@ import {
|
|
|
10
14
|
getEnsAddressQueryOptions,
|
|
11
15
|
} from '@wagmi/core/query'
|
|
12
16
|
|
|
13
|
-
import type { ConfigParameter } from '../types/properties.js'
|
|
14
|
-
import {
|
|
15
|
-
type UseQueryParameters,
|
|
16
|
-
type UseQueryReturnType,
|
|
17
|
-
useQuery,
|
|
18
|
-
} from '../utils/query.js'
|
|
17
|
+
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
18
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
19
19
|
import { useChainId } from './useChainId.js'
|
|
20
20
|
import { useConfig } from './useConfig.js'
|
|
21
21
|
|
|
@@ -24,22 +24,19 @@ export type UseEnsAddressParameters<
|
|
|
24
24
|
selectData = GetEnsAddressData,
|
|
25
25
|
> = Evaluate<
|
|
26
26
|
GetEnsAddressOptions<config> &
|
|
27
|
-
ConfigParameter<config> &
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
>
|
|
35
|
-
| undefined
|
|
36
|
-
}
|
|
27
|
+
ConfigParameter<config> &
|
|
28
|
+
QueryParameter<
|
|
29
|
+
GetEnsAddressQueryFnData,
|
|
30
|
+
GetEnsAddressErrorType,
|
|
31
|
+
selectData,
|
|
32
|
+
GetEnsAddressQueryKey<config>
|
|
33
|
+
>
|
|
37
34
|
>
|
|
38
35
|
|
|
39
36
|
export type UseEnsAddressReturnType<selectData = GetEnsAddressData> =
|
|
40
|
-
UseQueryReturnType<selectData,
|
|
37
|
+
UseQueryReturnType<selectData, GetEnsAddressErrorType>
|
|
41
38
|
|
|
42
|
-
/** https://
|
|
39
|
+
/** https://wagmi.sh/react/api/hooks/useEnsAddress */
|
|
43
40
|
export function useEnsAddress<
|
|
44
41
|
config extends Config = ResolvedRegister['config'],
|
|
45
42
|
selectData = GetEnsAddressData,
|
|
@@ -51,11 +48,11 @@ export function useEnsAddress<
|
|
|
51
48
|
const config = useConfig(parameters)
|
|
52
49
|
const chainId = useChainId()
|
|
53
50
|
|
|
54
|
-
const
|
|
51
|
+
const options = getEnsAddressQueryOptions(config, {
|
|
55
52
|
...parameters,
|
|
56
53
|
chainId: parameters.chainId ?? chainId,
|
|
57
54
|
})
|
|
58
55
|
const enabled = Boolean(name && (query.enabled ?? true))
|
|
59
56
|
|
|
60
|
-
return useQuery({ ...
|
|
57
|
+
return useQuery({ ...query, ...options, enabled })
|
|
61
58
|
}
|