Closed snd closed 6 years ago
i started working on this over here: https://github.com/paritytech/sol-rs/pull/14
thinking of the following API at the moment:
1) to get all logs:
pub fn raw_logs(&self) -> Vec<ethabi::RawLog>
2) to get logs for a specific event:
pub fn logs<T: EventTrait>(&self, event: T) -> Vec<T::Log>
used like this:
let deposit_logs = evm.logs(foreign_bridge.events().deposit());
2 is currently not possible because the EventTrait
doesn't exist.
currently events created by ethabi derive are structs that implement the same methods but don't share a trait: https://gist.github.com/snd/8dad886c6acdf057a18e2c29b6255c48#file-foreign_bridge-rs-L86
the events created by ethabi derive could all implement the following trait which would make 2 possible:
pub trait EventTrait {
type Log;
fn parse_log(&self, log: ethabi::RawLog) -> ethabi::Result<Self::Log>;
fn create_filter(&self) -> ethabi::TopicFilter;
}
i don't like the name EventTrait
. ethabi::Event
is already taken by the event struct.
i'd love your feedback on this
right now it just returns a vec of
()
per event. make it return actual events. also make the filter optional for the case where the user simply wants all events.