fix: suggestions fix 1

This commit is contained in:
Oleksandr Pravdyvyi 2025-10-30 15:00:21 +02:00
parent a903c221db
commit c2b8459645
No known key found for this signature in database
GPG Key ID: 9F8955C63C443871
2 changed files with 17 additions and 5 deletions

View File

@ -1,7 +1,7 @@
use anyhow::Result; use anyhow::Result;
use base58::ToBase58; use base58::ToBase58;
use clap::Subcommand; use clap::Subcommand;
use nssa::{Address, program::Program}; use nssa::{Account, Address, program::Program};
use serde::Serialize; use serde::Serialize;
use crate::{ use crate::{
@ -103,7 +103,7 @@ impl WalletSubcommand for NewSubcommand {
NewSubcommand::Public {} => { NewSubcommand::Public {} => {
let addr = wallet_core.create_new_account_public(); let addr = wallet_core.create_new_account_public();
println!("Generated new account with addr {addr}"); println!("Generated new account with addr Public/{addr}");
let path = wallet_core.store_persistent_data().await?; let path = wallet_core.store_persistent_data().await?;
@ -121,7 +121,7 @@ impl WalletSubcommand for NewSubcommand {
.unwrap(); .unwrap();
println!( println!(
"Generated new account with addr {}", "Generated new account with addr Private/{}",
addr.to_bytes().to_base58() addr.to_bytes().to_base58()
); );
println!("With npk {}", hex::encode(key.nullifer_public_key.0)); println!("With npk {}", hex::encode(key.nullifer_public_key.0));
@ -205,6 +205,12 @@ impl WalletSubcommand for AccountSubcommand {
.ok_or(anyhow::anyhow!("Private account not found in storage"))?, .ok_or(anyhow::anyhow!("Private account not found in storage"))?,
}; };
if account == Account::default() {
println!("Account is Uninitialized");
return Ok(SubcommandReturnValue::Empty);
}
if raw { if raw {
let account_hr: HumanReadableAccount = account.clone().into(); let account_hr: HumanReadableAccount = account.clone().into();
println!("{}", serde_json::to_string(&account_hr).unwrap()); println!("{}", serde_json::to_string(&account_hr).unwrap());
@ -219,16 +225,22 @@ impl WalletSubcommand for AccountSubcommand {
_ if account.program_owner == auth_tr_prog_id => { _ if account.program_owner == auth_tr_prog_id => {
let acc_view: AuthenticatedTransferAccountView = account.into(); let acc_view: AuthenticatedTransferAccountView = account.into();
println!("Account owned by authenticated transfer program");
serde_json::to_string(&acc_view)? serde_json::to_string(&acc_view)?
} }
_ if account.program_owner == token_prog_id => { _ if account.program_owner == token_prog_id => {
if let Some(token_def) = TokenDefinition::parse(&account.data) { if let Some(token_def) = TokenDefinition::parse(&account.data) {
let acc_view: TokedDefinitionAccountView = token_def.into(); let acc_view: TokedDefinitionAccountView = token_def.into();
println!("Definition account owned by token program");
serde_json::to_string(&acc_view)? serde_json::to_string(&acc_view)?
} else if let Some(token_hold) = TokenHolding::parse(&account.data) { } else if let Some(token_hold) = TokenHolding::parse(&account.data) {
let acc_view: TokedHoldingAccountView = token_hold.into(); let acc_view: TokedHoldingAccountView = token_hold.into();
println!("Holding account owned by token program");
serde_json::to_string(&acc_view)? serde_json::to_string(&acc_view)?
} else { } else {
anyhow::bail!("Invalid data for account {addr:#?} with token program"); anyhow::bail!("Invalid data for account {addr:#?} with token program");

View File

@ -12,7 +12,7 @@ use crate::{
///Represents generic CLI subcommand for a wallet working with token program ///Represents generic CLI subcommand for a wallet working with token program
#[derive(Subcommand, Debug, Clone)] #[derive(Subcommand, Debug, Clone)]
pub enum TokenProgramAgnosticSubcommand { pub enum TokenProgramAgnosticSubcommand {
///Produce new ERC-20 token ///Produce a new token
/// ///
///Currently the only supported privacy options is for public definition ///Currently the only supported privacy options is for public definition
New { New {
@ -94,7 +94,7 @@ impl WalletSubcommand for TokenProgramAgnosticSubcommand {
anyhow::bail!("Unavailable privacy pairing") anyhow::bail!("Unavailable privacy pairing")
} }
(AddressPrivacyKind::Private, AddressPrivacyKind::Public) => { (AddressPrivacyKind::Private, AddressPrivacyKind::Public) => {
//Probably valid. If definition is not public, but supply is it is very suspicious. //ToDo: Probably valid. If definition is not public, but supply is it is very suspicious.
anyhow::bail!("Unavailable privacy pairing") anyhow::bail!("Unavailable privacy pairing")
} }
}; };