Skip to content

Commit

Permalink
update pollingInterval with hardcoded 1s
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 committed Apr 10, 2024
1 parent bf7a595 commit 05b8d9b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import type { NextPage } from "next";
import { useAccount } from "wagmi";
import { Address } from "~~/components/scaffold-eth";
import { useScaffoldWatchContractEvent, useScaffoldWriteContract } from "~~/hooks/scaffold-eth";
import {
useScaffoldEventHistory,
useScaffoldWatchContractEvent,
useScaffoldWriteContract,
} from "~~/hooks/scaffold-eth";

const Home: NextPage = () => {
const { address: connectedAddress } = useAccount();
Expand All @@ -18,6 +22,15 @@ const Home: NextPage = () => {
},
});

const { data: eventHistoryData } = useScaffoldEventHistory({
contractName: "YourContract",
eventName: "GreetingChange",
fromBlock: 0n,
watch: true,
});

console.log("eventHistoryData:", eventHistoryData);

const handleWrite = async () => {
try {
await writeYourContracAsync({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ export const useScaffoldWatchContractEvent = <
chainId: targetNetwork.id,
onLogs: listenerWithIndexedArgs,
eventName,
pollingInterval: 1000,
});
};

0 comments on commit 05b8d9b

Please sign in to comment.