use option<identifier> for all wallet commands

This commit is contained in:
Sergio Chouhy 2026-04-27 19:57:25 -03:00
parent eb3d3d8a8d
commit c3f47f6685
3 changed files with 24 additions and 26 deletions

View File

@ -228,7 +228,7 @@ async fn create_and_transfer_public_token() -> Result<()> {
holder_label: None, holder_label: None,
holder_npk: None, holder_npk: None,
holder_vpk: None, holder_vpk: None,
holder_identifier: 0, holder_identifier: None,
amount: mint_amount, amount: mint_amount,
}; };
@ -569,7 +569,7 @@ async fn create_token_with_private_definition() -> Result<()> {
holder_label: None, holder_label: None,
holder_npk: None, holder_npk: None,
holder_vpk: None, holder_vpk: None,
holder_identifier: 0, holder_identifier: None,
amount: mint_amount_public, amount: mint_amount_public,
}; };
@ -618,7 +618,7 @@ async fn create_token_with_private_definition() -> Result<()> {
holder_label: None, holder_label: None,
holder_npk: None, holder_npk: None,
holder_vpk: None, holder_vpk: None,
holder_identifier: 0, holder_identifier: None,
amount: mint_amount_private, amount: mint_amount_private,
}; };
@ -1155,7 +1155,7 @@ async fn token_claiming_path_with_private_accounts() -> Result<()> {
holder_label: None, holder_label: None,
holder_npk: Some(hex::encode(holder_keys.nullifier_public_key.0)), holder_npk: Some(hex::encode(holder_keys.nullifier_public_key.0)),
holder_vpk: Some(hex::encode(holder_keys.viewing_public_key.0)), holder_vpk: Some(hex::encode(holder_keys.viewing_public_key.0)),
holder_identifier, holder_identifier: Some(holder_identifier),
amount: mint_amount, amount: mint_amount,
}; };

View File

@ -156,7 +156,6 @@ impl WalletSubcommand for AuthTransferSubcommand {
anyhow::bail!("Provide only one of --to or --to-label") anyhow::bail!("Provide only one of --to or --to-label")
} }
}; };
let to_identifier = to_identifier.unwrap_or_else(rand::random);
let underlying_subcommand = match (to, to_npk, to_vpk) { let underlying_subcommand = match (to, to_npk, to_vpk) {
(None, None, None) => { (None, None, None) => {
anyhow::bail!( anyhow::bail!(
@ -313,8 +312,8 @@ pub enum NativeTokenTransferProgramSubcommandShielded {
#[arg(long)] #[arg(long)]
to_vpk: String, to_vpk: String,
/// Identifier for the recipient's private account. /// Identifier for the recipient's private account.
#[arg(long, default_value_t = 0)] #[arg(long)]
to_identifier: u128, to_identifier: Option<u128>,
/// amount - amount of balance to move. /// amount - amount of balance to move.
#[arg(long)] #[arg(long)]
amount: u128, amount: u128,
@ -353,8 +352,8 @@ pub enum NativeTokenTransferProgramSubcommandPrivate {
#[arg(long)] #[arg(long)]
to_vpk: String, to_vpk: String,
/// Identifier for the recipient's private account. /// Identifier for the recipient's private account.
#[arg(long, default_value_t = 0)] #[arg(long)]
to_identifier: u128, to_identifier: Option<u128>,
/// amount - amount of balance to move. /// amount - amount of balance to move.
#[arg(long)] #[arg(long)]
amount: u128, amount: u128,
@ -416,7 +415,7 @@ impl WalletSubcommand for NativeTokenTransferProgramSubcommandPrivate {
from, from,
to_npk, to_npk,
to_vpk, to_vpk,
to_identifier, to_identifier.unwrap_or_else(rand::random),
amount, amount,
) )
.await?; .await?;
@ -498,7 +497,7 @@ impl WalletSubcommand for NativeTokenTransferProgramSubcommandShielded {
from, from,
to_npk, to_npk,
to_vpk, to_vpk,
to_identifier, to_identifier.unwrap_or_else(rand::random),
amount, amount,
) )
.await?; .await?;

View File

@ -145,8 +145,8 @@ pub enum TokenProgramAgnosticSubcommand {
holder_vpk: Option<String>, holder_vpk: Option<String>,
/// Identifier for the holder's private account (only used when minting to a foreign /// Identifier for the holder's private account (only used when minting to a foreign
/// private account via `--holder-npk`/`--holder-vpk`). /// private account via `--holder-npk`/`--holder-vpk`).
#[arg(long, default_value_t = 0)] #[arg(long)]
holder_identifier: u128, holder_identifier: Option<u128>,
/// amount - amount of balance to mint. /// amount - amount of balance to mint.
#[arg(long)] #[arg(long)]
amount: u128, amount: u128,
@ -256,7 +256,6 @@ impl WalletSubcommand for TokenProgramAgnosticSubcommand {
anyhow::bail!("Provide only one of --to or --to-label") anyhow::bail!("Provide only one of --to or --to-label")
} }
}; };
let to_identifier = to_identifier.unwrap_or_else(rand::random);
let underlying_subcommand = match (to, to_npk, to_vpk) { let underlying_subcommand = match (to, to_npk, to_vpk) {
(None, None, None) => { (None, None, None) => {
anyhow::bail!( anyhow::bail!(
@ -601,8 +600,8 @@ pub enum TokenProgramSubcommandPrivate {
#[arg(long)] #[arg(long)]
recipient_vpk: String, recipient_vpk: String,
/// Identifier for the recipient's private account. /// Identifier for the recipient's private account.
#[arg(long, default_value_t = 0)] #[arg(long)]
recipient_identifier: u128, recipient_identifier: Option<u128>,
#[arg(short, long)] #[arg(short, long)]
balance_to_move: u128, balance_to_move: u128,
}, },
@ -633,8 +632,8 @@ pub enum TokenProgramSubcommandPrivate {
#[arg(short, long)] #[arg(short, long)]
holder_vpk: String, holder_vpk: String,
/// Identifier for the holder's private account. /// Identifier for the holder's private account.
#[arg(long, default_value_t = 0)] #[arg(long)]
holder_identifier: u128, holder_identifier: Option<u128>,
#[arg(short, long)] #[arg(short, long)]
amount: u128, amount: u128,
}, },
@ -695,8 +694,8 @@ pub enum TokenProgramSubcommandShielded {
#[arg(long)] #[arg(long)]
recipient_vpk: String, recipient_vpk: String,
/// Identifier for the recipient's private account. /// Identifier for the recipient's private account.
#[arg(long, default_value_t = 0)] #[arg(long)]
recipient_identifier: u128, recipient_identifier: Option<u128>,
#[arg(short, long)] #[arg(short, long)]
balance_to_move: u128, balance_to_move: u128,
}, },
@ -727,8 +726,8 @@ pub enum TokenProgramSubcommandShielded {
#[arg(short, long)] #[arg(short, long)]
holder_vpk: String, holder_vpk: String,
/// Identifier for the holder's private account. /// Identifier for the holder's private account.
#[arg(long, default_value_t = 0)] #[arg(long)]
holder_identifier: u128, holder_identifier: Option<u128>,
#[arg(short, long)] #[arg(short, long)]
amount: u128, amount: u128,
}, },
@ -910,7 +909,7 @@ impl WalletSubcommand for TokenProgramSubcommandPrivate {
sender_account_id, sender_account_id,
recipient_npk, recipient_npk,
recipient_vpk, recipient_vpk,
recipient_identifier, recipient_identifier.unwrap_or_else(rand::random),
balance_to_move, balance_to_move,
) )
.await?; .await?;
@ -1030,7 +1029,7 @@ impl WalletSubcommand for TokenProgramSubcommandPrivate {
definition_account_id, definition_account_id,
holder_npk, holder_npk,
holder_vpk, holder_vpk,
holder_identifier, holder_identifier.unwrap_or_else(rand::random),
amount, amount,
) )
.await?; .await?;
@ -1196,7 +1195,7 @@ impl WalletSubcommand for TokenProgramSubcommandShielded {
sender_account_id, sender_account_id,
recipient_npk, recipient_npk,
recipient_vpk, recipient_vpk,
recipient_identifier, recipient_identifier.unwrap_or_else(rand::random),
balance_to_move, balance_to_move,
) )
.await?; .await?;
@ -1338,7 +1337,7 @@ impl WalletSubcommand for TokenProgramSubcommandShielded {
definition_account_id, definition_account_id,
holder_npk, holder_npk,
holder_vpk, holder_vpk,
holder_identifier, holder_identifier.unwrap_or_else(rand::random),
amount, amount,
) )
.await?; .await?;