Skip to content

Commit

Permalink
feat: add TxRequest::from_recovered_transaction helper (#1960)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jan 29, 2025
1 parent 4554735 commit 98f8109
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/rpc-types-eth/src/transaction/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use alloc::{
vec,
vec::Vec,
};
use alloy_consensus::transaction::Recovered;

/// Represents _all_ transaction requests to/from RPC.
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -186,6 +187,12 @@ impl TransactionRequest {
}
}

/// Initializes the [`TransactionRequest`] with the provided transaction and sender.
pub fn from_recovered_transaction<T: TransactionTrait>(tx: Recovered<T>) -> Self {
let (tx, from) = tx.into_parts();
Self::from_transaction(tx).from(from)
}

/// Initializes the [`TransactionRequest`] with the provided transaction and sender.
pub fn from_transaction_with_sender<T: TransactionTrait>(tx: T, from: Address) -> Self {
Self::from_transaction(tx).from(from)
Expand Down

0 comments on commit 98f8109

Please sign in to comment.