mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore: rm custom chainspec parser (#8998)
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
use crate::{
|
||||
args::{
|
||||
get_secret_key,
|
||||
utils::{chain_help, chain_spec_value_parser, hash_or_num_value_parser, SUPPORTED_CHAINS},
|
||||
utils::{chain_help, genesis_value_parser, hash_or_num_value_parser, SUPPORTED_CHAINS},
|
||||
DatabaseArgs, DiscoveryArgs, NetworkArgs,
|
||||
},
|
||||
utils::get_single_header,
|
||||
@ -40,7 +40,7 @@ pub struct Command {
|
||||
value_name = "CHAIN_OR_PATH",
|
||||
long_help = chain_help(),
|
||||
default_value = SUPPORTED_CHAINS[0],
|
||||
value_parser = chain_spec_value_parser
|
||||
value_parser = genesis_value_parser
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
|
||||
@ -32,35 +32,6 @@ pub fn parse_duration_from_secs(arg: &str) -> eyre::Result<Duration, std::num::P
|
||||
Ok(Duration::from_secs(seconds))
|
||||
}
|
||||
|
||||
/// Clap value parser for [`ChainSpec`]s that takes either a built-in chainspec or the path
|
||||
/// to a custom one.
|
||||
pub fn chain_spec_value_parser(s: &str) -> eyre::Result<Arc<ChainSpec>, eyre::Error> {
|
||||
Ok(match s {
|
||||
#[cfg(not(feature = "optimism"))]
|
||||
"mainnet" => MAINNET.clone(),
|
||||
#[cfg(not(feature = "optimism"))]
|
||||
"goerli" => GOERLI.clone(),
|
||||
#[cfg(not(feature = "optimism"))]
|
||||
"sepolia" => SEPOLIA.clone(),
|
||||
#[cfg(not(feature = "optimism"))]
|
||||
"holesky" => HOLESKY.clone(),
|
||||
#[cfg(not(feature = "optimism"))]
|
||||
"dev" => DEV.clone(),
|
||||
#[cfg(feature = "optimism")]
|
||||
"optimism" => OP_MAINNET.clone(),
|
||||
#[cfg(feature = "optimism")]
|
||||
"optimism_sepolia" | "optimism-sepolia" => OP_SEPOLIA.clone(),
|
||||
#[cfg(feature = "optimism")]
|
||||
"base" => BASE_MAINNET.clone(),
|
||||
#[cfg(feature = "optimism")]
|
||||
"base_sepolia" | "base-sepolia" => BASE_SEPOLIA.clone(),
|
||||
_ => {
|
||||
let raw = fs::read_to_string(PathBuf::from(shellexpand::full(s)?.into_owned()))?;
|
||||
serde_json::from_str(&raw)?
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// The help info for the --chain flag
|
||||
pub fn chain_help() -> String {
|
||||
format!("The chain this node is running.\nPossible values are either a built-in chain or the path to a chain specification file.\n\nBuilt-in chains:\n {}", SUPPORTED_CHAINS.join(", "))
|
||||
@ -178,7 +149,6 @@ mod tests {
|
||||
#[test]
|
||||
fn parse_known_chain_spec() {
|
||||
for chain in SUPPORTED_CHAINS {
|
||||
chain_spec_value_parser(chain).unwrap();
|
||||
genesis_value_parser(chain).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user