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: remove unused cli command line options #4644

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 2 additions & 46 deletions api/bin/chainflip-cli/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pub use chainflip_engine::settings::StateChain;
use chainflip_engine::{
constants::{CONFIG_ROOT, DEFAULT_CONFIG_ROOT},
settings::{
resolve_settings_path, CfSettings, Eth, EthOptions, PathResolutionExpectation,
StateChainOptions, DEFAULT_SETTINGS_DIR,
resolve_settings_path, CfSettings, PathResolutionExpectation, StateChainOptions,
DEFAULT_SETTINGS_DIR,
},
};
use clap::Parser;
Expand All @@ -24,9 +24,6 @@ pub struct CLICommandLineOptions {
#[clap(flatten)]
state_chain_opts: StateChainOptions,

#[clap(flatten)]
eth_opts: EthOptions,

#[clap(subcommand)]
pub cmd: CliCommand,
}
Expand All @@ -41,8 +38,6 @@ impl Source for CLICommandLineOptions {

self.state_chain_opts.insert_all(&mut map);

self.eth_opts.insert_all(&mut map);

Ok(map)
}
}
Expand All @@ -53,7 +48,6 @@ impl Default for CLICommandLineOptions {
Self {
config_root: DEFAULT_CONFIG_ROOT.to_owned(),
state_chain_opts: StateChainOptions::default(),
eth_opts: EthOptions::default(),
// an arbitrary simple command
cmd: CliCommand::StopBidding {},
}
Expand Down Expand Up @@ -214,21 +208,12 @@ fn account_role_parser(s: &str) -> Result<AccountRole, String> {
#[derive(Deserialize, Debug, Default)]
pub struct CLISettings {
pub state_chain: StateChain,

pub eth: Eth,
}

impl CfSettings for CLISettings {
type CommandLineOptions = CLICommandLineOptions;

fn validate_settings(&mut self, config_root: &Path) -> Result<(), ConfigError> {
self.eth.validate_settings()?;
self.eth.private_key_file = resolve_settings_path(
config_root,
&self.eth.private_key_file,
Some(PathResolutionExpectation::ExistingFile),
)?;

self.state_chain.validate_settings()?;
self.state_chain.signing_key_file = resolve_settings_path(
config_root,
Expand Down Expand Up @@ -298,7 +283,6 @@ mod tests {
.unwrap();

assert_eq!(settings.state_chain.ws_endpoint, "ws://localhost:9944");
assert_eq!(settings.eth.nodes.primary.ws_endpoint.as_ref(), "ws://localhost:8545");
}

#[test]
Expand All @@ -316,14 +300,6 @@ mod tests {
state_chain_signing_key_file: Some(PathBuf::from_str("signing_key_file").unwrap()),
},

eth_opts: EthOptions {
eth_ws_endpoint: Some("ws://endpoint2:1234".to_owned()),
eth_http_endpoint: Some("http://endpoint3:1234".to_owned()),
eth_private_key_file: Some(PathBuf::from_str("eth_key_file").unwrap()),
eth_backup_ws_endpoint: Some("ws://endpoint4:1234".to_owned()),
eth_backup_http_endpoint: Some("http://endpoint5:1234".to_owned()),
},

cmd: CliCommand::Rotate {}, // Not used in this test
};

Expand All @@ -339,25 +315,5 @@ mod tests {
opts.state_chain_opts.state_chain_signing_key_file.unwrap(),
settings.state_chain.signing_key_file
);
assert_eq!(
opts.eth_opts.eth_ws_endpoint.unwrap(),
settings.eth.nodes.primary.ws_endpoint.as_ref()
);
assert_eq!(
opts.eth_opts.eth_http_endpoint.unwrap(),
settings.eth.nodes.primary.http_endpoint.as_ref()
);

let eth_backup_node = settings.eth.nodes.backup.unwrap();
assert_eq!(
opts.eth_opts.eth_backup_ws_endpoint.unwrap(),
eth_backup_node.ws_endpoint.as_ref()
);
assert_eq!(
opts.eth_opts.eth_backup_http_endpoint.unwrap(),
eth_backup_node.http_endpoint.as_ref()
);

assert_eq!(opts.eth_opts.eth_private_key_file.unwrap(), settings.eth.private_key_file);
}
}
Loading