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>

source

pub const fn new(provider: P, filter: Filter) -> Self

Creates a new event with the provided provider and filter.

source

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.

source

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.

source

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.

source

pub fn select(self, filter: impl Into<FilterBlockOption>) -> Self

Sets the inner filter object

See Filter::select.

source

pub fn from_block<B: Into<BlockNumberOrTag>>(self, block: B) -> Self

Sets the from block number

source

pub fn to_block<B: Into<BlockNumberOrTag>>(self, block: B) -> Self

Sets the to block number

source

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.

source

pub fn at_block_hash<A: Into<B256>>(self, hash: A) -> Self

Pins the block hash for the filter

source

pub fn address<A: Into<ValueOrArray<Address>>>(self, address: A) -> Self

Sets the address to query with this filter.

See Filter::address.

source

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

source

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)

source

pub fn event_signature<TO: Into<Topic>>(self, topic: TO) -> Self

Sets event_signature(topic0) (the event name for non-anonymous events)

source

pub fn topic1<TO: Into<Topic>>(self, topic: TO) -> Self

Sets the 1st indexed topic

source

pub fn topic2<TO: Into<Topic>>(self, topic: TO) -> Self

Sets the 2nd indexed topic

source

pub fn topic3<TO: Into<Topic>>(self, topic: TO) -> Self

Sets the 3rd indexed topic

source§

impl<T, P: Clone, E, N> Event<T, &P, E, N>

source

pub fn with_cloned_provider(self) -> Event<T, P, E, N>

Clones the provider and returns a new event with the cloned provider.

Trait Implementations§

source§

impl<T, P: Debug, E, N> Debug for Event<T, P, E, N>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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>
where P: Send, T: Send, E: Send, N: Send,

§

impl<T, P, E, N> Sync for Event<T, P, E, N>
where P: Sync, T: Sync, E: Sync, N: Sync,

§

impl<T, P, E, N> Unpin for Event<T, P, E, N>
where P: Unpin, T: Unpin, E: Unpin, N: Unpin,

§

impl<T, P, E, N> UnwindSafe for Event<T, P, E, N>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T