diff --git a/nym-wallet/src-tauri/src/operations/mixnet/account.rs b/nym-wallet/src-tauri/src/operations/mixnet/account.rs index e3d5464e70..8ed635dbe2 100644 --- a/nym-wallet/src-tauri/src/operations/mixnet/account.rs +++ b/nym-wallet/src-tauri/src/operations/mixnet/account.rs @@ -387,7 +387,7 @@ pub async fn sign_in_with_password( let id = wallet_storage::AccountId::new(DEFAULT_WALLET_ACCOUNT_ID.to_string()); let password = wallet_storage::UserPassword::new(password); let stored_account = wallet_storage::load_existing_wallet_login_information(&id, &password)?; - let (mnemonic, all_accounts) = extract_mnemonic_and_all_accounts(stored_account, id)?; + let (mnemonic, all_accounts) = extract_mnemonic_and_all_accounts(stored_account)?; { let mut w_state = state.write().await; @@ -399,7 +399,6 @@ pub async fn sign_in_with_password( fn extract_mnemonic_and_all_accounts( stored_account: StoredLogin, - id: wallet_storage::AccountId, ) -> Result<(Mnemonic, Vec), BackendError> { let mnemonic = match stored_account { StoredLogin::Mnemonic(ref account) => account.mnemonic().clone(), @@ -417,7 +416,7 @@ fn extract_mnemonic_and_all_accounts( // Keep track of all accounts for that id let all_accounts: Vec<_> = stored_account - .unwrap_into_multiple_accounts(id) + .unwrap_into_multiple_accounts() .into_accounts() .collect(); @@ -478,7 +477,7 @@ async fn reset_state_with_all_accounts_from_file( ) -> Result<(), BackendError> { let stored_account = wallet_storage::load_existing_wallet_login_information(id, password)?; let all_accounts: Vec<_> = stored_account - .unwrap_into_multiple_accounts(id.clone()) + .unwrap_into_multiple_accounts() .into_accounts() .collect(); diff --git a/nym-wallet/src-tauri/src/wallet_storage/account_data.rs b/nym-wallet/src-tauri/src/wallet_storage/account_data.rs index bc21ceae84..d54ef89571 100644 --- a/nym-wallet/src-tauri/src/wallet_storage/account_data.rs +++ b/nym-wallet/src-tauri/src/wallet_storage/account_data.rs @@ -10,6 +10,7 @@ use crate::error::BackendError; use super::encryption::EncryptedData; use super::password::AccountId; use super::UserPassword; +use super::DEFAULT_NAME_FIRST_ACCOUNT; const CURRENT_WALLET_FILE_VERSION: u32 = 1; @@ -160,9 +161,11 @@ impl StoredLogin { } } - pub(crate) fn unwrap_into_multiple_accounts(self, id: AccountId) -> MultipleAccounts { + pub(crate) fn unwrap_into_multiple_accounts(self) -> MultipleAccounts { match self { - StoredLogin::Mnemonic(ref account) => account.clone().into_multiple(id), + StoredLogin::Mnemonic(ref account) => account + .clone() + .into_multiple(AccountId::new(DEFAULT_NAME_FIRST_ACCOUNT.to_string())), StoredLogin::Multiple(ref accounts) => accounts.clone(), } } diff --git a/nym-wallet/src-tauri/src/wallet_storage/mod.rs b/nym-wallet/src-tauri/src/wallet_storage/mod.rs index c6e8d4173b..441c3329ba 100644 --- a/nym-wallet/src-tauri/src/wallet_storage/mod.rs +++ b/nym-wallet/src-tauri/src/wallet_storage/mod.rs @@ -22,7 +22,7 @@ pub(crate) const DEFAULT_WALLET_ACCOUNT_ID: &str = "default"; /// When converting a single account entry to one that contains many, the first account will use /// this name. -const DEFAULT_NAME_FIRST_ACCOUNT: &str = "Account 1"; +pub(crate) const DEFAULT_NAME_FIRST_ACCOUNT: &str = "Account 1"; fn get_storage_directory() -> Result { tauri::api::path::local_data_dir() @@ -158,8 +158,7 @@ fn append_account_to_wallet_login_information_at_file( let decrypted_login = stored_wallet.decrypt_login(&id, password)?; // Add accounts to the inner structure - let mut accounts = decrypted_login - .unwrap_into_multiple_accounts(AccountId::new(DEFAULT_NAME_FIRST_ACCOUNT.to_string())); + let mut accounts = decrypted_login.unwrap_into_multiple_accounts(); accounts.add(inner_id, mnemonic, hd_path)?; let encrypted_accounts = EncryptedLogin {