reth_primitives_traits/transaction/mod.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
//! Transaction abstraction
pub mod signed;
use core::{fmt, hash::Hash};
use alloy_primitives::B256;
use reth_codecs::Compact;
use serde::{Deserialize, Serialize};
use crate::{FullTxType, InMemorySize, MaybeArbitrary, TxType};
/// Helper trait that unifies all behaviour required by transaction to support full node operations.
pub trait FullTransaction: Transaction<Type: FullTxType> + Compact {}
impl<T> FullTransaction for T where T: Transaction<Type: FullTxType> + Compact {}
/// Abstraction of a transaction.
pub trait Transaction:
Send
+ Sync
+ Unpin
+ Clone
+ Default
+ fmt::Debug
+ Eq
+ PartialEq
+ Hash
+ Serialize
+ for<'de> Deserialize<'de>
+ TransactionExt
+ InMemorySize
+ MaybeArbitrary
{
}
impl<T> Transaction for T where
T: Send
+ Sync
+ Unpin
+ Clone
+ Default
+ fmt::Debug
+ Eq
+ PartialEq
+ Hash
+ Serialize
+ for<'de> Deserialize<'de>
+ TransactionExt
+ InMemorySize
+ MaybeArbitrary
{
}
/// Extension trait of [`alloy_consensus::Transaction`].
pub trait TransactionExt: alloy_consensus::Transaction {
/// Transaction envelope type ID.
type Type: TxType;
/// Heavy operation that return signature hash over rlp encoded transaction.
/// It is only for signature signing or signer recovery.
fn signature_hash(&self) -> B256;
/// Returns the transaction type.
fn tx_type(&self) -> Self::Type {
Self::Type::try_from(self.ty()).expect("should decode tx type id")
}
}