mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(sdk): add NodePrimitives::TxType (#12332)
This commit is contained in:
@ -25,7 +25,7 @@ use reth_node_builder::{
|
||||
BuilderContext, Node, NodeAdapter, NodeComponentsBuilder, PayloadBuilderConfig, PayloadTypes,
|
||||
};
|
||||
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
|
||||
use reth_primitives::{Block, Header, Receipt, TransactionSigned};
|
||||
use reth_primitives::{Block, Header, Receipt, TransactionSigned, TxType};
|
||||
use reth_provider::CanonStateSubscriptions;
|
||||
use reth_rpc::EthApi;
|
||||
use reth_tracing::tracing::{debug, info};
|
||||
@ -44,6 +44,7 @@ pub struct EthPrimitives;
|
||||
impl NodePrimitives for EthPrimitives {
|
||||
type Block = Block;
|
||||
type SignedTx = TransactionSigned;
|
||||
type TxType = TxType;
|
||||
type Receipt = Receipt;
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ use reth_optimism_evm::{OpEvmConfig, OpExecutionStrategyFactory};
|
||||
use reth_optimism_payload_builder::builder::OpPayloadTransactions;
|
||||
use reth_optimism_rpc::OpEthApi;
|
||||
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService, PayloadStore};
|
||||
use reth_primitives::{Block, Header, Receipt, TransactionSigned};
|
||||
use reth_primitives::{Block, Header, Receipt, TransactionSigned, TxType};
|
||||
use reth_provider::CanonStateSubscriptions;
|
||||
use reth_tracing::tracing::{debug, info};
|
||||
use reth_transaction_pool::{
|
||||
@ -47,6 +47,7 @@ pub struct OpPrimitives;
|
||||
impl NodePrimitives for OpPrimitives {
|
||||
type Block = Block;
|
||||
type SignedTx = TransactionSigned;
|
||||
type TxType = TxType;
|
||||
type Receipt = Receipt;
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ pub use storage::StorageEntry;
|
||||
|
||||
/// Transaction types
|
||||
pub mod tx_type;
|
||||
pub use tx_type::TxType;
|
||||
pub use tx_type::{FullTxType, TxType};
|
||||
|
||||
/// Common header types
|
||||
pub mod header;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use core::fmt;
|
||||
|
||||
use crate::{BlockBody, FullBlock, FullReceipt, FullSignedTx};
|
||||
use crate::{BlockBody, FullBlock, FullReceipt, FullSignedTx, FullTxType};
|
||||
|
||||
/// Configures all the primitive types of the node.
|
||||
pub trait NodePrimitives: Send + Sync + Unpin + Clone + Default + fmt::Debug {
|
||||
@ -8,6 +8,8 @@ pub trait NodePrimitives: Send + Sync + Unpin + Clone + Default + fmt::Debug {
|
||||
type Block: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static;
|
||||
/// Signed version of the transaction type.
|
||||
type SignedTx: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static;
|
||||
/// Transaction envelope type ID.
|
||||
type TxType: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static;
|
||||
/// A receipt.
|
||||
type Receipt: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static;
|
||||
}
|
||||
@ -15,6 +17,7 @@ pub trait NodePrimitives: Send + Sync + Unpin + Clone + Default + fmt::Debug {
|
||||
impl NodePrimitives for () {
|
||||
type Block = ();
|
||||
type SignedTx = ();
|
||||
type TxType = ();
|
||||
type Receipt = ();
|
||||
}
|
||||
|
||||
@ -24,15 +27,18 @@ pub trait FullNodePrimitives: Send + Sync + Unpin + Clone + Default + fmt::Debug
|
||||
type Block: FullBlock<Body: BlockBody<SignedTransaction = Self::SignedTx>>;
|
||||
/// Signed version of the transaction type.
|
||||
type SignedTx: FullSignedTx;
|
||||
/// Transaction envelope type ID.
|
||||
type TxType: FullTxType;
|
||||
/// A receipt.
|
||||
type Receipt: FullReceipt;
|
||||
}
|
||||
|
||||
impl<T> NodePrimitives for T
|
||||
where
|
||||
T: FullNodePrimitives<Block: 'static, SignedTx: 'static, Receipt: 'static>,
|
||||
T: FullNodePrimitives<Block: 'static, SignedTx: 'static, Receipt: 'static, TxType: 'static>,
|
||||
{
|
||||
type Block = T::Block;
|
||||
type SignedTx = T::SignedTx;
|
||||
type TxType = T::TxType;
|
||||
type Receipt = T::Receipt;
|
||||
}
|
||||
|
||||
@ -3,6 +3,13 @@ use core::fmt;
|
||||
use alloy_eips::eip2718::Eip2718Error;
|
||||
use alloy_primitives::{U64, U8};
|
||||
use alloy_rlp::{Decodable, Encodable};
|
||||
use reth_codecs::Compact;
|
||||
|
||||
/// Helper trait that unifies all behaviour required by transaction type ID to support full node
|
||||
/// operations.
|
||||
pub trait FullTxType: TxType + Compact {}
|
||||
|
||||
impl<T> FullTxType for T where T: TxType + Compact {}
|
||||
|
||||
/// Trait representing the behavior of a transaction type.
|
||||
pub trait TxType:
|
||||
|
||||
Reference in New Issue
Block a user