-
Notifications
You must be signed in to change notification settings - Fork 151
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(dyn-abi): DynSolType::coerce_str
#380
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amazing work!
it's been a while since I read some nom code but I still love how readable this is.
test coverage looks decent.
this will simplify so much
// TODO: escapes? | ||
let min = if has_delim { 0 } else { 1 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, good question, maybe this could happen with same escaped json inputs, but I think we can ignore that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super readable! This is gonna be super handy—love it
crates/dyn-abi/src/coerce.rs
Outdated
fn uint_units(input: &mut &str) -> PResult<usize> { | ||
alpha0(input).and_then(|s| { | ||
Ok(match s { | ||
"ether" => 18, | ||
"gwei" | "nano" | "nanoether" => 9, | ||
"" | "wei" => 0, | ||
_ => return Err(ErrMode::from_error_kind(input, ErrorKind::Fail)), | ||
}) | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super handy, lets us replace a few utilities we have in foundry
wdyt about adding more units?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have anything in mind? Solidity only supports wei
, gwei
, and ether
|
||
assert_eq!( | ||
DynSolType::Uint(256) | ||
.coerce_str("0.000000000000000001ether") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have documentation of all the formats supported?
Added in 0e974a1 @prestwich |
perfection |
Motivation
Port of
ethabi::Tokenizer
, with extra featuresSolution
PR Checklist