From 0f05fd0ea8cac313d1783f9a0385e900b99cc4c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Anda=20Estensen?= Date: Wed, 27 Nov 2024 09:58:22 +0100 Subject: [PATCH 1/2] chore(bolt-cli): add lints --- bolt-cli/Cargo.toml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bolt-cli/Cargo.toml b/bolt-cli/Cargo.toml index e3ed4bbad..d530448aa 100644 --- a/bolt-cli/Cargo.toml +++ b/bolt-cli/Cargo.toml @@ -45,3 +45,12 @@ alloy-node-bindings = "0.6.3" [build-dependencies] tonic-build = "0.12.3" + +[lints.clippy] +explicit_iter_loop = "warn" +if_not_else = "warn" +manual_let_else = "warn" +match_bool = "warn" +redundant_else = "warn" +unnecessary_self_imports = "warn" +use_self = "warn" From 6630fbcd0c0aa8ffbd9bb10a026df15ef95364b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Anda=20Estensen?= Date: Wed, 27 Nov 2024 09:59:15 +0100 Subject: [PATCH 2/2] chore(bolt-cli): fix lints --- bolt-cli/src/cli.rs | 18 +++++++++--------- bolt-cli/src/common/keystore.rs | 16 ++++++++-------- bolt-cli/src/contracts/mod.rs | 10 +++++----- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/bolt-cli/src/cli.rs b/bolt-cli/src/cli.rs index 6dfc5ad0d..ffdeb11a2 100644 --- a/bolt-cli/src/cli.rs +++ b/bolt-cli/src/cli.rs @@ -40,11 +40,11 @@ impl Cmd { /// Run the command. pub async fn run(self) -> eyre::Result<()> { match self { - Cmd::Delegate(cmd) => cmd.run().await, - Cmd::Pubkeys(cmd) => cmd.run().await, - Cmd::Send(cmd) => cmd.run().await, - Cmd::Validators(cmd) => cmd.run().await, - Cmd::Operators(cmd) => cmd.run().await, + Self::Delegate(cmd) => cmd.run().await, + Self::Pubkeys(cmd) => cmd.run().await, + Self::Send(cmd) => cmd.run().await, + Self::Validators(cmd) => cmd.run().await, + Self::Operators(cmd) => cmd.run().await, } } } @@ -406,10 +406,10 @@ impl Chain { /// Get the fork version for the given chain. pub fn fork_version(&self) -> [u8; 4] { match self { - Chain::Mainnet => [0, 0, 0, 0], - Chain::Holesky => [1, 1, 112, 0], - Chain::Helder => [16, 0, 0, 0], - Chain::Kurtosis => [16, 0, 0, 56], + Self::Mainnet => [0, 0, 0, 0], + Self::Holesky => [1, 1, 112, 0], + Self::Helder => [16, 0, 0, 0], + Self::Kurtosis => [16, 0, 0, 56], } } diff --git a/bolt-cli/src/common/keystore.rs b/bolt-cli/src/common/keystore.rs index 76e8ce061..3a6ee33ac 100644 --- a/bolt-cli/src/common/keystore.rs +++ b/bolt-cli/src/common/keystore.rs @@ -39,9 +39,9 @@ impl KeystoreSecret { /// Create a new [`KeystoreSecret`] from the provided [`LocalKeystoreOpts`]. pub fn from_keystore_options(opts: &LocalKeystoreOpts) -> Result { if let Some(password_path) = &opts.password_path { - Ok(KeystoreSecret::from_directory(password_path)?) + Ok(Self::from_directory(password_path)?) } else if let Some(password) = &opts.password { - Ok(KeystoreSecret::from_unique_password(password.clone())) + Ok(Self::from_unique_password(password.clone())) } else { // This case is prevented upstream by clap's validation. bail!("Either `password_path` or `password` must be provided") @@ -61,19 +61,19 @@ impl KeystoreSecret { let secret = fs::read_to_string(&path).wrap_err("Failed to read secret file")?; secrets.insert(filename.trim_start_matches("0x").to_string(), secret); } - Ok(KeystoreSecret::Directory(secrets)) + Ok(Self::Directory(secrets)) } /// Set a unique password for all validators in the keystore. pub fn from_unique_password(password: String) -> Self { - KeystoreSecret::Unique(password) + Self::Unique(password) } /// Get the password for the given validator public key. pub fn get(&self, validator_pubkey: &str) -> Option<&str> { match self { - KeystoreSecret::Unique(password) => Some(password.as_str()), - KeystoreSecret::Directory(secrets) => secrets.get(validator_pubkey).map(|s| s.as_str()), + Self::Unique(password) => Some(password.as_str()), + Self::Directory(secrets) => secrets.get(validator_pubkey).map(|s| s.as_str()), } } } @@ -83,13 +83,13 @@ impl KeystoreSecret { impl Drop for KeystoreSecret { fn drop(&mut self) { match self { - KeystoreSecret::Unique(password) => { + Self::Unique(password) => { let bytes = unsafe { password.as_bytes_mut() }; for b in bytes.iter_mut() { *b = 0; } } - KeystoreSecret::Directory(secrets) => { + Self::Directory(secrets) => { for secret in secrets.values_mut() { let bytes = unsafe { secret.as_bytes_mut() }; for b in bytes.iter_mut() { diff --git a/bolt-cli/src/contracts/mod.rs b/bolt-cli/src/contracts/mod.rs index 52603efff..bceb293b4 100644 --- a/bolt-cli/src/contracts/mod.rs +++ b/bolt-cli/src/contracts/mod.rs @@ -72,11 +72,11 @@ pub enum EigenLayerStrategy { impl std::fmt::Display for EigenLayerStrategy { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let output = match self { - EigenLayerStrategy::StEth => "stETH", - EigenLayerStrategy::REth => "rETH", - EigenLayerStrategy::WEth => "wETH", - EigenLayerStrategy::CbEth => "cbETH", - EigenLayerStrategy::MEth => "mETH", + Self::StEth => "stETH", + Self::REth => "rETH", + Self::WEth => "wETH", + Self::CbEth => "cbETH", + Self::MEth => "mETH", }; write!(f, "{}", output) }