From 658567358131ea2aa5ee9bc17876dde4c665a08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20=C5=BBuk?= Date: Thu, 16 Mar 2023 16:16:58 +0100 Subject: [PATCH 1/3] fix: accept ethlive as a chain name --- CHANGELOG.md | 1 + ethers-core/src/types/chain.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b9fb0f2b..bfa1f4b0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/ethers-core/src/types/chain.rs b/ethers-core/src/types/chain.rs index f5264a216..f5a9fa86a 100644 --- a/ethers-core/src/types/chain.rs +++ b/ethers-core/src/types/chain.rs @@ -47,6 +47,7 @@ pub type ParseChainError = TryFromPrimitiveError; #[strum(serialize_all = "kebab-case")] #[repr(u64)] pub enum Chain { + #[strum(serialize = "ethlive")] Mainnet = 1, Morden = 2, Ropsten = 3, From 5f9c065e429d329f223f8ab387133e616580dc94 Mon Sep 17 00:00:00 2001 From: CodeSandwich Date: Thu, 16 Mar 2023 18:33:33 +0100 Subject: [PATCH 2/3] Fix mainnet chain formatting --- ethers-core/src/types/chain.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ethers-core/src/types/chain.rs b/ethers-core/src/types/chain.rs index f5a9fa86a..14df98e4e 100644 --- a/ethers-core/src/types/chain.rs +++ b/ethers-core/src/types/chain.rs @@ -47,7 +47,7 @@ pub type ParseChainError = TryFromPrimitiveError; #[strum(serialize_all = "kebab-case")] #[repr(u64)] pub enum Chain { - #[strum(serialize = "ethlive")] + #[strum(serialize = "ethlive", serialize = "mainnet")] Mainnet = 1, Morden = 2, Ropsten = 3, @@ -548,6 +548,7 @@ impl Chain { #[cfg(test)] mod tests { use super::*; + use std::str::FromStr; use strum::IntoEnumIterator; #[test] @@ -555,6 +556,21 @@ mod tests { assert_eq!(serde_json::to_string(&Chain::default()).unwrap(), "\"mainnet\""); } + #[test] + fn test_parse_mainnet() { + assert_eq!(Chain::from_str("mainnet").unwrap(), Chain::Mainnet); + } + + #[test] + fn test_parse_ethlive() { + assert_eq!(Chain::from_str("ethlive").unwrap(), Chain::Mainnet); + } + + #[test] + fn test_format_mainnet() { + assert_eq!(format!("{}", Chain::Mainnet), "mainnet"); + } + #[test] fn test_enum_iter() { assert_eq!(Chain::COUNT, Chain::iter().size_hint().0); From 53f6e099382d3bc5d4220ff848f0826613088a92 Mon Sep 17 00:00:00 2001 From: CodeSandwich Date: Thu, 16 Mar 2023 18:37:32 +0100 Subject: [PATCH 3/3] Drop unnecessary chain formatting tests --- ethers-core/src/types/chain.rs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/ethers-core/src/types/chain.rs b/ethers-core/src/types/chain.rs index 14df98e4e..9189c4781 100644 --- a/ethers-core/src/types/chain.rs +++ b/ethers-core/src/types/chain.rs @@ -548,7 +548,6 @@ impl Chain { #[cfg(test)] mod tests { use super::*; - use std::str::FromStr; use strum::IntoEnumIterator; #[test] @@ -556,21 +555,6 @@ mod tests { assert_eq!(serde_json::to_string(&Chain::default()).unwrap(), "\"mainnet\""); } - #[test] - fn test_parse_mainnet() { - assert_eq!(Chain::from_str("mainnet").unwrap(), Chain::Mainnet); - } - - #[test] - fn test_parse_ethlive() { - assert_eq!(Chain::from_str("ethlive").unwrap(), Chain::Mainnet); - } - - #[test] - fn test_format_mainnet() { - assert_eq!(format!("{}", Chain::Mainnet), "mainnet"); - } - #[test] fn test_enum_iter() { assert_eq!(Chain::COUNT, Chain::iter().size_hint().0);