-
Notifications
You must be signed in to change notification settings - Fork 917
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
Add indexed args to events #540
Conversation
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.
Tysm @rin-st 🙌, Looking great to me !
Just fixed types for EventSubsriber because now people can also access through the index :
Regarding useScaffoldEvenHistory
currently in the main
branch too data : any[]
we should fix it to other PR
Let's see what others have to say about indexed args 🙌
Nice! 👍 |
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 and it seems a nice improvement. Thanks @rin-st !!
@technophile-04 your types doesn't work for other contract, could you check it? upd. It seems it's because of other viem version |
Actually Rinat I think we missed updating Also I think we updated the types just for I just tried adding it to |
I did it intentionally since without that pr people could be blocked from completing the challenges and I thought something wrong with types. I'll update it in challenges. Merging this, thanks! |
Description
Started here
Problem:
After migrating to viem and wagmi 1+ access to event parameters changed.
Before (ethers.js):
All the parameters of the event were accessible by index of argument in listener function or basically by index in args array.
After. We have two cases:
SomeEvent(uint256 arg1, uint256 arg2)
. We can access that event parameters on frontend only by param name:const {arg1, arg2} = event.args
SomeEvent(uint256, uint256)
. We can access that event parameters on frontend only by index:const [arg1, arg2] = event.args
or the sameconst arg1 = event.args[0]; const arg2 = event.args[1];
so writing frontend we're depending on how contract events are written and can't write universal code
Solution:
Add indexed parameters for frontend for named event parameters too. So for case with named params
SomeEvent(uint256 arg1, uint256 arg2)
we can access event params by param name OR by index of param.And it means we can always access event parameters at least by index
Additional Information
Your ENS/address:
0xrinat