mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-06 23:33:10 +00:00
Merge pull request #198 from vacp2p/arjentix/iss-185-wallet-list-all-accounts
feat: add list account subcommand
This commit is contained in:
commit
6a507fdad1
@ -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"
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user