-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
Not exactly sure how to describe this, but I suppose it would be analogous to the Contract object what we know and love from ethers which can be instantiated as an interface from an ABI or as an instance when also provided with an address and web3Provider.
This would allow us to make generalizations for arbitrary contracts some common functionalities.
One particular place where this could come in handy is when implementing an Event Listener in place of the generic EventRetrieving
pub struct EventHandler<C: EventRetrieving, S: EventStoring<C::Event>> {
contract: C,
store: S,
last_handled_block: Option<u64>,
}Where
pub trait EventRetrieving {
type Event: ParseLog;
fn get_events(&self) -> AllEventsBuilder<DynTransport, Self::Event>;
fn web3(&self) -> Web3<DynTransport>;
}At the moment we need to implement EventRetrieving in a very boiler plate kind of way for each contract we want to listen to.
impl EventRetrieving for GPv2SettlementContract {
type Event = ContractEvent;
fn get_events(&self) -> AllEventsBuilder<DynTransport, Self::Event> {
self.0.all_events()
}
fn web3(&self) -> Web3<DynTransport> {
self.0.raw_instance().web3()
}
}Metadata
Metadata
Assignees
Labels
No labels