mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Implement try_from rpc tx for TransactionSignedEcRecovered (#7752)
This commit is contained in:
@ -1822,6 +1822,25 @@ impl IntoRecoveredTransaction for TransactionSignedEcRecovered {
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<reth_rpc_types::Transaction> for TransactionSignedEcRecovered {
|
||||
type Error = ConversionError;
|
||||
|
||||
fn try_from(tx: reth_rpc_types::Transaction) -> Result<Self, Self::Error> {
|
||||
let signature = tx.signature.ok_or(ConversionError::MissingSignature)?;
|
||||
|
||||
TransactionSigned::from_transaction_and_signature(
|
||||
tx.try_into()?,
|
||||
Signature {
|
||||
r: signature.r,
|
||||
s: signature.s,
|
||||
odd_y_parity: signature.y_parity.ok_or(ConversionError::MissingYParity)?.0,
|
||||
},
|
||||
)
|
||||
.try_into_ecrecovered()
|
||||
.map_err(|_| ConversionError::InvalidSignature)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
|
||||
Reference in New Issue
Block a user