-
Notifications
You must be signed in to change notification settings - Fork 797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rewrite useScaffoldEventHistory hook #869
Conversation
Great changes! And thank you for testing steps! 🙏 |
As I understand there's no polling interval anymore upd. My bad, it works as expected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working great, thank you!
This should possibly be added to
|
Thanks Rinat and Damu review, updated it with suggested changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm!
Description:
Rewrote useScaffoldEventHistory with
useInfiniteQuery
fromtanstack-query
.Our present logic felt like a bit try-hard solution to get it working also introducing lots of imperative logic and also have a bug example #633.
I have been diving deep in to
tanstack-query
recently and also had #633 in back of mind for a while, anduseInfiniteQuery
seems like a perfect solution for this with some additional advantage:Solves bug:
useScaffoldEventHistory
multi-chain inconsistent behaviour #633Cleans up the code nicely
feature like
refetch
, it will allow people to imperatively fetch events again after a write is performed(without needing for watch) :Example :
Testing steps :
2. Copy this in externalContract.ts :
3. Copy this in `app/page.tsx` :
Update
scaffold.config.ts#targetNetworks
with[chains.sepolia, chains.baseSepolia]
.yarn start.
Connect wallet and switch network to
baseSepolia
you will see that instead of showing just 3 events it appended the events to previously fetched events fromsepolia
Demo: bug video :
Screen.Recording.2024-06-23.at.5.06.18.PM.mov
Now switch to this branch(no need to stash above changes, you could directly switch to this PR branch) and try test point 6 again it should work as expected and solve bug:
useScaffoldEventHistory
multi-chain inconsistent behaviour #633.Demo: bug is solved :
Screen.Recording.2024-06-23.at.5.09.09.PM.mov
Testing watch mode:
Just to make sure we don't break anything and
watch
mode also works perfectly, you revert all the above changes keep everything clean switch to this branch. Run three magical commandyarn chain
,yarn deploy
andyarn start
after that copy this inapp/page.tsx
Example :
Set the greeting on home page and see it updating
Also types should also work as expected and consuming it still remains same, but we need to document some new return values like
refetch
,isFetchingNewEvents
in SE-2 docs