Skip to content

Commit

Permalink
feat(abi): add human readable tokenizer and parser (gakonst#1234)
Browse files Browse the repository at this point in the history
* feat(abi): add human readable tokenizer and parser

* feat(abi): support nested tuples
  • Loading branch information
mattsse authored May 9, 2022
1 parent dc199f3 commit 790550c
Show file tree
Hide file tree
Showing 6 changed files with 862 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ethers-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ thiserror = { version = "1.0.31", default-features = false }
bytes = { version = "1.1.0", features = ["serde"] }
hex = { version = "0.4.3", default-features = false, features = ["std"] }
once_cell = { version = "1.10.0", optional = true }
unicode-xid = "0.2.2"

# macros feature enabled dependencies
cargo_metadata = { version = "0.14.2", optional = true }
Expand Down
10 changes: 7 additions & 3 deletions ethers-core/src/abi/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Boilerplate error definitions.
use crate::abi::InvalidOutputType;
use crate::abi::{human_readable, InvalidOutputType};
use thiserror::Error;

/// A type alias for std's Result with the Error as our error type.
Expand All @@ -10,8 +10,12 @@ pub type Result<T, E = ParseError> = std::result::Result<T, E>;
pub enum ParseError {
#[error("{0}")]
Message(String),
// ethabi parser error
#[error(transparent)]
ParseError(#[from] super::Error),
ParseError(#[from] ethabi::Error),
// errors from human readable lexer
#[error(transparent)]
LexerError(#[from] human_readable::lexer::LexerError),
}

macro_rules! _format_err {
Expand All @@ -32,7 +36,7 @@ pub(crate) use _bail as bail;
pub enum AbiError {
/// Thrown when the ABI decoding fails
#[error(transparent)]
DecodingError(#[from] crate::abi::Error),
DecodingError(#[from] ethabi::Error),

/// Thrown when detokenizing an argument
#[error(transparent)]
Expand Down
Loading

0 comments on commit 790550c

Please sign in to comment.