wagmi 2.0.0 → 2.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/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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
type Config,
|
|
5
|
-
type
|
|
5
|
+
type ReadContractErrorType,
|
|
6
6
|
type ResolvedRegister,
|
|
7
7
|
} from '@wagmi/core'
|
|
8
8
|
import { type UnionEvaluate } from '@wagmi/core/internal'
|
|
@@ -19,9 +19,8 @@ import {
|
|
|
19
19
|
type ContractFunctionName,
|
|
20
20
|
} from 'viem'
|
|
21
21
|
|
|
22
|
-
import type { ConfigParameter } from '../types/properties.js'
|
|
22
|
+
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
23
23
|
import {
|
|
24
|
-
type UseQueryParameters,
|
|
25
24
|
type UseQueryReturnType,
|
|
26
25
|
structuralSharing,
|
|
27
26
|
useQuery,
|
|
@@ -29,7 +28,7 @@ import {
|
|
|
29
28
|
import { useChainId } from './useChainId.js'
|
|
30
29
|
import { useConfig } from './useConfig.js'
|
|
31
30
|
|
|
32
|
-
export type
|
|
31
|
+
export type UseReadContractParameters<
|
|
33
32
|
abi extends Abi | readonly unknown[] = Abi,
|
|
34
33
|
functionName extends ContractFunctionName<
|
|
35
34
|
abi,
|
|
@@ -44,19 +43,16 @@ export type UseContractReadParameters<
|
|
|
44
43
|
selectData = ReadContractData<abi, functionName, args>,
|
|
45
44
|
> = UnionEvaluate<
|
|
46
45
|
ReadContractOptions<abi, functionName, args, config> &
|
|
47
|
-
ConfigParameter<config> &
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
>
|
|
55
|
-
| undefined
|
|
56
|
-
}
|
|
46
|
+
ConfigParameter<config> &
|
|
47
|
+
QueryParameter<
|
|
48
|
+
ReadContractQueryFnData<abi, functionName, args>,
|
|
49
|
+
ReadContractErrorType,
|
|
50
|
+
selectData,
|
|
51
|
+
ReadContractQueryKey<abi, functionName, args, config>
|
|
52
|
+
>
|
|
57
53
|
>
|
|
58
54
|
|
|
59
|
-
export type
|
|
55
|
+
export type UseReadContractReturnType<
|
|
60
56
|
abi extends Abi | readonly unknown[] = Abi,
|
|
61
57
|
functionName extends ContractFunctionName<
|
|
62
58
|
abi,
|
|
@@ -68,39 +64,40 @@ export type UseContractReadReturnType<
|
|
|
68
64
|
functionName
|
|
69
65
|
> = ContractFunctionArgs<abi, 'pure' | 'view', functionName>,
|
|
70
66
|
selectData = ReadContractData<abi, functionName, args>,
|
|
71
|
-
> = UseQueryReturnType<selectData,
|
|
67
|
+
> = UseQueryReturnType<selectData, ReadContractErrorType>
|
|
72
68
|
|
|
73
|
-
/** https://
|
|
74
|
-
export function
|
|
69
|
+
/** https://wagmi.sh/react/api/hooks/useReadContract */
|
|
70
|
+
export function useReadContract<
|
|
75
71
|
const abi extends Abi | readonly unknown[],
|
|
76
72
|
functionName extends ContractFunctionName<abi, 'pure' | 'view'>,
|
|
77
73
|
args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,
|
|
78
74
|
config extends Config = ResolvedRegister['config'],
|
|
79
75
|
selectData = ReadContractData<abi, functionName, args>,
|
|
80
76
|
>(
|
|
81
|
-
parameters:
|
|
77
|
+
parameters: UseReadContractParameters<
|
|
82
78
|
abi,
|
|
83
79
|
functionName,
|
|
84
80
|
args,
|
|
85
81
|
config,
|
|
86
82
|
selectData
|
|
87
83
|
> = {} as any,
|
|
88
|
-
):
|
|
84
|
+
): UseReadContractReturnType<abi, functionName, args, selectData> {
|
|
89
85
|
const { abi, address, functionName, query = {} } = parameters
|
|
86
|
+
|
|
90
87
|
const config = useConfig(parameters)
|
|
91
88
|
const chainId = useChainId()
|
|
92
89
|
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
chainId: parameters.chainId ?? chainId,
|
|
96
|
-
|
|
90
|
+
const options = readContractQueryOptions<config, abi, functionName, args>(
|
|
91
|
+
config,
|
|
92
|
+
{ ...(parameters as any), chainId: parameters.chainId ?? chainId },
|
|
93
|
+
)
|
|
97
94
|
const enabled = Boolean(
|
|
98
95
|
address && abi && functionName && (query.enabled ?? true),
|
|
99
96
|
)
|
|
100
97
|
|
|
101
98
|
return useQuery({
|
|
102
|
-
...queryOptions,
|
|
103
99
|
...query,
|
|
100
|
+
...options,
|
|
104
101
|
enabled,
|
|
105
102
|
structuralSharing: query.structuralSharing ?? structuralSharing,
|
|
106
103
|
})
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
type Config,
|
|
5
|
-
type
|
|
5
|
+
type ReadContractsErrorType,
|
|
6
6
|
type ResolvedRegister,
|
|
7
7
|
} from '@wagmi/core'
|
|
8
8
|
import { type Evaluate } from '@wagmi/core/internal'
|
|
@@ -14,11 +14,13 @@ import {
|
|
|
14
14
|
readContractsQueryOptions,
|
|
15
15
|
} from '@wagmi/core/query'
|
|
16
16
|
import { useMemo } from 'react'
|
|
17
|
-
import type
|
|
17
|
+
import { type ContractFunctionParameters } from 'viem'
|
|
18
18
|
|
|
19
|
-
import type { ConfigParameter } from '../types/properties.js'
|
|
20
19
|
import {
|
|
21
|
-
type
|
|
20
|
+
type ConfigParameter,
|
|
21
|
+
type QueryParameter,
|
|
22
|
+
} from '../types/properties.js'
|
|
23
|
+
import {
|
|
22
24
|
type UseQueryReturnType,
|
|
23
25
|
structuralSharing,
|
|
24
26
|
useQuery,
|
|
@@ -26,55 +28,52 @@ import {
|
|
|
26
28
|
import { useChainId } from './useChainId.js'
|
|
27
29
|
import { useConfig } from './useConfig.js'
|
|
28
30
|
|
|
29
|
-
export type
|
|
31
|
+
export type UseReadContractsParameters<
|
|
30
32
|
contracts extends readonly unknown[] = readonly ContractFunctionParameters[],
|
|
31
33
|
allowFailure extends boolean = true,
|
|
32
34
|
config extends Config = Config,
|
|
33
35
|
selectData = ReadContractsData<contracts, allowFailure>,
|
|
34
36
|
> = Evaluate<
|
|
35
|
-
ReadContractsOptions<
|
|
36
|
-
ConfigParameter<config> &
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
>
|
|
44
|
-
| undefined
|
|
45
|
-
}
|
|
37
|
+
ReadContractsOptions<contracts, allowFailure, config> &
|
|
38
|
+
ConfigParameter<config> &
|
|
39
|
+
QueryParameter<
|
|
40
|
+
ReadContractsQueryFnData<contracts, allowFailure>,
|
|
41
|
+
ReadContractsErrorType,
|
|
42
|
+
selectData,
|
|
43
|
+
ReadContractsQueryKey<contracts, allowFailure, config>
|
|
44
|
+
>
|
|
46
45
|
>
|
|
47
46
|
|
|
48
|
-
export type
|
|
47
|
+
export type UseReadContractsReturnType<
|
|
49
48
|
contracts extends readonly unknown[] = readonly ContractFunctionParameters[],
|
|
50
49
|
allowFailure extends boolean = true,
|
|
51
50
|
selectData = ReadContractsData<contracts, allowFailure>,
|
|
52
|
-
> = UseQueryReturnType<selectData,
|
|
51
|
+
> = UseQueryReturnType<selectData, ReadContractsErrorType>
|
|
53
52
|
|
|
54
|
-
/** https://
|
|
55
|
-
export function
|
|
53
|
+
/** https://wagmi.sh/react/api/hooks/useReadContracts */
|
|
54
|
+
export function useReadContracts<
|
|
56
55
|
const contracts extends readonly unknown[],
|
|
57
56
|
allowFailure extends boolean = true,
|
|
58
57
|
config extends Config = ResolvedRegister['config'],
|
|
59
58
|
selectData = ReadContractsData<contracts, allowFailure>,
|
|
60
59
|
>(
|
|
61
|
-
parameters:
|
|
60
|
+
parameters: UseReadContractsParameters<
|
|
62
61
|
contracts,
|
|
63
62
|
allowFailure,
|
|
64
63
|
config,
|
|
65
64
|
selectData
|
|
66
65
|
> = {},
|
|
67
|
-
):
|
|
66
|
+
): UseReadContractsReturnType<contracts, allowFailure, selectData> {
|
|
68
67
|
const { contracts = [], query = {} } = parameters
|
|
69
68
|
|
|
70
69
|
const config = useConfig(parameters)
|
|
71
70
|
const chainId = useChainId()
|
|
72
71
|
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
chainId,
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
const options = readContractsQueryOptions<config, contracts, allowFailure>(
|
|
73
|
+
config,
|
|
74
|
+
{ ...parameters, chainId },
|
|
75
|
+
)
|
|
76
|
+
|
|
78
77
|
const enabled = useMemo(() => {
|
|
79
78
|
let isContractsValid = false
|
|
80
79
|
for (const contract of contracts) {
|
|
@@ -90,7 +89,7 @@ export function useContractReads<
|
|
|
90
89
|
}, [contracts, query.enabled])
|
|
91
90
|
|
|
92
91
|
return useQuery({
|
|
93
|
-
...
|
|
92
|
+
...options,
|
|
94
93
|
...query,
|
|
95
94
|
enabled,
|
|
96
95
|
structuralSharing: query.structuralSharing ?? structuralSharing,
|
|
@@ -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 ReconnectErrorType } from '@wagmi/core'
|
|
5
5
|
import type { Evaluate } from '@wagmi/core/internal'
|
|
6
6
|
import {
|
|
7
7
|
type ReconnectData,
|
|
@@ -23,7 +23,7 @@ export type UseReconnectParameters<context = unknown> = Evaluate<
|
|
|
23
23
|
mutation?:
|
|
24
24
|
| UseMutationParameters<
|
|
25
25
|
ReconnectData,
|
|
26
|
-
|
|
26
|
+
ReconnectErrorType,
|
|
27
27
|
ReconnectVariables,
|
|
28
28
|
context
|
|
29
29
|
>
|
|
@@ -34,7 +34,7 @@ export type UseReconnectParameters<context = unknown> = Evaluate<
|
|
|
34
34
|
export type UseReconnectReturnType<context = unknown> = Evaluate<
|
|
35
35
|
UseMutationReturnType<
|
|
36
36
|
ReconnectData,
|
|
37
|
-
|
|
37
|
+
ReconnectErrorType,
|
|
38
38
|
ReconnectVariables,
|
|
39
39
|
context
|
|
40
40
|
> & {
|
|
@@ -44,7 +44,7 @@ export type UseReconnectReturnType<context = unknown> = Evaluate<
|
|
|
44
44
|
}
|
|
45
45
|
>
|
|
46
46
|
|
|
47
|
-
/** https://
|
|
47
|
+
/** https://wagmi.sh/react/api/hooks/useReconnect */
|
|
48
48
|
export function useReconnect<context = unknown>(
|
|
49
49
|
parameters: UseReconnectParameters<context> = {},
|
|
50
50
|
): UseReconnectReturnType<context> {
|
|
@@ -4,7 +4,7 @@ import { useMutation } from '@tanstack/react-query'
|
|
|
4
4
|
import type {
|
|
5
5
|
Config,
|
|
6
6
|
ResolvedRegister,
|
|
7
|
-
|
|
7
|
+
SendTransactionErrorType,
|
|
8
8
|
} from '@wagmi/core'
|
|
9
9
|
import type { Evaluate } from '@wagmi/core/internal'
|
|
10
10
|
import {
|
|
@@ -30,7 +30,7 @@ export type UseSendTransactionParameters<
|
|
|
30
30
|
mutation?:
|
|
31
31
|
| UseMutationParameters<
|
|
32
32
|
SendTransactionData,
|
|
33
|
-
|
|
33
|
+
SendTransactionErrorType,
|
|
34
34
|
SendTransactionVariables<config, config['chains'][number]['id']>,
|
|
35
35
|
context
|
|
36
36
|
>
|
|
@@ -44,7 +44,7 @@ export type UseSendTransactionReturnType<
|
|
|
44
44
|
> = Evaluate<
|
|
45
45
|
UseMutationReturnType<
|
|
46
46
|
SendTransactionData,
|
|
47
|
-
|
|
47
|
+
SendTransactionErrorType,
|
|
48
48
|
SendTransactionVariables<config, config['chains'][number]['id']>,
|
|
49
49
|
context
|
|
50
50
|
> & {
|
|
@@ -53,7 +53,7 @@ export type UseSendTransactionReturnType<
|
|
|
53
53
|
}
|
|
54
54
|
>
|
|
55
55
|
|
|
56
|
-
/** https://
|
|
56
|
+
/** https://wagmi.sh/react/api/hooks/useSendTransaction */
|
|
57
57
|
export function useSendTransaction<
|
|
58
58
|
config extends Config = ResolvedRegister['config'],
|
|
59
59
|
context = unknown,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import { useMutation } from '@tanstack/react-query'
|
|
4
|
-
import { type
|
|
4
|
+
import { type SignMessageErrorType } from '@wagmi/core'
|
|
5
5
|
import type { Evaluate } from '@wagmi/core/internal'
|
|
6
6
|
import {
|
|
7
7
|
type SignMessageData,
|
|
@@ -23,7 +23,7 @@ export type UseSignMessageParameters<context = unknown> = Evaluate<
|
|
|
23
23
|
mutation?:
|
|
24
24
|
| UseMutationParameters<
|
|
25
25
|
SignMessageData,
|
|
26
|
-
|
|
26
|
+
SignMessageErrorType,
|
|
27
27
|
SignMessageVariables,
|
|
28
28
|
context
|
|
29
29
|
>
|
|
@@ -34,7 +34,7 @@ export type UseSignMessageParameters<context = unknown> = Evaluate<
|
|
|
34
34
|
export type UseSignMessageReturnType<context = unknown> = Evaluate<
|
|
35
35
|
UseMutationReturnType<
|
|
36
36
|
SignMessageData,
|
|
37
|
-
|
|
37
|
+
SignMessageErrorType,
|
|
38
38
|
SignMessageVariables,
|
|
39
39
|
context
|
|
40
40
|
> & {
|
|
@@ -43,7 +43,7 @@ export type UseSignMessageReturnType<context = unknown> = Evaluate<
|
|
|
43
43
|
}
|
|
44
44
|
>
|
|
45
45
|
|
|
46
|
-
/** https://
|
|
46
|
+
/** https://wagmi.sh/react/api/hooks/useSignMessage */
|
|
47
47
|
export function useSignMessage<context = unknown>(
|
|
48
48
|
parameters: UseSignMessageParameters<context> = {},
|
|
49
49
|
): UseSignMessageReturnType<context> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import { useMutation } from '@tanstack/react-query'
|
|
4
|
-
import type {
|
|
4
|
+
import type { SignTypedDataErrorType } from '@wagmi/core'
|
|
5
5
|
import type { Evaluate } from '@wagmi/core/internal'
|
|
6
6
|
import {
|
|
7
7
|
type SignTypedDataData,
|
|
@@ -23,7 +23,7 @@ export type UseSignTypedDataParameters<context = unknown> = Evaluate<
|
|
|
23
23
|
mutation?:
|
|
24
24
|
| UseMutationParameters<
|
|
25
25
|
SignTypedDataData,
|
|
26
|
-
|
|
26
|
+
SignTypedDataErrorType,
|
|
27
27
|
SignTypedDataVariables,
|
|
28
28
|
context
|
|
29
29
|
>
|
|
@@ -34,7 +34,7 @@ export type UseSignTypedDataParameters<context = unknown> = Evaluate<
|
|
|
34
34
|
export type UseSignTypedDataReturnType<context = unknown> = Evaluate<
|
|
35
35
|
UseMutationReturnType<
|
|
36
36
|
SignTypedDataData,
|
|
37
|
-
|
|
37
|
+
SignTypedDataErrorType,
|
|
38
38
|
SignTypedDataVariables,
|
|
39
39
|
context
|
|
40
40
|
> & {
|
|
@@ -43,7 +43,7 @@ export type UseSignTypedDataReturnType<context = unknown> = Evaluate<
|
|
|
43
43
|
}
|
|
44
44
|
>
|
|
45
45
|
|
|
46
|
-
/** https://
|
|
46
|
+
/** https://wagmi.sh/react/api/hooks/useSignTypedData */
|
|
47
47
|
export function useSignTypedData<context = unknown>(
|
|
48
48
|
parameters: UseSignTypedDataParameters<context> = {},
|
|
49
49
|
): UseSignTypedDataReturnType<context> {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import type {
|
|
4
4
|
Config,
|
|
5
5
|
ResolvedRegister,
|
|
6
|
-
|
|
6
|
+
SimulateContractErrorType,
|
|
7
7
|
} from '@wagmi/core'
|
|
8
8
|
import {
|
|
9
9
|
type SimulateContractData,
|
|
@@ -14,17 +14,13 @@ import {
|
|
|
14
14
|
} from '@wagmi/core/query'
|
|
15
15
|
import type { Abi, ContractFunctionArgs, ContractFunctionName } from 'viem'
|
|
16
16
|
|
|
17
|
-
import type { ConfigParameter } from '../types/properties.js'
|
|
18
|
-
import {
|
|
19
|
-
type UseQueryParameters,
|
|
20
|
-
type UseQueryReturnType,
|
|
21
|
-
useQuery,
|
|
22
|
-
} from '../utils/query.js'
|
|
17
|
+
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
18
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
23
19
|
import { useChainId } from './useChainId.js'
|
|
24
20
|
import { useConfig } from './useConfig.js'
|
|
25
21
|
import { useConnectorClient } from './useConnectorClient.js'
|
|
26
22
|
|
|
27
|
-
export type
|
|
23
|
+
export type UseSimulateContractParameters<
|
|
28
24
|
abi extends Abi | readonly unknown[] = Abi,
|
|
29
25
|
functionName extends ContractFunctionName<
|
|
30
26
|
abi,
|
|
@@ -39,18 +35,15 @@ export type UseContractSimulateParameters<
|
|
|
39
35
|
chainId extends config['chains'][number]['id'] | undefined = undefined,
|
|
40
36
|
selectData = SimulateContractData<abi, functionName, args, config, chainId>,
|
|
41
37
|
> = SimulateContractOptions<abi, functionName, args, config, chainId> &
|
|
42
|
-
ConfigParameter<config> &
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
>
|
|
50
|
-
| undefined
|
|
51
|
-
}
|
|
38
|
+
ConfigParameter<config> &
|
|
39
|
+
QueryParameter<
|
|
40
|
+
SimulateContractQueryFnData<abi, functionName, args, config, chainId>,
|
|
41
|
+
SimulateContractErrorType,
|
|
42
|
+
selectData,
|
|
43
|
+
SimulateContractQueryKey<abi, functionName, args, config, chainId>
|
|
44
|
+
>
|
|
52
45
|
|
|
53
|
-
export type
|
|
46
|
+
export type UseSimulateContractReturnType<
|
|
54
47
|
abi extends Abi | readonly unknown[] = Abi,
|
|
55
48
|
functionName extends ContractFunctionName<
|
|
56
49
|
abi,
|
|
@@ -64,10 +57,10 @@ export type UseContractSimulateReturnType<
|
|
|
64
57
|
config extends Config = Config,
|
|
65
58
|
chainId extends config['chains'][number]['id'] | undefined = undefined,
|
|
66
59
|
selectData = SimulateContractData<abi, functionName, args, config, chainId>,
|
|
67
|
-
> = UseQueryReturnType<selectData,
|
|
60
|
+
> = UseQueryReturnType<selectData, SimulateContractErrorType>
|
|
68
61
|
|
|
69
|
-
/** https://
|
|
70
|
-
export function
|
|
62
|
+
/** https://wagmi.sh/react/api/hooks/useSimulateContract */
|
|
63
|
+
export function useSimulateContract<
|
|
71
64
|
const abi extends Abi | readonly unknown[],
|
|
72
65
|
functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,
|
|
73
66
|
args extends ContractFunctionArgs<
|
|
@@ -79,7 +72,7 @@ export function useContractSimulate<
|
|
|
79
72
|
chainId extends config['chains'][number]['id'] | undefined = undefined,
|
|
80
73
|
selectData = SimulateContractData<abi, functionName, args, config, chainId>,
|
|
81
74
|
>(
|
|
82
|
-
parameters:
|
|
75
|
+
parameters: UseSimulateContractParameters<
|
|
83
76
|
abi,
|
|
84
77
|
functionName,
|
|
85
78
|
args,
|
|
@@ -87,7 +80,7 @@ export function useContractSimulate<
|
|
|
87
80
|
chainId,
|
|
88
81
|
selectData
|
|
89
82
|
> = {} as any,
|
|
90
|
-
):
|
|
83
|
+
): UseSimulateContractReturnType<
|
|
91
84
|
abi,
|
|
92
85
|
functionName,
|
|
93
86
|
args,
|
|
@@ -104,8 +97,14 @@ export function useContractSimulate<
|
|
|
104
97
|
})
|
|
105
98
|
const chainId = useChainId()
|
|
106
99
|
|
|
107
|
-
const
|
|
108
|
-
|
|
100
|
+
const options = simulateContractQueryOptions<
|
|
101
|
+
config,
|
|
102
|
+
abi,
|
|
103
|
+
functionName,
|
|
104
|
+
args,
|
|
105
|
+
chainId
|
|
106
|
+
>(config, {
|
|
107
|
+
...parameters,
|
|
109
108
|
account: parameters.account ?? connectorClient?.account,
|
|
110
109
|
chainId: parameters.chainId ?? chainId,
|
|
111
110
|
})
|
|
@@ -113,5 +112,5 @@ export function useContractSimulate<
|
|
|
113
112
|
abi && address && functionName && (query.enabled ?? true),
|
|
114
113
|
)
|
|
115
114
|
|
|
116
|
-
return useQuery({ ...
|
|
115
|
+
return useQuery({ ...query, ...options, enabled })
|
|
117
116
|
}
|
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
Config,
|
|
6
6
|
Connector,
|
|
7
7
|
ResolvedRegister,
|
|
8
|
-
|
|
8
|
+
SwitchAccountErrorType,
|
|
9
9
|
} from '@wagmi/core'
|
|
10
10
|
import type { Evaluate } from '@wagmi/core/internal'
|
|
11
11
|
import {
|
|
@@ -32,7 +32,7 @@ export type UseSwitchAccountParameters<
|
|
|
32
32
|
mutation?:
|
|
33
33
|
| UseMutationParameters<
|
|
34
34
|
SwitchAccountData<config>,
|
|
35
|
-
|
|
35
|
+
SwitchAccountErrorType,
|
|
36
36
|
SwitchAccountVariables,
|
|
37
37
|
context
|
|
38
38
|
>
|
|
@@ -46,7 +46,7 @@ export type UseSwitchAccountReturnType<
|
|
|
46
46
|
> = Evaluate<
|
|
47
47
|
UseMutationReturnType<
|
|
48
48
|
SwitchAccountData<config>,
|
|
49
|
-
|
|
49
|
+
SwitchAccountErrorType,
|
|
50
50
|
SwitchAccountVariables,
|
|
51
51
|
context
|
|
52
52
|
> & {
|
|
@@ -56,7 +56,7 @@ export type UseSwitchAccountReturnType<
|
|
|
56
56
|
}
|
|
57
57
|
>
|
|
58
58
|
|
|
59
|
-
/** https://
|
|
59
|
+
/** https://wagmi.sh/react/api/hooks/useSwitchAccount */
|
|
60
60
|
export function useSwitchAccount<
|
|
61
61
|
config extends Config = ResolvedRegister['config'],
|
|
62
62
|
context = unknown,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import { useMutation } from '@tanstack/react-query'
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
Config,
|
|
6
|
+
ResolvedRegister,
|
|
7
|
+
SwitchChainErrorType,
|
|
8
|
+
} from '@wagmi/core'
|
|
5
9
|
import type { Evaluate } from '@wagmi/core/internal'
|
|
6
10
|
import {
|
|
7
11
|
type SwitchChainData,
|
|
@@ -26,7 +30,7 @@ export type UseSwitchChainParameters<
|
|
|
26
30
|
mutation?:
|
|
27
31
|
| UseMutationParameters<
|
|
28
32
|
SwitchChainData<config, config['chains'][number]['id']>,
|
|
29
|
-
|
|
33
|
+
SwitchChainErrorType,
|
|
30
34
|
SwitchChainVariables<config, config['chains'][number]['id']>,
|
|
31
35
|
context
|
|
32
36
|
>
|
|
@@ -40,7 +44,7 @@ export type UseSwitchChainReturnType<
|
|
|
40
44
|
> = Evaluate<
|
|
41
45
|
UseMutationReturnType<
|
|
42
46
|
SwitchChainData<config, config['chains'][number]['id']>,
|
|
43
|
-
|
|
47
|
+
SwitchChainErrorType,
|
|
44
48
|
SwitchChainVariables<config, config['chains'][number]['id']>,
|
|
45
49
|
context
|
|
46
50
|
> & {
|
|
@@ -50,7 +54,7 @@ export type UseSwitchChainReturnType<
|
|
|
50
54
|
}
|
|
51
55
|
>
|
|
52
56
|
|
|
53
|
-
/** https://
|
|
57
|
+
/** https://wagmi.sh/react/api/hooks/useSwitchChain */
|
|
54
58
|
export function useSwitchChain<
|
|
55
59
|
config extends Config = ResolvedRegister['config'],
|
|
56
60
|
context = unknown,
|
package/src/hooks/useToken.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import type { Config,
|
|
3
|
+
import type { Config, GetTokenErrorType, ResolvedRegister } from '@wagmi/core'
|
|
4
4
|
import { type Evaluate } from '@wagmi/core/internal'
|
|
5
5
|
import {
|
|
6
6
|
type GetTokenData,
|
|
@@ -10,12 +10,8 @@ import {
|
|
|
10
10
|
getTokenQueryOptions,
|
|
11
11
|
} from '@wagmi/core/query'
|
|
12
12
|
|
|
13
|
-
import type { ConfigParameter } from '../types/properties.js'
|
|
14
|
-
import {
|
|
15
|
-
type UseQueryParameters,
|
|
16
|
-
type UseQueryReturnType,
|
|
17
|
-
useQuery,
|
|
18
|
-
} from '../utils/query.js'
|
|
13
|
+
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
14
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
19
15
|
import { useChainId } from './useChainId.js'
|
|
20
16
|
import { useConfig } from './useConfig.js'
|
|
21
17
|
|
|
@@ -24,24 +20,25 @@ export type UseTokenParameters<
|
|
|
24
20
|
selectData = GetTokenData,
|
|
25
21
|
> = Evaluate<
|
|
26
22
|
GetTokenOptions<config> &
|
|
27
|
-
ConfigParameter<config> &
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
>
|
|
35
|
-
| undefined
|
|
36
|
-
}
|
|
23
|
+
ConfigParameter<config> &
|
|
24
|
+
QueryParameter<
|
|
25
|
+
GetTokenQueryFnData,
|
|
26
|
+
GetTokenErrorType,
|
|
27
|
+
selectData,
|
|
28
|
+
GetTokenQueryKey<config>
|
|
29
|
+
>
|
|
37
30
|
>
|
|
38
31
|
|
|
39
32
|
export type UseTokenReturnType<selectData = GetTokenData> = UseQueryReturnType<
|
|
40
33
|
selectData,
|
|
41
|
-
|
|
34
|
+
GetTokenErrorType
|
|
42
35
|
>
|
|
43
36
|
|
|
44
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated
|
|
39
|
+
*
|
|
40
|
+
* https://wagmi.sh/react/api/hooks/useToken
|
|
41
|
+
*/
|
|
45
42
|
export function useToken<
|
|
46
43
|
config extends Config = ResolvedRegister['config'],
|
|
47
44
|
selectData = GetTokenData,
|
|
@@ -53,11 +50,11 @@ export function useToken<
|
|
|
53
50
|
const config = useConfig(parameters)
|
|
54
51
|
const chainId = useChainId()
|
|
55
52
|
|
|
56
|
-
const
|
|
53
|
+
const options = getTokenQueryOptions(config, {
|
|
57
54
|
...parameters,
|
|
58
55
|
chainId: parameters.chainId ?? chainId,
|
|
59
56
|
})
|
|
60
57
|
const enabled = Boolean(address && (query.enabled ?? true))
|
|
61
58
|
|
|
62
|
-
return useQuery({ ...
|
|
59
|
+
return useQuery({ ...query, ...options, enabled })
|
|
63
60
|
}
|