@@ -53,7 +53,8 @@ pub type ParseChainError = TryFromPrimitiveError<Chain>;
53
53
#[ strum( serialize_all = "kebab-case" ) ]
54
54
#[ repr( u64 ) ]
55
55
pub enum Chain {
56
- #[ strum( serialize = "ethlive" , serialize = "mainnet" ) ]
56
+ #[ strum( to_string = "mainnet" , serialize = "ethlive" ) ]
57
+ #[ serde( alias = "ethlive" ) ]
57
58
Mainnet = 1 ,
58
59
Morden = 2 ,
59
60
Ropsten = 3 ,
@@ -598,6 +599,7 @@ mod tests {
598
599
599
600
// kebab-case
600
601
const ALIASES : & [ ( Chain , & [ & str ] ) ] = & [
602
+ ( Mainnet , & [ "ethlive" ] ) ,
601
603
( BinanceSmartChain , & [ "bsc" , "binance-smart-chain" ] ) ,
602
604
( BinanceSmartChainTestnet , & [ "bsc-testnet" , "binance-smart-chain-testnet" ] ) ,
603
605
( XDai , & [ "xdai" , "gnosis" , "gnosis-chain" ] ) ,
@@ -614,4 +616,13 @@ mod tests {
614
616
}
615
617
}
616
618
}
619
+
620
+ #[ test]
621
+ fn serde_to_string_match ( ) {
622
+ for chain in Chain :: iter ( ) {
623
+ let chain_serde = serde_json:: to_string ( & chain) . unwrap ( ) ;
624
+ let chain_string = format ! ( "\" {}\" " , chain. to_string( ) ) ;
625
+ assert_eq ! ( chain_serde, chain_string) ;
626
+ }
627
+ }
617
628
}
0 commit comments