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
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
Config,
|
|
5
|
+
GetTransactionErrorType,
|
|
6
|
+
ResolvedRegister,
|
|
7
|
+
} from '@wagmi/core'
|
|
4
8
|
import { type Evaluate } from '@wagmi/core/internal'
|
|
5
9
|
import {
|
|
6
10
|
type GetTransactionData,
|
|
@@ -10,12 +14,8 @@ import {
|
|
|
10
14
|
getTransactionQueryOptions,
|
|
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
|
|
|
@@ -25,25 +25,22 @@ export type UseTransactionParameters<
|
|
|
25
25
|
selectData = GetTransactionData<config, chainId>,
|
|
26
26
|
> = Evaluate<
|
|
27
27
|
GetTransactionOptions<config, chainId> &
|
|
28
|
-
ConfigParameter<config> &
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
>
|
|
36
|
-
| undefined
|
|
37
|
-
}
|
|
28
|
+
ConfigParameter<config> &
|
|
29
|
+
QueryParameter<
|
|
30
|
+
GetTransactionQueryFnData<config, chainId>,
|
|
31
|
+
GetTransactionErrorType,
|
|
32
|
+
selectData,
|
|
33
|
+
GetTransactionQueryKey<config, chainId>
|
|
34
|
+
>
|
|
38
35
|
>
|
|
39
36
|
|
|
40
37
|
export type UseTransactionReturnType<
|
|
41
38
|
config extends Config = Config,
|
|
42
39
|
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
43
40
|
selectData = GetTransactionData<config, chainId>,
|
|
44
|
-
> = UseQueryReturnType<selectData,
|
|
41
|
+
> = UseQueryReturnType<selectData, GetTransactionErrorType>
|
|
45
42
|
|
|
46
|
-
/** https://
|
|
43
|
+
/** https://wagmi.sh/react/api/hooks/useTransaction */
|
|
47
44
|
export function useTransaction<
|
|
48
45
|
config extends Config = ResolvedRegister['config'],
|
|
49
46
|
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
@@ -56,7 +53,7 @@ export function useTransaction<
|
|
|
56
53
|
const config = useConfig(parameters)
|
|
57
54
|
const chainId = useChainId()
|
|
58
55
|
|
|
59
|
-
const
|
|
56
|
+
const options = getTransactionQueryOptions(config, {
|
|
60
57
|
...parameters,
|
|
61
58
|
chainId: parameters.chainId ?? chainId,
|
|
62
59
|
})
|
|
@@ -64,5 +61,9 @@ export function useTransaction<
|
|
|
64
61
|
!(blockHash && blockNumber && blockTag && hash) && (query.enabled ?? true),
|
|
65
62
|
)
|
|
66
63
|
|
|
67
|
-
return useQuery({
|
|
64
|
+
return useQuery({
|
|
65
|
+
...(query as any),
|
|
66
|
+
...options,
|
|
67
|
+
enabled,
|
|
68
|
+
}) as UseTransactionReturnType<config, chainId, selectData>
|
|
68
69
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type Config,
|
|
5
|
+
type GetTransactionCountErrorType,
|
|
6
|
+
type ResolvedRegister,
|
|
7
|
+
} from '@wagmi/core'
|
|
8
|
+
import type { Evaluate } from '@wagmi/core/internal'
|
|
9
|
+
import type { GetTransactionCountQueryFnData } from '@wagmi/core/query'
|
|
10
|
+
import {
|
|
11
|
+
type GetTransactionCountData,
|
|
12
|
+
type GetTransactionCountOptions,
|
|
13
|
+
type GetTransactionCountQueryKey,
|
|
14
|
+
getTransactionCountQueryOptions,
|
|
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 UseTransactionCountParameters<
|
|
23
|
+
config extends Config = Config,
|
|
24
|
+
selectData = GetTransactionCountData,
|
|
25
|
+
> = Evaluate<
|
|
26
|
+
GetTransactionCountOptions<config> &
|
|
27
|
+
ConfigParameter<config> &
|
|
28
|
+
QueryParameter<
|
|
29
|
+
GetTransactionCountQueryFnData,
|
|
30
|
+
GetTransactionCountErrorType,
|
|
31
|
+
selectData,
|
|
32
|
+
GetTransactionCountQueryKey<config>
|
|
33
|
+
>
|
|
34
|
+
>
|
|
35
|
+
|
|
36
|
+
export type UseTransactionCountReturnType<
|
|
37
|
+
selectData = GetTransactionCountData,
|
|
38
|
+
> = UseQueryReturnType<selectData, GetTransactionCountErrorType>
|
|
39
|
+
|
|
40
|
+
/** https://wagmi.sh/react/api/hooks/useTransactionCount */
|
|
41
|
+
export function useTransactionCount<
|
|
42
|
+
config extends Config = ResolvedRegister['config'],
|
|
43
|
+
selectData = GetTransactionCountData,
|
|
44
|
+
>(
|
|
45
|
+
parameters: UseTransactionCountParameters<config, selectData> = {},
|
|
46
|
+
): UseTransactionCountReturnType<selectData> {
|
|
47
|
+
const { address, query = {} } = parameters
|
|
48
|
+
|
|
49
|
+
const config = useConfig(parameters)
|
|
50
|
+
const chainId = useChainId()
|
|
51
|
+
|
|
52
|
+
const options = getTransactionCountQueryOptions(config, {
|
|
53
|
+
...parameters,
|
|
54
|
+
chainId: parameters.chainId ?? chainId,
|
|
55
|
+
})
|
|
56
|
+
const enabled = Boolean(address && (query.enabled ?? true))
|
|
57
|
+
|
|
58
|
+
return useQuery({ ...query, ...options, enabled })
|
|
59
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type Config,
|
|
5
|
+
type ResolvedRegister,
|
|
6
|
+
type VerifyMessageErrorType,
|
|
7
|
+
} from '@wagmi/core'
|
|
8
|
+
import type { Evaluate } from '@wagmi/core/internal'
|
|
9
|
+
import {
|
|
10
|
+
type VerifyMessageData,
|
|
11
|
+
type VerifyMessageOptions,
|
|
12
|
+
type VerifyMessageQueryKey,
|
|
13
|
+
verifyMessageQueryOptions,
|
|
14
|
+
} from '@wagmi/core/query'
|
|
15
|
+
import type { VerifyMessageQueryFnData } from '@wagmi/core/query'
|
|
16
|
+
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
17
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
18
|
+
import { useChainId } from './useChainId.js'
|
|
19
|
+
import { useConfig } from './useConfig.js'
|
|
20
|
+
|
|
21
|
+
export type UseVerifyMessageParameters<
|
|
22
|
+
config extends Config = Config,
|
|
23
|
+
selectData = VerifyMessageData,
|
|
24
|
+
> = Evaluate<
|
|
25
|
+
VerifyMessageOptions<config> &
|
|
26
|
+
ConfigParameter<config> &
|
|
27
|
+
QueryParameter<
|
|
28
|
+
VerifyMessageQueryFnData,
|
|
29
|
+
VerifyMessageErrorType,
|
|
30
|
+
selectData,
|
|
31
|
+
VerifyMessageQueryKey
|
|
32
|
+
>
|
|
33
|
+
>
|
|
34
|
+
|
|
35
|
+
export type UseVerifyMessageReturnType<selectData = VerifyMessageData> =
|
|
36
|
+
UseQueryReturnType<selectData, VerifyMessageErrorType>
|
|
37
|
+
|
|
38
|
+
/** https://wagmi.sh/react/api/hooks/useVerifyMessage */
|
|
39
|
+
export function useVerifyMessage<
|
|
40
|
+
config extends Config = ResolvedRegister['config'],
|
|
41
|
+
selectData = VerifyMessageData,
|
|
42
|
+
>(
|
|
43
|
+
parameters: UseVerifyMessageParameters<config, selectData> = {},
|
|
44
|
+
): UseVerifyMessageReturnType<selectData> {
|
|
45
|
+
const { address, message, signature, query = {} } = parameters
|
|
46
|
+
|
|
47
|
+
const config = useConfig(parameters)
|
|
48
|
+
const chainId = useChainId()
|
|
49
|
+
|
|
50
|
+
const options = verifyMessageQueryOptions(config, {
|
|
51
|
+
...parameters,
|
|
52
|
+
chainId: parameters.chainId ?? chainId,
|
|
53
|
+
})
|
|
54
|
+
const enabled = Boolean(
|
|
55
|
+
address && message && signature && (query.enabled ?? true),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
return useQuery({ ...query, ...options, enabled })
|
|
59
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type Config,
|
|
5
|
+
type ResolvedRegister,
|
|
6
|
+
type VerifyTypedDataErrorType,
|
|
7
|
+
} from '@wagmi/core'
|
|
8
|
+
import {
|
|
9
|
+
type VerifyTypedDataData,
|
|
10
|
+
type VerifyTypedDataOptions,
|
|
11
|
+
type VerifyTypedDataQueryKey,
|
|
12
|
+
verifyTypedDataQueryOptions,
|
|
13
|
+
} from '@wagmi/core/query'
|
|
14
|
+
import type { VerifyTypedDataQueryFnData } from '@wagmi/core/query'
|
|
15
|
+
import { type TypedData } from 'viem'
|
|
16
|
+
import type { ConfigParameter, QueryParameter } from '../types/properties.js'
|
|
17
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query.js'
|
|
18
|
+
import { useChainId } from './useChainId.js'
|
|
19
|
+
import { useConfig } from './useConfig.js'
|
|
20
|
+
|
|
21
|
+
export type UseVerifyTypedDataParameters<
|
|
22
|
+
typedData extends TypedData | Record<string, unknown> = TypedData,
|
|
23
|
+
primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,
|
|
24
|
+
config extends Config = Config,
|
|
25
|
+
selectData = VerifyTypedDataData,
|
|
26
|
+
> = VerifyTypedDataOptions<typedData, primaryType, config> &
|
|
27
|
+
ConfigParameter<config> &
|
|
28
|
+
QueryParameter<
|
|
29
|
+
VerifyTypedDataQueryFnData,
|
|
30
|
+
VerifyTypedDataErrorType,
|
|
31
|
+
selectData,
|
|
32
|
+
VerifyTypedDataQueryKey<typedData, primaryType, config>
|
|
33
|
+
>
|
|
34
|
+
|
|
35
|
+
export type UseVerifyTypedDataReturnType<selectData = VerifyTypedDataData> =
|
|
36
|
+
UseQueryReturnType<selectData, VerifyTypedDataErrorType>
|
|
37
|
+
|
|
38
|
+
/** https://wagmi.sh/react/api/hooks/useVerifyTypedData */
|
|
39
|
+
export function useVerifyTypedData<
|
|
40
|
+
const typedData extends TypedData | Record<string, unknown>,
|
|
41
|
+
primaryType extends keyof typedData | 'EIP712Domain',
|
|
42
|
+
config extends Config = ResolvedRegister['config'],
|
|
43
|
+
selectData = VerifyTypedDataData,
|
|
44
|
+
>(
|
|
45
|
+
parameters: UseVerifyTypedDataParameters<
|
|
46
|
+
typedData,
|
|
47
|
+
primaryType,
|
|
48
|
+
config,
|
|
49
|
+
selectData
|
|
50
|
+
> = {} as any,
|
|
51
|
+
): UseVerifyTypedDataReturnType<selectData> {
|
|
52
|
+
const {
|
|
53
|
+
address,
|
|
54
|
+
message,
|
|
55
|
+
primaryType,
|
|
56
|
+
signature,
|
|
57
|
+
types,
|
|
58
|
+
query = {},
|
|
59
|
+
} = parameters
|
|
60
|
+
|
|
61
|
+
const config = useConfig(parameters)
|
|
62
|
+
const chainId = useChainId()
|
|
63
|
+
|
|
64
|
+
const options = verifyTypedDataQueryOptions<config, typedData, primaryType>(
|
|
65
|
+
config,
|
|
66
|
+
{
|
|
67
|
+
...parameters,
|
|
68
|
+
chainId: parameters.chainId ?? chainId,
|
|
69
|
+
},
|
|
70
|
+
)
|
|
71
|
+
const enabled = Boolean(
|
|
72
|
+
address &&
|
|
73
|
+
message &&
|
|
74
|
+
primaryType &&
|
|
75
|
+
signature &&
|
|
76
|
+
types &&
|
|
77
|
+
(query.enabled ?? true),
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
return useQuery({ ...query, ...options, enabled })
|
|
81
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import type {
|
|
4
4
|
Config,
|
|
5
5
|
ResolvedRegister,
|
|
6
|
-
|
|
6
|
+
WaitForTransactionReceiptErrorType,
|
|
7
7
|
} from '@wagmi/core'
|
|
8
8
|
import { type Evaluate } from '@wagmi/core/internal'
|
|
9
9
|
import {
|
|
@@ -14,12 +14,8 @@ import {
|
|
|
14
14
|
waitForTransactionReceiptQueryOptions,
|
|
15
15
|
} from '@wagmi/core/query'
|
|
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
|
|
|
@@ -29,25 +25,22 @@ export type UseWaitForTransactionReceiptParameters<
|
|
|
29
25
|
selectData = WaitForTransactionReceiptData<config, chainId>,
|
|
30
26
|
> = Evaluate<
|
|
31
27
|
WaitForTransactionReceiptOptions<config, chainId> &
|
|
32
|
-
ConfigParameter<config> &
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
>
|
|
40
|
-
| undefined
|
|
41
|
-
}
|
|
28
|
+
ConfigParameter<config> &
|
|
29
|
+
QueryParameter<
|
|
30
|
+
WaitForTransactionReceiptQueryFnData<config, chainId>,
|
|
31
|
+
WaitForTransactionReceiptErrorType,
|
|
32
|
+
selectData,
|
|
33
|
+
WaitForTransactionReceiptQueryKey<config, chainId>
|
|
34
|
+
>
|
|
42
35
|
>
|
|
43
36
|
|
|
44
37
|
export type UseWaitForTransactionReceiptReturnType<
|
|
45
38
|
config extends Config = Config,
|
|
46
39
|
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
47
40
|
selectData = WaitForTransactionReceiptData<config, chainId>,
|
|
48
|
-
> = UseQueryReturnType<selectData,
|
|
41
|
+
> = UseQueryReturnType<selectData, WaitForTransactionReceiptErrorType>
|
|
49
42
|
|
|
50
|
-
/** https://
|
|
43
|
+
/** https://wagmi.sh/react/api/hooks/useWaitForTransactionReceipt */
|
|
51
44
|
export function useWaitForTransactionReceipt<
|
|
52
45
|
config extends Config = ResolvedRegister['config'],
|
|
53
46
|
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
@@ -64,11 +57,15 @@ export function useWaitForTransactionReceipt<
|
|
|
64
57
|
const config = useConfig(parameters)
|
|
65
58
|
const chainId = useChainId()
|
|
66
59
|
|
|
67
|
-
const
|
|
60
|
+
const options = waitForTransactionReceiptQueryOptions(config, {
|
|
68
61
|
...parameters,
|
|
69
62
|
chainId: parameters.chainId ?? chainId,
|
|
70
63
|
})
|
|
71
|
-
const enabled = Boolean(
|
|
64
|
+
const enabled = Boolean(hash && (query.enabled ?? true))
|
|
72
65
|
|
|
73
|
-
return useQuery({
|
|
66
|
+
return useQuery({
|
|
67
|
+
...(query as any),
|
|
68
|
+
...options,
|
|
69
|
+
enabled,
|
|
70
|
+
}) as UseWaitForTransactionReceiptReturnType<config, chainId, selectData>
|
|
74
71
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { useQueryClient } from '@tanstack/react-query'
|
|
7
7
|
import type {
|
|
8
8
|
Config,
|
|
9
|
-
|
|
9
|
+
GetWalletClientErrorType,
|
|
10
10
|
ResolvedRegister,
|
|
11
11
|
} from '@wagmi/core'
|
|
12
12
|
import { type Evaluate, type Omit } from '@wagmi/core/internal'
|
|
@@ -36,17 +36,19 @@ export type UseWalletClientParameters<
|
|
|
36
36
|
> = Evaluate<
|
|
37
37
|
GetWalletClientOptions<config, chainId> &
|
|
38
38
|
ConfigParameter<config> & {
|
|
39
|
-
query?:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
query?:
|
|
40
|
+
| Evaluate<
|
|
41
|
+
Omit<
|
|
42
|
+
UseQueryParameters<
|
|
43
|
+
GetWalletClientQueryFnData<config, chainId>,
|
|
44
|
+
GetWalletClientErrorType,
|
|
45
|
+
selectData,
|
|
46
|
+
GetWalletClientQueryKey<config, chainId>
|
|
47
|
+
>,
|
|
48
|
+
'gcTime' | 'staleTime'
|
|
49
|
+
>
|
|
50
|
+
>
|
|
51
|
+
| undefined
|
|
50
52
|
}
|
|
51
53
|
>
|
|
52
54
|
|
|
@@ -54,9 +56,9 @@ export type UseWalletClientReturnType<
|
|
|
54
56
|
config extends Config = Config,
|
|
55
57
|
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
56
58
|
selectData = GetWalletClientData<config, chainId>,
|
|
57
|
-
> = UseQueryReturnType<selectData,
|
|
59
|
+
> = UseQueryReturnType<selectData, GetWalletClientErrorType>
|
|
58
60
|
|
|
59
|
-
/** https://
|
|
61
|
+
/** https://wagmi.sh/react/api/hooks/useWalletClient */
|
|
60
62
|
export function useWalletClient<
|
|
61
63
|
config extends Config = ResolvedRegister['config'],
|
|
62
64
|
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
@@ -71,11 +73,14 @@ export function useWalletClient<
|
|
|
71
73
|
const { address, connector, status } = useAccount()
|
|
72
74
|
const chainId = useChainId()
|
|
73
75
|
|
|
74
|
-
const { queryKey, ...options } = getWalletClientQueryOptions
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
const { queryKey, ...options } = getWalletClientQueryOptions<config, chainId>(
|
|
77
|
+
config,
|
|
78
|
+
{
|
|
79
|
+
...parameters,
|
|
80
|
+
chainId: parameters.chainId ?? chainId,
|
|
81
|
+
connector: parameters.connector ?? connector,
|
|
82
|
+
},
|
|
83
|
+
)
|
|
79
84
|
const enabled = Boolean(status !== 'disconnected' && (query.enabled ?? true))
|
|
80
85
|
|
|
81
86
|
// biome-ignore lint/nursery/useExhaustiveDependencies: `queryKey` not required
|
|
@@ -86,11 +91,10 @@ export function useWalletClient<
|
|
|
86
91
|
}, [address, queryClient])
|
|
87
92
|
|
|
88
93
|
return useQuery({
|
|
89
|
-
...options,
|
|
90
94
|
...query,
|
|
95
|
+
...options,
|
|
91
96
|
queryKey,
|
|
92
97
|
enabled,
|
|
93
|
-
gcTime: 0,
|
|
94
98
|
staleTime: Infinity,
|
|
95
99
|
})
|
|
96
100
|
}
|
|
@@ -24,7 +24,7 @@ export type UseWatchBlockNumberParameters<
|
|
|
24
24
|
|
|
25
25
|
export type UseWatchBlockNumberReturnType = void
|
|
26
26
|
|
|
27
|
-
/** https://
|
|
27
|
+
/** https://wagmi.sh/react/api/hooks/useWatchBlockNumber */
|
|
28
28
|
export function useWatchBlockNumber<
|
|
29
29
|
config extends Config = ResolvedRegister['config'],
|
|
30
30
|
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type Config,
|
|
5
|
+
type ResolvedRegister,
|
|
6
|
+
type WatchBlocksParameters,
|
|
7
|
+
watchBlocks,
|
|
8
|
+
} from '@wagmi/core'
|
|
9
|
+
import { type UnionEvaluate, type UnionPartial } from '@wagmi/core/internal'
|
|
10
|
+
import { useEffect } from 'react'
|
|
11
|
+
import type { BlockTag } from 'viem'
|
|
12
|
+
|
|
13
|
+
import type { ConfigParameter, EnabledParameter } from '../types/properties.js'
|
|
14
|
+
import { useChainId } from './useChainId.js'
|
|
15
|
+
import { useConfig } from './useConfig.js'
|
|
16
|
+
|
|
17
|
+
export type UseWatchBlocksParameters<
|
|
18
|
+
includeTransactions extends boolean = false,
|
|
19
|
+
blockTag extends BlockTag = 'latest',
|
|
20
|
+
config extends Config = Config,
|
|
21
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
22
|
+
> = UnionEvaluate<
|
|
23
|
+
UnionPartial<
|
|
24
|
+
WatchBlocksParameters<includeTransactions, blockTag, config, chainId>
|
|
25
|
+
> &
|
|
26
|
+
ConfigParameter<config> &
|
|
27
|
+
EnabledParameter
|
|
28
|
+
>
|
|
29
|
+
|
|
30
|
+
export type UseWatchBlocksReturnType = void
|
|
31
|
+
|
|
32
|
+
/** https://wagmi.sh/react/hooks/useWatchBlocks */
|
|
33
|
+
export function useWatchBlocks<
|
|
34
|
+
config extends Config = ResolvedRegister['config'],
|
|
35
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
36
|
+
includeTransactions extends boolean = false,
|
|
37
|
+
blockTag extends BlockTag = 'latest',
|
|
38
|
+
>(
|
|
39
|
+
parameters: UseWatchBlocksParameters<
|
|
40
|
+
includeTransactions,
|
|
41
|
+
blockTag,
|
|
42
|
+
config,
|
|
43
|
+
chainId
|
|
44
|
+
> = {} as any,
|
|
45
|
+
): UseWatchBlocksReturnType {
|
|
46
|
+
const { enabled = true, onBlock, config: _, ...rest } = parameters
|
|
47
|
+
|
|
48
|
+
const config = useConfig(parameters)
|
|
49
|
+
const configChainId = useChainId()
|
|
50
|
+
const chainId = parameters.chainId ?? configChainId
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!enabled) return
|
|
54
|
+
if (!onBlock) return
|
|
55
|
+
return watchBlocks(config, {
|
|
56
|
+
...(rest as any),
|
|
57
|
+
chainId,
|
|
58
|
+
onBlock,
|
|
59
|
+
})
|
|
60
|
+
}, [chainId, config, enabled, onBlock, rest])
|
|
61
|
+
}
|
|
@@ -30,7 +30,7 @@ export type UseWatchContractEventParameters<
|
|
|
30
30
|
|
|
31
31
|
export type UseWatchContractEventReturnType = void
|
|
32
32
|
|
|
33
|
-
/** https://
|
|
33
|
+
/** https://wagmi.sh/react/api/hooks/useWatchContractEvent */
|
|
34
34
|
export function useWatchContractEvent<
|
|
35
35
|
const abi extends Abi | readonly unknown[],
|
|
36
36
|
eventName extends ContractEventName<abi>,
|
|
@@ -24,7 +24,7 @@ export type UseWatchPendingTransactionsParameters<
|
|
|
24
24
|
|
|
25
25
|
export type UseWatchPendingTransactionsReturnType = void
|
|
26
26
|
|
|
27
|
-
/** https://
|
|
27
|
+
/** https://wagmi.sh/react/api/hooks/useWatchPendingTransactions */
|
|
28
28
|
export function useWatchPendingTransactions<
|
|
29
29
|
config extends Config = ResolvedRegister['config'],
|
|
30
30
|
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
@@ -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
|
+
WriteContractErrorType,
|
|
8
|
+
} from '@wagmi/core'
|
|
5
9
|
import {
|
|
6
10
|
type WriteContractData,
|
|
7
11
|
type WriteContractMutate,
|
|
@@ -18,14 +22,14 @@ import type {
|
|
|
18
22
|
} from '../utils/query.js'
|
|
19
23
|
import { useConfig } from './useConfig.js'
|
|
20
24
|
|
|
21
|
-
export type
|
|
25
|
+
export type UseWriteContractParameters<
|
|
22
26
|
config extends Config = Config,
|
|
23
27
|
context = unknown,
|
|
24
28
|
> = ConfigParameter<config> & {
|
|
25
29
|
mutation?:
|
|
26
30
|
| UseMutationParameters<
|
|
27
31
|
WriteContractData,
|
|
28
|
-
|
|
32
|
+
WriteContractErrorType,
|
|
29
33
|
WriteContractVariables<
|
|
30
34
|
Abi,
|
|
31
35
|
string,
|
|
@@ -38,12 +42,12 @@ export type UseContractWriteParameters<
|
|
|
38
42
|
| undefined
|
|
39
43
|
}
|
|
40
44
|
|
|
41
|
-
export type
|
|
45
|
+
export type UseWriteContractReturnType<
|
|
42
46
|
config extends Config = Config,
|
|
43
47
|
context = unknown,
|
|
44
48
|
> = UseMutationReturnType<
|
|
45
49
|
WriteContractData,
|
|
46
|
-
|
|
50
|
+
WriteContractErrorType,
|
|
47
51
|
WriteContractVariables<
|
|
48
52
|
Abi,
|
|
49
53
|
string,
|
|
@@ -53,17 +57,17 @@ export type UseContractWriteReturnType<
|
|
|
53
57
|
>,
|
|
54
58
|
context
|
|
55
59
|
> & {
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
writeContract: WriteContractMutate<config, context>
|
|
61
|
+
writeContractAsync: WriteContractMutateAsync<config, context>
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
/** https://
|
|
61
|
-
export function
|
|
64
|
+
/** https://wagmi.sh/react/api/hooks/useWriteContract */
|
|
65
|
+
export function useWriteContract<
|
|
62
66
|
config extends Config = ResolvedRegister['config'],
|
|
63
67
|
context = unknown,
|
|
64
68
|
>(
|
|
65
|
-
parameters:
|
|
66
|
-
):
|
|
69
|
+
parameters: UseWriteContractParameters<config, context> = {},
|
|
70
|
+
): UseWriteContractReturnType<config, context> {
|
|
67
71
|
const { mutation } = parameters
|
|
68
72
|
|
|
69
73
|
const config = useConfig(parameters)
|
|
@@ -74,10 +78,10 @@ export function useContractWrite<
|
|
|
74
78
|
...mutationOptions,
|
|
75
79
|
})
|
|
76
80
|
|
|
77
|
-
type Return =
|
|
81
|
+
type Return = UseWriteContractReturnType<config, context>
|
|
78
82
|
return {
|
|
79
83
|
...result,
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
writeContract: mutate as Return['writeContract'],
|
|
85
|
+
writeContractAsync: mutateAsync as Return['writeContractAsync'],
|
|
82
86
|
}
|
|
83
87
|
}
|
package/src/hydrate.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { type ResolvedRegister, type State, hydrate } from '@wagmi/core'
|
|
4
|
+
import { type ReactElement, useEffect, useRef } from 'react'
|
|
5
|
+
|
|
6
|
+
export type HydrateProps = {
|
|
7
|
+
config: ResolvedRegister['config']
|
|
8
|
+
initialState?: State | undefined
|
|
9
|
+
reconnectOnMount?: boolean | undefined
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function Hydrate(parameters: React.PropsWithChildren<HydrateProps>) {
|
|
13
|
+
const { children, config, initialState, reconnectOnMount = true } = parameters
|
|
14
|
+
|
|
15
|
+
const { onMount } = hydrate(config, {
|
|
16
|
+
initialState,
|
|
17
|
+
reconnectOnMount,
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
// Hydrate for non-SSR
|
|
21
|
+
if (!config._internal.ssr) onMount()
|
|
22
|
+
|
|
23
|
+
// Hydrate for SSR
|
|
24
|
+
const active = useRef(true)
|
|
25
|
+
// biome-ignore lint/nursery/useExhaustiveDependencies:
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!active.current) return
|
|
28
|
+
if (!config._internal.ssr) return
|
|
29
|
+
onMount()
|
|
30
|
+
return () => {
|
|
31
|
+
active.current = false
|
|
32
|
+
}
|
|
33
|
+
}, [])
|
|
34
|
+
|
|
35
|
+
return children as ReactElement
|
|
36
|
+
}
|