mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 00:58:11 -05:00
chore: add tx type constants (#1639)
Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
This commit is contained in:
@@ -61,7 +61,7 @@ pub use storage::{StorageEntry, StorageTrieEntry};
|
||||
pub use transaction::{
|
||||
AccessList, AccessListItem, FromRecoveredTransaction, IntoRecoveredTransaction, Signature,
|
||||
Transaction, TransactionKind, TransactionSigned, TransactionSignedEcRecovered, TxEip1559,
|
||||
TxEip2930, TxLegacy, TxType,
|
||||
TxEip2930, TxLegacy, TxType, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, LEGACY_TX_TYPE_ID,
|
||||
};
|
||||
pub use withdrawal::Withdrawal;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use reth_rlp::{
|
||||
length_of_length, Decodable, DecodeError, Encodable, Header, EMPTY_LIST_CODE, EMPTY_STRING_CODE,
|
||||
};
|
||||
pub use signature::Signature;
|
||||
pub use tx_type::TxType;
|
||||
pub use tx_type::{TxType, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, LEGACY_TX_TYPE_ID};
|
||||
|
||||
mod access_list;
|
||||
mod signature;
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
use reth_codecs::{derive_arbitrary, Compact};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Identifier for legacy transaction, however [TxLegacy](crate::TxLegacy) this is technically not
|
||||
/// typed.
|
||||
pub const LEGACY_TX_TYPE_ID: u8 = 0;
|
||||
|
||||
/// Identifier for [TxEip2930](crate::TxEip2930) transaction.
|
||||
pub const EIP2930_TX_TYPE_ID: u8 = 1;
|
||||
|
||||
/// Identifier for [TxEip1559](crate::TxEip1559) transaction.
|
||||
pub const EIP1559_TX_TYPE_ID: u8 = 2;
|
||||
|
||||
/// Transaction Type
|
||||
#[derive_arbitrary(compact)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Default, Serialize, Deserialize)]
|
||||
@@ -17,9 +27,9 @@ pub enum TxType {
|
||||
impl From<TxType> for u8 {
|
||||
fn from(value: TxType) -> Self {
|
||||
match value {
|
||||
TxType::Legacy => 0,
|
||||
TxType::EIP2930 => 1,
|
||||
TxType::EIP1559 => 2,
|
||||
TxType::Legacy => LEGACY_TX_TYPE_ID,
|
||||
TxType::EIP2930 => EIP2930_TX_TYPE_ID,
|
||||
TxType::EIP1559 => EIP1559_TX_TYPE_ID,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user