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

chore(sdk): improve usability TxType trait #12548

Merged
merged 1 commit into from
Nov 15, 2024
Merged

chore(sdk): improve usability TxType trait #12548

merged 1 commit into from
Nov 15, 2024

Conversation

emhane
Copy link
Member

@emhane emhane commented Nov 14, 2024

Ref #12454

@emhane emhane added C-debt Refactor of code section that is hard to understand or maintain A-sdk Related to reth's use as a library labels Nov 14, 2024
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense.

though I think these functions should ideally be decoupled from type because the are also useful on the tx itself

Comment on lines +33 to +46
/// Returns `true` if this is a legacy transaction.
fn is_legacy(&self) -> bool;

impl<T> TxType for T where
T: Send
+ Sync
+ Unpin
+ Clone
+ Copy
+ Default
+ fmt::Debug
+ fmt::Display
+ PartialEq
+ Eq
+ PartialEq<u8>
+ Into<u8>
+ Into<U8>
+ TryFrom<u8, Error: fmt::Debug>
+ TryFrom<u64, Error: fmt::Debug>
+ TryFrom<U64>
+ alloy_rlp::Encodable
+ alloy_rlp::Decodable
{
/// Returns `true` if this is an eip-2930 transaction.
fn is_eip2930(&self) -> bool;

/// Returns `true` if this is an eip-1559 transaction.
fn is_eip1559(&self) -> bool;

/// Returns `true` if this is an eip-4844 transaction.
fn is_eip4844(&self) -> bool;

/// Returns `true` if this is an eip-7702 transaction.
fn is_eip7702(&self) -> bool;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually not sure if we call these on the txtype itself, we def call them on the tx.
so I assume we could upstream these to alloy, probably as a standalone new trait

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have match statements on TxType, which these would replace. Agree that they should be added to the tx trait too, along with the useful as_eipX -> Option<&tx> methods

@emhane emhane added this pull request to the merge queue Nov 15, 2024
Merged via the queue into main with commit 5f66fa4 Nov 15, 2024
42 checks passed
@emhane emhane deleted the emhane/tx-type branch November 15, 2024 13:46
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-debt Refactor of code section that is hard to understand or maintain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants