Skip to content

Commit

Permalink
The new changes in useScaffoldWriteContract give me error if I don't …
Browse files Browse the repository at this point in the history
…add the `args: []`
  • Loading branch information
Nadai2010 committed Oct 15, 2024
1 parent 404e35c commit 0e5d371
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion packages/nextjs/app/token-vendor/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const TokenVendor: NextPage = () => {
const { data: tokensPerEth } = useScaffoldReadContract({
contractName: "Vendor",
functionName: "tokens_per_eth",
args: [],
});

const { sendAsync: transferTokens } = useScaffoldWriteContract({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const useScaffoldReadContract = <
address: deployedContract?.address,
abi: deployedContract?.abi,
watch: true,
args,
args: args || [],
enabled:
args && (!Array.isArray(args) || !args.some((arg) => arg === undefined)),
blockIdentifier: "pending" as BlockNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const useScaffoldWriteContract = <
}) => {
// if no args supplied, use the one supplied from hook
let newArgs = params?.args;
if (!newArgs) {
if (Object.keys(newArgs || {}).length <= 0) {
newArgs = args;
}

Expand All @@ -100,7 +100,7 @@ export const useScaffoldWriteContract = <
? parseFunctionParams({
abiFunction,
abi: deployedContractData.abi,
inputs: args as any[],
inputs: newArgs as any[],
isRead: false,
isReadArgsParsing: false,
}).flat(Infinity)
Expand Down

0 comments on commit 0e5d371

Please sign in to comment.