Skip to content

Commit fcb9061

Browse files
authored
fix: serde rename resolver to types (#335)
* fix: rename resolver to types * doc: linebreak * lint: clipppy
1 parent 7942cf2 commit fcb9061

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

crates/dyn-abi/src/eip712/typed_data.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ impl<'de> Deserialize<'de> for Eip712Types {
2828
}
2929
}
3030

31-
/// Represents the [EIP-712](https://eips.ethereum.org/EIPS/eip-712) typed data object.
31+
/// Represents the [EIP-712](https://eips.ethereum.org/EIPS/eip-712) typed data
32+
/// object.
3233
///
3334
/// Typed data is a JSON object containing type information, domain separator
3435
/// parameters and the message object which has the following schema:
@@ -70,6 +71,7 @@ pub struct TypedData {
7071
pub domain: Eip712Domain,
7172

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

7577
/// The type of the message.
@@ -224,6 +226,21 @@ mod tests {
224226
use alloy_sol_types::sol;
225227
use serde_json::json;
226228

229+
#[test]
230+
fn test_round_trip_ser() {
231+
let json = json!({
232+
"types": {
233+
"EIP712Domain": []
234+
},
235+
"primaryType": "EIP712Domain",
236+
"domain": {},
237+
"message": {}
238+
});
239+
let typed_data: TypedData = serde_json::from_value(json.clone()).unwrap();
240+
let val = serde_json::to_value(typed_data).unwrap();
241+
assert_eq!(val, json);
242+
}
243+
227244
#[test]
228245
fn test_full_domain() {
229246
let json = json!({

0 commit comments

Comments
 (0)