alloy_dyn_abi::eip712

Struct 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 PartialEq for Resolver

Source§

fn eq(&self, other: &Resolver) -> 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 Resolver

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 Resolver

Source§

impl StructuralPartialEq for Resolver

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