alloy_json_abi

Struct EventParam

Source
pub struct EventParam {
    pub indexed: bool,
    pub components: Vec<Param>,
    pub internal_type: Option<InternalType>,
    /* private fields */
}
Expand description

A Solidity Event parameter.

Event parameters are distinct from function parameters in that they have an indexed field.

Fields§

§indexed: bool

Whether the parameter is indexed. Indexed parameters have their value, or the hash of their value, stored in the log topics.

§components: Vec<Param>

If the parameter is a compound type (a struct or tuple), a list of the parameter’s components, in order. Empty otherwise. Because the components are not top-level event params, they will not have an indexed field.

§internal_type: Option<InternalType>

The internal type of the parameter. This type represents the type that the author of the Solidity contract specified. E.g. for a contract, this will be contract MyContract while the type field will be address.

Implementations§

Source§

impl EventParam

Source

pub fn parse(input: &str) -> Result<Self>

Parse an event parameter from a Solidity parameter string.

§Examples
use alloy_json_abi::EventParam;
assert_eq!(
    EventParam::parse("uint256[] indexed foo"),
    Ok(EventParam {
        name: "foo".into(),
        ty: "uint256[]".into(),
        indexed: true,
        components: vec![],
        internal_type: None,
    })
);
Source

pub fn new( name: &str, ty: &str, indexed: bool, components: Vec<Param>, internal_type: Option<InternalType>, ) -> Result<Self>

Validate and create new instance of EventParam

Source

pub const fn internal_type(&self) -> Option<&InternalType>

The internal type of the parameter.

Source

pub fn is_udt(&self) -> bool

True if the parameter is a UDT (user-defined type).

A UDT will have

  • an internal type that does not match its canonical type
  • no space in its internal type (as it does not have a keyword body)

Any Other specifier will definitely be a UDT if it contains a contract.

Source

pub const fn is_struct(&self) -> bool

True if the parameter is a struct.

Source

pub const fn is_enum(&self) -> bool

True if the parameter is an enum.

Source

pub const fn is_contract(&self) -> bool

True if the parameter is a contract.

Source

pub fn udt_specifier(&self) -> Option<TypeSpecifier<'_>>

The UDT specifier is a TypeSpecifier containing the UDT name and any array sizes. It is computed from the internal_type. If this param is not a UDT, this function will return None.

Source

pub fn struct_specifier(&self) -> Option<TypeSpecifier<'_>>

The struct specifier is a TypeSpecifier containing the struct name and any array sizes. It is computed from the internal_type If this param is not a struct, this function will return None.

Source

pub fn enum_specifier(&self) -> Option<TypeSpecifier<'_>>

The enum specifier is a TypeSpecifier containing the enum name and any array sizes. It is computed from the internal_type. If this param is not a enum, this function will return None.

Source

pub fn contract_specifier(&self) -> Option<TypeSpecifier<'_>>

The struct specifier is a TypeSpecifier containing the contract name and any array sizes. It is computed from the internal_type If this param is not a struct, this function will return None.

Source

pub fn is_simple_type(&self) -> bool

True if the type is simple

Source

pub fn is_complex_type(&self) -> bool

True if the type is complex (tuple or struct)

Source

pub fn selector_type_raw(&self, s: &mut String)

Formats the canonical type of this parameter into the given string.

This is used to encode the preimage of the event selector.

Source

pub fn full_selector_type_raw(&self, s: &mut String)

Formats the canonical type of this parameter into the given string including then names of the params.

Source

pub fn selector_type(&self) -> Cow<'_, str>

Returns the canonical type of this parameter.

This is used to encode the preimage of the event selector.

Trait Implementations§

Source§

impl Clone for EventParam

Source§

fn clone(&self) -> EventParam

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EventParam

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for EventParam

Source§

fn default() -> EventParam

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for EventParam

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for EventParam

Source§

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

Formats the value using the given formatter. Read more
Source§

impl FromStr for EventParam

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for EventParam

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for EventParam

Source§

fn eq(&self, other: &EventParam) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for EventParam

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for EventParam

Source§

impl StructuralPartialEq for EventParam

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

Source§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,