From 6275d284007168bfdab4cde165bbdb20dcc08b3e Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Mon, 26 Aug 2024 20:10:36 +0200 Subject: [PATCH 1/2] Implement conversion from alloy_primitives::Signature to alloy_rpc_types_eth::Signature --- crates/rpc-types-eth/src/transaction/signature.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/rpc-types-eth/src/transaction/signature.rs b/crates/rpc-types-eth/src/transaction/signature.rs index 2a456b11cd3..c4572e55bb4 100644 --- a/crates/rpc-types-eth/src/transaction/signature.rs +++ b/crates/rpc-types-eth/src/transaction/signature.rs @@ -75,6 +75,20 @@ impl TryFrom for alloy_primitives::Signature { } } +impl From 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_byte_non_eip155().unwrap_or(signature.v().y_parity_byte()) + != 0, + )), + } + } +} + #[cfg(test)] mod tests { use super::*; From 723db63d5c0442f8b30d8e2ff0c8be86bca823fc Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Wed, 28 Aug 2024 10:06:29 +0200 Subject: [PATCH 2/2] Simplify y-parity conversion --- crates/rpc-types-eth/src/transaction/signature.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/rpc-types-eth/src/transaction/signature.rs b/crates/rpc-types-eth/src/transaction/signature.rs index c4572e55bb4..5599fc9afc6 100644 --- a/crates/rpc-types-eth/src/transaction/signature.rs +++ b/crates/rpc-types-eth/src/transaction/signature.rs @@ -81,10 +81,7 @@ impl From for Signature { v: U256::from(signature.v().to_u64()), r: signature.r(), s: signature.s(), - y_parity: Some(Parity::from( - signature.v().y_parity_byte_non_eip155().unwrap_or(signature.v().y_parity_byte()) - != 0, - )), + y_parity: Some(Parity::from(signature.v().y_parity())), } } }