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(core): more type parsing #2095

Merged
merged 3 commits into from Jan 31, 2023
Merged

Conversation

DaniPopes
Copy link
Collaborator

Motivation

Upstreaming from foundry-cli/cast helper parsers

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Updated the changelog
  • Breaking changes

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

Comment on lines 102 to 111
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()))
}
}
Copy link
Collaborator

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

Comment on lines +648 to +652
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()))
Copy link
Collaborator

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?

Copy link
Owner

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

Comment on lines +648 to +652
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()))
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants