alloy_sol_types

Trait SolEvent

Source
pub trait SolEvent: Sized {
    type DataTuple<'a>: SolType<Token<'a> = Self::DataToken<'a>>;
    type DataToken<'a>: TokenSeq<'a>;
    type TopicList: TopicList;

    const SIGNATURE: &'static str;
    const SIGNATURE_HASH: FixedBytes<32>;
    const ANONYMOUS: bool;
Show 18 methods // Required methods fn new( topics: <Self::TopicList as SolType>::RustType, data: <Self::DataTuple<'_> as SolType>::RustType, ) -> Self; fn tokenize_body(&self) -> Self::DataToken<'_>; fn topics(&self) -> <Self::TopicList as SolType>::RustType; fn encode_topics_raw(&self, out: &mut [WordToken]) -> Result<()>; // Provided methods fn new_checked( topics: <Self::TopicList as SolType>::RustType, data: <Self::DataTuple<'_> as SolType>::RustType, ) -> Result<Self> { ... } fn check_signature( topics: &<Self::TopicList as SolType>::RustType, ) -> Result<()> { ... } fn abi_encoded_size(&self) -> usize { ... } fn encode_data_to(&self, out: &mut Vec<u8>) { ... } fn encode_data(&self) -> Vec<u8> { ... } fn encode_topics(&self) -> Vec<WordToken> { ... } fn encode_topics_array<const LEN: usize>(&self) -> [WordToken; LEN] { ... } fn encode_log_data(&self) -> LogData { ... } fn encode_log(log: &Log<Self>) -> Log<LogData> { ... } fn decode_topics<I, D>( topics: I, ) -> Result<<Self::TopicList as SolType>::RustType> where I: IntoIterator<Item = D>, D: Into<WordToken> { ... } fn abi_decode_data<'a>( data: &'a [u8], validate: bool, ) -> Result<<Self::DataTuple<'a> as SolType>::RustType> { ... } fn decode_raw_log<I, D>( topics: I, data: &[u8], validate: bool, ) -> Result<Self> where I: IntoIterator<Item = D>, D: Into<WordToken> { ... } fn decode_log_data(log: &LogData, validate: bool) -> Result<Self> { ... } fn decode_log(log: &Log, validate: bool) -> Result<Log<Self>> { ... }
}
Expand description

Solidity event.

§Implementer’s Guide

It should not be necessary to implement this trait manually. Instead, use the sol! procedural macro to parse Solidity syntax into types that implement this trait.

Required Associated Constants§

Source

const SIGNATURE: &'static str

The event’s ABI signature.

For anonymous events, this is unused, but is still present.

Source

const SIGNATURE_HASH: FixedBytes<32>

The event’s ABI signature hash, or selector: keccak256(SIGNATURE)

For non-anonymous events, this will be the first topic (topic0). For anonymous events, this is unused, but is still present.

Source

const ANONYMOUS: bool

Whether the event is anonymous.

Required Associated Types§

Source

type DataTuple<'a>: SolType<Token<'a> = Self::DataToken<'a>>

The underlying tuple type which represents this event’s non-indexed parameters. These parameters are ABI encoded and included in the log body.

If this event has no non-indexed parameters, this will be the unit type ().

Source

type DataToken<'a>: TokenSeq<'a>

The TokenSeq type corresponding to the tuple.

Source

type TopicList: TopicList

The underlying tuple type which represents this event’s topics.

These are ABI encoded and included in the log struct returned by the RPC node.

See the TopicList trait for more details.

Required Methods§

Source

fn new( topics: <Self::TopicList as SolType>::RustType, data: <Self::DataTuple<'_> as SolType>::RustType, ) -> Self

Convert decoded rust data to the event type.

Does not check that topics[0] is the correct hash. Use new_checked instead.

Source

fn tokenize_body(&self) -> Self::DataToken<'_>

Tokenize the event’s non-indexed parameters.

Source

fn topics(&self) -> <Self::TopicList as SolType>::RustType

The event’s topics.

Source

fn encode_topics_raw(&self, out: &mut [WordToken]) -> Result<()>

Encode the topics of this event into the given buffer.

§Errors

This method should return an error only if the buffer is too small.

Provided Methods§

Source

fn new_checked( topics: <Self::TopicList as SolType>::RustType, data: <Self::DataTuple<'_> as SolType>::RustType, ) -> Result<Self>

Convert decoded rust data to the event type.

Checks that topics[0] is the correct hash.

Source

fn check_signature( topics: &<Self::TopicList as SolType>::RustType, ) -> Result<()>

Check that the event’s signature matches the given topics.

Source

fn abi_encoded_size(&self) -> usize

The size of the ABI-encoded dynamic data in bytes.

Source

fn encode_data_to(&self, out: &mut Vec<u8>)

ABI-encode the dynamic data of this event into the given buffer.

Source

fn encode_data(&self) -> Vec<u8>

ABI-encode the dynamic data of this event.

Source

fn encode_topics(&self) -> Vec<WordToken>

Encode the topics of this event.

The returned vector will have length Self::TopicList::COUNT.

Source

fn encode_topics_array<const LEN: usize>(&self) -> [WordToken; LEN]

Encode the topics of this event into a fixed-size array.

This method will not compile if LEN is not equal to Self::TopicList::COUNT.

Source

fn encode_log_data(&self) -> LogData

Encode this event to a LogData.

Source

fn encode_log(log: &Log<Self>) -> Log<LogData>

Transform ca Log containing this event into a Log containing LogData.

Source

fn decode_topics<I, D>( topics: I, ) -> Result<<Self::TopicList as SolType>::RustType>
where I: IntoIterator<Item = D>, D: Into<WordToken>,

Decode the topics of this event from the given data.

Source

fn abi_decode_data<'a>( data: &'a [u8], validate: bool, ) -> Result<<Self::DataTuple<'a> as SolType>::RustType>

ABI-decodes the dynamic data of this event from the given buffer.

Source

fn decode_raw_log<I, D>(topics: I, data: &[u8], validate: bool) -> Result<Self>
where I: IntoIterator<Item = D>, D: Into<WordToken>,

Decode the event from the given log info.

Source

fn decode_log_data(log: &LogData, validate: bool) -> Result<Self>

Decode the event from the given log object.

Source

fn decode_log(log: &Log, validate: bool) -> Result<Log<Self>>

Decode the event from the given log object.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§