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
impl EventParam
Sourcepub fn parse(input: &str) -> Result<Self>
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,
})
);
Sourcepub fn new(
name: &str,
ty: &str,
indexed: bool,
components: Vec<Param>,
internal_type: Option<InternalType>,
) -> Result<Self>
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
Sourcepub const fn internal_type(&self) -> Option<&InternalType>
pub const fn internal_type(&self) -> Option<&InternalType>
The internal type of the parameter.
Sourcepub fn is_udt(&self) -> bool
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.
Sourcepub const fn is_contract(&self) -> bool
pub const fn is_contract(&self) -> bool
True if the parameter is a contract.
Sourcepub fn udt_specifier(&self) -> Option<TypeSpecifier<'_>>
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
.
Sourcepub fn struct_specifier(&self) -> Option<TypeSpecifier<'_>>
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
.
Sourcepub fn enum_specifier(&self) -> Option<TypeSpecifier<'_>>
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
.
Sourcepub fn contract_specifier(&self) -> Option<TypeSpecifier<'_>>
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
.
Sourcepub fn is_simple_type(&self) -> bool
pub fn is_simple_type(&self) -> bool
True if the type is simple
Sourcepub fn is_complex_type(&self) -> bool
pub fn is_complex_type(&self) -> bool
True if the type is complex (tuple or struct)
Sourcepub fn selector_type_raw(&self, s: &mut String)
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.
Sourcepub fn full_selector_type_raw(&self, s: &mut String)
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.
Sourcepub fn selector_type(&self) -> Cow<'_, str>
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
impl Clone for EventParam
Source§fn clone(&self) -> EventParam
fn clone(&self) -> EventParam
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for EventParam
impl Debug for EventParam
Source§impl Default for EventParam
impl Default for EventParam
Source§fn default() -> EventParam
fn default() -> EventParam
Source§impl<'de> Deserialize<'de> for EventParam
impl<'de> Deserialize<'de> for EventParam
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for EventParam
impl Display for EventParam
Source§impl FromStr for EventParam
impl FromStr for EventParam
Source§impl Hash for EventParam
impl Hash for EventParam
Source§impl PartialEq for EventParam
impl PartialEq for EventParam
Source§impl Serialize for EventParam
impl Serialize for EventParam
impl Eq for EventParam
impl StructuralPartialEq for EventParam
Auto Trait Implementations§
impl Freeze for EventParam
impl RefUnwindSafe for EventParam
impl Send for EventParam
impl Sync for EventParam
impl Unpin for EventParam
impl UnwindSafe for EventParam
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)