-
Notifications
You must be signed in to change notification settings - Fork 21
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 decodeArgs()
method for Event
#33
Conversation
looks good so far. Other than more tests, all I can think to add right now is |
I would probably also eliminate |
@esaulpaugh Fixed your comments and added more tests |
Okay, thanks. I will look at it. |
I'm thinking that if it's going to be doing decoding, Event should derive indexed and non-indexed TupleTypes only once, when constructed, and reuse them. Right? Unless there's a compelling reason not to, I think Event could just keep references to three TupleTypes: inputs, indexed, and nonIndexed. And non-anonymous Events would calculate topics[0] once during construction and use it to verify the topics arrays it's decoding with What do you think? |
That sounds great! Adding those things now |
@esaulpaugh Here you go! I opted to throw a |
I also refactored my code a bit and extracted some parts into more methods |
I usually just throw |
Fixed! If this looks good to you and you decide to merge it, would you mind cutting a release for it? That way I can merge some internal PR I have open as well 🙂 |
LGTM. I will be releasing version 6.0.0 with this included soon. Thanks. After the release I will go through the abi-spec some more and see if there is anything else I'm missing. |
Great! Thank you |
Hey @esaulpaugh,
Here's my implementation of the decode function for Events.
I still need to add a few more tests for edge cases, but I wanted your opinion before doing so.
In a few words:
topics
array, that we can easily decode using the usual decoding functions. However, dynamic types are not decodable as only a special hash of their encoding is stored, so we decode that instead.data
byte array, which we decode in one go. I'm not a fan of thedata
naming, but that's the terminology used in the Solidity docs, so I figured it's better to stay consistent.This split between
topics
anddata
as input parameters is similar to what is done inethereumj
or to how things are presented in tools like etherscan.Would that implementation work for you?
Feel free to also let me know about any code style changes you would like me to make, in order to match the project's choices in that regard.