Struct alloy_dyn_abi::eip712::Resolver

source ·
pub struct Resolver { /* private fields */ }
Available on crate feature eip712 only.
Expand description

A dependency graph built from the Eip712Types object. This is used to safely resolve JSON into a crate::DynSolType by detecting cycles in the type graph and traversing the dep graph.

Implementations§

source§

impl Resolver

source

pub fn from_struct<S: SolStruct>() -> Self

Instantiate a new resolver from a SolStruct type.

source

pub fn ingest_string(&mut self, s: impl AsRef<str>) -> Result<()>

Ingest types from an EIP-712 encodeType.

source

pub fn ingest_sol_struct<S: SolStruct>(&mut self)

Ingest a sol struct typedef.

source

pub fn ingest(&mut self, type_def: TypeDef)

Ingest a type.

source

pub fn ingest_types(&mut self, types: &Eip712Types)

Ingest a Types object into the resolver, discarding any invalid types.

source

pub fn linearize(&self, type_name: &str) -> Result<Vec<&TypeDef>>

This function linearizes a type into a list of typedefs of its dependencies.

source

pub fn resolve(&self, type_name: &str) -> Result<DynSolType>

Resolve a typename into a crate::DynSolType or return an error if the type is missing, or contains a circular dependency.

source

pub fn encode_type(&self, name: &str) -> Result<String>

Encode the type into an EIP-712 encodeType string

https://eips.ethereum.org/EIPS/eip-712#definition-of-encodetype

source

pub fn type_hash(&self, name: &str) -> Result<B256>

Compute the keccak256 hash of the EIP-712 encodeType string.

source

pub fn encode_data(&self, value: &DynSolValue) -> Result<Option<Vec<u8>>>

Encode the data according to EIP-712 encodeData rules.

source

pub fn eip712_data_word(&self, value: &DynSolValue) -> Result<B256>

Encode the data as a struct property according to EIP-712 encodeData rules. Atomic types are encoded as-is, while non-atomic types are encoded as their encodeData hash.

source

pub fn contains_type_name(&self, name: &str) -> bool

Check if the resolver graph contains a type by its name.

§Warning

This checks by NAME only. It does NOT check for type

Trait Implementations§

source§

impl Clone for Resolver

source§

fn clone(&self) -> Resolver

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 Resolver

source§

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

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

impl Default for Resolver

source§

fn default() -> Resolver

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

impl<'de> Deserialize<'de> for Resolver

source§

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

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

impl From<&Eip712Types> for Resolver

source§

fn from(types: &Eip712Types) -> Self

Converts to this type from the input type.
source§

impl From<&Resolver> for Eip712Types

source§

fn from(resolver: &Resolver) -> Self

Converts to this type from the input type.
source§

impl From<Eip712Types> for Resolver

source§

fn from(types: Eip712Types) -> Self

Converts to this type from the input type.
source§

impl Serialize for Resolver

source§

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

Serialize this value into the given Serde serializer. Read more

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

§

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