mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add receipt builder for OpExecutionStrategy (#13792)
This commit is contained in:
@ -18,7 +18,7 @@ use reth_primitives_traits::Block;
|
||||
pub use transaction::{signed::OpTransactionSigned, tx_type::OpTxType};
|
||||
|
||||
mod receipt;
|
||||
pub use receipt::OpReceipt;
|
||||
pub use receipt::{DepositReceipt, OpReceipt};
|
||||
|
||||
/// Optimism-specific block type.
|
||||
pub type OpBlock = alloy_consensus::Block<OpTransactionSigned>;
|
||||
|
||||
@ -211,6 +211,21 @@ impl InMemorySize for OpReceipt {
|
||||
|
||||
impl reth_primitives_traits::Receipt for OpReceipt {}
|
||||
|
||||
/// Trait for deposit receipt.
|
||||
pub trait DepositReceipt: reth_primitives_traits::Receipt {
|
||||
/// Returns deposit receipt if it is a deposit transaction.
|
||||
fn as_deposit_receipt_mut(&mut self) -> Option<&mut OpDepositReceipt>;
|
||||
}
|
||||
|
||||
impl DepositReceipt for OpReceipt {
|
||||
fn as_deposit_receipt_mut(&mut self) -> Option<&mut OpDepositReceipt> {
|
||||
match self {
|
||||
Self::Deposit(receipt) => Some(receipt),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "reth-codec")]
|
||||
mod compact {
|
||||
use super::*;
|
||||
|
||||
@ -22,7 +22,7 @@ use core::{
|
||||
use derive_more::{AsRef, Deref};
|
||||
#[cfg(not(feature = "std"))]
|
||||
use once_cell::sync::OnceCell as OnceLock;
|
||||
use op_alloy_consensus::{OpPooledTransaction, OpTypedTransaction, TxDeposit};
|
||||
use op_alloy_consensus::{DepositTransaction, OpPooledTransaction, OpTypedTransaction, TxDeposit};
|
||||
#[cfg(any(test, feature = "reth-codec"))]
|
||||
use proptest as _;
|
||||
use reth_primitives_traits::{
|
||||
@ -601,6 +601,30 @@ impl TryFrom<OpTransactionSigned> for OpPooledTransaction {
|
||||
}
|
||||
}
|
||||
|
||||
impl DepositTransaction for OpTransactionSigned {
|
||||
fn source_hash(&self) -> Option<B256> {
|
||||
match &self.transaction {
|
||||
OpTypedTransaction::Deposit(tx) => Some(tx.source_hash),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn mint(&self) -> Option<u128> {
|
||||
match &self.transaction {
|
||||
OpTypedTransaction::Deposit(tx) => tx.mint,
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_system_transaction(&self) -> bool {
|
||||
self.is_deposit()
|
||||
}
|
||||
|
||||
fn is_deposit(&self) -> bool {
|
||||
self.is_deposit()
|
||||
}
|
||||
}
|
||||
|
||||
/// Bincode-compatible transaction type serde implementations.
|
||||
#[cfg(feature = "serde-bincode-compat")]
|
||||
pub mod serde_bincode_compat {
|
||||
|
||||
Reference in New Issue
Block a user