mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(sdk): improve usability TxType trait (#12548)
This commit is contained in:
@ -19,3 +19,4 @@ alloy-eips.workspace = true
|
||||
alloy-rlp.workspace = true
|
||||
derive_more.workspace = true
|
||||
bytes.workspace = true
|
||||
reth-primitives-traits.workspace = true
|
||||
@ -8,4 +8,4 @@
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
|
||||
pub mod bedrock;
|
||||
pub mod op_tx_type;
|
||||
pub mod tx_type;
|
||||
|
||||
@ -2,22 +2,51 @@
|
||||
//! `OpTxType` implements `reth_primitives_traits::TxType`.
|
||||
//! This type is required because a `Compact` impl is needed on the deposit tx type.
|
||||
|
||||
use core::fmt::Debug;
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use alloy_primitives::{U64, U8};
|
||||
use alloy_rlp::{Decodable, Encodable, Error};
|
||||
use bytes::BufMut;
|
||||
use core::fmt::Debug;
|
||||
use derive_more::{
|
||||
derive::{From, Into},
|
||||
Display,
|
||||
};
|
||||
use op_alloy_consensus::OpTxType as AlloyOpTxType;
|
||||
use std::convert::TryFrom;
|
||||
use reth_primitives_traits::TxType;
|
||||
|
||||
/// Wrapper type for `AlloyOpTxType` to implement `TxType` trait.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Display, Ord, Hash, From, Into)]
|
||||
#[into(u8)]
|
||||
pub struct OpTxType(AlloyOpTxType);
|
||||
|
||||
impl TxType for OpTxType {
|
||||
#[inline]
|
||||
fn is_legacy(&self) -> bool {
|
||||
matches!(self.0, AlloyOpTxType::Legacy)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_eip2930(&self) -> bool {
|
||||
matches!(self.0, AlloyOpTxType::Eip2930)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_eip1559(&self) -> bool {
|
||||
matches!(self.0, AlloyOpTxType::Eip1559)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_eip4844(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_eip7702(&self) -> bool {
|
||||
matches!(self.0, AlloyOpTxType::Eip7702)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<OpTxType> for U8 {
|
||||
fn from(tx_type: OpTxType) -> Self {
|
||||
Self::from(u8::from(tx_type))
|
||||
Reference in New Issue
Block a user