Skip to content

Commit

Permalink
chore: remove expects
Browse files Browse the repository at this point in the history
  • Loading branch information
grumbach committed Jan 7, 2025
1 parent 30fd900 commit f3cf215
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ant-cli/src/commands/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn create(no_password: bool, password: Option<String>) -> Result<()> {
let wallet_private_key = Wallet::random_private_key();

let wallet_address = Wallet::new_from_private_key(DUMMY_NETWORK, &wallet_private_key)
.expect("Infallible")
.map_err(|e| eyre!("Unexpected error: Failed to create wallet from private key: {e}"))?
.address()
.to_string();

Expand All @@ -48,7 +48,7 @@ pub fn import(
let maybe_encryption_password = maybe_request_password(no_password, password)?;

let wallet_address = Wallet::new_from_private_key(DUMMY_NETWORK, &wallet_private_key)
.expect("Infallible")
.map_err(|e| eyre!("Unexpected error: Failed to create wallet from private key: {e}"))?
.address()
.to_string();

Expand All @@ -70,7 +70,7 @@ pub fn export() -> Result<()> {
let wallet_private_key = select_wallet_private_key()?;

let wallet_address = Wallet::new_from_private_key(DUMMY_NETWORK, &wallet_private_key)
.expect("Infallible")
.map_err(|e| eyre!("Failed to create wallet from private key loaded from disk: {e}"))?
.address()
.to_string();

Expand Down
3 changes: 2 additions & 1 deletion ant-cli/src/wallet/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ pub fn decrypt_private_key(encrypted_data: &str, password: &str) -> Result<Strin
})?;

// Create secret key from decrypted byte
Ok(String::from_utf8(decrypted_data.to_vec()).expect("not able to convert private key"))
String::from_utf8(decrypted_data.to_vec())
.map_err(|e| eyre!("Failed to convert private key: {e}"))
}

#[cfg(test)]
Expand Down

0 comments on commit f3cf215

Please sign in to comment.