wallet: fix default inner account name
This commit is contained in:
@@ -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<wallet_storage::WalletAccount>), 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();
|
||||
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<PathBuf, BackendError> {
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user