Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr committed Nov 1, 2024
1 parent e127567 commit 58e6de0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions crates/primitives/src/signature/primitive_sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,9 @@ mod signature_serde {
struct HumanReadableRepr {
r: U256,
s: U256,
#[serde(rename = "yParity", alias = "v")]
y_parity: U64,
#[serde(rename = "yParity")]
y_parity: Option<U64>,
v: Option<U64>,
}

#[derive(Serialize, Deserialize)]
Expand All @@ -355,7 +356,8 @@ mod signature_serde {
// if the serializer is human readable, serialize as a map, otherwise as a tuple
if serializer.is_human_readable() {
HumanReadableRepr {
y_parity: U64::from(self.y_parity as u64),
y_parity: Some(U64::from(self.y_parity as u64)),
v: None,
r: self.r,
s: self.s,
}
Expand All @@ -373,7 +375,10 @@ mod signature_serde {
D: Deserializer<'de>,
{
let (y_parity, r, s) = if deserializer.is_human_readable() {
let HumanReadableRepr { y_parity, r, s } = <_>::deserialize(deserializer)?;
let HumanReadableRepr { y_parity, v, r, s } = <_>::deserialize(deserializer)?;
let y_parity = y_parity
.or(v)
.ok_or_else(|| serde::de::Error::custom("missing `yParity` or `v`"))?;
(y_parity, r, s)
} else {
let NonHumanReadableRepr((r, s, y_parity)) = <_>::deserialize(deserializer)?;
Expand Down

0 comments on commit 58e6de0

Please sign in to comment.