diff --git a/cmd/soroban-cli/src/commands/keys/add.rs b/cmd/soroban-cli/src/commands/keys/add.rs index 271833de3..c31d850fc 100644 --- a/cmd/soroban-cli/src/commands/keys/add.rs +++ b/cmd/soroban-cli/src/commands/keys/add.rs @@ -5,8 +5,13 @@ use sep5::SeedPhrase; use crate::{ commands::global, - config::{address::KeyName, locator, secret::{self, Secret}}, - print::Print, signer::secure_store, + config::{ + address::KeyName, + locator, + secret::{self, Secret}, + }, + print::Print, + signer::secure_store, }; #[derive(thiserror::Error, Debug)] @@ -51,7 +56,7 @@ impl Cmd { fn read_secret(&self, print: &Print) -> Result { if let Ok(secret_key) = std::env::var("SOROBAN_SECRET_KEY") { - return Ok(Secret::SecretKey { secret_key }) + return Ok(Secret::SecretKey { secret_key }); } else if self.secrets.secure_store { let prompt = "Type a 12 or 24 word seed phrase:"; let secret_key = read_password(print, prompt)?; @@ -71,4 +76,4 @@ fn read_password(print: &Print, prompt: &str) -> Result { print.arrowln(prompt); std::io::stdout().flush().map_err(|_| Error::PasswordRead)?; rpassword::read_password().map_err(|_| Error::PasswordRead) -} \ No newline at end of file +} diff --git a/cmd/soroban-cli/src/commands/keys/generate.rs b/cmd/soroban-cli/src/commands/keys/generate.rs index 8f633fe70..f24d90e10 100644 --- a/cmd/soroban-cli/src/commands/keys/generate.rs +++ b/cmd/soroban-cli/src/commands/keys/generate.rs @@ -5,12 +5,7 @@ use super::super::config::{ locator, network, secret::{self, Secret}, }; -use crate::{ - commands::global, - config::address::KeyName, - print::Print, - signer::secure_store, -}; +use crate::{commands::global, config::address::KeyName, print::Print, signer::secure_store}; #[derive(thiserror::Error, Debug)] pub enum Error { @@ -27,7 +22,7 @@ pub enum Error { IdentityAlreadyExists(String), #[error(transparent)] - SecureStore(#[from] secure_store::Error) + SecureStore(#[from] secure_store::Error), } #[derive(Debug, clap::Parser, Clone)] diff --git a/cmd/soroban-cli/src/config/locator.rs b/cmd/soroban-cli/src/config/locator.rs index 24232482f..0d952b035 100644 --- a/cmd/soroban-cli/src/config/locator.rs +++ b/cmd/soroban-cli/src/config/locator.rs @@ -12,7 +12,13 @@ use std::{ }; use stellar_strkey::{Contract, DecodeError}; -use crate::{commands::{global, HEADING_GLOBAL}, print::Print, signer::{self, keyring::StellarEntry}, utils::find_config_dir, Pwd}; +use crate::{ + commands::{global, HEADING_GLOBAL}, + print::Print, + signer::{self, keyring::StellarEntry}, + utils::find_config_dir, + Pwd, +}; use super::{ alias, diff --git a/cmd/soroban-cli/src/config/secret.rs b/cmd/soroban-cli/src/config/secret.rs index e147ae639..e49cb2011 100644 --- a/cmd/soroban-cli/src/config/secret.rs +++ b/cmd/soroban-cli/src/config/secret.rs @@ -6,7 +6,9 @@ use sep5::SeedPhrase; use stellar_strkey::ed25519::{PrivateKey, PublicKey}; use crate::{ - print::Print, signer::{self, keyring, LocalKey, SecureStoreEntry, Signer, SignerKind}, utils + print::Print, + signer::{self, keyring, LocalKey, SecureStoreEntry, Signer, SignerKind}, + utils, }; #[derive(thiserror::Error, Debug)] diff --git a/cmd/soroban-cli/src/signer/secure_store.rs b/cmd/soroban-cli/src/signer/secure_store.rs index 62113a1fc..12c7d41fc 100644 --- a/cmd/soroban-cli/src/signer/secure_store.rs +++ b/cmd/soroban-cli/src/signer/secure_store.rs @@ -1,11 +1,17 @@ use sep5::SeedPhrase; use crate::{ - config::{address::KeyName, locator, secret::{self, Secret}}, print::Print, signer::keyring::{self, StellarEntry} + config::{ + address::KeyName, + locator, + secret::{self, Secret}, + }, + print::Print, + signer::keyring::{self, StellarEntry}, }; #[derive(thiserror::Error, Debug)] -pub enum Error{ +pub enum Error { #[error(transparent)] Config(#[from] locator::Error), @@ -19,10 +25,14 @@ pub enum Error{ DoesNotSupportPrivateKey, #[error(transparent)] - SeedPhrase(#[from] sep5::Error) + SeedPhrase(#[from] sep5::Error), } -pub fn save_secret(print: &Print, entry_name: &KeyName, seed_phrase: SeedPhrase) -> Result { +pub fn save_secret( + print: &Print, + entry_name: &KeyName, + seed_phrase: SeedPhrase, +) -> Result { // secure_store:org.stellar.cli: let entry_name_with_prefix = format!( "{}{}-{}", @@ -49,11 +59,13 @@ fn write_to_secure_store( print.infoln(format!("Writing to secure store: {entry_name}")); let entry = StellarEntry::new(entry_name)?; Ok(if let Ok(key) = entry.get_public_key(None) { - print.warnln(format!("A key for {entry_name} already exists in your operating system's secure store: {key}")); + print.warnln(format!( + "A key for {entry_name} already exists in your operating system's secure store: {key}" + )); } else { print.infoln(format!( "Saving a new key to your operating system's secure store: {entry_name}" )); entry.set_seed_phrase(seed_phrase)?; }) -} \ No newline at end of file +}