Skip to content

Commit

Permalink
alloy-compat: impl TryFrom<alloy_rpc_types::Transaction> for Transact…
Browse files Browse the repository at this point in the history
…ionSignedNoHash
  • Loading branch information
tcoratger committed Jul 25, 2024
1 parent c4bf5bb commit a6ce492
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 a6ce492

Please sign in to comment.