From e37653083c8ae8097b8c3023c63b7f42ff125982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Bro=C5=84ski?= Date: Tue, 6 Feb 2024 14:52:59 +0100 Subject: [PATCH] Fix clippy warnings. --- kairos-cli/bin/commands/deposit.rs | 6 +++--- kairos-cli/bin/commands/mod.rs | 2 +- kairos-cli/bin/commands/transfer.rs | 8 ++++---- kairos-cli/bin/commands/withdraw.rs | 6 +++--- kairos-cli/bin/common/args.rs | 4 ++-- kairos-cli/bin/crypto/private_key.rs | 3 +-- kairos-cli/bin/crypto/public_key.rs | 1 + kairos-cli/bin/crypto/signer.rs | 2 ++ kairos-cli/bin/main.rs | 6 +++--- 9 files changed, 20 insertions(+), 18 deletions(-) diff --git a/kairos-cli/bin/commands/deposit.rs b/kairos-cli/bin/commands/deposit.rs index 49137647..bc97b58b 100644 --- a/kairos-cli/bin/commands/deposit.rs +++ b/kairos-cli/bin/commands/deposit.rs @@ -10,7 +10,7 @@ impl ClientCommand for Deposit { const NAME: &'static str = "deposit"; const ABOUT: &'static str = "Deposits funds into your account"; - fn new() -> Command { + fn new_cmd() -> Command { Command::new(Self::NAME) .about(Self::ABOUT) .arg(amount::arg()) @@ -18,10 +18,10 @@ impl ClientCommand for Deposit { } fn run(matches: &ArgMatches) -> Result { - let amount = amount::get(matches)?; + let _amount = amount::get(matches)?; let private_key = private_key::get(matches)?; - let signer = CasperSigner::from_key(private_key); + let _signer = CasperSigner::from_key(private_key); // TODO: Create transaction and sign it with `signer`. diff --git a/kairos-cli/bin/commands/mod.rs b/kairos-cli/bin/commands/mod.rs index 71c1cfff..c6f4a61d 100644 --- a/kairos-cli/bin/commands/mod.rs +++ b/kairos-cli/bin/commands/mod.rs @@ -17,7 +17,7 @@ pub trait ClientCommand { const ABOUT: &'static str; /// Constructs the clap subcommand. - fn new() -> Command; + fn new_cmd() -> Command; /// Parses the arg matches and runs the subcommand. fn run(matches: &ArgMatches) -> Result; diff --git a/kairos-cli/bin/commands/transfer.rs b/kairos-cli/bin/commands/transfer.rs index 6967fc41..2a9f4b92 100644 --- a/kairos-cli/bin/commands/transfer.rs +++ b/kairos-cli/bin/commands/transfer.rs @@ -36,7 +36,7 @@ impl ClientCommand for Transfer { const NAME: &'static str = "transfer"; const ABOUT: &'static str = "Transfers funds to another account"; - fn new() -> Command { + fn new_cmd() -> Command { Command::new(Self::NAME) .about(Self::ABOUT) .arg(recipient::arg()) @@ -45,11 +45,11 @@ impl ClientCommand for Transfer { } fn run(matches: &ArgMatches) -> Result { - let recipient = recipient::get(matches)?; - let amount = amount::get(matches)?; + let _recipient = recipient::get(matches)?; + let _amount = amount::get(matches)?; let private_key = private_key::get(matches)?; - let signer = CasperSigner::from_key(private_key); + let _signer = CasperSigner::from_key(private_key); // TODO: Create transaction and sign it with `signer`. diff --git a/kairos-cli/bin/commands/withdraw.rs b/kairos-cli/bin/commands/withdraw.rs index 15deb43a..b8ec133f 100644 --- a/kairos-cli/bin/commands/withdraw.rs +++ b/kairos-cli/bin/commands/withdraw.rs @@ -10,7 +10,7 @@ impl ClientCommand for Withdraw { const NAME: &'static str = "withdraw"; const ABOUT: &'static str = "Withdraws funds from your account"; - fn new() -> Command { + fn new_cmd() -> Command { Command::new(Self::NAME) .about(Self::ABOUT) .arg(amount::arg()) @@ -18,10 +18,10 @@ impl ClientCommand for Withdraw { } fn run(matches: &ArgMatches) -> Result { - let amount = amount::get(matches)?; + let _amount = amount::get(matches)?; let private_key = private_key::get(matches)?; - let signer = CasperSigner::from_key(private_key); + let _signer = CasperSigner::from_key(private_key); // TODO: Create transaction and sign it with `signer`. diff --git a/kairos-cli/bin/common/args.rs b/kairos-cli/bin/common/args.rs index fcd0926f..73e268ac 100644 --- a/kairos-cli/bin/common/args.rs +++ b/kairos-cli/bin/common/args.rs @@ -20,7 +20,7 @@ pub mod amount { let value = matches .get_one::(ARG_NAME) .map(String::as_str) - .ok_or_else(|| CliError::MissingArgument { context: ARG_NAME })?; + .ok_or(CliError::MissingArgument { context: ARG_NAME })?; let amount = value .parse::() @@ -51,7 +51,7 @@ pub mod private_key { let value = matches .get_one::(ARG_NAME) .map(String::as_str) - .ok_or_else(|| CliError::MissingArgument { context: ARG_NAME })?; + .ok_or(CliError::MissingArgument { context: ARG_NAME })?; let private_key = CasperPrivateKey::from_file(value).map_err(|error| CliError::CryptoError { error })?; diff --git a/kairos-cli/bin/crypto/private_key.rs b/kairos-cli/bin/crypto/private_key.rs index 7ca479a3..7ed7a911 100644 --- a/kairos-cli/bin/crypto/private_key.rs +++ b/kairos-cli/bin/crypto/private_key.rs @@ -10,7 +10,6 @@ impl CasperPrivateKey { pub fn from_file(file_path: &str) -> Result { let secret_key = casper_types::SecretKey::from_file(file_path) .map_err(|_e| CryptoError::FailedToParseKey {})?; - let private_key = casper_types::SecretKey::from(secret_key); - Ok(Self(private_key)) + Ok(Self(secret_key)) } } diff --git a/kairos-cli/bin/crypto/public_key.rs b/kairos-cli/bin/crypto/public_key.rs index b5d6bb66..f90b7fee 100644 --- a/kairos-cli/bin/crypto/public_key.rs +++ b/kairos-cli/bin/crypto/public_key.rs @@ -19,6 +19,7 @@ impl CasperPublicKey { Self(public_key) } + #[allow(unused)] fn get(&self) -> Result, CryptoError> { self.0 .to_bytes() diff --git a/kairos-cli/bin/crypto/signer.rs b/kairos-cli/bin/crypto/signer.rs index d6f63b4f..065cd14b 100644 --- a/kairos-cli/bin/crypto/signer.rs +++ b/kairos-cli/bin/crypto/signer.rs @@ -1,3 +1,5 @@ +#![allow(unused)] + use super::private_key::CasperPrivateKey; use super::public_key::CasperPublicKey; use crate::crypto::error::CryptoError; diff --git a/kairos-cli/bin/main.rs b/kairos-cli/bin/main.rs index 886d1624..a0f2789c 100644 --- a/kairos-cli/bin/main.rs +++ b/kairos-cli/bin/main.rs @@ -10,9 +10,9 @@ use std::process; fn cli() -> Command { Command::new("Kairos Client") .about("CLI for interacting with Kairos") - .subcommand(Deposit::new()) - .subcommand(Transfer::new()) - .subcommand(Withdraw::new()) + .subcommand(Deposit::new_cmd()) + .subcommand(Transfer::new_cmd()) + .subcommand(Withdraw::new_cmd()) } fn main() {