feat: add list account subcommand

This commit is contained in:
Daniil Polyakov 2025-11-27 04:22:49 +03:00
parent d78c83b7d3
commit d7331455fc
3 changed files with 24 additions and 2 deletions

View File

@ -1169,8 +1169,8 @@ pub fn prepare_function_map() -> HashMap<String, TestFunction> {
// #[nssa_integration_test]
// pub async fn test_success_private_transfer_to_another_owned_account_cont_run_path() {
// info!(
// "########## test_success_private_transfer_to_another_owned_account_cont_run_path ##########"
// );
// "########## test_success_private_transfer_to_another_owned_account_cont_run_path
// ##########" );
// let continious_run_handle = tokio::spawn(wallet::execute_continious_run());
// let from: AccountId = ACC_SENDER_PRIVATE.parse().unwrap();

View File

@ -19,6 +19,7 @@ borsh.workspace = true
base58.workspace = true
hex = "0.4.3"
rand.workspace = true
itertools = "0.14.0"
[dependencies.key_protocol]
path = "../key_protocol"

View File

@ -1,6 +1,7 @@
use anyhow::Result;
use base58::ToBase58;
use clap::Subcommand;
use itertools::Itertools as _;
use nssa::{Account, AccountId, program::Program};
use serde::Serialize;
@ -83,6 +84,9 @@ pub enum AccountSubcommand {
New(NewSubcommand),
/// Sync private accounts
SyncPrivate {},
/// List all accounts owned by the wallet
#[command(visible_alias = "ls")]
List {},
}
/// Represents generic register CLI subcommand
@ -294,6 +298,23 @@ impl WalletSubcommand for AccountSubcommand {
Ok(SubcommandReturnValue::SyncedToBlock(curr_last_block))
}
AccountSubcommand::List {} => {
let user_data = &wallet_core.storage.user_data;
let accounts = user_data
.pub_account_signing_keys
.keys()
.map(|id| format!("Public/{id}"))
.chain(
user_data
.user_private_accounts
.keys()
.map(|id| format!("Private/{id}")),
)
.format(",\n");
println!("{accounts}");
Ok(SubcommandReturnValue::Empty)
}
}
}
}