Skip to content

Commit

Permalink
Implement conversion between signature types (#1198)
Browse files Browse the repository at this point in the history
* Implement conversion from alloy_primitives::Signature to alloy_rpc_types_eth::Signature

* Simplify y-parity conversion
  • Loading branch information
emhane authored Aug 28, 2024
1 parent 05cc4e0 commit e1489b7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/rpc-types-eth/src/transaction/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ impl TryFrom<Signature> for alloy_primitives::Signature {
}
}

impl From<alloy_primitives::Signature> for Signature {
fn from(signature: alloy_primitives::Signature) -> Self {
Self {
v: U256::from(signature.v().to_u64()),
r: signature.r(),
s: signature.s(),
y_parity: Some(Parity::from(signature.v().y_parity())),
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit e1489b7

Please sign in to comment.