Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion crates/dyn-abi/src/eip712/typed_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ impl<'de> Deserialize<'de> for Eip712Types {
}
}

/// Represents the [EIP-712](https://eips.ethereum.org/EIPS/eip-712) typed data object.
/// Represents the [EIP-712](https://eips.ethereum.org/EIPS/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:
Expand Down Expand Up @@ -70,6 +71,7 @@ pub struct TypedData {
pub domain: Eip712Domain,

/// The custom types used by this message.
#[serde(rename = "types")]
pub resolver: Resolver,

/// The type of the message.
Expand Down Expand Up @@ -224,6 +226,21 @@ mod tests {
use alloy_sol_types::sol;
use serde_json::json;

#[test]
fn test_round_trip_ser() {
let json = json!({
"types": {
"EIP712Domain": []
},
"primaryType": "EIP712Domain",
"domain": {},
"message": {}
});
let typed_data: TypedData = serde_json::from_value(json.clone()).unwrap();
let val = serde_json::to_value(typed_data).unwrap();
assert_eq!(val, json);
}

#[test]
fn test_full_domain() {
let json = json!({
Expand Down