diff --git a/nym-wallet/src-tauri/src/operations/mixnet/account.rs b/nym-wallet/src-tauri/src/operations/mixnet/account.rs index c448d74939..d6d5a81c7d 100644 --- a/nym-wallet/src-tauri/src/operations/mixnet/account.rs +++ b/nym-wallet/src-tauri/src/operations/mixnet/account.rs @@ -442,29 +442,17 @@ pub async fn sign_in_with_password( } }; - // Keep track of all accounts - // WIP(JON): simplify + // Keep track of all accounts for that id let all_accounts: HashMap<_, _> = match stored_account { StoredLogin::Mnemonic(ref account) => [( id.to_string(), - DecryptedAccount { - id: id.to_string(), - mnemonic: account.mnemonic().clone(), - }, + DecryptedAccount::new(id.to_string(), account.mnemonic().clone()), )] .into_iter() .collect(), StoredLogin::Multiple(ref accounts) => accounts .get_accounts() - .map(|account| { - ( - account.id.to_string(), - DecryptedAccount { - id: account.id.to_string(), - mnemonic: account.account.mnemonic().clone(), - }, - ) - }) + .map(|account| (account.id.to_string(), account.into())) .collect(), }; { diff --git a/nym-wallet/src-tauri/src/state.rs b/nym-wallet/src-tauri/src/state.rs index c1672d9391..bc98dbcb4e 100644 --- a/nym-wallet/src-tauri/src/state.rs +++ b/nym-wallet/src-tauri/src/state.rs @@ -1,8 +1,8 @@ use crate::config::{Config, OptionalValidators, ValidatorUrl}; use crate::error::BackendError; use crate::network::Network; +use crate::wallet_storage::account_data::WalletAccount; -use bip39::Mnemonic; use strum::IntoEnumIterator; use validator_client::nymd::SigningNymdClient; use validator_client::Client; @@ -180,8 +180,22 @@ macro_rules! client { #[derive(Clone)] pub(crate) struct DecryptedAccount { pub id: String, - pub mnemonic: Mnemonic, - // address: String + pub mnemonic: bip39::Mnemonic, +} + +impl DecryptedAccount { + pub fn new(id: String, mnemonic: bip39::Mnemonic) -> Self { + Self { id, mnemonic } + } +} + +impl From<&WalletAccount> for DecryptedAccount { + fn from(wallet_account: &WalletAccount) -> Self { + Self { + id: wallet_account.id.to_string(), + mnemonic: wallet_account.account.mnemonic().clone(), + } + } } #[macro_export]