fix: support eip712 domain chain ids as string (#1756)
* fix: support eip712 domain chain ids as string * chore: add rustfmt.toml
This commit is contained in:
parent
5c762c44d7
commit
fac31f631c
|
@ -254,3 +254,25 @@ where
|
||||||
let num = <[LenientBlockNumber; 1]>::deserialize(deserializer)?[0].into();
|
let num = <[LenientBlockNumber; 1]>::deserialize(deserializer)?[0].into();
|
||||||
Ok(num)
|
Ok(num)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "eip712")]
|
||||||
|
fn test_deserialize_string_chain_id() {
|
||||||
|
use crate::types::transaction::eip712::EIP712Domain;
|
||||||
|
|
||||||
|
let val = serde_json::json!(
|
||||||
|
{
|
||||||
|
"name": "Seaport",
|
||||||
|
"version": "1.1",
|
||||||
|
"chainId": "137",
|
||||||
|
"verifyingContract": "0x00000000006c3852cbEf3e08E8dF289169EdE581"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
let domain: EIP712Domain = serde_json::from_value(val).unwrap();
|
||||||
|
assert_eq!(domain.chain_id, Some(137u64.into()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ pub struct EIP712Domain {
|
||||||
#[serde(
|
#[serde(
|
||||||
default,
|
default,
|
||||||
skip_serializing_if = "Option::is_none",
|
skip_serializing_if = "Option::is_none",
|
||||||
deserialize_with = "crate::types::serde_helpers::deserialize_number_opt"
|
deserialize_with = "crate::types::serde_helpers::deserialize_stringified_numeric_opt"
|
||||||
)]
|
)]
|
||||||
pub chain_id: Option<U256>,
|
pub chain_id: Option<U256>,
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue