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: impl From<Eip2718Error> for alloy_rlp::Error #1359

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions crates/consensus/src/transaction/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,7 @@ impl Encodable for TxEnvelope {

impl Decodable for TxEnvelope {
fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> {
match Self::network_decode(buf) {
Ok(t) => Ok(t),
Err(Eip2718Error::RlpError(e)) => Err(e),
Err(Eip2718Error::UnexpectedType(_)) => {
Err(alloy_rlp::Error::Custom("unexpected tx type"))
}
_ => Err(alloy_rlp::Error::Custom("unknown error decoding tx envelope")),
}
Ok(Self::network_decode(buf)?)
}
}

Expand Down
9 changes: 9 additions & 0 deletions crates/eips/src/eip2718.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ impl From<alloy_rlp::Error> for Eip2718Error {
}
}

impl From<Eip2718Error> for alloy_rlp::Error {
fn from(err: Eip2718Error) -> Self {
match err {
Eip2718Error::RlpError(err) => err,
Eip2718Error::UnexpectedType(_) => alloy_rlp::Error::Custom("Unexpected type flag"),
}
}
}

#[cfg(feature = "std")]
impl std::error::Error for Eip2718Error {}
Comment on lines 57 to 58
Copy link
Member

Choose a reason for hiding this comment

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

unrelated: this lacks fn source which should return the wrapped rlperr

mind fixing this in a separate pr quickly?


Expand Down
Loading