Struct alloy_dyn_abi::eip712::TypedData
source · pub struct TypedData {
pub domain: Eip712Domain,
pub resolver: Resolver,
pub primary_type: String,
pub message: Value,
}
eip712
only.Expand description
Represents the EIP-712 typed data object.
Typed data is a JSON object containing type information, domain separator parameters and the message object which has the following schema:
{
"type": "object",
"properties": {
"types": {
"type": "object",
"properties": {
"EIP712Domain": { "type": "array" }
},
"additionalProperties": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"type": { "type": "string" }
},
"required": ["name", "type"]
}
},
"required": ["EIP712Domain"]
},
"primaryType": { "type": "string" },
"domain": { "type": "object" },
"message": { "type": "object" }
},
"required": ["types", "primaryType", "domain", "message"]
}
Fields§
§domain: Eip712Domain
Signing domain metadata. The signing domain is the intended context for the signature (e.g. the dapp, protocol, etc. that it’s intended for). This data is used to construct the domain separator of the message.
resolver: Resolver
The custom types used by this message.
primary_type: String
The type of the message.
message: Value
The message to be signed.
Implementations§
source§impl TypedData
impl TypedData
sourcepub fn from_struct<S: SolStruct + Serialize>(
s: &S,
domain: Option<Eip712Domain>,
) -> Self
pub fn from_struct<S: SolStruct + Serialize>( s: &S, domain: Option<Eip712Domain>, ) -> Self
Instantiate TypedData
from a SolStruct
that implements
serde::Serialize
.
sourcepub const fn domain(&self) -> &Eip712Domain
pub const fn domain(&self) -> &Eip712Domain
Returns the domain for this typed data.
sourcepub fn coerce(&self) -> Result<DynSolValue>
pub fn coerce(&self) -> Result<DynSolValue>
Coerce the message to the type specified by primary_type
, using the
types map as a resolver.
sourcepub fn type_hash(&self) -> Result<B256>
pub fn type_hash(&self) -> Result<B256>
Calculate the Keccak-256 hash of encodeType
for this value.
Fails if this type is not a struct.
sourcepub fn hash_struct(&self) -> Result<B256>
pub fn hash_struct(&self) -> Result<B256>
Calculate the hashStruct
for this value.
Fails if this type is not a struct.
sourcepub fn encode_data(&self) -> Result<Vec<u8>>
pub fn encode_data(&self) -> Result<Vec<u8>>
Calculate the encodeData
for this value.
Fails if this type is not a struct.
sourcepub fn encode_type(&self) -> Result<String>
pub fn encode_type(&self) -> Result<String>
Calculate the encodeType
for this value.
Fails if this type is not a struct.
sourcepub fn eip712_signing_hash(&self) -> Result<B256>
pub fn eip712_signing_hash(&self) -> Result<B256>
Calculate the EIP-712 signing hash for this value.
This is the hash of the magic bytes 0x1901 concatenated with the domain
separator and the hashStruct
result.
Trait Implementations§
source§impl<'de> Deserialize<'de> for TypedData
impl<'de> Deserialize<'de> for TypedData
TypedData
is most likely going to be a stringified JSON object, so we have
to implement Deserialize manually to parse the string first.
See: