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: unify names of supported chains #1581

26 changes: 24 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ semver = "1.0.5"
once_cell = "1.9.0"
similar = { version = "2.1.0", features = ["inline"] }
strsim = "0.10.0"

strum = { version = "0.22.0", features = ["derive"] }

[dev-dependencies]
foundry-utils = { path = "./../utils", features = ["test"] }
Expand Down
74 changes: 36 additions & 38 deletions cli/src/cmd/forge/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use ethers::prelude::Chain;
use eyre::Result;
use foundry_config::{cache, Chain as FoundryConfigChain, Config};

use strum::{EnumString, EnumVariantNames, VariantNames};

#[derive(Debug, Parser)]
pub struct CacheArgs {
#[clap(subcommand)]
Expand All @@ -35,31 +37,44 @@ impl FromStr for ChainOrAll {
}
}

#[derive(Debug, EnumString, EnumVariantNames)]
#[strum(serialize_all = "kebab-case")]
pub enum PossibleChains {
All,
Mainnet,
Ropsten,
Rinkeby,
Goerli,
Kovan,
Xdai,
Polygon,
PolygonMumbai,
Avalanche,
AvalancheFuji,
Sepolia,
Moonbeam,
MoonbeamDev,
Moonriver,
Optimism,
OptimismKovan,
Fantom,
FantomTestnet,
Arbitrum,
ArbitrumTestnet,
Bsc,
BscTestnet,
Cronos,
CronosTestnet,
}
Copy link
Member

Choose a reason for hiding this comment

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

can we even replace this with the native ethers-rs Chain?


#[derive(Debug, Parser)]
pub struct CleanArgs {
// TODO refactor to dedup shared logic with ClapChain in opts/mod
#[clap(
env = "CHAIN",
default_value = "all",
possible_values = [
"all",
"mainnet",
"ropsten",
"rinkeby",
"goerli",
"kovan",
"xdai",
"polygon",
"polygon_mumbai",
"avalanche",
"avalanche_fuji",
"sepolia",
"moonbeam",
"moonbeam_dev",
"moonriver",
"optimism",
"optimism-kovan"
])]
possible_values = PossibleChains::VARIANTS
)]
chains: Vec<ChainOrAll>,

#[clap(
Expand All @@ -78,25 +93,8 @@ pub struct LsArgs {
#[clap(
env = "CHAIN",
default_value = "all",
possible_values = [
"all",
"mainnet",
"ropsten",
"rinkeby",
"goerli",
"kovan",
"xdai",
"polygon",
"polygon_mumbai",
"avalanche",
"avalanche_fuji",
"sepolia",
"moonbeam",
"moonbeam_dev",
"moonriver",
"optimism",
"optimism-kovan"
])]
possible_values = PossibleChains::VARIANTS
)]
chains: Vec<ChainOrAll>,
}

Expand Down