alloy_sol_types

Trait SolStruct

Source
pub trait SolStruct: SolType<RustType = Self> {
    const NAME: &'static str;

    // Required methods
    fn eip712_components() -> Vec<Cow<'static, str>>;
    fn eip712_root_type() -> Cow<'static, str>;
    fn eip712_encode_data(&self) -> Vec<u8> ;

    // Provided methods
    fn eip712_encode_type() -> Cow<'static, str> { ... }
    fn eip712_type_hash(&self) -> B256 { ... }
    fn eip712_hash_struct(&self) -> B256 { ... }
    fn eip712_signing_hash(&self, domain: &Eip712Domain) -> B256 { ... }
}
Expand description

A Solidity struct.

This trait is used to implement ABI and EIP-712 encoding and decoding.

§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.

§Note

Special attention should be paid to eip712_encode_type for complex Solidity types. Nested Solidity structs must properly encode their type.

To be clear, a struct with a nested struct must encode the nested struct’s type as well.

See EIP-712#definition-of-encodetype for more details.

Required Associated Constants§

Source

const NAME: &'static str

The struct name.

Used in eip712_encode_type.

Required Methods§

Source

fn eip712_components() -> Vec<Cow<'static, str>>

Returns component EIP-712 types. These types are used to construct the encodeType string. These are the types of the struct’s fields, and should not include the root type.

Source

fn eip712_root_type() -> Cow<'static, str>

Return the root EIP-712 type. This type is used to construct the encodeType string.

Source

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

Encodes this domain using EIP-712 encodeData.

Provided Methods§

Source

fn eip712_encode_type() -> Cow<'static, str>

The EIP-712-encoded type string.

See EIP-712 encodeType.

Source

fn eip712_type_hash(&self) -> B256

Calculates the EIP-712 typeHash for this struct.

This is defined as the Keccak-256 hash of the encodeType string.

Source

fn eip712_hash_struct(&self) -> B256

Hashes this struct according to EIP-712 hashStruct.

Source

fn eip712_signing_hash(&self, domain: &Eip712Domain) -> B256

Does something.

See EIP-712 signTypedData.

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§