From 35c89207b2d804e629fdaa1e940a4f051d5e533b Mon Sep 17 00:00:00 2001 From: Jinsuk Park Date: Wed, 9 Oct 2024 16:19:27 +0900 Subject: [PATCH] refactor private_keys handling --- cli/src/main.rs | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/cli/src/main.rs b/cli/src/main.rs index d0993cc..714820e 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -33,30 +33,29 @@ static DB: LazyLock = std::sync::LazyLock::new(|| { }); fn get_signers_with_defaults(private_keys: Option>) -> Vec { - if private_keys.is_some() { + if let Some(private_keys) = private_keys { println!("Using provided private keys."); - return private_keys - .unwrap() + private_keys .into_iter() .map(|k| PrivateKeySigner::from_str(&k).expect("Invalid private key")) - .collect::>(); - } + .collect::>() + } else { + println!("No private keys provided. Using default private keys."); + let private_keys = private_keys.unwrap_or_default(); + let private_keys = [ + private_keys, + DEFAULT_PRV_KEYS + .into_iter() + .map(|s| s.to_owned()) + .collect::>(), + ] + .concat(); - println!("No private keys provided. Using default private keys."); - let private_keys = private_keys.unwrap_or_default(); - let private_keys = [ - private_keys, - DEFAULT_PRV_KEYS + private_keys .into_iter() - .map(|s| s.to_owned()) - .collect::>(), - ] - .concat(); - - private_keys - .into_iter() - .map(|k| PrivateKeySigner::from_str(&k).expect("Invalid private key")) - .collect::>() + .map(|k| PrivateKeySigner::from_str(&k).expect("Invalid private key")) + .collect::>() + } } #[tokio::main]