mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add additional conversion trait for pooled tx element (#4279)
This commit is contained in:
@ -91,11 +91,12 @@ pub use storage::StorageEntry;
|
||||
pub use transaction::{
|
||||
util::secp256k1::{public_key_to_address, recover_signer, sign_message},
|
||||
AccessList, AccessListItem, AccessListWithGasUsed, BlobTransaction, BlobTransactionSidecar,
|
||||
FromRecoveredTransaction, IntoRecoveredTransaction, InvalidTransactionError,
|
||||
PooledTransactionsElement, PooledTransactionsElementEcRecovered, Signature, Transaction,
|
||||
TransactionKind, TransactionMeta, TransactionSigned, TransactionSignedEcRecovered,
|
||||
TransactionSignedNoHash, TxEip1559, TxEip2930, TxEip4844, TxLegacy, TxType, EIP1559_TX_TYPE_ID,
|
||||
EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID,
|
||||
FromRecoveredPooledTransaction, FromRecoveredTransaction, IntoRecoveredTransaction,
|
||||
InvalidTransactionError, PooledTransactionsElement, PooledTransactionsElementEcRecovered,
|
||||
Signature, Transaction, TransactionKind, TransactionMeta, TransactionSigned,
|
||||
TransactionSignedEcRecovered, TransactionSignedNoHash, TxEip1559, TxEip2930, TxEip4844,
|
||||
TxLegacy, TxType, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID,
|
||||
LEGACY_TX_TYPE_ID,
|
||||
};
|
||||
pub use withdrawal::Withdrawal;
|
||||
|
||||
|
||||
@ -1089,6 +1089,16 @@ impl FromRecoveredTransaction for TransactionSignedEcRecovered {
|
||||
}
|
||||
}
|
||||
|
||||
/// A transaction type that can be created from a [`PooledTransactionsElementEcRecovered`]
|
||||
/// transaction.
|
||||
///
|
||||
/// This is a conversion trait that'll ensure transactions received via P2P can be converted to the
|
||||
/// transaction type that the transaction pool uses.
|
||||
pub trait FromRecoveredPooledTransaction {
|
||||
/// Converts to this type from the given [`PooledTransactionsElementEcRecovered`].
|
||||
fn from_recovered_transaction(tx: PooledTransactionsElementEcRecovered) -> Self;
|
||||
}
|
||||
|
||||
/// The inverse of [`FromRecoveredTransaction`] that ensure the transaction can be sent over the
|
||||
/// network
|
||||
pub trait IntoRecoveredTransaction {
|
||||
|
||||
@ -373,6 +373,12 @@ impl PooledTransactionsElementEcRecovered {
|
||||
self.transaction
|
||||
}
|
||||
|
||||
/// Transform back to [`PooledTransactionsElement`]
|
||||
pub fn into_ecrecovered_transaction(self) -> TransactionSignedEcRecovered {
|
||||
let (tx, signer) = self.into_components();
|
||||
tx.into_ecrecovered_transaction(signer)
|
||||
}
|
||||
|
||||
/// Desolve Self to its component
|
||||
pub fn into_components(self) -> (PooledTransactionsElement, Address) {
|
||||
(self.transaction, self.signer)
|
||||
|
||||
Reference in New Issue
Block a user