Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce trait for OpTransaction #11736

Open
Tracked by #11239
mattsse opened this issue Oct 15, 2024 · 1 comment · May be fixed by #11745
Open
Tracked by #11239

Introduce trait for OpTransaction #11736

mattsse opened this issue Oct 15, 2024 · 1 comment · May be fixed by #11745
Assignees
Labels
A-sdk Related to reth's use as a library C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started

Comments

@mattsse
Copy link
Collaborator

mattsse commented Oct 15, 2024

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

@mattsse mattsse added C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started A-sdk Related to reth's use as a library labels Oct 15, 2024
@hoank101
Copy link

hi @mattsse Can i work on this?

github-merge-queue bot pushed a commit to alloy-rs/op-alloy that referenced this issue Oct 15, 2024
This PR will help this issue
paradigmxyz/reth#11736
 converted into a trait from reth to alloy-rs
<!--
Thank you for your Pull Request. Please provide a description above and
review
the requirements below.

Bug fixes and new features should include tests.

Contributors guide:
https://github.com/alloy-rs/core/blob/main/CONTRIBUTING.md

The contributors guide includes instructions for running rustfmt and
building the
documentation.
-->

<!-- ** Please select "Allow edits from maintainers" in the PR Options
** -->

## Motivation

<!--
Explain the context and why you're making that change. What is the
problem
you're trying to solve? In some cases there is not a problem and this
can be
thought of as being the motivation for your change.
-->

## Solution

<!--
Summarize the solution and provide any necessary context needed to
understand
the code change.
-->

## PR Checklist

- [x] Added Tests
- [x] Added Documentation
- [ ] Breaking changes

---------

Co-authored-by: refcell <abigger87@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sdk Related to reth's use as a library C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

2 participants