wagmi 2.0.0-beta.8 → 2.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/esm/errors/base.js +1 -1
- package/dist/esm/errors/base.js.map +1 -1
- package/dist/esm/errors/context.js +1 -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 +11 -2
- package/dist/esm/exports/codegen.js.map +1 -1
- package/dist/esm/exports/connectors.js +1 -0
- package/dist/esm/exports/connectors.js.map +1 -1
- package/dist/esm/exports/index.js +13 -1
- 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/{createWriteContract.js → createUseWriteContract.js} +33 -14
- 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 +1 -1
- package/dist/esm/hooks/useAccountEffect.js.map +1 -1
- package/dist/esm/hooks/useBalance.js +1 -1
- package/dist/esm/hooks/useBalance.js.map +1 -1
- package/dist/esm/hooks/useBlock.js +1 -1
- package/dist/esm/hooks/useBlock.js.map +1 -1
- package/dist/esm/hooks/useBlockNumber.js +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/esm/hooks/useConnect.js.map +1 -1
- package/dist/esm/hooks/useConnections.js +1 -1
- package/dist/esm/hooks/useConnections.js.map +1 -1
- package/dist/esm/hooks/useConnectorClient.js +1 -1
- package/dist/esm/hooks/useConnectorClient.js.map +1 -1
- package/dist/esm/hooks/useConnectors.js +1 -1
- package/dist/esm/hooks/useConnectors.js.map +1 -1
- package/dist/esm/hooks/useDisconnect.js +1 -1
- package/dist/esm/hooks/useDisconnect.js.map +1 -1
- package/dist/esm/hooks/useEnsAddress.js +1 -1
- package/dist/esm/hooks/useEnsAddress.js.map +1 -1
- package/dist/esm/hooks/useEnsAvatar.js +1 -1
- package/dist/esm/hooks/useEnsAvatar.js.map +1 -1
- package/dist/esm/hooks/useEnsName.js +1 -1
- package/dist/esm/hooks/useEnsName.js.map +1 -1
- package/dist/esm/hooks/useEnsResolver.js +1 -1
- package/dist/esm/hooks/useEnsResolver.js.map +1 -1
- package/dist/esm/hooks/useEstimateFeesPerGas.js +1 -1
- package/dist/esm/hooks/useEstimateFeesPerGas.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 +1 -1
- package/dist/esm/hooks/useInfiniteReadContracts.js.map +1 -1
- package/dist/esm/hooks/usePublicClient.js +1 -1
- package/dist/esm/hooks/usePublicClient.js.map +1 -1
- package/dist/esm/hooks/useReadContract.js +1 -1
- package/dist/esm/hooks/useReadContract.js.map +1 -1
- package/dist/esm/hooks/useReadContracts.js +1 -1
- package/dist/esm/hooks/useReadContracts.js.map +1 -1
- 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/useSimulateContract.js +1 -1
- package/dist/esm/hooks/useSimulateContract.js.map +1 -1
- 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 +1 -1
- package/dist/esm/hooks/useTransaction.js +1 -1
- package/dist/esm/hooks/useTransaction.js.map +1 -1
- package/dist/esm/hooks/useTransactionCount.js +1 -1
- package/dist/esm/hooks/useTransactionCount.js.map +1 -1
- 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 +1 -1
- package/dist/esm/hooks/useWaitForTransactionReceipt.js.map +1 -1
- package/dist/esm/hooks/useWalletClient.js +1 -1
- 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 +1 -1
- package/dist/esm/hooks/useWatchBlocks.js.map +1 -1
- 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/useWriteContract.js +1 -1
- package/dist/esm/hooks/useWriteContract.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.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 +5 -2
- package/dist/types/exports/codegen.d.ts.map +1 -1
- package/dist/types/exports/connectors.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +6 -0
- 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 +1 -1
- package/dist/types/hooks/useAccountEffect.d.ts.map +1 -1
- package/dist/types/hooks/useBalance.d.ts +1 -1
- package/dist/types/hooks/useBalance.d.ts.map +1 -1
- package/dist/types/hooks/useBlock.d.ts +1 -1
- package/dist/types/hooks/useBlock.d.ts.map +1 -1
- package/dist/types/hooks/useBlockNumber.d.ts +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/types/hooks/useConnectorClient.d.ts.map +1 -1
- package/dist/types/hooks/useConnectors.d.ts +1 -1
- package/dist/types/hooks/useConnectors.d.ts.map +1 -1
- package/dist/types/hooks/useDisconnect.d.ts +1 -1
- package/dist/types/hooks/useDisconnect.d.ts.map +1 -1
- package/dist/types/hooks/useEnsAddress.d.ts +1 -1
- package/dist/types/hooks/useEnsAddress.d.ts.map +1 -1
- package/dist/types/hooks/useEnsAvatar.d.ts +1 -1
- package/dist/types/hooks/useEnsAvatar.d.ts.map +1 -1
- package/dist/types/hooks/useEnsName.d.ts +1 -1
- package/dist/types/hooks/useEnsName.d.ts.map +1 -1
- package/dist/types/hooks/useEnsResolver.d.ts +1 -1
- package/dist/types/hooks/useEnsResolver.d.ts.map +1 -1
- package/dist/types/hooks/useEstimateFeesPerGas.d.ts +1 -1
- package/dist/types/hooks/useEstimateFeesPerGas.d.ts.map +1 -1
- package/dist/types/hooks/useEstimateGas.d.ts +1 -1
- 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 +1 -1
- package/dist/types/hooks/useInfiniteReadContracts.d.ts.map +1 -1
- package/dist/types/hooks/usePublicClient.d.ts +1 -1
- package/dist/types/hooks/usePublicClient.d.ts.map +1 -1
- package/dist/types/hooks/useReadContract.d.ts +1 -1
- package/dist/types/hooks/useReadContract.d.ts.map +1 -1
- package/dist/types/hooks/useReadContracts.d.ts +1 -1
- package/dist/types/hooks/useReadContracts.d.ts.map +1 -1
- package/dist/types/hooks/useReconnect.d.ts +1 -1
- package/dist/types/hooks/useReconnect.d.ts.map +1 -1
- package/dist/types/hooks/useSendTransaction.d.ts +1 -1
- package/dist/types/hooks/useSendTransaction.d.ts.map +1 -1
- package/dist/types/hooks/useSignMessage.d.ts +1 -1
- package/dist/types/hooks/useSignMessage.d.ts.map +1 -1
- package/dist/types/hooks/useSignTypedData.d.ts +1 -1
- package/dist/types/hooks/useSignTypedData.d.ts.map +1 -1
- package/dist/types/hooks/useSimulateContract.d.ts +1 -1
- package/dist/types/hooks/useSimulateContract.d.ts.map +1 -1
- package/dist/types/hooks/useSwitchAccount.d.ts +1 -1
- package/dist/types/hooks/useSwitchAccount.d.ts.map +1 -1
- package/dist/types/hooks/useSwitchChain.d.ts +1 -1
- package/dist/types/hooks/useSwitchChain.d.ts.map +1 -1
- package/dist/types/hooks/useToken.d.ts +1 -1
- package/dist/types/hooks/useTransaction.d.ts +1 -1
- package/dist/types/hooks/useTransaction.d.ts.map +1 -1
- package/dist/types/hooks/useTransactionCount.d.ts +1 -1
- package/dist/types/hooks/useTransactionCount.d.ts.map +1 -1
- 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 +1 -1
- package/dist/types/hooks/useWaitForTransactionReceipt.d.ts.map +1 -1
- package/dist/types/hooks/useWalletClient.d.ts +1 -1
- 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 +1 -1
- package/dist/types/hooks/useWatchBlocks.d.ts.map +1 -1
- 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 +1 -1
- package/dist/types/hooks/useWriteContract.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/errors/base.ts +1 -1
- package/src/errors/context.ts +1 -1
- package/src/exports/actions.ts +2 -1
- package/src/exports/chains.ts +1 -0
- package/src/exports/codegen.ts +16 -2
- package/src/exports/connectors.ts +1 -0
- package/src/exports/index.ts +43 -1
- package/src/exports/query.ts +1 -0
- package/src/hooks/codegen/{createReadContract.ts → createUseReadContract.ts} +44 -18
- package/src/hooks/codegen/createUseSimulateContract.ts +121 -0
- package/src/hooks/codegen/createUseWatchContractEvent.ts +98 -0
- package/src/hooks/codegen/{createWriteContract.ts → createUseWriteContract.ts} +102 -37
- package/src/hooks/useAccount.ts +1 -1
- package/src/hooks/useAccountEffect.ts +1 -1
- package/src/hooks/useBalance.ts +1 -1
- package/src/hooks/useBlock.ts +1 -1
- package/src/hooks/useBlockNumber.ts +1 -1
- package/src/hooks/useBlockTransactionCount.ts +65 -0
- package/src/hooks/useChainId.ts +1 -1
- package/src/hooks/useClient.ts +1 -1
- package/src/hooks/useConfig.ts +1 -1
- package/src/hooks/useConnect.ts +1 -1
- package/src/hooks/useConnections.ts +1 -1
- package/src/hooks/useConnectorClient.ts +1 -1
- package/src/hooks/useConnectors.ts +1 -1
- package/src/hooks/useDisconnect.ts +1 -1
- package/src/hooks/useEnsAddress.ts +1 -1
- package/src/hooks/useEnsAvatar.ts +1 -1
- package/src/hooks/useEnsName.ts +1 -1
- package/src/hooks/useEnsResolver.ts +1 -1
- package/src/hooks/useEstimateFeesPerGas.ts +1 -1
- package/src/hooks/useEstimateGas.ts +1 -1
- 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 +1 -1
- package/src/hooks/usePublicClient.ts +1 -1
- package/src/hooks/useReadContract.ts +1 -1
- package/src/hooks/useReadContracts.ts +1 -1
- package/src/hooks/useReconnect.ts +1 -1
- package/src/hooks/useSendTransaction.ts +1 -1
- package/src/hooks/useSignMessage.ts +1 -1
- package/src/hooks/useSignTypedData.ts +1 -1
- package/src/hooks/useSimulateContract.ts +1 -1
- package/src/hooks/useSwitchAccount.ts +1 -1
- package/src/hooks/useSwitchChain.ts +1 -1
- package/src/hooks/useToken.ts +1 -1
- package/src/hooks/useTransaction.ts +1 -1
- package/src/hooks/useTransactionCount.ts +1 -1
- package/src/hooks/useVerifyMessage.ts +59 -0
- package/src/hooks/useVerifyTypedData.ts +81 -0
- package/src/hooks/useWaitForTransactionReceipt.ts +1 -1
- package/src/hooks/useWalletClient.ts +1 -1
- package/src/hooks/useWatchBlockNumber.ts +1 -1
- package/src/hooks/useWatchBlocks.ts +1 -1
- package/src/hooks/useWatchContractEvent.ts +1 -1
- package/src/hooks/useWatchPendingTransactions.ts +1 -1
- package/src/hooks/useWriteContract.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/esm/hooks/codegen/createReadContract.js +0 -23
- package/dist/esm/hooks/codegen/createReadContract.js.map +0 -1
- package/dist/esm/hooks/codegen/createWriteContract.js.map +0 -1
- package/dist/types/hooks/codegen/createReadContract.d.ts +0 -17
- package/dist/types/hooks/codegen/createReadContract.d.ts.map +0 -1
- package/dist/types/hooks/codegen/createWriteContract.d.ts +0 -26
- package/dist/types/hooks/codegen/createWriteContract.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type MutateOptions } from '@tanstack/react-query'
|
|
2
2
|
import {
|
|
3
3
|
type Config,
|
|
4
4
|
type ResolvedRegister,
|
|
@@ -37,40 +37,64 @@ import {
|
|
|
37
37
|
|
|
38
38
|
type stateMutability = 'nonpayable' | 'payable'
|
|
39
39
|
|
|
40
|
-
export type
|
|
40
|
+
export type CreateUseWriteContractParameters<
|
|
41
41
|
abi extends Abi | readonly unknown[],
|
|
42
42
|
address extends Address | Record<number, Address> | undefined = undefined,
|
|
43
|
+
functionName extends
|
|
44
|
+
| ContractFunctionName<abi, stateMutability>
|
|
45
|
+
| undefined = undefined,
|
|
43
46
|
> = {
|
|
44
47
|
abi: abi | Abi | readonly unknown[]
|
|
45
48
|
address?: address | Address | Record<number, Address> | undefined
|
|
49
|
+
functionName?:
|
|
50
|
+
| functionName
|
|
51
|
+
| ContractFunctionName<abi, stateMutability>
|
|
52
|
+
| undefined
|
|
46
53
|
}
|
|
47
54
|
|
|
48
|
-
export type
|
|
55
|
+
export type CreateUseWriteContractReturnType<
|
|
49
56
|
abi extends Abi | readonly unknown[],
|
|
50
57
|
address extends Address | Record<number, Address> | undefined,
|
|
58
|
+
functionName extends ContractFunctionName<abi, stateMutability> | undefined,
|
|
51
59
|
> = <config extends Config = ResolvedRegister['config'], context = unknown>(
|
|
52
60
|
parameters?: UseWriteContractParameters<config, context>,
|
|
53
61
|
) => Evaluate<
|
|
54
|
-
|
|
62
|
+
Omit<
|
|
63
|
+
wagmi_UseWriteContractReturnType<config, context>,
|
|
64
|
+
'writeContract' | 'writeContractAsync'
|
|
65
|
+
> & {
|
|
55
66
|
writeContract: <
|
|
56
67
|
const abi2 extends abi,
|
|
57
|
-
functionName extends ContractFunctionName<
|
|
58
|
-
|
|
68
|
+
name extends functionName extends ContractFunctionName<
|
|
69
|
+
abi,
|
|
70
|
+
stateMutability
|
|
71
|
+
>
|
|
72
|
+
? functionName
|
|
73
|
+
: ContractFunctionName<abi, stateMutability>,
|
|
74
|
+
args extends ContractFunctionArgs<abi2, stateMutability, name>,
|
|
59
75
|
chainId extends config['chains'][number]['id'],
|
|
60
76
|
>(
|
|
61
|
-
variables: Variables<
|
|
77
|
+
variables: Variables<
|
|
78
|
+
abi2,
|
|
79
|
+
functionName,
|
|
80
|
+
name,
|
|
81
|
+
args,
|
|
82
|
+
config,
|
|
83
|
+
chainId,
|
|
84
|
+
address
|
|
85
|
+
>,
|
|
62
86
|
options?:
|
|
63
87
|
| MutateOptions<
|
|
64
88
|
WriteContractData,
|
|
65
89
|
WriteContractErrorType,
|
|
66
90
|
WriteContractVariables<
|
|
67
91
|
abi2,
|
|
68
|
-
|
|
92
|
+
name,
|
|
69
93
|
args,
|
|
70
94
|
config,
|
|
71
95
|
chainId,
|
|
72
96
|
// use `functionName` to make sure it's not union of all possible function names
|
|
73
|
-
|
|
97
|
+
name
|
|
74
98
|
>,
|
|
75
99
|
context
|
|
76
100
|
>
|
|
@@ -78,23 +102,36 @@ export type CreateWriteContractReturnType<
|
|
|
78
102
|
) => void
|
|
79
103
|
writeContractAsync: <
|
|
80
104
|
const abi2 extends abi,
|
|
81
|
-
functionName extends ContractFunctionName<
|
|
82
|
-
|
|
105
|
+
name extends functionName extends ContractFunctionName<
|
|
106
|
+
abi,
|
|
107
|
+
stateMutability
|
|
108
|
+
>
|
|
109
|
+
? functionName
|
|
110
|
+
: ContractFunctionName<abi, stateMutability>,
|
|
111
|
+
args extends ContractFunctionArgs<abi2, stateMutability, name>,
|
|
83
112
|
chainId extends config['chains'][number]['id'],
|
|
84
113
|
>(
|
|
85
|
-
variables: Variables<
|
|
114
|
+
variables: Variables<
|
|
115
|
+
abi2,
|
|
116
|
+
functionName,
|
|
117
|
+
name,
|
|
118
|
+
args,
|
|
119
|
+
config,
|
|
120
|
+
chainId,
|
|
121
|
+
address
|
|
122
|
+
>,
|
|
86
123
|
options?:
|
|
87
124
|
| MutateOptions<
|
|
88
125
|
WriteContractData,
|
|
89
126
|
WriteContractErrorType,
|
|
90
127
|
WriteContractVariables<
|
|
91
128
|
abi2,
|
|
92
|
-
|
|
129
|
+
name,
|
|
93
130
|
args,
|
|
94
131
|
config,
|
|
95
132
|
chainId,
|
|
96
133
|
// use `functionName` to make sure it's not union of all possible function names
|
|
97
|
-
|
|
134
|
+
name
|
|
98
135
|
>,
|
|
99
136
|
context
|
|
100
137
|
>
|
|
@@ -103,23 +140,26 @@ export type CreateWriteContractReturnType<
|
|
|
103
140
|
}
|
|
104
141
|
>
|
|
105
142
|
|
|
106
|
-
export function
|
|
143
|
+
export function createUseWriteContract<
|
|
107
144
|
const abi extends Abi | readonly unknown[],
|
|
108
145
|
const address extends
|
|
109
146
|
| Address
|
|
110
147
|
| Record<number, Address>
|
|
111
148
|
| undefined = undefined,
|
|
149
|
+
functionName extends
|
|
150
|
+
| ContractFunctionName<abi, stateMutability>
|
|
151
|
+
| undefined = undefined,
|
|
112
152
|
>(
|
|
113
|
-
config:
|
|
114
|
-
):
|
|
153
|
+
config: CreateUseWriteContractParameters<abi, address, functionName>,
|
|
154
|
+
): CreateUseWriteContractReturnType<abi, address, functionName> {
|
|
115
155
|
if (config.address !== undefined && typeof config.address === 'object')
|
|
116
|
-
return (
|
|
156
|
+
return (parameters) => {
|
|
117
157
|
const result = useWriteContract(parameters)
|
|
118
158
|
const configChainId = useChainId()
|
|
119
159
|
const account = useAccount()
|
|
120
160
|
type Args = Parameters<wagmi_UseWriteContractReturnType['writeContract']>
|
|
121
161
|
return {
|
|
122
|
-
...result,
|
|
162
|
+
...(result as any),
|
|
123
163
|
writeContract: useCallback(
|
|
124
164
|
(...args: Args) => {
|
|
125
165
|
let chainId
|
|
@@ -129,8 +169,11 @@ export function createWriteContract<
|
|
|
129
169
|
else if (args[0].account === undefined) chainId = account.chainId
|
|
130
170
|
else chainId = configChainId
|
|
131
171
|
|
|
132
|
-
const
|
|
133
|
-
|
|
172
|
+
const variables = {
|
|
173
|
+
...(args[0] as any),
|
|
174
|
+
address: chainId ? config.address?.[chainId] : undefined,
|
|
175
|
+
abi: config.abi,
|
|
176
|
+
}
|
|
134
177
|
result.writeContract(variables, args[1] as any)
|
|
135
178
|
},
|
|
136
179
|
[
|
|
@@ -150,8 +193,11 @@ export function createWriteContract<
|
|
|
150
193
|
else if (args[0].account === undefined) chainId = account.chainId
|
|
151
194
|
else chainId = configChainId
|
|
152
195
|
|
|
153
|
-
const
|
|
154
|
-
|
|
196
|
+
const variables = {
|
|
197
|
+
...(args[0] as any),
|
|
198
|
+
address: chainId ? config.address?.[chainId] : undefined,
|
|
199
|
+
abi: config.abi,
|
|
200
|
+
}
|
|
155
201
|
return result.writeContractAsync(variables, args[1] as any)
|
|
156
202
|
},
|
|
157
203
|
[
|
|
@@ -163,52 +209,66 @@ export function createWriteContract<
|
|
|
163
209
|
],
|
|
164
210
|
),
|
|
165
211
|
}
|
|
166
|
-
}
|
|
212
|
+
}
|
|
167
213
|
|
|
168
|
-
return (
|
|
214
|
+
return (parameters) => {
|
|
169
215
|
const result = useWriteContract(parameters)
|
|
170
216
|
type Args = Parameters<wagmi_UseWriteContractReturnType['writeContract']>
|
|
171
217
|
return {
|
|
172
|
-
...result,
|
|
218
|
+
...(result as any),
|
|
173
219
|
writeContract: useCallback(
|
|
174
220
|
(...args: Args) => {
|
|
175
|
-
const
|
|
176
|
-
|
|
221
|
+
const variables = {
|
|
222
|
+
...(args[0] as any),
|
|
223
|
+
...(config.address ? { address: config.address } : {}),
|
|
224
|
+
...(config.functionName
|
|
225
|
+
? { functionName: config.functionName }
|
|
226
|
+
: {}),
|
|
227
|
+
abi: config.abi,
|
|
228
|
+
}
|
|
177
229
|
result.writeContract(variables, args[1] as any)
|
|
178
230
|
},
|
|
179
231
|
[config, result.writeContract],
|
|
180
232
|
),
|
|
181
233
|
writeContractAsync: useCallback(
|
|
182
234
|
(...args: Args) => {
|
|
183
|
-
const
|
|
184
|
-
|
|
235
|
+
const variables = {
|
|
236
|
+
...(args[0] as any),
|
|
237
|
+
...(config.address ? { address: config.address } : {}),
|
|
238
|
+
...(config.functionName
|
|
239
|
+
? { functionName: config.functionName }
|
|
240
|
+
: {}),
|
|
241
|
+
abi: config.abi,
|
|
242
|
+
}
|
|
185
243
|
return result.writeContractAsync(variables, args[1] as any)
|
|
186
244
|
},
|
|
187
245
|
[config, result.writeContractAsync],
|
|
188
246
|
),
|
|
189
247
|
}
|
|
190
|
-
}
|
|
248
|
+
}
|
|
191
249
|
}
|
|
192
250
|
|
|
193
251
|
type Variables<
|
|
194
252
|
abi extends Abi | readonly unknown[],
|
|
195
|
-
functionName extends ContractFunctionName<abi, stateMutability
|
|
196
|
-
|
|
253
|
+
functionName extends ContractFunctionName<abi, stateMutability> | undefined,
|
|
254
|
+
name extends ContractFunctionName<abi, stateMutability>,
|
|
255
|
+
args extends ContractFunctionArgs<abi, stateMutability, name>,
|
|
197
256
|
config extends Config,
|
|
198
257
|
chainId extends config['chains'][number]['id'],
|
|
199
258
|
address extends Address | Record<number, Address> | undefined,
|
|
200
259
|
///
|
|
201
260
|
allFunctionNames = ContractFunctionName<abi, stateMutability>,
|
|
202
261
|
chains extends readonly Chain[] = SelectChains<config, chainId>,
|
|
203
|
-
omittedProperties extends 'abi' | 'address' =
|
|
262
|
+
omittedProperties extends 'abi' | 'address' | 'functionName' =
|
|
204
263
|
| 'abi'
|
|
205
|
-
| (address extends undefined ? never : 'address')
|
|
264
|
+
| (address extends undefined ? never : 'address')
|
|
265
|
+
| (functionName extends undefined ? never : 'functionName'),
|
|
206
266
|
> = UnionEvaluate<
|
|
207
267
|
{
|
|
208
268
|
[key in keyof chains]: UnionOmit<
|
|
209
269
|
viem_WriteContractParameters<
|
|
210
270
|
abi,
|
|
211
|
-
|
|
271
|
+
name,
|
|
212
272
|
args,
|
|
213
273
|
chains[key],
|
|
214
274
|
Account,
|
|
@@ -219,7 +279,12 @@ type Variables<
|
|
|
219
279
|
>
|
|
220
280
|
}[number] &
|
|
221
281
|
(address extends Record<number, Address>
|
|
222
|
-
? {
|
|
282
|
+
? {
|
|
283
|
+
chainId?:
|
|
284
|
+
| keyof address
|
|
285
|
+
| (chainId extends keyof address ? chainId : never)
|
|
286
|
+
| undefined
|
|
287
|
+
}
|
|
223
288
|
: Evaluate<ChainIdParameter<config, chainId>>) &
|
|
224
289
|
ConnectorParameter & { __mode?: 'prepared' }
|
|
225
290
|
>
|
package/src/hooks/useAccount.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type UseAccountParameters = ConfigParameter
|
|
|
14
14
|
|
|
15
15
|
export type UseAccountReturnType = GetAccountReturnType
|
|
16
16
|
|
|
17
|
-
/** https://
|
|
17
|
+
/** https://rc.wagmi.sh/react/api/hooks/useAccount */
|
|
18
18
|
export function useAccount(
|
|
19
19
|
parameters: UseAccountParameters = {},
|
|
20
20
|
): UseAccountReturnType {
|
|
@@ -23,7 +23,7 @@ export type UseAccountEffectParameters = Evaluate<
|
|
|
23
23
|
} & ConfigParameter
|
|
24
24
|
>
|
|
25
25
|
|
|
26
|
-
/** https://
|
|
26
|
+
/** https://rc.wagmi.sh/react/api/hooks/useAccountEffect */
|
|
27
27
|
export function useAccountEffect(parameters: UseAccountEffectParameters = {}) {
|
|
28
28
|
const { onConnect, onDisconnect } = parameters
|
|
29
29
|
|
package/src/hooks/useBalance.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type UseBalanceParameters<
|
|
|
36
36
|
export type UseBalanceReturnType<selectData = GetBalanceData> =
|
|
37
37
|
UseQueryReturnType<selectData, GetBalanceErrorType>
|
|
38
38
|
|
|
39
|
-
/** https://
|
|
39
|
+
/** https://rc.wagmi.sh/react/api/hooks/useBalance */
|
|
40
40
|
export function useBalance<
|
|
41
41
|
config extends Config = ResolvedRegister['config'],
|
|
42
42
|
selectData = GetBalanceData,
|
package/src/hooks/useBlock.ts
CHANGED
|
@@ -67,7 +67,7 @@ export type UseBlockReturnType<
|
|
|
67
67
|
selectData = GetBlockData<includeTransactions, blockTag>,
|
|
68
68
|
> = UseQueryReturnType<selectData, GetBlockErrorType>
|
|
69
69
|
|
|
70
|
-
/** https://
|
|
70
|
+
/** https://rc.wagmi.sh/react/hooks/useBlock */
|
|
71
71
|
export function useBlock<
|
|
72
72
|
includeTransactions extends boolean = false,
|
|
73
73
|
blockTag extends BlockTag = 'latest',
|
|
@@ -56,7 +56,7 @@ export type UseBlockNumberParameters<
|
|
|
56
56
|
export type UseBlockNumberReturnType<selectData = GetBlockNumberData> =
|
|
57
57
|
UseQueryReturnType<selectData, GetBlockNumberErrorType>
|
|
58
58
|
|
|
59
|
-
/** https://
|
|
59
|
+
/** https://rc.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'],
|
|
@@ -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://rc.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://rc.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> {
|
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://rc.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://rc.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
|
@@ -57,7 +57,7 @@ export type UseConnectReturnType<
|
|
|
57
57
|
}
|
|
58
58
|
>
|
|
59
59
|
|
|
60
|
-
/** https://
|
|
60
|
+
/** https://rc.wagmi.sh/react/api/hooks/useConnect */
|
|
61
61
|
export function useConnect<
|
|
62
62
|
config extends Config = ResolvedRegister['config'],
|
|
63
63
|
context = unknown,
|
|
@@ -14,7 +14,7 @@ export type UseConnectionsParameters = ConfigParameter
|
|
|
14
14
|
|
|
15
15
|
export type UseConnectionsReturnType = GetConnectionsReturnType
|
|
16
16
|
|
|
17
|
-
/** https://
|
|
17
|
+
/** https://rc.wagmi.sh/react/api/hooks/useConnections */
|
|
18
18
|
export function useConnections(
|
|
19
19
|
parameters: UseConnectionsParameters = {},
|
|
20
20
|
): UseConnectionsReturnType {
|
|
@@ -55,7 +55,7 @@ export type UseConnectorClientReturnType<
|
|
|
55
55
|
selectData = GetConnectorClientData<config, chainId>,
|
|
56
56
|
> = UseQueryReturnType<selectData, GetConnectorClientErrorType>
|
|
57
57
|
|
|
58
|
-
/** https://
|
|
58
|
+
/** https://rc.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'],
|
|
@@ -14,7 +14,7 @@ export type UseConnectorsParameters = ConfigParameter
|
|
|
14
14
|
|
|
15
15
|
export type UseConnectorsReturnType = GetConnectorsReturnType
|
|
16
16
|
|
|
17
|
-
/** https://
|
|
17
|
+
/** https://rc.wagmi.sh/react/api/hooks/useConnectors */
|
|
18
18
|
export function useConnectors(
|
|
19
19
|
parameters: UseConnectorsParameters = {},
|
|
20
20
|
): UseConnectorsReturnType {
|
|
@@ -45,7 +45,7 @@ export type UseDisconnectReturnType<context = unknown> = Evaluate<
|
|
|
45
45
|
}
|
|
46
46
|
>
|
|
47
47
|
|
|
48
|
-
/** https://
|
|
48
|
+
/** https://rc.wagmi.sh/react/api/hooks/useDisconnect */
|
|
49
49
|
export function useDisconnect<context = unknown>(
|
|
50
50
|
parameters: UseDisconnectParameters<context> = {},
|
|
51
51
|
): UseDisconnectReturnType<context> {
|
|
@@ -36,7 +36,7 @@ export type UseEnsAddressParameters<
|
|
|
36
36
|
export type UseEnsAddressReturnType<selectData = GetEnsAddressData> =
|
|
37
37
|
UseQueryReturnType<selectData, GetEnsAddressErrorType>
|
|
38
38
|
|
|
39
|
-
/** https://
|
|
39
|
+
/** https://rc.wagmi.sh/react/api/hooks/useEnsAddress */
|
|
40
40
|
export function useEnsAddress<
|
|
41
41
|
config extends Config = ResolvedRegister['config'],
|
|
42
42
|
selectData = GetEnsAddressData,
|
|
@@ -36,7 +36,7 @@ export type UseEnsAvatarParameters<
|
|
|
36
36
|
export type UseEnsAvatarReturnType<selectData = GetEnsAvatarData> =
|
|
37
37
|
UseQueryReturnType<selectData, GetEnsAvatarErrorType>
|
|
38
38
|
|
|
39
|
-
/** https://
|
|
39
|
+
/** https://rc.wagmi.sh/react/api/hooks/useEnsAvatar */
|
|
40
40
|
export function useEnsAvatar<
|
|
41
41
|
config extends Config = ResolvedRegister['config'],
|
|
42
42
|
selectData = GetEnsAvatarData,
|
package/src/hooks/useEnsName.ts
CHANGED
|
@@ -32,7 +32,7 @@ export type UseEnsNameParameters<
|
|
|
32
32
|
export type UseEnsNameReturnType<selectData = GetEnsNameData> =
|
|
33
33
|
UseQueryReturnType<selectData, GetEnsNameErrorType>
|
|
34
34
|
|
|
35
|
-
/** https://
|
|
35
|
+
/** https://rc.wagmi.sh/react/api/hooks/useEnsName */
|
|
36
36
|
export function useEnsName<
|
|
37
37
|
config extends Config = ResolvedRegister['config'],
|
|
38
38
|
selectData = GetEnsNameData,
|
|
@@ -36,7 +36,7 @@ export type UseEnsResolverParameters<
|
|
|
36
36
|
export type UseEnsResolverReturnType<selectData = GetEnsResolverData> =
|
|
37
37
|
UseQueryReturnType<selectData, GetEnsResolverErrorType>
|
|
38
38
|
|
|
39
|
-
/** https://
|
|
39
|
+
/** https://rc.wagmi.sh/react/api/hooks/useEnsResolver */
|
|
40
40
|
export function useEnsResolver<
|
|
41
41
|
config extends Config = ResolvedRegister['config'],
|
|
42
42
|
selectData = GetEnsResolverData,
|
|
@@ -40,7 +40,7 @@ export type UseEstimateFeesPerGasReturnType<
|
|
|
40
40
|
selectData = EstimateFeesPerGasData<type>,
|
|
41
41
|
> = UseQueryReturnType<selectData, EstimateFeesPerGasErrorType>
|
|
42
42
|
|
|
43
|
-
/** https://
|
|
43
|
+
/** https://rc.wagmi.sh/react/api/hooks/useEstimateFeesPerGas */
|
|
44
44
|
export function useEstimateFeesPerGas<
|
|
45
45
|
config extends Config = ResolvedRegister['config'],
|
|
46
46
|
type extends FeeValuesType = 'eip1559',
|
|
@@ -35,7 +35,7 @@ export type UseEstimateGasParameters<
|
|
|
35
35
|
export type UseEstimateGasReturnType<selectData = EstimateGasData> =
|
|
36
36
|
UseQueryReturnType<selectData, EstimateGasErrorType>
|
|
37
37
|
|
|
38
|
-
/** https://
|
|
38
|
+
/** https://rc.wagmi.sh/react/api/hooks/useEstimateGas */
|
|
39
39
|
export function useEstimateGas<
|
|
40
40
|
config extends Config = ResolvedRegister['config'],
|
|
41
41
|
chainId extends config['chains'][number]['id'] | undefined = undefined,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type Config,
|
|
5
|
+
type EstimateMaxPriorityFeePerGasErrorType,
|
|
6
|
+
type ResolvedRegister,
|
|
7
|
+
} from '@wagmi/core'
|
|
8
|
+
import { type Evaluate } from '@wagmi/core/internal'
|
|
9
|
+
import {
|
|
10
|
+
type EstimateMaxPriorityFeePerGasData,
|
|
11
|
+
type EstimateMaxPriorityFeePerGasOptions,
|
|
12
|
+
type EstimateMaxPriorityFeePerGasQueryFnData,
|
|
13
|
+
type EstimateMaxPriorityFeePerGasQueryKey,
|
|
14
|
+
estimateMaxPriorityFeePerGasQueryOptions,
|
|
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 UseEstimateMaxPriorityFeePerGasParameters<
|
|
23
|
+
config extends Config = Config,
|
|
24
|
+
selectData = EstimateMaxPriorityFeePerGasData,
|
|
25
|
+
> = Evaluate<
|
|
26
|
+
EstimateMaxPriorityFeePerGasOptions<config> &
|
|
27
|
+
ConfigParameter<config> &
|
|
28
|
+
QueryParameter<
|
|
29
|
+
EstimateMaxPriorityFeePerGasQueryFnData,
|
|
30
|
+
EstimateMaxPriorityFeePerGasErrorType,
|
|
31
|
+
selectData,
|
|
32
|
+
EstimateMaxPriorityFeePerGasQueryKey<config>
|
|
33
|
+
>
|
|
34
|
+
>
|
|
35
|
+
|
|
36
|
+
export type UseEstimateMaxPriorityFeePerGasReturnType<
|
|
37
|
+
selectData = EstimateMaxPriorityFeePerGasData,
|
|
38
|
+
> = UseQueryReturnType<selectData, EstimateMaxPriorityFeePerGasErrorType>
|
|
39
|
+
|
|
40
|
+
/** https://rc.wagmi.sh/react/api/hooks/useEstimateMaxPriorityFeePerGas */
|
|
41
|
+
export function useEstimateMaxPriorityFeePerGas<
|
|
42
|
+
config extends Config = ResolvedRegister['config'],
|
|
43
|
+
selectData = EstimateMaxPriorityFeePerGasData,
|
|
44
|
+
>(
|
|
45
|
+
parameters: UseEstimateMaxPriorityFeePerGasParameters<
|
|
46
|
+
config,
|
|
47
|
+
selectData
|
|
48
|
+
> = {},
|
|
49
|
+
): UseEstimateMaxPriorityFeePerGasReturnType<selectData> {
|
|
50
|
+
const { query = {} } = parameters
|
|
51
|
+
|
|
52
|
+
const config = useConfig(parameters)
|
|
53
|
+
const chainId = useChainId()
|
|
54
|
+
|
|
55
|
+
const options = estimateMaxPriorityFeePerGasQueryOptions(config, {
|
|
56
|
+
...parameters,
|
|
57
|
+
chainId: parameters.chainId ?? chainId,
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
return useQuery({ ...query, ...options })
|
|
61
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type Config,
|
|
5
|
+
type GetFeeHistoryErrorType,
|
|
6
|
+
type ResolvedRegister,
|
|
7
|
+
} from '@wagmi/core'
|
|
8
|
+
import { type Evaluate } from '@wagmi/core/internal'
|
|
9
|
+
import {
|
|
10
|
+
type GetFeeHistoryData,
|
|
11
|
+
type GetFeeHistoryOptions,
|
|
12
|
+
type GetFeeHistoryQueryFnData,
|
|
13
|
+
type GetFeeHistoryQueryKey,
|
|
14
|
+
getFeeHistoryQueryOptions,
|
|
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 UseFeeHistoryParameters<
|
|
23
|
+
config extends Config = Config,
|
|
24
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
25
|
+
selectData = GetFeeHistoryData,
|
|
26
|
+
> = Evaluate<
|
|
27
|
+
GetFeeHistoryOptions<config, chainId> &
|
|
28
|
+
ConfigParameter<config> &
|
|
29
|
+
QueryParameter<
|
|
30
|
+
GetFeeHistoryQueryFnData,
|
|
31
|
+
GetFeeHistoryErrorType,
|
|
32
|
+
selectData,
|
|
33
|
+
GetFeeHistoryQueryKey<config, chainId>
|
|
34
|
+
>
|
|
35
|
+
>
|
|
36
|
+
|
|
37
|
+
export type UseFeeHistoryReturnType<selectData = GetFeeHistoryData> =
|
|
38
|
+
UseQueryReturnType<selectData, GetFeeHistoryErrorType>
|
|
39
|
+
|
|
40
|
+
/** https://rc.wagmi.sh/react/api/hooks/useFeeHistory */
|
|
41
|
+
export function useFeeHistory<
|
|
42
|
+
config extends Config = ResolvedRegister['config'],
|
|
43
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
44
|
+
selectData = GetFeeHistoryData,
|
|
45
|
+
>(
|
|
46
|
+
parameters: UseFeeHistoryParameters<config, chainId, selectData> = {},
|
|
47
|
+
): UseFeeHistoryReturnType<selectData> {
|
|
48
|
+
const { blockCount, rewardPercentiles, query = {} } = parameters
|
|
49
|
+
|
|
50
|
+
const config = useConfig(parameters)
|
|
51
|
+
const chainId = useChainId()
|
|
52
|
+
|
|
53
|
+
const options = getFeeHistoryQueryOptions(config, {
|
|
54
|
+
...parameters,
|
|
55
|
+
chainId: parameters.chainId ?? chainId,
|
|
56
|
+
})
|
|
57
|
+
const enabled = Boolean(
|
|
58
|
+
blockCount && rewardPercentiles && (query.enabled ?? true),
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
return useQuery({ ...query, ...options, enabled })
|
|
62
|
+
}
|