Skip to content

Commit

Permalink
impl `TryFrom<alloy_rpc_types::Transaction> for TransactionSignedNoHa…
Browse files Browse the repository at this point in the history
…sh` (#9823)
  • Loading branch information
tcoratger authored Jul 27, 2024
1 parent 800e247 commit 1ffa3d1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions crates/primitives/src/alloy_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 1ffa3d1

Please sign in to comment.