Skip to content

Introduce trait for OpTransaction #11736

@mattsse

Description

@mattsse

we have extra helpers for deposit functions:

/// Returns the source hash of the transaction, which uniquely identifies its source.
/// If not a deposit transaction, this will always return `None`.
#[cfg(feature = "optimism")]
pub const fn source_hash(&self) -> Option<B256> {
match self {
Self::Deposit(TxDeposit { source_hash, .. }) => Some(*source_hash),
_ => None,
}
}
/// Returns the amount of ETH locked up on L1 that will be minted on L2. If the transaction
/// is not a deposit transaction, this will always return `None`.
#[cfg(feature = "optimism")]
pub const fn mint(&self) -> Option<u128> {
match self {
Self::Deposit(TxDeposit { mint, .. }) => *mint,
_ => None,
}
}
/// Returns whether or not the transaction is a system transaction. If the transaction
/// is not a deposit transaction, this will always return `false`.
#[cfg(feature = "optimism")]
pub const fn is_system_transaction(&self) -> bool {
match self {
Self::Deposit(TxDeposit { is_system_transaction, .. }) => *is_system_transaction,
_ => false,
}
}
/// Returns whether or not the transaction is an Optimism Deposited transaction.
#[cfg(feature = "optimism")]
pub const fn is_deposit(&self) -> bool {
matches!(self, Self::Deposit(_))
}

these should be converted into a trait on https://github.com/alloy-rs/op-alloy and implemented on

https://github.com/alloy-rs/op-alloy/blob/56f636e8f624164fdea9c5356ee59b40af8f5e9d/crates/consensus/src/transaction/deposit.rs#L15-L15

Metadata

Metadata

Assignees

Labels

A-sdkRelated to reth's use as a libraryC-enhancementNew feature or requestD-good-first-issueNice and easy! A great choice to get started

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions