impl TryFrom<alloy_rpc_types::Transaction> for TransactionSignedNoHash (#9823)

This commit is contained in:
Thomas Coratger
2024-07-27 02:04:15 +02:00
committed by GitHub
parent 800e247f97
commit 1ffa3d147d

View File

@ -2,8 +2,8 @@
use crate::{
constants::EMPTY_TRANSACTIONS, transaction::extract_chain_id, Block, Signature, Transaction,
TransactionSigned, TransactionSignedEcRecovered, TxEip1559, TxEip2930, TxEip4844, TxLegacy,
TxType,
TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash, TxEip1559, TxEip2930,
TxEip4844, TxLegacy, TxType,
};
use alloy_primitives::TxKind;
use alloy_rlp::Error as RlpError;
@ -296,6 +296,17 @@ impl TryFrom<alloy_rpc_types::Signature> for Signature {
}
}
impl TryFrom<alloy_rpc_types::Transaction> for TransactionSignedNoHash {
type Error = alloy_rpc_types::ConversionError;
fn try_from(tx: alloy_rpc_types::Transaction) -> Result<Self, Self::Error> {
Ok(Self {
signature: tx.signature.ok_or(Self::Error::MissingSignature)?.try_into()?,
transaction: tx.try_into()?,
})
}
}
#[cfg(test)]
#[cfg(feature = "optimism")]
mod tests {