Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants