doc: cli docs added

This commit is contained in:
Pravdyvy 2025-10-28 16:53:39 +02:00
parent 5840f9b779
commit 785ed5f169
6 changed files with 47 additions and 22 deletions

View File

@ -69,14 +69,16 @@ impl TokenHolding {
///Represents generic chain CLI subcommand ///Represents generic chain CLI subcommand
#[derive(Subcommand, Debug, Clone)] #[derive(Subcommand, Debug, Clone)]
pub enum AccountSubcommand { pub enum AccountSubcommand {
///Get ///Get account data
Get { Get {
#[arg(long)] ///Flag to get raw account data
#[arg(short, long)]
raw: bool, raw: bool,
///Valid 32 byte base58 string with privacy prefix
#[arg(short, long)] #[arg(short, long)]
addr: String, addr: String,
}, },
///New ///Produce new public or private account
#[command(subcommand)] #[command(subcommand)]
New(NewSubcommand), New(NewSubcommand),
///Sync private accounts ///Sync private accounts
@ -260,7 +262,7 @@ impl WalletSubcommand for AccountSubcommand {
.is_empty() .is_empty()
{ {
parse_block_range( parse_block_range(
last_synced_block, last_synced_block + 1,
curr_last_block, curr_last_block,
wallet_core.sequencer_client.clone(), wallet_core.sequencer_client.clone(),
wallet_core, wallet_core,

View File

@ -6,12 +6,16 @@ use crate::{SubcommandReturnValue, WalletCore, cli::WalletSubcommand};
///Represents generic chain CLI subcommand ///Represents generic chain CLI subcommand
#[derive(Subcommand, Debug, Clone)] #[derive(Subcommand, Debug, Clone)]
pub enum ChainSubcommand { pub enum ChainSubcommand {
///Get current block id from sequencer
CurrentBlockId {}, CurrentBlockId {},
///Get block at id from sequencer
Block { Block {
#[arg(short, long)] #[arg(short, long)]
id: u64, id: u64,
}, },
///Get transaction at hash from sequencer
Transaction { Transaction {
///hash - valid 32 byte hex string
#[arg(short, long)] #[arg(short, long)]
hash: String, hash: String,
}, },

View File

@ -12,22 +12,28 @@ use crate::{
///Represents generic CLI subcommand for a wallet working with native token transfer program ///Represents generic CLI subcommand for a wallet working with native token transfer program
#[derive(Subcommand, Debug, Clone)] #[derive(Subcommand, Debug, Clone)]
pub enum AuthTransferSubcommand { pub enum AuthTransferSubcommand {
///Initialize account under authenticated transfer program
Init { Init {
///addr - valid 32 byte base58 string ///addr - valid 32 byte base58 string with privacy prefix
#[arg(long)] #[arg(long)]
addr: String, addr: String,
}, },
///Send native tokens from one account to another with variable privacy
///
///If receiver is private, then `to` and (`to_npk` , `to_ipk`) is a mutually exclusive patterns.
///
///First is used for owned accounts, second otherwise.
Send { Send {
///from - valid 32 byte base58 string ///from - valid 32 byte base58 string with privacy prefix
#[arg(long)] #[arg(long)]
from: String, from: String,
///to - valid 32 byte base58 string ///to - valid 32 byte base58 string with privacy prefix
#[arg(long)] #[arg(long)]
to: Option<String>, to: Option<String>,
///to_npk - valid 32 byte base58 string ///to_npk - valid 32 byte hex string
#[arg(long)] #[arg(long)]
to_npk: Option<String>, to_npk: Option<String>,
///to_ipk - valid 33 byte base58 string ///to_ipk - valid 33 byte hex string
#[arg(long)] #[arg(long)]
to_ipk: Option<String>, to_ipk: Option<String>,
///amount - amount of balance to move ///amount - amount of balance to move

View File

@ -12,9 +12,9 @@ use crate::{
///Represents generic CLI subcommand for a wallet working with pinata program ///Represents generic CLI subcommand for a wallet working with pinata program
#[derive(Subcommand, Debug, Clone)] #[derive(Subcommand, Debug, Clone)]
pub enum PinataProgramAgnosticSubcommand { pub enum PinataProgramAgnosticSubcommand {
///Claim ///Claim pinata
Claim { Claim {
///to_addr - valid 32 byte base58 string ///to_addr - valid 32 byte base58 string with privacy prefix
#[arg(long)] #[arg(long)]
to_addr: String, to_addr: String,
///solution - solution to pinata challenge ///solution - solution to pinata challenge

View File

@ -12,11 +12,14 @@ 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
///
///Currently the only supported privacy options is for public definition
New { New {
///addr - valid 32 byte base58 string ///definition_addr - valid 32 byte base58 string with privacy prefix
#[arg(long)] #[arg(long)]
definition_addr: String, definition_addr: String,
///addr - valid 32 byte base58 string ///supply_addr - valid 32 byte base58 string with privacy prefix
#[arg(long)] #[arg(long)]
supply_addr: String, supply_addr: String,
#[arg(short, long)] #[arg(short, long)]
@ -24,11 +27,16 @@ pub enum TokenProgramAgnosticSubcommand {
#[arg(short, long)] #[arg(short, long)]
total_supply: u128, total_supply: u128,
}, },
///Send tokens from one account to another with variable privacy
///
///If receiver is private, then `to` and (`to_npk` , `to_ipk`) is a mutually exclusive patterns.
///
///First is used for owned accounts, second otherwise.
Send { Send {
///from - valid 32 byte base58 string ///from - valid 32 byte base58 string with privacy prefix
#[arg(long)] #[arg(long)]
from: String, from: String,
///to - valid 32 byte base58 string ///to - valid 32 byte base58 string with privacy prefix
#[arg(long)] #[arg(long)]
to: Option<String>, to: Option<String>,
///to_npk - valid 32 byte hex string ///to_npk - valid 32 byte hex string

View File

@ -198,27 +198,32 @@ impl WalletCore {
#[derive(Subcommand, Debug, Clone)] #[derive(Subcommand, Debug, Clone)]
#[clap(about)] #[clap(about)]
pub enum Command { pub enum Command {
///Transfer command ///Authenticated transfer subcommand
#[command(subcommand)] #[command(subcommand)]
AuthTransfer(AuthTransferSubcommand), AuthTransfer(AuthTransferSubcommand),
///Chain command ///Generic chain info subcommand
#[command(subcommand)] #[command(subcommand)]
ChainInfo(ChainSubcommand), ChainInfo(ChainSubcommand),
///Chain command ///Account view and sync subcommand
#[command(subcommand)] #[command(subcommand)]
Account(AccountSubcommand), Account(AccountSubcommand),
///Pinata command ///Pinata program interaction subcommand
#[command(subcommand)] #[command(subcommand)]
Pinata(PinataProgramAgnosticSubcommand), Pinata(PinataProgramAgnosticSubcommand),
///Token command ///Token program interaction subcommand
#[command(subcommand)] #[command(subcommand)]
Token(TokenProgramAgnosticSubcommand), Token(TokenProgramAgnosticSubcommand),
// Check the wallet can connect to the node and builtin local programs /// Check the wallet can connect to the node and builtin local programs
// match the remote versions /// match the remote versions
CheckHealth {}, CheckHealth {},
} }
///To execute commands, env var NSSA_WALLET_HOME_DIR must be set into directory with config ///To execute commands, env var NSSA_WALLET_HOME_DIR must be set into directory with config
///
/// All account adresses must be valid 32 byte base58 strings.
///
/// All account addresses must be provided as {privacy_prefix}/{addr},
/// where valid options for `privacy_prefix` is `Public` and `Private`
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[clap(version, about)] #[clap(version, about)]
pub struct Args { pub struct Args {