-
Notifications
You must be signed in to change notification settings - Fork 151
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
feat: Solidity events support #83
Conversation
* fix: event trait fixes * fix: re-exporting event * refactor: event trait take 2 * refactor: improve topic detokenization * refactor: change events to account for indexed structs not in body * fix: move test to bottom of event
/// For more details, see the [Solidity reference][ref]. | ||
/// | ||
/// [ref]: https://docs.soliditylang.org/en/latest/abi-spec.html#encoding-of-indexed-event-parameters | ||
pub trait EventTopic: SolType { |
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.
will this need to be generated in sol!
for all structs?
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.
Can be done with a blanket impl:
impl<T: SolStruct> EventTopic for T
where
T::Tuple: EventTopic,
{
fn topic_preimage_length(rust: &T) -> usize {
let tuple = rust.to_rust();
T::Tuple::topic_preimage_length(&tuple)
}
}
But we're cloning the data to get the inner tuple, so this is not ideal
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.
But we're cloning the data to get the inner tuple, so this is not ideal
I'm gonna think about this a bit more. what do you think of this:
trait SolType {
type BorrowAbstraction: From<Self::RustType>;
fn encode<T: Into<Self::BorrowAbstraction>>(t: T)
}
pub enum TupleBorrowAbstraction<T, U> {
Owned((T,U)),
Borrowed(&(T, U)),
MembersBorrowed((&T, &U))
}
// From impls here
Closes #38