Skip to content

Commit

Permalink
Fix useScaffoldContractWrite so it properly throws errors (#758)
Browse files Browse the repository at this point in the history
Co-authored-by: Shiv Bhonde <shivbhonde04@gmail.com>
  • Loading branch information
corwinthill and technophile-04 committed Mar 8, 2024
1 parent 408c016 commit 03a2dfa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTargetNetwork } from "./useTargetNetwork";
import { Abi, ExtractAbiFunctionNames } from "abitype";
import { useContractWrite, useNetwork } from "wagmi";
import { useDeployedContractInfo, useTransactor } from "~~/hooks/scaffold-eth";
import { getParsedError, notification } from "~~/utils/scaffold-eth";
import { notification } from "~~/utils/scaffold-eth";
import { ContractAbi, ContractName, UseScaffoldWriteConfig } from "~~/utils/scaffold-eth/contract";

type UpdatedArgs = Parameters<ReturnType<typeof useContractWrite<Abi, string, undefined>>["writeAsync"]>[0];
Expand Down Expand Up @@ -83,8 +83,7 @@ export const useScaffoldContractWrite = <

return writeTxResult;
} catch (e: any) {
const message = getParsedError(e);
notification.error(message);
throw e;
} finally {
setIsMining(false);
}
Expand Down
1 change: 1 addition & 0 deletions packages/nextjs/hooks/scaffold-eth/useTransactor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const useTransactor = (_walletClient?: WalletClient): TransactionFunc =>
console.error("⚡️ ~ file: useTransactor.ts ~ error", error);
const message = getParsedError(error);
notification.error(message);
throw error;
}

return transactionHash;
Expand Down

0 comments on commit 03a2dfa

Please sign in to comment.