Skip to content

Commit

Permalink
refactor private_keys handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jinmel committed Oct 9, 2024
1 parent f533ea8 commit 35c8920
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,29 @@ static DB: LazyLock<SqliteDb> = std::sync::LazyLock::new(|| {
});

fn get_signers_with_defaults(private_keys: Option<Vec<String>>) -> Vec<PrivateKeySigner> {
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::<Vec<PrivateKeySigner>>();
}
.collect::<Vec<PrivateKeySigner>>()
} 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::<Vec<_>>(),
]
.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::<Vec<_>>(),
]
.concat();

private_keys
.into_iter()
.map(|k| PrivateKeySigner::from_str(&k).expect("Invalid private key"))
.collect::<Vec<PrivateKeySigner>>()
.map(|k| PrivateKeySigner::from_str(&k).expect("Invalid private key"))
.collect::<Vec<PrivateKeySigner>>()
}
}

#[tokio::main]
Expand Down

0 comments on commit 35c8920

Please sign in to comment.