From f3cf215ae5e4e51bf0712ffb9341d9ca9199f03e Mon Sep 17 00:00:00 2001 From: grumbach Date: Wed, 8 Jan 2025 00:29:23 +0900 Subject: [PATCH] chore: remove expects --- ant-cli/src/commands/wallet.rs | 6 +++--- ant-cli/src/wallet/encryption.rs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ant-cli/src/commands/wallet.rs b/ant-cli/src/commands/wallet.rs index 5f123dcb68..4bfe385b26 100644 --- a/ant-cli/src/commands/wallet.rs +++ b/ant-cli/src/commands/wallet.rs @@ -22,7 +22,7 @@ pub fn create(no_password: bool, password: Option) -> 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(); @@ -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(); @@ -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(); diff --git a/ant-cli/src/wallet/encryption.rs b/ant-cli/src/wallet/encryption.rs index 1ea081e088..bbad0cc2f7 100644 --- a/ant-cli/src/wallet/encryption.rs +++ b/ant-cli/src/wallet/encryption.rs @@ -123,7 +123,8 @@ pub fn decrypt_private_key(encrypted_data: &str, password: &str) -> Result