Struct alloy_contract::Event
source · pub struct Event<T, P, E, N = Ethereum> {
pub provider: P,
pub filter: Filter,
/* private fields */
}
Expand description
Helper for managing the event filter before querying or streaming its logs
Fields§
§provider: P
The provider to use for querying or streaming logs.
filter: Filter
The filter to use for querying or streaming logs.
Implementations§
source§impl<T: Transport + Clone, P: Provider<T, N>, E: SolEvent, N: Network> Event<T, P, E, N>
impl<T: Transport + Clone, P: Provider<T, N>, E: SolEvent, N: Network> Event<T, P, E, N>
sourcepub const fn new(provider: P, filter: Filter) -> Self
pub const fn new(provider: P, filter: Filter) -> Self
Creates a new event with the provided provider and filter.
sourcepub async fn query(&self) -> Result<Vec<(E, Log)>, Error>
pub async fn query(&self) -> Result<Vec<(E, Log)>, Error>
Queries the blockchain for the selected filter and returns a vector of matching event logs.
sourcepub async fn query_raw(&self) -> TransportResult<Vec<Log>>
pub async fn query_raw(&self) -> TransportResult<Vec<Log>>
Queries the blockchain for the selected filter and returns a vector of matching event logs, without decoding them.
sourcepub async fn watch(&self) -> TransportResult<EventPoller<T, E>>
pub async fn watch(&self) -> TransportResult<EventPoller<T, E>>
Watches for events that match the filter.
Returns a stream of decoded events and raw logs.
sourcepub fn select(self, filter: impl Into<FilterBlockOption>) -> Self
pub fn select(self, filter: impl Into<FilterBlockOption>) -> Self
Sets the inner filter object
See Filter::select
.
sourcepub fn from_block<B: Into<BlockNumberOrTag>>(self, block: B) -> Self
pub fn from_block<B: Into<BlockNumberOrTag>>(self, block: B) -> Self
Sets the from block number
sourcepub fn to_block<B: Into<BlockNumberOrTag>>(self, block: B) -> Self
pub fn to_block<B: Into<BlockNumberOrTag>>(self, block: B) -> Self
Sets the to block number
sourcepub fn is_pending_block_filter(&self) -> bool
pub fn is_pending_block_filter(&self) -> bool
Return true
if filter configured to match pending block.
This means that both from_block
and to_block
are set to the pending
tag.
sourcepub fn at_block_hash<A: Into<B256>>(self, hash: A) -> Self
pub fn at_block_hash<A: Into<B256>>(self, hash: A) -> Self
Pins the block hash for the filter
sourcepub fn address<A: Into<ValueOrArray<Address>>>(self, address: A) -> Self
pub fn address<A: Into<ValueOrArray<Address>>>(self, address: A) -> Self
Sets the address to query with this filter.
See Filter::address
.
sourcepub fn event(self, event_name: &str) -> Self
pub fn event(self, event_name: &str) -> Self
Given the event signature in string form, it hashes it and adds it to the topics to monitor
sourcepub fn events(self, events: impl IntoIterator<Item = impl AsRef<[u8]>>) -> Self
pub fn events(self, events: impl IntoIterator<Item = impl AsRef<[u8]>>) -> Self
Hashes all event signatures and sets them as array to event_signature(topic0)
sourcepub fn event_signature<TO: Into<Topic>>(self, topic: TO) -> Self
pub fn event_signature<TO: Into<Topic>>(self, topic: TO) -> Self
Sets event_signature(topic0) (the event name for non-anonymous events)
Trait Implementations§
Auto Trait Implementations§
impl<T, P, E, N> Freeze for Event<T, P, E, N>where
P: Freeze,
impl<T, P, E, N> RefUnwindSafe for Event<T, P, E, N>
impl<T, P, E, N> Send for Event<T, P, E, N>
impl<T, P, E, N> Sync for Event<T, P, E, N>
impl<T, P, E, N> Unpin for Event<T, P, E, N>
impl<T, P, E, N> UnwindSafe for Event<T, P, E, N>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more