Skip to content

Commit

Permalink
update useTransactor parameter types (#846)
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 committed May 15, 2024
1 parent 0db0d5f commit b86cbd7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions packages/nextjs/components/scaffold-eth/Faucet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const Faucet = () => {
}, []);

const sendETH = async () => {
if (!faucetAddress) {
if (!faucetAddress || !inputAddress) {
return;
}
try {
Expand All @@ -64,7 +64,6 @@ export const Faucet = () => {
to: inputAddress,
value: parseEther(sendValue as `${number}`),
account: faucetAddress,
chain: hardhat,
});
setLoading(false);
setInputAddress(undefined);
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/components/scaffold-eth/FaucetButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export const FaucetButton = () => {
const faucetTxn = useTransactor(localWalletClient);

const sendETH = async () => {
if (!address) return;
try {
setLoading(true);
await faucetTxn({
chain: hardhat,
account: FAUCET_ADDRESS,
to: address,
value: parseEther(NUM_OF_ETH),
Expand Down
7 changes: 4 additions & 3 deletions packages/nextjs/hooks/scaffold-eth/useTransactor.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { getPublicClient } from "@wagmi/core";
import { Hash, SendTransactionParameters, WalletClient } from "viem";
import { useWalletClient } from "wagmi";
import { Config, useWalletClient } from "wagmi";
import { SendTransactionMutate } from "wagmi/query";
import { wagmiConfig } from "~~/services/web3/wagmiConfig";
import { getBlockExplorerTxLink, getParsedError, notification } from "~~/utils/scaffold-eth";
import { TransactorFuncOptions } from "~~/utils/scaffold-eth/contract";

type TransactionFunc = (
tx: (() => Promise<Hash>) | SendTransactionParameters,
tx: (() => Promise<Hash>) | Parameters<SendTransactionMutate<Config, undefined>>[0],
options?: TransactorFuncOptions,
) => Promise<Hash | undefined>;

Expand Down Expand Up @@ -58,7 +59,7 @@ export const useTransactor = (_walletClient?: WalletClient): TransactionFunc =>
const result = await tx();
transactionHash = result;
} else if (tx != null) {
transactionHash = await walletClient.sendTransaction(tx);
transactionHash = await walletClient.sendTransaction(tx as SendTransactionParameters);
} else {
throw new Error("Incorrect transaction passed to transactor");
}
Expand Down

0 comments on commit b86cbd7

Please sign in to comment.