-
Notifications
You must be signed in to change notification settings - Fork 794
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