pub struct Eip712Domain {
pub name: Option<Cow<'static, str>>,
pub version: Option<Cow<'static, str>>,
pub chain_id: Option<U256>,
pub verifying_contract: Option<Address>,
pub salt: Option<B256>,
}
Expand description
EIP-712 domain attributes used in determining the domain separator.
Unused fields are left out of the struct type.
Protocol designers only need to include the fields that make sense for their signing domain.
Fields§
§name: Option<Cow<'static, str>>
The user readable name of signing domain, i.e. the name of the DApp or the protocol.
version: Option<Cow<'static, str>>
The current major version of the signing domain. Signatures from different versions are not compatible.
chain_id: Option<U256>
The EIP-155 chain ID. The user-agent should refuse signing if it does not match the currently active chain.
verifying_contract: Option<Address>
The address of the contract that will verify the signature.
salt: Option<B256>
A disambiguating salt for the protocol. This can be used as a domain separator of last resort.
Implementations§
Source§impl Eip712Domain
impl Eip712Domain
Sourcepub const fn new(
name: Option<Cow<'static, str>>,
version: Option<Cow<'static, str>>,
chain_id: Option<U256>,
verifying_contract: Option<Address>,
salt: Option<B256>,
) -> Self
pub const fn new( name: Option<Cow<'static, str>>, version: Option<Cow<'static, str>>, chain_id: Option<U256>, verifying_contract: Option<Address>, salt: Option<B256>, ) -> Self
Instantiate a new EIP-712 domain.
Use the eip712_domain!
macro for easier
instantiation.
Sourcepub fn encode_type(&self) -> String
pub fn encode_type(&self) -> String
The EIP-712-encoded type string.
See EIP-712 encodeType
.
Sourcepub fn type_hash(&self) -> B256
pub fn type_hash(&self) -> B256
Calculates the EIP-712 typeHash
for this domain.
This is defined as the Keccak-256 hash of the
encodeType
string.
Sourcepub const fn num_words(&self) -> usize
pub const fn num_words(&self) -> usize
Returns the number of ABI words (32 bytes) that will be used to encode the domain.
Sourcepub const fn abi_encoded_size(&self) -> usize
pub const fn abi_encoded_size(&self) -> usize
Returns the number of bytes that will be used to encode the domain.
Sourcepub fn encode_data_to(&self, out: &mut Vec<u8>)
pub fn encode_data_to(&self, out: &mut Vec<u8>)
Encodes this domain using EIP-712 encodeData
into the given buffer.
Sourcepub fn encode_data(&self) -> Vec<u8> ⓘ
pub fn encode_data(&self) -> Vec<u8> ⓘ
Encodes this domain using EIP-712 encodeData
.
Sourcepub fn hash_struct(&self) -> B256
pub fn hash_struct(&self) -> B256
Hashes this domain according to EIP-712 hashStruct
.
Trait Implementations§
Source§impl Clone for Eip712Domain
impl Clone for Eip712Domain
Source§fn clone(&self) -> Eip712Domain
fn clone(&self) -> Eip712Domain
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Eip712Domain
impl Debug for Eip712Domain
Source§impl Default for Eip712Domain
impl Default for Eip712Domain
Source§fn default() -> Eip712Domain
fn default() -> Eip712Domain
Source§impl<'de> Deserialize<'de> for Eip712Domain
impl<'de> Deserialize<'de> for Eip712Domain
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for Eip712Domain
impl Hash for Eip712Domain
Source§impl PartialEq for Eip712Domain
impl PartialEq for Eip712Domain
Source§impl Serialize for Eip712Domain
impl Serialize for Eip712Domain
impl Eq for Eip712Domain
impl StructuralPartialEq for Eip712Domain
Auto Trait Implementations§
impl Freeze for Eip712Domain
impl RefUnwindSafe for Eip712Domain
impl Send for Eip712Domain
impl Sync for Eip712Domain
impl Unpin for Eip712Domain
impl UnwindSafe for Eip712Domain
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
)