Skip to content

feat: impl FromStr for chain constants #54

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

Merged
merged 3 commits into from
May 21, 2025
Merged

Conversation

anna-carroll
Copy link
Contributor

@anna-carroll anna-carroll commented May 20, 2025

in service of implementing FromEnvVar in bin-base using impl_for_parseable! macro

Implemented for all types with pecorino()/test() instantiations, except purposefully did not implement for TxCache because I thought we may want the behavior for that to be different - e.g. treat the env var as the tx cache endpoint.

@anna-carroll anna-carroll self-assigned this May 20, 2025
@anna-carroll anna-carroll requested a review from a team as a code owner May 20, 2025 15:30
Copy link
Member

@prestwich prestwich left a comment

Choose a reason for hiding this comment

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

if you want this to be even more rust idiomatic:

pub enum KnownChains { 
    Pecorino,
    #[cfg(...)]
    Test,
}

impl FromStr for KnownChains {
     type Err = ParseChainError;

     fn from_str(&self) { 
        // do chain name parsing
        // and the match block repeated across your existing impls
        // other impls use `let chain: KnownChain = s.parse()?;`
    } 
}

@anna-carroll anna-carroll merged commit de53777 into main May 21, 2025
6 checks passed
@anna-carroll anna-carroll deleted the anna/constants-from-str branch May 21, 2025 12:15
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.

3 participants