mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: integrate OpPrimitives (#13556)
This commit is contained in:
@ -14,25 +14,27 @@ extern crate alloc;
|
||||
pub mod bedrock;
|
||||
pub mod transaction;
|
||||
|
||||
use reth_primitives_traits::Block;
|
||||
pub use transaction::{signed::OpTransactionSigned, tx_type::OpTxType};
|
||||
|
||||
mod receipt;
|
||||
pub use receipt::OpReceipt;
|
||||
|
||||
/// Optimism primitive types.
|
||||
pub type OpPrimitives = reth_primitives::EthPrimitives;
|
||||
/// Optimism-specific block type.
|
||||
pub type OpBlock = reth_primitives::Block<OpTransactionSigned>;
|
||||
|
||||
// TODO: once we are ready for separating primitive types, introduce a separate `NodePrimitives`
|
||||
// implementation used exclusively by legacy engine.
|
||||
//
|
||||
// #[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||
// pub struct OpPrimitives;
|
||||
//
|
||||
// impl NodePrimitives for OpPrimitives {
|
||||
// type Block = Block;
|
||||
// type BlockHeader = Header;
|
||||
// type BlockBody = BlockBody;
|
||||
// type SignedTx = TransactionSigned;
|
||||
// type TxType = OpTxType;
|
||||
// type Receipt = Receipt;
|
||||
// }
|
||||
/// Optimism-specific block body type.
|
||||
pub type OpBlockBody = <OpBlock as Block>::Body;
|
||||
|
||||
/// Primitive types for Optimism Node.
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||
pub struct OpPrimitives;
|
||||
|
||||
#[cfg(feature = "optimism")]
|
||||
impl reth_primitives::NodePrimitives for OpPrimitives {
|
||||
type Block = OpBlock;
|
||||
type BlockHeader = alloy_consensus::Header;
|
||||
type BlockBody = OpBlockBody;
|
||||
type SignedTx = OpTransactionSigned;
|
||||
type Receipt = OpReceipt;
|
||||
}
|
||||
|
||||
@ -66,6 +66,11 @@ impl OpTransactionSigned {
|
||||
pub fn new_unhashed(transaction: OpTypedTransaction, signature: Signature) -> Self {
|
||||
Self { hash: Default::default(), signature, transaction }
|
||||
}
|
||||
|
||||
/// Returns whether this transaction is a deposit.
|
||||
pub const fn is_deposit(&self) -> bool {
|
||||
matches!(self.transaction, OpTypedTransaction::Deposit(_))
|
||||
}
|
||||
}
|
||||
|
||||
impl SignedTransaction for OpTransactionSigned {
|
||||
|
||||
Reference in New Issue
Block a user