mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: add is_broadcastable_in_full to txtype (#12739)
This commit is contained in:
@ -49,4 +49,14 @@ pub trait TxType:
|
||||
|
||||
/// Returns `true` if this is an eip-7702 transaction.
|
||||
fn is_eip7702(&self) -> bool;
|
||||
|
||||
/// Returns whether this transaction type can be __broadcasted__ as full transaction over the
|
||||
/// network.
|
||||
///
|
||||
/// Some transactions are not broadcastable as objects and only allowed to be broadcasted as
|
||||
/// hashes, e.g. because they missing context (e.g. blob sidecar).
|
||||
fn is_broadcastable_in_full(&self) -> bool {
|
||||
// EIP-4844 transactions are not broadcastable in full, only hashes are allowed.
|
||||
!self.is_eip4844()
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,8 +257,16 @@ mod tests {
|
||||
use super::*;
|
||||
use alloy_primitives::hex;
|
||||
use reth_codecs::{txtype::*, Compact};
|
||||
use reth_primitives_traits::TxType as _;
|
||||
use rstest::rstest;
|
||||
|
||||
#[test]
|
||||
fn is_broadcastable() {
|
||||
assert!(TxType::Legacy.is_broadcastable_in_full());
|
||||
assert!(TxType::Eip1559.is_broadcastable_in_full());
|
||||
assert!(!TxType::Eip4844.is_broadcastable_in_full());
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case(U64::from(LEGACY_TX_TYPE_ID), Ok(TxType::Legacy))]
|
||||
#[case(U64::from(EIP2930_TX_TYPE_ID), Ok(TxType::Eip2930))]
|
||||
|
||||
Reference in New Issue
Block a user