Skip to content

Commit

Permalink
fix: only prepare if all required params are provided
Browse files Browse the repository at this point in the history
  • Loading branch information
aramalipoor committed Oct 3, 2022
1 parent 6a8b8b4 commit 591f968
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/react/src/common/hooks/useContractWriteAndWait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const useContractWriteAndWait = <ArgsType extends any[] = any[]>({
confirmations = 1,
...restOfConfig
}: ContractWriteConfig<ArgsType>) => {
const { isConnected } = useAccount();
const { address, isConnected } = useAccount();
const { chain } = useNetwork();

const {
Expand All @@ -47,6 +47,14 @@ export const useContractWriteAndWait = <ArgsType extends any[] = any[]>({
isError: prepareIsError,
isLoading: prepareLoading,
} = usePrepareContractWrite({
enabled: Boolean(
isConnected &&
address &&
contractAddress &&
contractInterface &&
args !== undefined &&
functionName,
),
addressOrName: contractAddress as string,
contractInterface,
functionName,
Expand Down

0 comments on commit 591f968

Please sign in to comment.