Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Added the ability to add an account ID to the account list without using the legacy keychain #449

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2636,7 +2636,7 @@ fn get_used_account_list_path(credentials_home_dir: &std::path::Path) -> std::pa
credentials_home_dir.join("accounts.json")
}

pub fn create_used_account_list_from_keychain(
pub fn create_used_account_list_from_legacy_keychain(
credentials_home_dir: &std::path::Path,
) -> color_eyre::eyre::Result<()> {
let mut used_account_list: std::collections::BTreeSet<near_primitives::types::AccountId> =
Expand All @@ -2661,8 +2661,13 @@ pub fn create_used_account_list_from_keychain(
}
}

let used_account_list_path = get_used_account_list_path(credentials_home_dir);
std::fs::create_dir_all(credentials_home_dir)?;
if !used_account_list_path.exists() {
std::fs::File::create(&used_account_list_path)
.wrap_err_with(|| format!("Failed to create file: {:?}", &used_account_list_path))?;
}
if !used_account_list.is_empty() {
let used_account_list_path = get_used_account_list_path(credentials_home_dir);
let used_account_list_buf = serde_json::to_string(
&used_account_list
.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn main() -> crate::common::CliResult {
let config = crate::config::Config::get_config_toml()?;

if !crate::common::is_used_account_list_exist(&config.credentials_home_dir) {
crate::common::create_used_account_list_from_keychain(&config.credentials_home_dir)?;
crate::common::create_used_account_list_from_legacy_keychain(&config.credentials_home_dir)?;
}

#[cfg(not(debug_assertions))]
Expand Down
Loading