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
|
@@ -10,6 +10,6 @@ export type UseWriteContractReturnType<config extends Config = Config, context =
|
|
|
10
10
|
writeContract: WriteContractMutate<config, context>;
|
|
11
11
|
writeContractAsync: WriteContractMutateAsync<config, context>;
|
|
12
12
|
};
|
|
13
|
-
/** https://
|
|
13
|
+
/** https://rc.wagmi.sh/react/api/hooks/useWriteContract */
|
|
14
14
|
export declare function useWriteContract<config extends Config = ResolvedRegister['config'], context = unknown>(parameters?: UseWriteContractParameters<config, context>): UseWriteContractReturnType<config, context>;
|
|
15
15
|
//# sourceMappingURL=useWriteContract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWriteContract.d.ts","sourceRoot":"","sources":["../../../src/hooks/useWriteContract.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,MAAM,EACN,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAE5B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAE/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,mBAAmB,CAAA;AAG1B,MAAM,MAAM,0BAA0B,CACpC,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,OAAO,GAAG,OAAO,IACf,eAAe,CAAC,MAAM,CAAC,GAAG;IAC5B,QAAQ,CAAC,EACL,qBAAqB,CACnB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,CACpB,GAAG,EACH,MAAM,EACN,SAAS,OAAO,EAAE,EAClB,MAAM,EACN,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAC/B,EACD,OAAO,CACR,GACD,SAAS,CAAA;CACd,CAAA;AAED,MAAM,MAAM,0BAA0B,CACpC,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,OAAO,GAAG,OAAO,IACf,qBAAqB,CACvB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,CACpB,GAAG,EACH,MAAM,EACN,SAAS,OAAO,EAAE,EAClB,MAAM,EACN,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAC/B,EACD,OAAO,CACR,GAAG;IACF,aAAa,EAAE,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnD,kBAAkB,EAAE,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9D,CAAA;AAED,
|
|
1
|
+
{"version":3,"file":"useWriteContract.d.ts","sourceRoot":"","sources":["../../../src/hooks/useWriteContract.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,MAAM,EACN,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAE5B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAE/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,mBAAmB,CAAA;AAG1B,MAAM,MAAM,0BAA0B,CACpC,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,OAAO,GAAG,OAAO,IACf,eAAe,CAAC,MAAM,CAAC,GAAG;IAC5B,QAAQ,CAAC,EACL,qBAAqB,CACnB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,CACpB,GAAG,EACH,MAAM,EACN,SAAS,OAAO,EAAE,EAClB,MAAM,EACN,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAC/B,EACD,OAAO,CACR,GACD,SAAS,CAAA;CACd,CAAA;AAED,MAAM,MAAM,0BAA0B,CACpC,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,OAAO,GAAG,OAAO,IACf,qBAAqB,CACvB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,CACpB,GAAG,EACH,MAAM,EACN,SAAS,OAAO,EAAE,EAClB,MAAM,EACN,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAC/B,EACD,OAAO,CACR,GAAG;IACF,aAAa,EAAE,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnD,kBAAkB,EAAE,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9D,CAAA;AAED,2DAA2D;AAC3D,wBAAgB,gBAAgB,CAC9B,MAAM,SAAS,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,EAClD,OAAO,GAAG,OAAO,EAEjB,UAAU,GAAE,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAM,GAC3D,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAC,CAiB7C"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "2.0.0-
|
|
1
|
+
export declare const version = "2.0.0-rc.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,eAAe,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wagmi",
|
|
3
3
|
"description": "React Hooks for Ethereum",
|
|
4
|
-
"version": "2.0.0-
|
|
4
|
+
"version": "2.0.0-rc.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@tanstack/react-query": ">=5.0.0",
|
|
76
76
|
"react": ">=18",
|
|
77
77
|
"typescript": ">=5.0.4",
|
|
78
|
-
"viem": "2.0.0-
|
|
78
|
+
"viem": "2.0.0-rc.0"
|
|
79
79
|
},
|
|
80
80
|
"peerDependenciesMeta": {
|
|
81
81
|
"typescript": {
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"use-sync-external-store": "
|
|
87
|
-
"@wagmi/connectors": "4.0.0-
|
|
88
|
-
"@wagmi/core": "2.0.0-
|
|
86
|
+
"use-sync-external-store": "1.2.0",
|
|
87
|
+
"@wagmi/connectors": "4.0.0-rc.0",
|
|
88
|
+
"@wagmi/core": "2.0.0-rc.0"
|
|
89
89
|
},
|
|
90
90
|
"contributors": [
|
|
91
91
|
"awkweb.eth <t@wevm.dev>",
|
package/src/errors/base.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type BaseErrorType = BaseError & { name: 'WagmiError' }
|
|
|
6
6
|
export class BaseError extends CoreError {
|
|
7
7
|
override name = 'WagmiError'
|
|
8
8
|
override get docsBaseUrl() {
|
|
9
|
-
return 'https://
|
|
9
|
+
return 'https://rc.wagmi.sh/react'
|
|
10
10
|
}
|
|
11
11
|
override get version() {
|
|
12
12
|
return getVersion()
|
package/src/errors/context.ts
CHANGED
|
@@ -7,7 +7,7 @@ export class WagmiProviderNotFoundError extends BaseError {
|
|
|
7
7
|
override name = 'WagmiProviderNotFoundError'
|
|
8
8
|
constructor() {
|
|
9
9
|
super('`useConfig` must be used within `WagmiProvider`.', {
|
|
10
|
-
docsPath: 'https://
|
|
10
|
+
docsPath: 'https://rc.wagmi.sh/react/api/WagmiProvider',
|
|
11
11
|
})
|
|
12
12
|
}
|
|
13
13
|
}
|
package/src/exports/actions.ts
CHANGED
package/src/exports/chains.ts
CHANGED
package/src/exports/codegen.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// @wagmi/core/codegen
|
|
3
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
2
4
|
|
|
3
|
-
export
|
|
5
|
+
export * from '@wagmi/core/codegen'
|
|
6
|
+
|
|
7
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
8
|
+
// Hooks
|
|
9
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
10
|
+
|
|
11
|
+
export { createUseSimulateContract } from '../hooks/codegen/createUseSimulateContract.js'
|
|
12
|
+
|
|
13
|
+
export { createUseReadContract } from '../hooks/codegen/createUseReadContract.js'
|
|
14
|
+
|
|
15
|
+
export { createUseWatchContractEvent } from '../hooks/codegen/createUseWatchContractEvent.js'
|
|
16
|
+
|
|
17
|
+
export { createUseWriteContract } from '../hooks/codegen/createUseWriteContract.js'
|
package/src/exports/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
////////////////////////////////////////////////////////////////////////////////
|
|
2
2
|
// Context
|
|
3
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
3
4
|
|
|
4
5
|
export {
|
|
5
6
|
type WagmiProviderProps,
|
|
@@ -13,6 +14,7 @@ export {
|
|
|
13
14
|
|
|
14
15
|
////////////////////////////////////////////////////////////////////////////////
|
|
15
16
|
// Errors
|
|
17
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
16
18
|
|
|
17
19
|
export { type BaseErrorType, BaseError } from '../errors/base.js'
|
|
18
20
|
|
|
@@ -23,6 +25,7 @@ export {
|
|
|
23
25
|
|
|
24
26
|
////////////////////////////////////////////////////////////////////////////////
|
|
25
27
|
// Hooks
|
|
28
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
26
29
|
|
|
27
30
|
export {
|
|
28
31
|
type UseAccountParameters,
|
|
@@ -53,6 +56,12 @@ export {
|
|
|
53
56
|
useBlockNumber,
|
|
54
57
|
} from '../hooks/useBlockNumber.js'
|
|
55
58
|
|
|
59
|
+
export {
|
|
60
|
+
type UseBlockTransactionCountParameters,
|
|
61
|
+
type UseBlockTransactionCountReturnType,
|
|
62
|
+
useBlockTransactionCount,
|
|
63
|
+
} from '../hooks/useBlockTransactionCount.js'
|
|
64
|
+
|
|
56
65
|
export {
|
|
57
66
|
type UseChainIdParameters,
|
|
58
67
|
type UseChainIdReturnType,
|
|
@@ -139,6 +148,24 @@ export {
|
|
|
139
148
|
useEstimateGas,
|
|
140
149
|
} from '../hooks/useEstimateGas.js'
|
|
141
150
|
|
|
151
|
+
export {
|
|
152
|
+
type UseEstimateMaxPriorityFeePerGasParameters,
|
|
153
|
+
type UseEstimateMaxPriorityFeePerGasReturnType,
|
|
154
|
+
useEstimateMaxPriorityFeePerGas,
|
|
155
|
+
} from '../hooks/useEstimateMaxPriorityFeePerGas.js'
|
|
156
|
+
|
|
157
|
+
export {
|
|
158
|
+
type UseFeeHistoryParameters,
|
|
159
|
+
type UseFeeHistoryReturnType,
|
|
160
|
+
useFeeHistory,
|
|
161
|
+
} from '../hooks/useFeeHistory.js'
|
|
162
|
+
|
|
163
|
+
export {
|
|
164
|
+
type UseGasPriceParameters,
|
|
165
|
+
type UseGasPriceReturnType,
|
|
166
|
+
useGasPrice,
|
|
167
|
+
} from '../hooks/useGasPrice.js'
|
|
168
|
+
|
|
142
169
|
export {
|
|
143
170
|
type UseInfiniteContractReadsParameters,
|
|
144
171
|
type UseInfiniteContractReadsReturnType,
|
|
@@ -230,6 +257,18 @@ export {
|
|
|
230
257
|
useTransactionCount,
|
|
231
258
|
} from '../hooks/useTransactionCount.js'
|
|
232
259
|
|
|
260
|
+
export {
|
|
261
|
+
type UseVerifyMessageParameters,
|
|
262
|
+
type UseVerifyMessageReturnType,
|
|
263
|
+
useVerifyMessage,
|
|
264
|
+
} from '../hooks/useVerifyMessage.js'
|
|
265
|
+
|
|
266
|
+
export {
|
|
267
|
+
type UseVerifyTypedDataParameters,
|
|
268
|
+
type UseVerifyTypedDataReturnType,
|
|
269
|
+
useVerifyTypedData,
|
|
270
|
+
} from '../hooks/useVerifyTypedData.js'
|
|
271
|
+
|
|
233
272
|
export {
|
|
234
273
|
type UseWalletClientParameters,
|
|
235
274
|
type UseWalletClientReturnType,
|
|
@@ -275,7 +314,8 @@ export {
|
|
|
275
314
|
} from '../hooks/useWriteContract.js'
|
|
276
315
|
|
|
277
316
|
////////////////////////////////////////////////////////////////////////////////
|
|
278
|
-
//
|
|
317
|
+
// Hydrate
|
|
318
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
279
319
|
|
|
280
320
|
export {
|
|
281
321
|
type HydrateProps,
|
|
@@ -284,6 +324,7 @@ export {
|
|
|
284
324
|
|
|
285
325
|
////////////////////////////////////////////////////////////////////////////////
|
|
286
326
|
// @wagmi/core
|
|
327
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
287
328
|
|
|
288
329
|
export {
|
|
289
330
|
// Config
|
|
@@ -336,5 +377,6 @@ export {
|
|
|
336
377
|
|
|
337
378
|
////////////////////////////////////////////////////////////////////////////////
|
|
338
379
|
// Version
|
|
380
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
339
381
|
|
|
340
382
|
export { version } from '../version.js'
|
package/src/exports/query.ts
CHANGED
|
@@ -22,7 +22,10 @@ import {
|
|
|
22
22
|
type ContractFunctionName,
|
|
23
23
|
} from 'viem'
|
|
24
24
|
|
|
25
|
-
import
|
|
25
|
+
import {
|
|
26
|
+
type ConfigParameter,
|
|
27
|
+
type QueryParameter,
|
|
28
|
+
} from '../../types/properties.js'
|
|
26
29
|
import { useAccount } from '../useAccount.js'
|
|
27
30
|
import { useChainId } from '../useChainId.js'
|
|
28
31
|
import {
|
|
@@ -32,58 +35,72 @@ import {
|
|
|
32
35
|
|
|
33
36
|
type stateMutability = 'pure' | 'view'
|
|
34
37
|
|
|
35
|
-
export type
|
|
38
|
+
export type CreateUseReadContractParameters<
|
|
36
39
|
abi extends Abi | readonly unknown[],
|
|
37
40
|
address extends Address | Record<number, Address> | undefined = undefined,
|
|
41
|
+
functionName extends
|
|
42
|
+
| ContractFunctionName<abi, stateMutability>
|
|
43
|
+
| undefined = undefined,
|
|
38
44
|
> = {
|
|
39
45
|
abi: abi | Abi | readonly unknown[]
|
|
40
46
|
address?: address | Address | Record<number, Address> | undefined
|
|
47
|
+
functionName?:
|
|
48
|
+
| functionName
|
|
49
|
+
| ContractFunctionName<abi, stateMutability>
|
|
50
|
+
| undefined
|
|
41
51
|
}
|
|
42
52
|
|
|
43
|
-
export type
|
|
53
|
+
export type CreateUseReadContractReturnType<
|
|
44
54
|
abi extends Abi | readonly unknown[],
|
|
45
55
|
address extends Address | Record<number, Address> | undefined,
|
|
56
|
+
functionName extends ContractFunctionName<abi, stateMutability> | undefined,
|
|
46
57
|
///
|
|
47
|
-
omittedProperties extends 'abi' | 'address' | 'chainId' =
|
|
58
|
+
omittedProperties extends 'abi' | 'address' | 'chainId' | 'functionName' =
|
|
48
59
|
| 'abi'
|
|
49
60
|
| (address extends undefined ? never : 'address')
|
|
50
|
-
| (address extends Record<number, Address> ? 'chainId' : never)
|
|
61
|
+
| (address extends Record<number, Address> ? 'chainId' : never)
|
|
62
|
+
| (functionName extends undefined ? never : 'functionName'),
|
|
51
63
|
> = <
|
|
52
|
-
functionName extends ContractFunctionName<abi, stateMutability
|
|
53
|
-
|
|
64
|
+
name extends functionName extends ContractFunctionName<abi, stateMutability>
|
|
65
|
+
? functionName
|
|
66
|
+
: ContractFunctionName<abi, stateMutability>,
|
|
67
|
+
args extends ContractFunctionArgs<abi, stateMutability, name>,
|
|
54
68
|
config extends Config = ResolvedRegister['config'],
|
|
55
|
-
selectData = ReadContractData<abi,
|
|
69
|
+
selectData = ReadContractData<abi, name, args>,
|
|
56
70
|
>(
|
|
57
71
|
parameters?: UnionEvaluate<
|
|
58
72
|
UnionPartial<
|
|
59
73
|
UnionOmit<
|
|
60
|
-
ReadContractParameters<abi,
|
|
74
|
+
ReadContractParameters<abi, name, args, config>,
|
|
61
75
|
omittedProperties
|
|
62
76
|
>
|
|
63
77
|
> &
|
|
64
78
|
ScopeKeyParameter &
|
|
65
79
|
ConfigParameter<config> &
|
|
66
80
|
QueryParameter<
|
|
67
|
-
ReadContractQueryFnData<abi,
|
|
81
|
+
ReadContractQueryFnData<abi, name, args>,
|
|
68
82
|
ReadContractErrorType,
|
|
69
83
|
selectData,
|
|
70
|
-
ReadContractQueryKey<abi,
|
|
84
|
+
ReadContractQueryKey<abi, name, args, config>
|
|
71
85
|
>
|
|
72
86
|
> &
|
|
73
87
|
(address extends Record<number, Address>
|
|
74
88
|
? { chainId?: keyof address | undefined }
|
|
75
89
|
: unknown),
|
|
76
|
-
) => UseReadContractReturnType<abi,
|
|
90
|
+
) => UseReadContractReturnType<abi, name, args, selectData>
|
|
77
91
|
|
|
78
|
-
export function
|
|
92
|
+
export function createUseReadContract<
|
|
79
93
|
const abi extends Abi | readonly unknown[],
|
|
80
94
|
const address extends
|
|
81
95
|
| Address
|
|
82
96
|
| Record<number, Address>
|
|
83
97
|
| undefined = undefined,
|
|
98
|
+
functionName extends
|
|
99
|
+
| ContractFunctionName<abi, stateMutability>
|
|
100
|
+
| undefined = undefined,
|
|
84
101
|
>(
|
|
85
|
-
config:
|
|
86
|
-
):
|
|
102
|
+
config: CreateUseReadContractParameters<abi, address, functionName>,
|
|
103
|
+
): CreateUseReadContractReturnType<abi, address, functionName> {
|
|
87
104
|
if (config.address !== undefined && typeof config.address === 'object')
|
|
88
105
|
return (parameters) => {
|
|
89
106
|
const configChainId = useChainId()
|
|
@@ -92,11 +109,20 @@ export function createReadContract<
|
|
|
92
109
|
(parameters as { chainId?: number })?.chainId ??
|
|
93
110
|
account.chainId ??
|
|
94
111
|
configChainId
|
|
95
|
-
|
|
96
|
-
|
|
112
|
+
return useReadContract({
|
|
113
|
+
...(parameters as any),
|
|
114
|
+
...(config.functionName ? { functionName: config.functionName } : {}),
|
|
115
|
+
address: config.address?.[chainId],
|
|
116
|
+
abi: config.abi,
|
|
117
|
+
})
|
|
97
118
|
}
|
|
98
119
|
|
|
99
120
|
return (parameters) => {
|
|
100
|
-
return useReadContract({
|
|
121
|
+
return useReadContract({
|
|
122
|
+
...(parameters as any),
|
|
123
|
+
...(config.address ? { address: config.address } : {}),
|
|
124
|
+
...(config.functionName ? { functionName: config.functionName } : {}),
|
|
125
|
+
abi: config.abi,
|
|
126
|
+
})
|
|
101
127
|
}
|
|
102
128
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Config,
|
|
3
|
+
type ResolvedRegister,
|
|
4
|
+
type SimulateContractErrorType,
|
|
5
|
+
type SimulateContractParameters,
|
|
6
|
+
} from '@wagmi/core'
|
|
7
|
+
import { type ScopeKeyParameter, type UnionPartial } from '@wagmi/core/internal'
|
|
8
|
+
import {
|
|
9
|
+
type SimulateContractData,
|
|
10
|
+
type SimulateContractQueryFnData,
|
|
11
|
+
type SimulateContractQueryKey,
|
|
12
|
+
} from '@wagmi/core/query'
|
|
13
|
+
import {
|
|
14
|
+
type Abi,
|
|
15
|
+
type Address,
|
|
16
|
+
type ContractFunctionArgs,
|
|
17
|
+
type ContractFunctionName,
|
|
18
|
+
} from 'viem'
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
type ConfigParameter,
|
|
22
|
+
type QueryParameter,
|
|
23
|
+
} from '../../types/properties.js'
|
|
24
|
+
import { useAccount } from '../useAccount.js'
|
|
25
|
+
import { useChainId } from '../useChainId.js'
|
|
26
|
+
import {
|
|
27
|
+
type UseSimulateContractReturnType,
|
|
28
|
+
useSimulateContract,
|
|
29
|
+
} from '../useSimulateContract.js'
|
|
30
|
+
|
|
31
|
+
type stateMutability = 'nonpayable' | 'payable'
|
|
32
|
+
|
|
33
|
+
export type CreateUseSimulateContractParameters<
|
|
34
|
+
abi extends Abi | readonly unknown[],
|
|
35
|
+
address extends Address | Record<number, Address> | undefined = undefined,
|
|
36
|
+
functionName extends
|
|
37
|
+
| ContractFunctionName<abi, stateMutability>
|
|
38
|
+
| undefined = undefined,
|
|
39
|
+
> = {
|
|
40
|
+
abi: abi | Abi | readonly unknown[]
|
|
41
|
+
address?: address | Address | Record<number, Address> | undefined
|
|
42
|
+
functionName?:
|
|
43
|
+
| functionName
|
|
44
|
+
| ContractFunctionName<abi, stateMutability>
|
|
45
|
+
| undefined
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type CreateUseSimulateContractReturnType<
|
|
49
|
+
abi extends Abi | readonly unknown[],
|
|
50
|
+
address extends Address | Record<number, Address> | undefined,
|
|
51
|
+
functionName extends ContractFunctionName<abi, stateMutability> | undefined,
|
|
52
|
+
> = <
|
|
53
|
+
name extends functionName extends ContractFunctionName<abi, stateMutability>
|
|
54
|
+
? functionName
|
|
55
|
+
: ContractFunctionName<abi, stateMutability>,
|
|
56
|
+
args extends ContractFunctionArgs<abi, stateMutability, name>,
|
|
57
|
+
config extends Config = ResolvedRegister['config'],
|
|
58
|
+
chainId extends config['chains'][number]['id'] | undefined = undefined,
|
|
59
|
+
selectData = SimulateContractData<abi, name, args, config, chainId>,
|
|
60
|
+
>(
|
|
61
|
+
parameters?: {
|
|
62
|
+
abi?: undefined
|
|
63
|
+
address?: address extends undefined ? Address : undefined
|
|
64
|
+
functionName?: functionName extends undefined ? name : undefined
|
|
65
|
+
chainId?: address extends Record<number, Address>
|
|
66
|
+
?
|
|
67
|
+
| keyof address
|
|
68
|
+
| (chainId extends keyof address ? chainId : never)
|
|
69
|
+
| undefined
|
|
70
|
+
: chainId | number | undefined
|
|
71
|
+
} & UnionPartial<
|
|
72
|
+
// TODO: Take `abi` and `address` from above and omit from below (currently breaks inference)
|
|
73
|
+
SimulateContractParameters<abi, name, args, config, chainId>
|
|
74
|
+
> &
|
|
75
|
+
ScopeKeyParameter &
|
|
76
|
+
ConfigParameter<config> &
|
|
77
|
+
QueryParameter<
|
|
78
|
+
SimulateContractQueryFnData<abi, name, args, config, chainId>,
|
|
79
|
+
SimulateContractErrorType,
|
|
80
|
+
selectData,
|
|
81
|
+
SimulateContractQueryKey<abi, name, args, config, chainId>
|
|
82
|
+
>,
|
|
83
|
+
) => UseSimulateContractReturnType<abi, name, args, config, chainId, selectData>
|
|
84
|
+
|
|
85
|
+
export function createUseSimulateContract<
|
|
86
|
+
const abi extends Abi | readonly unknown[],
|
|
87
|
+
const address extends
|
|
88
|
+
| Address
|
|
89
|
+
| Record<number, Address>
|
|
90
|
+
| undefined = undefined,
|
|
91
|
+
functionName extends
|
|
92
|
+
| ContractFunctionName<abi, stateMutability>
|
|
93
|
+
| undefined = undefined,
|
|
94
|
+
>(
|
|
95
|
+
config: CreateUseSimulateContractParameters<abi, address, functionName>,
|
|
96
|
+
): CreateUseSimulateContractReturnType<abi, address, functionName> {
|
|
97
|
+
if (config.address !== undefined && typeof config.address === 'object')
|
|
98
|
+
return (parameters) => {
|
|
99
|
+
const configChainId = useChainId()
|
|
100
|
+
const account = useAccount()
|
|
101
|
+
const chainId =
|
|
102
|
+
(parameters as { chainId?: number })?.chainId ??
|
|
103
|
+
account.chainId ??
|
|
104
|
+
configChainId
|
|
105
|
+
return useSimulateContract({
|
|
106
|
+
...(parameters as any),
|
|
107
|
+
...(config.functionName ? { functionName: config.functionName } : {}),
|
|
108
|
+
address: config.address?.[chainId],
|
|
109
|
+
abi: config.abi,
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return (parameters) => {
|
|
114
|
+
return useSimulateContract({
|
|
115
|
+
...(parameters as any),
|
|
116
|
+
...(config.address ? { address: config.address } : {}),
|
|
117
|
+
...(config.functionName ? { functionName: config.functionName } : {}),
|
|
118
|
+
abi: config.abi,
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Config,
|
|
3
|
+
type ResolvedRegister,
|
|
4
|
+
type WatchContractEventParameters,
|
|
5
|
+
} from '@wagmi/core'
|
|
6
|
+
import {
|
|
7
|
+
type UnionEvaluate,
|
|
8
|
+
type UnionOmit,
|
|
9
|
+
type UnionPartial,
|
|
10
|
+
} from '@wagmi/core/internal'
|
|
11
|
+
import { type Abi, type Address, type ContractEventName } from 'viem'
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
type ConfigParameter,
|
|
15
|
+
type EnabledParameter,
|
|
16
|
+
} from '../../types/properties.js'
|
|
17
|
+
import { useAccount } from '../useAccount.js'
|
|
18
|
+
import { useChainId } from '../useChainId.js'
|
|
19
|
+
import { useWatchContractEvent } from '../useWatchContractEvent.js'
|
|
20
|
+
|
|
21
|
+
export type CreateUseWatchContractEventParameters<
|
|
22
|
+
abi extends Abi | readonly unknown[],
|
|
23
|
+
address extends Address | Record<number, Address> | undefined = undefined,
|
|
24
|
+
eventName extends ContractEventName<abi> | undefined = undefined,
|
|
25
|
+
> = {
|
|
26
|
+
abi: abi | Abi | readonly unknown[]
|
|
27
|
+
address?: address | Address | Record<number, Address> | undefined
|
|
28
|
+
eventName?: eventName | ContractEventName<abi> | undefined
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type CreateUseWatchContractEventReturnType<
|
|
32
|
+
abi extends Abi | readonly unknown[],
|
|
33
|
+
address extends Address | Record<number, Address> | undefined,
|
|
34
|
+
eventName extends ContractEventName<abi> | undefined,
|
|
35
|
+
///
|
|
36
|
+
omittedProperties extends 'abi' | 'address' | 'chainId' | 'eventName' =
|
|
37
|
+
| 'abi'
|
|
38
|
+
| (address extends undefined ? never : 'address')
|
|
39
|
+
| (address extends Record<number, Address> ? 'chainId' : never)
|
|
40
|
+
| (eventName extends undefined ? never : 'eventName'),
|
|
41
|
+
> = <
|
|
42
|
+
name extends eventName extends ContractEventName<abi>
|
|
43
|
+
? eventName
|
|
44
|
+
: ContractEventName<abi>,
|
|
45
|
+
strict extends boolean | undefined = undefined,
|
|
46
|
+
config extends Config = ResolvedRegister['config'],
|
|
47
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
48
|
+
>(
|
|
49
|
+
parameters?: UnionEvaluate<
|
|
50
|
+
UnionPartial<
|
|
51
|
+
UnionOmit<
|
|
52
|
+
WatchContractEventParameters<abi, name, strict, config, chainId>,
|
|
53
|
+
omittedProperties
|
|
54
|
+
>
|
|
55
|
+
> &
|
|
56
|
+
ConfigParameter<config> &
|
|
57
|
+
EnabledParameter
|
|
58
|
+
> &
|
|
59
|
+
(address extends Record<number, Address>
|
|
60
|
+
? { chainId?: keyof address | undefined }
|
|
61
|
+
: unknown),
|
|
62
|
+
) => void
|
|
63
|
+
|
|
64
|
+
export function createUseWatchContractEvent<
|
|
65
|
+
const abi extends Abi | readonly unknown[],
|
|
66
|
+
const address extends
|
|
67
|
+
| Address
|
|
68
|
+
| Record<number, Address>
|
|
69
|
+
| undefined = undefined,
|
|
70
|
+
eventName extends ContractEventName<abi> | undefined = undefined,
|
|
71
|
+
>(
|
|
72
|
+
config: CreateUseWatchContractEventParameters<abi, address, eventName>,
|
|
73
|
+
): CreateUseWatchContractEventReturnType<abi, address, eventName> {
|
|
74
|
+
if (config.address !== undefined && typeof config.address === 'object')
|
|
75
|
+
return (parameters) => {
|
|
76
|
+
const configChainId = useChainId()
|
|
77
|
+
const account = useAccount()
|
|
78
|
+
const chainId =
|
|
79
|
+
(parameters as { chainId?: number })?.chainId ??
|
|
80
|
+
account.chainId ??
|
|
81
|
+
configChainId
|
|
82
|
+
return useWatchContractEvent({
|
|
83
|
+
...(parameters as any),
|
|
84
|
+
...(config.eventName ? { eventName: config.eventName } : {}),
|
|
85
|
+
address: config.address?.[chainId],
|
|
86
|
+
abi: config.abi,
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return (parameters) => {
|
|
91
|
+
return useWatchContractEvent({
|
|
92
|
+
...(parameters as any),
|
|
93
|
+
...(config.address ? { address: config.address } : {}),
|
|
94
|
+
...(config.eventName ? { eventName: config.eventName } : {}),
|
|
95
|
+
abi: config.abi,
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
}
|