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(core): more type parsing #2095
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.
lgtm
impl FromStr for NameOrAddress { | ||
type Err = Infallible; | ||
type Err = <Address as FromStr>::Err; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
Ok(Self::Name(s.to_string())) | ||
if s.starts_with("0x") { | ||
s.parse().map(Self::Address) | ||
} else { | ||
Ok(Self::Name(s.to_string())) | ||
} | ||
} |
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 a great change
n => { | ||
if let Ok(n) = n.parse::<U64>() { | ||
Ok(Self::Number(n)) | ||
} else if let Ok(n) = n.parse::<u64>() { | ||
Ok(Self::Number(n.into())) |
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 no longer compliant with the rpc spec for block number, but I guess this is fine?
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.
Fine w/ me. More flexibility, and people create BlockNumber
themselves, vs always parsing it out from the hex returned from RPC
n => { | ||
if let Ok(n) = n.parse::<U64>() { | ||
Ok(Self::Number(n)) | ||
} else if let Ok(n) = n.parse::<u64>() { | ||
Ok(Self::Number(n.into())) |
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.
Fine w/ me. More flexibility, and people create BlockNumber
themselves, vs always parsing it out from the hex returned from RPC
Motivation
Upstreaming from foundry-cli/cast helper parsers
Solution
PR Checklist