-
Notifications
You must be signed in to change notification settings - Fork 23
feat(zink-codegen): introduce derive macro for events #298
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
Conversation
@clearloop seems like log does not exist |
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.
Sorry for the late! was busy these days, almost finished! your new tests are totally correct!
at the current stage, you now need to handle the log function in the visitor, see https://github.com/zink-lang/zink/blob/main/codegen/src/visitor/log.rs#L62
If you need more details or have specific questions, free feel to pin me in the telegram group! In case this issue is a bit harder than the previous, just updated the bounty to large level!
|
|
|
like this |
quite similar to what i did first, made the tests fail |
it sorts normally: |
looks closed! now you can decode this output to see what exactly the log is!
|
see my fix here: malik672/zink@sync...zink-lang:zink:cl/sync |
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.
Everything works now!
Now we need to wrap these log functions into our proc-macro
for the event abi part, let's handle it in a separated PR (#299), since it modifies logic in compiler
need to generate sugar functions in our proc-macro, the implementation till 583dbe2 makes sure our deep logic are working now, so the last thing is wrap them in proc-macro |
@clearloop might need your help here |
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.
Instead of quote!
, construct the functions with the ImplItemType could make things more dynamic
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.
Thanks for contributing on this issue! however, I can not send you the full bounty because I solved the issue instead finally XD, it's unfair to other contributors who solve tricky issues independently, hope you can understand!
Apart from that, thank you again for spending time on digging the feature! see the transaction 🎁 : https://polygonscan.com/tx/0x1b588cab3bdb014fe247acf4c06f825515af6b8ee4c1df1c505de220f7af39b1
pub enum MyEvent { | ||
/// Event with one topic | ||
Topic1(U256), | ||
/// Event with two topics | ||
Topic2(U256, U256), | ||
/// Event with three topics | ||
Topic3(U256, U256, U256), | ||
/// Event with four topics | ||
Topic4(U256, U256, U256, U256), | ||
} |
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.
How do you specify indexed topics?
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.
@CalabashSquash you can use the #[indexed]
attribute on the fields you want to index within each variant. for example:
#[derive(Event)]
pub enum MyEvent {
/// Event with one topic, indexed
Topic1(#[indexed] U256),
/// Event with two topics, first one indexed
Topic2(#[indexed] U256, U256),
/// Event with three topics, first two indexed
Topic3(#[indexed] U256, #[indexed] U256, U256),
/// Event with four topics, first three indexed
Topic4(#[indexed] U256, #[indexed] U256, #[indexed] U256, U256),
}
the #[indexed]
attribute marks a field as an indexed topic, which will be included in the event's topics for efficient filtering on the Ethereum blockchain. also, note that non-anonymous events can have up to 3 indexed fields, anonymous events can have up to 4 indexed fields and fields without #[indexed]
are stored in the event's data payload, not as topics.
the logic lies here
Resolves #255
0x30bE4D758d86cfb1Ae74Ae698f2CF4BA7dC8d693