scaffold-eth-2 icon indicating copy to clipboard operation
scaffold-eth-2 copied to clipboard

bug: wagmi v2 useScaffoldWatchContractEvent doesn't work as expected

Open rin-st opened this issue 2 months ago • 0 comments

Is there an existing issue for this?

Which method was used to setup Scaffold-ETH 2 ?

git clone, npx create-eth@latest

Current Behavior

When using useScaffoldWatchContractEvent with a watched hook or useScaffoldEventHistory, onLogs doesn't fire or fire sometimes. Tried to make it work, but no luck in hardhat and foundry, on sepolia it works from time to time. But onError from useScaffoldWatchContractEvent fires often.

Also tried to make an app without <ScaffoldApp> wrapper to minimize rerenders and logic that can cause the bug, used pure wagmi hook useWatchContractEvent and watched useBalance on hardhat. Result - onLogs fires sometimes, but not in 100% of cases. So looks like it's on wagmi side. Raised an issue .

Probably I'm missing something, so if you know what's wrong please let me know

Expected Behavior

onLogs fires in 100% cases

Steps To Reproduce

Example of app without scaffold hooks (based on sre challenge 3). You'll need to start second app on localhost:3001 and send eth to your account from localhost:3000

Example 2 with our hooks. Challenge 3 with wagmi v2 (working on this)

Anything else?

see also last part of Shiv's message https://github.com/scaffold-eth/scaffold-eth-2/pull/700#issuecomment-2048117489

rin-st avatar May 03 '24 19:05 rin-st