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

feat: add helper to eip155 variant #774

Closed
wants to merge 1 commit into from

Conversation

mattsse
Copy link
Member

@mattsse mattsse commented Oct 17, 2024

sometimes we need special checks for 155 or need to know if it is 155

adds two helpers for this

ref https://github.com/bluealloy/revm/pull/1824/files

/// Applies a check to the [`Parity::Eip155`] v value if this instance is a [`Parity::Eip155`].
///
/// Returns [`Ok`] if the instance is not [`Parity::Eip155`]
pub fn ensure_eip155<F, E>(&self, f: F) -> Result<(), E>
Copy link
Member

Choose a reason for hiding this comment

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

This is too specific, doesn't make sense to have as a method, is_ and as_ are enough

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm this would make things like:

            // Check y_parity
            if let Parity::Eip155(parity) = auth.signature().v() {
                if parity > u8::MAX as u64 {
                    return Err(InvalidAuthorization::InvalidYParity);
                }
            }
            Ok(())

slightly easier imo

Copy link
Member

Choose a reason for hiding this comment

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

the same is achievable with as_eip().is_some_and(), again this is too specific

Copy link
Member Author

Choose a reason for hiding this comment

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

still think this is nice to have and doesn't hurt really, but closing because can be solved with some extra calls as well

@mattsse mattsse closed this Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants