mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: EthApi traits abstraction (#13170)
This commit is contained in:
@ -447,31 +447,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<H, B> reth_primitives_traits::Block for SealedBlock<H, B>
|
||||
where
|
||||
H: reth_primitives_traits::BlockHeader,
|
||||
B: reth_primitives_traits::BlockBody<OmmerHeader = H>,
|
||||
{
|
||||
type Header = H;
|
||||
type Body = B;
|
||||
|
||||
fn new(header: Self::Header, body: Self::Body) -> Self {
|
||||
Self { header: SealedHeader::seal(header), body }
|
||||
}
|
||||
|
||||
fn header(&self) -> &Self::Header {
|
||||
self.header.header()
|
||||
}
|
||||
|
||||
fn body(&self) -> &Self::Body {
|
||||
&self.body
|
||||
}
|
||||
|
||||
fn split(self) -> (Self::Header, Self::Body) {
|
||||
(self.header.unseal(), self.body)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "arbitrary"))]
|
||||
impl<'a, H, B> arbitrary::Arbitrary<'a> for SealedBlock<H, B>
|
||||
where
|
||||
@ -1022,7 +997,6 @@ mod tests {
|
||||
const fn _traits() {
|
||||
const fn assert_block<T: reth_primitives_traits::Block>() {}
|
||||
assert_block::<Block>();
|
||||
assert_block::<SealedBlock>();
|
||||
}
|
||||
|
||||
/// Check parsing according to EIP-1898.
|
||||
|
||||
@ -1506,6 +1506,11 @@ impl<T> RecoveredTx<T> {
|
||||
pub const fn from_signed_transaction(signed_transaction: T, signer: Address) -> Self {
|
||||
Self { signed_transaction, signer }
|
||||
}
|
||||
|
||||
/// Applies the given closure to the inner transactions.
|
||||
pub fn map_transaction<Tx>(self, f: impl FnOnce(T) -> Tx) -> RecoveredTx<Tx> {
|
||||
RecoveredTx::from_signed_transaction(f(self.signed_transaction), self.signer)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Encodable> Encodable for RecoveredTx<T> {
|
||||
|
||||
@ -654,6 +654,18 @@ impl TryFrom<TransactionSigned> for PooledTransactionsElement {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PooledTransactionsElement> for TransactionSigned {
|
||||
fn from(element: PooledTransactionsElement) -> Self {
|
||||
match element {
|
||||
PooledTransactionsElement::Legacy(tx) => tx.into(),
|
||||
PooledTransactionsElement::Eip2930(tx) => tx.into(),
|
||||
PooledTransactionsElement::Eip1559(tx) => tx.into(),
|
||||
PooledTransactionsElement::Eip7702(tx) => tx.into(),
|
||||
PooledTransactionsElement::BlobTransaction(blob_tx) => blob_tx.into_parts().0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "arbitrary"))]
|
||||
impl<'a> arbitrary::Arbitrary<'a> for PooledTransactionsElement {
|
||||
/// Generates an arbitrary `PooledTransactionsElement`.
|
||||
|
||||
Reference in New Issue
Block a user