mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: use generics for RecoveredTx (#13650)
This commit is contained in:
@ -911,14 +911,14 @@ impl TransactionSigned {
|
||||
|
||||
/// Returns the [`RecoveredTx`] transaction with the given sender.
|
||||
#[inline]
|
||||
pub const fn with_signer(self, signer: Address) -> RecoveredTx {
|
||||
pub const fn with_signer(self, signer: Address) -> RecoveredTx<Self> {
|
||||
RecoveredTx::from_signed_transaction(self, signer)
|
||||
}
|
||||
|
||||
/// Consumes the type, recover signer and return [`RecoveredTx`]
|
||||
///
|
||||
/// Returns `None` if the transaction's signature is invalid, see also [`Self::recover_signer`].
|
||||
pub fn into_ecrecovered(self) -> Option<RecoveredTx> {
|
||||
pub fn into_ecrecovered(self) -> Option<RecoveredTx<Self>> {
|
||||
let signer = self.recover_signer()?;
|
||||
Some(RecoveredTx { signed_transaction: self, signer })
|
||||
}
|
||||
@ -928,7 +928,7 @@ impl TransactionSigned {
|
||||
///
|
||||
/// Returns `None` if the transaction's signature is invalid, see also
|
||||
/// [`Self::recover_signer_unchecked`].
|
||||
pub fn into_ecrecovered_unchecked(self) -> Option<RecoveredTx> {
|
||||
pub fn into_ecrecovered_unchecked(self) -> Option<RecoveredTx<Self>> {
|
||||
let signer = self.recover_signer_unchecked()?;
|
||||
Some(RecoveredTx { signed_transaction: self, signer })
|
||||
}
|
||||
@ -938,7 +938,7 @@ impl TransactionSigned {
|
||||
///
|
||||
/// Returns `Err(Self)` if the transaction's signature is invalid, see also
|
||||
/// [`Self::recover_signer_unchecked`].
|
||||
pub fn try_into_ecrecovered_unchecked(self) -> Result<RecoveredTx, Self> {
|
||||
pub fn try_into_ecrecovered_unchecked(self) -> Result<RecoveredTx<Self>, Self> {
|
||||
match self.recover_signer_unchecked() {
|
||||
None => Err(self),
|
||||
Some(signer) => Ok(RecoveredTx { signed_transaction: self, signer }),
|
||||
@ -1182,8 +1182,8 @@ impl alloy_consensus::Transaction for TransactionSigned {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RecoveredTx> for TransactionSigned {
|
||||
fn from(recovered: RecoveredTx) -> Self {
|
||||
impl From<RecoveredTx<Self>> for TransactionSigned {
|
||||
fn from(recovered: RecoveredTx<Self>) -> Self {
|
||||
recovered.signed_transaction
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! Defines the types for blob transactions, legacy, and other EIP-2718 transactions included in a
|
||||
//! response to `GetPooledTransactions`.
|
||||
|
||||
use crate::RecoveredTx;
|
||||
use crate::{RecoveredTx, TransactionSigned};
|
||||
use alloy_consensus::transaction::PooledTransaction;
|
||||
use alloy_eips::eip4844::BlobTransactionSidecar;
|
||||
use reth_primitives_traits::transaction::error::TransactionConversionError;
|
||||
@ -11,7 +11,7 @@ pub type PooledTransactionsElementEcRecovered<T = PooledTransaction> = Recovered
|
||||
|
||||
impl PooledTransactionsElementEcRecovered {
|
||||
/// Transform back to [`RecoveredTx`]
|
||||
pub fn into_ecrecovered_transaction(self) -> RecoveredTx {
|
||||
pub fn into_ecrecovered_transaction(self) -> RecoveredTx<TransactionSigned> {
|
||||
let (tx, signer) = self.to_components();
|
||||
RecoveredTx::from_signed_transaction(tx.into(), signer)
|
||||
}
|
||||
@ -21,9 +21,9 @@ impl PooledTransactionsElementEcRecovered {
|
||||
///
|
||||
/// Returns the transaction is not an EIP-4844 transaction.
|
||||
pub fn try_from_blob_transaction(
|
||||
tx: RecoveredTx,
|
||||
tx: RecoveredTx<TransactionSigned>,
|
||||
sidecar: BlobTransactionSidecar,
|
||||
) -> Result<Self, RecoveredTx> {
|
||||
) -> Result<Self, RecoveredTx<TransactionSigned>> {
|
||||
let RecoveredTx { signer, signed_transaction } = tx;
|
||||
let transaction = signed_transaction
|
||||
.try_into_pooled_eip4844(sidecar)
|
||||
@ -33,10 +33,10 @@ impl PooledTransactionsElementEcRecovered {
|
||||
}
|
||||
|
||||
/// Converts a `Recovered` into a `PooledTransactionsElementEcRecovered`.
|
||||
impl TryFrom<RecoveredTx> for PooledTransactionsElementEcRecovered {
|
||||
impl TryFrom<RecoveredTx<TransactionSigned>> for PooledTransactionsElementEcRecovered {
|
||||
type Error = TransactionConversionError;
|
||||
|
||||
fn try_from(tx: RecoveredTx) -> Result<Self, Self::Error> {
|
||||
fn try_from(tx: RecoveredTx<TransactionSigned>) -> Result<Self, Self::Error> {
|
||||
match PooledTransaction::try_from(tx.signed_transaction) {
|
||||
Ok(pooled_transaction) => {
|
||||
Ok(Self::from_signed_transaction(pooled_transaction, tx.signer))
|
||||
|
||||
Reference in New Issue
Block a user