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

fix: accept ethlive as a chain name #2268

Merged
merged 4 commits into from
Mar 16, 2023
Merged

Conversation

CodeSandwich
Copy link
Contributor

@CodeSandwich CodeSandwich commented Mar 16, 2023

Motivation

I'm coming from Foundry. The result of cast chain for Ethereum mainnet returns ethlive. This value is then rejected as a --chain argument for forge verify-contract, maybe other commands too. The correct value for --chain is mainnet.

Solution

This PR adds support for parsing the ethlive name of a chain. This name was also used in dapptools, maybe also somewhere else, but it doesn't seem to be a bug on Foundry side to use it, it's just a less known value.

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.

I'd prefer an alias, and a test for this.

@@ -47,6 +47,7 @@ pub type ParseChainError = TryFromPrimitiveError<Chain>;
#[strum(serialize_all = "kebab-case")]
#[repr(u64)]
pub enum Chain {
#[strum(serialize = "ethlive")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

this will change replace "mainnet" whith ethlive.

imo mainnet is more meaningful.

we could add this as alias, but dunno how with strum tbh.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah it's weird, I learnt this not too long ago: you can have only one "to_string" attr, which is the main one. Then aliases use serialize = ...
I'll open a pr to add that to the comments above

Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -47,6 +47,7 @@ pub type ParseChainError = TryFromPrimitiveError<Chain>;
#[strum(serialize_all = "kebab-case")]
#[repr(u64)]
pub enum Chain {
#[strum(serialize = "ethlive")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

strum is weird and you have to this

Suggested change
#[strum(serialize = "ethlive")]
#[strum(to_string = "mainnet", serialize = "ethlive")]

Copy link
Contributor Author

@CodeSandwich CodeSandwich Mar 16, 2023

Choose a reason for hiding this comment

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

That's right, the proposed PR breaks the string representation. I've fixed it by adding another serialize parameter, it matches what other enum variants do. I've added tests checking that, but I see that in #2270 you've solved the tests coverage once and for all, so I'll remove them.

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.

4 participants