mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add utility trait methods to Transaction (#12704)
This commit is contained in:
@ -7,6 +7,11 @@ pub mod tx_type;
|
||||
use crate::{InMemorySize, MaybeArbitrary, MaybeCompact, MaybeSerde};
|
||||
use core::{fmt, hash::Hash};
|
||||
|
||||
use alloy_consensus::constants::{
|
||||
EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID,
|
||||
LEGACY_TX_TYPE_ID,
|
||||
};
|
||||
|
||||
/// Helper trait that unifies all behaviour required by transaction to support full node operations.
|
||||
pub trait FullTransaction: Transaction + MaybeCompact {}
|
||||
|
||||
@ -27,6 +32,35 @@ pub trait Transaction:
|
||||
+ MaybeSerde
|
||||
+ MaybeArbitrary
|
||||
{
|
||||
/// Returns true if the transaction is a legacy transaction.
|
||||
#[inline]
|
||||
fn is_legacy(&self) -> bool {
|
||||
self.ty() == LEGACY_TX_TYPE_ID
|
||||
}
|
||||
|
||||
/// Returns true if the transaction is an EIP-2930 transaction.
|
||||
#[inline]
|
||||
fn is_eip2930(&self) -> bool {
|
||||
self.ty() == EIP2930_TX_TYPE_ID
|
||||
}
|
||||
|
||||
/// Returns true if the transaction is an EIP-1559 transaction.
|
||||
#[inline]
|
||||
fn is_eip1559(&self) -> bool {
|
||||
self.ty() == EIP1559_TX_TYPE_ID
|
||||
}
|
||||
|
||||
/// Returns true if the transaction is an EIP-4844 transaction.
|
||||
#[inline]
|
||||
fn is_eip4844(&self) -> bool {
|
||||
self.ty() == EIP4844_TX_TYPE_ID
|
||||
}
|
||||
|
||||
/// Returns true if the transaction is an EIP-7702 transaction.
|
||||
#[inline]
|
||||
fn is_eip7702(&self) -> bool {
|
||||
self.ty() == EIP7702_TX_TYPE_ID
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Transaction for T where
|
||||
|
||||
Reference in New Issue
Block a user