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

fix: accept ethlive as a chain name #2268

Merged
merged 4 commits into from Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@

### Unreleased

- Add support for `ethlive` as a chain name [#2268](https://github.com/gakonst/ethers-rs/pull/2268)
- Add `other: OtherFields` to `TransactionReceipt` [#2209[](https://github.com/gakonst/ethers-rs/pull/2209)
- Add `Signature::recover_typed_data` [#2120](https://github.com/gakonst/ethers-rs/pull/2120)
- Add `abi::encode_packed` [#2104](https://github.com/gakonst/ethers-rs/pull/2104)
Expand Down
1 change: 1 addition & 0 deletions ethers-core/src/types/chain.rs
Expand Up @@ -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

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.

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.

I checked cast chain, and the reason we use ethlive is because of eth classic

https://github.com/foundry-rs/foundry/blob/816e00bb8cf564fa3f319d7d68511b05ac3e2b5d/cast/src/lib.rs#L413-L418

Mainnet = 1,
Morden = 2,
Ropsten = 3,
Expand Down