From 0fd2682d2efe948c89beea0d966ad8bbde2fc6f5 Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Wed, 15 Apr 2026 17:35:48 -0300 Subject: [PATCH] add identifier arguments to cli commands --- integration_tests/tests/amm.rs | 4 ++ integration_tests/tests/ata.rs | 3 ++ .../tests/auth_transfer/private.rs | 8 ++++ .../tests/auth_transfer/public.rs | 7 ++++ integration_tests/tests/indexer.rs | 3 ++ integration_tests/tests/keys_restoration.rs | 7 ++++ integration_tests/tests/token.rs | 10 +++++ .../src/cli/programs/native_token_transfer.rs | 19 +++++++++- wallet/src/cli/programs/token.rs | 38 +++++++++++++++++-- 9 files changed, 93 insertions(+), 6 deletions(-) diff --git a/integration_tests/tests/amm.rs b/integration_tests/tests/amm.rs index dde9e7f5..ce217d57 100644 --- a/integration_tests/tests/amm.rs +++ b/integration_tests/tests/amm.rs @@ -133,6 +133,7 @@ async fn amm_public() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 7, }; @@ -162,6 +163,7 @@ async fn amm_public() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 7, }; @@ -550,6 +552,7 @@ async fn amm_new_pool_using_labels() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 5, }; wallet::cli::execute_subcommand(ctx.wallet_mut(), Command::Token(subcommand)).await?; @@ -574,6 +577,7 @@ async fn amm_new_pool_using_labels() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 5, }; wallet::cli::execute_subcommand(ctx.wallet_mut(), Command::Token(subcommand)).await?; diff --git a/integration_tests/tests/ata.rs b/integration_tests/tests/ata.rs index c0918635..1bfcbab2 100644 --- a/integration_tests/tests/ata.rs +++ b/integration_tests/tests/ata.rs @@ -268,6 +268,7 @@ async fn transfer_and_burn_via_ata() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: fund_amount, }), ) @@ -500,6 +501,7 @@ async fn transfer_via_ata_private_owner() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: fund_amount, }), ) @@ -614,6 +616,7 @@ async fn burn_via_ata_private_owner() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: fund_amount, }), ) diff --git a/integration_tests/tests/auth_transfer/private.rs b/integration_tests/tests/auth_transfer/private.rs index a7d84b35..eac73322 100644 --- a/integration_tests/tests/auth_transfer/private.rs +++ b/integration_tests/tests/auth_transfer/private.rs @@ -30,6 +30,7 @@ async fn private_transfer_to_owned_account() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 100, }); @@ -71,6 +72,7 @@ async fn private_transfer_to_foreign_account() -> Result<()> { to_label: None, to_npk: Some(to_npk_string), to_vpk: Some(hex::encode(to_vpk.0)), + to_identifier: 0, amount: 100, }); @@ -121,6 +123,7 @@ async fn deshielded_transfer_to_public_account() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 100, }); @@ -186,6 +189,7 @@ async fn private_transfer_to_owned_account_using_claiming_path() -> Result<()> { to_label: None, to_npk: Some(hex::encode(to_keys.nullifier_public_key.0)), to_vpk: Some(hex::encode(to_keys.viewing_public_key.0)), + to_identifier: 0, amount: 100, }); @@ -236,6 +240,7 @@ async fn shielded_transfer_to_owned_private_account() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 100, }); @@ -280,6 +285,7 @@ async fn shielded_transfer_to_foreign_account() -> Result<()> { to_label: None, to_npk: Some(to_npk_string), to_vpk: Some(hex::encode(to_vpk.0)), + to_identifier: 0, amount: 100, }); @@ -352,6 +358,7 @@ async fn private_transfer_to_owned_account_continuous_run_path() -> Result<()> { to_label: None, to_npk: Some(hex::encode(to_keys.nullifier_public_key.0)), to_vpk: Some(hex::encode(to_keys.viewing_public_key.0)), + to_identifier: 0, amount: 100, }); @@ -455,6 +462,7 @@ async fn private_transfer_using_from_label() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 100, }); diff --git a/integration_tests/tests/auth_transfer/public.rs b/integration_tests/tests/auth_transfer/public.rs index 416c4490..d52084a1 100644 --- a/integration_tests/tests/auth_transfer/public.rs +++ b/integration_tests/tests/auth_transfer/public.rs @@ -23,6 +23,7 @@ async fn successful_transfer_to_existing_account() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 100, }); @@ -81,6 +82,7 @@ pub async fn successful_transfer_to_new_account() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 100, }); @@ -119,6 +121,7 @@ async fn failed_transfer_with_insufficient_balance() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 1_000_000, }); @@ -159,6 +162,7 @@ async fn two_consecutive_successful_transfers() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 100, }); @@ -193,6 +197,7 @@ async fn two_consecutive_successful_transfers() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 100, }); @@ -278,6 +283,7 @@ async fn successful_transfer_using_from_label() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 100, }); @@ -325,6 +331,7 @@ async fn successful_transfer_using_to_label() -> Result<()> { to_label: Some(label), to_npk: None, to_vpk: None, + to_identifier: 0, amount: 100, }); diff --git a/integration_tests/tests/indexer.rs b/integration_tests/tests/indexer.rs index 0aef4a42..72d0d0ed 100644 --- a/integration_tests/tests/indexer.rs +++ b/integration_tests/tests/indexer.rs @@ -112,6 +112,7 @@ async fn indexer_state_consistency() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 100, }); @@ -148,6 +149,7 @@ async fn indexer_state_consistency() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 100, }); @@ -234,6 +236,7 @@ async fn indexer_state_consistency_with_labels() -> Result<()> { to_label: Some(to_label_str), to_npk: None, to_vpk: None, + to_identifier: 0, amount: 100, }); diff --git a/integration_tests/tests/keys_restoration.rs b/integration_tests/tests/keys_restoration.rs index ecb5179c..704a133d 100644 --- a/integration_tests/tests/keys_restoration.rs +++ b/integration_tests/tests/keys_restoration.rs @@ -75,6 +75,7 @@ async fn sync_private_account_with_non_zero_chain_index() -> Result<()> { to_label: None, to_npk: Some(hex::encode(to_keys.nullifier_public_key.0)), to_vpk: Some(hex::encode(to_keys.viewing_public_key.0)), + to_identifier: 0, amount: 100, }); @@ -151,6 +152,7 @@ async fn restore_keys_from_seed() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 100, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; @@ -163,6 +165,7 @@ async fn restore_keys_from_seed() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 101, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; @@ -203,6 +206,7 @@ async fn restore_keys_from_seed() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 102, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; @@ -215,6 +219,7 @@ async fn restore_keys_from_seed() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 103, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; @@ -280,6 +285,7 @@ async fn restore_keys_from_seed() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 10, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; @@ -291,6 +297,7 @@ async fn restore_keys_from_seed() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: 11, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; diff --git a/integration_tests/tests/token.rs b/integration_tests/tests/token.rs index b3ab2d65..66e5cb84 100644 --- a/integration_tests/tests/token.rs +++ b/integration_tests/tests/token.rs @@ -134,6 +134,7 @@ async fn create_and_transfer_public_token() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: transfer_amount, }; @@ -227,6 +228,7 @@ async fn create_and_transfer_public_token() -> Result<()> { holder_label: None, holder_npk: None, holder_vpk: None, + holder_identifier: 0, amount: mint_amount, }; @@ -372,6 +374,7 @@ async fn create_and_transfer_token_with_private_supply() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: transfer_amount, }; @@ -566,6 +569,7 @@ async fn create_token_with_private_definition() -> Result<()> { holder_label: None, holder_npk: None, holder_vpk: None, + holder_identifier: 0, amount: mint_amount_public, }; @@ -614,6 +618,7 @@ async fn create_token_with_private_definition() -> Result<()> { holder_label: None, holder_npk: None, holder_vpk: None, + holder_identifier: 0, amount: mint_amount_private, }; @@ -756,6 +761,7 @@ async fn create_token_with_private_definition_and_supply() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: transfer_amount, }; @@ -887,6 +893,7 @@ async fn shielded_token_transfer() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: transfer_amount, }; @@ -1013,6 +1020,7 @@ async fn deshielded_token_transfer() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: transfer_amount, }; @@ -1148,6 +1156,7 @@ async fn token_claiming_path_with_private_accounts() -> Result<()> { holder_label: None, holder_npk: Some(hex::encode(holder_keys.nullifier_public_key.0)), holder_vpk: Some(hex::encode(holder_keys.viewing_public_key.0)), + holder_identifier: 0, amount: mint_amount, }; @@ -1351,6 +1360,7 @@ async fn transfer_token_using_from_label() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, + to_identifier: 0, amount: transfer_amount, }; wallet::cli::execute_subcommand(ctx.wallet_mut(), Command::Token(subcommand)).await?; diff --git a/wallet/src/cli/programs/native_token_transfer.rs b/wallet/src/cli/programs/native_token_transfer.rs index e5f13c7d..335025a5 100644 --- a/wallet/src/cli/programs/native_token_transfer.rs +++ b/wallet/src/cli/programs/native_token_transfer.rs @@ -59,6 +59,10 @@ pub enum AuthTransferSubcommand { /// `to_vpk` - valid 33 byte hex string. #[arg(long)] to_vpk: Option, + /// Identifier for the recipient's private account (only used when sending to a foreign + /// private account via `--to-npk`/`--to-vpk`). + #[arg(long, default_value_t = 0)] + to_identifier: u128, /// amount - amount of balance to move. #[arg(long)] amount: u128, @@ -132,6 +136,7 @@ impl WalletSubcommand for AuthTransferSubcommand { to_label, to_npk, to_vpk, + to_identifier, amount, } => { let from = resolve_id_or_label( @@ -210,6 +215,7 @@ impl WalletSubcommand for AuthTransferSubcommand { from, to_npk, to_vpk, + to_identifier, amount, }, ) @@ -220,6 +226,7 @@ impl WalletSubcommand for AuthTransferSubcommand { from, to_npk, to_vpk, + to_identifier, amount, }, ) @@ -304,6 +311,9 @@ pub enum NativeTokenTransferProgramSubcommandShielded { /// `to_vpk` - valid 33 byte hex string. #[arg(long)] to_vpk: String, + /// Identifier for the recipient's private account. + #[arg(long, default_value_t = 0)] + to_identifier: u128, /// amount - amount of balance to move. #[arg(long)] amount: u128, @@ -341,6 +351,9 @@ pub enum NativeTokenTransferProgramSubcommandPrivate { /// `to_vpk` - valid 33 byte hex string. #[arg(long)] to_vpk: String, + /// Identifier for the recipient's private account. + #[arg(long, default_value_t = 0)] + to_identifier: u128, /// amount - amount of balance to move. #[arg(long)] amount: u128, @@ -382,6 +395,7 @@ impl WalletSubcommand for NativeTokenTransferProgramSubcommandPrivate { from, to_npk, to_vpk, + to_identifier, amount, } => { let from: AccountId = from.parse().unwrap(); @@ -397,7 +411,7 @@ impl WalletSubcommand for NativeTokenTransferProgramSubcommandPrivate { nssa_core::encryption::shared_key_derivation::Secp256k1Point(to_vpk.to_vec()); let (tx_hash, [secret_from, _]) = NativeTokenTransfer(wallet_core) - .send_private_transfer_to_outer_account(from, to_npk, to_vpk, 0, amount) + .send_private_transfer_to_outer_account(from, to_npk, to_vpk, to_identifier, amount) .await?; println!("Transaction hash is {tx_hash}"); @@ -456,6 +470,7 @@ impl WalletSubcommand for NativeTokenTransferProgramSubcommandShielded { from, to_npk, to_vpk, + to_identifier, amount, } => { let from: AccountId = from.parse().unwrap(); @@ -472,7 +487,7 @@ impl WalletSubcommand for NativeTokenTransferProgramSubcommandShielded { nssa_core::encryption::shared_key_derivation::Secp256k1Point(to_vpk.to_vec()); let (tx_hash, _) = NativeTokenTransfer(wallet_core) - .send_shielded_transfer_to_outer_account(from, to_npk, to_vpk, 0, amount) + .send_shielded_transfer_to_outer_account(from, to_npk, to_vpk, to_identifier, amount) .await?; println!("Transaction hash is {tx_hash}"); diff --git a/wallet/src/cli/programs/token.rs b/wallet/src/cli/programs/token.rs index cfbd2e1a..6d3e5d72 100644 --- a/wallet/src/cli/programs/token.rs +++ b/wallet/src/cli/programs/token.rs @@ -73,6 +73,10 @@ pub enum TokenProgramAgnosticSubcommand { /// `to_vpk` - valid 33 byte hex string. #[arg(long)] to_vpk: Option, + /// Identifier for the recipient's private account (only used when sending to a foreign + /// private account via `--to-npk`/`--to-vpk`). + #[arg(long, default_value_t = 0)] + to_identifier: u128, /// amount - amount of balance to move. #[arg(long)] amount: u128, @@ -139,6 +143,10 @@ pub enum TokenProgramAgnosticSubcommand { /// `to_vpk` - valid 33 byte hex string. #[arg(long)] holder_vpk: Option, + /// Identifier for the holder's private account (only used when minting to a foreign + /// private account via `--holder-npk`/`--holder-vpk`). + #[arg(long, default_value_t = 0)] + holder_identifier: u128, /// amount - amount of balance to mint. #[arg(long)] amount: u128, @@ -228,6 +236,7 @@ impl WalletSubcommand for TokenProgramAgnosticSubcommand { to_label, to_npk, to_vpk, + to_identifier, amount, } => { let from = resolve_id_or_label( @@ -313,6 +322,7 @@ impl WalletSubcommand for TokenProgramAgnosticSubcommand { sender_account_id: from, recipient_npk: to_npk, recipient_vpk: to_vpk, + recipient_identifier: to_identifier, balance_to_move: amount, }, ), @@ -321,6 +331,7 @@ impl WalletSubcommand for TokenProgramAgnosticSubcommand { sender_account_id: from, recipient_npk: to_npk, recipient_vpk: to_vpk, + recipient_identifier: to_identifier, balance_to_move: amount, }, ), @@ -403,6 +414,7 @@ impl WalletSubcommand for TokenProgramAgnosticSubcommand { holder_label, holder_npk, holder_vpk, + holder_identifier, amount, } => { let definition = resolve_id_or_label( @@ -490,6 +502,7 @@ impl WalletSubcommand for TokenProgramAgnosticSubcommand { definition_account_id: definition, holder_npk, holder_vpk, + holder_identifier, amount, }, ), @@ -498,6 +511,7 @@ impl WalletSubcommand for TokenProgramAgnosticSubcommand { definition_account_id: definition, holder_npk, holder_vpk, + holder_identifier, amount, }, ), @@ -585,6 +599,9 @@ pub enum TokenProgramSubcommandPrivate { /// `recipient_vpk` - valid 33 byte hex string. #[arg(long)] recipient_vpk: String, + /// Identifier for the recipient's private account. + #[arg(long, default_value_t = 0)] + recipient_identifier: u128, #[arg(short, long)] balance_to_move: u128, }, @@ -614,6 +631,9 @@ pub enum TokenProgramSubcommandPrivate { holder_npk: String, #[arg(short, long)] holder_vpk: String, + /// Identifier for the holder's private account. + #[arg(long, default_value_t = 0)] + holder_identifier: u128, #[arg(short, long)] amount: u128, }, @@ -673,6 +693,9 @@ pub enum TokenProgramSubcommandShielded { /// `recipient_vpk` - valid 33 byte hex string. #[arg(long)] recipient_vpk: String, + /// Identifier for the recipient's private account. + #[arg(long, default_value_t = 0)] + recipient_identifier: u128, #[arg(short, long)] balance_to_move: u128, }, @@ -702,6 +725,9 @@ pub enum TokenProgramSubcommandShielded { holder_npk: String, #[arg(short, long)] holder_vpk: String, + /// Identifier for the holder's private account. + #[arg(long, default_value_t = 0)] + holder_identifier: u128, #[arg(short, long)] amount: u128, }, @@ -862,6 +888,7 @@ impl WalletSubcommand for TokenProgramSubcommandPrivate { sender_account_id, recipient_npk, recipient_vpk, + recipient_identifier, balance_to_move, } => { let sender_account_id: AccountId = sender_account_id.parse().unwrap(); @@ -882,7 +909,7 @@ impl WalletSubcommand for TokenProgramSubcommandPrivate { sender_account_id, recipient_npk, recipient_vpk, - 0, + recipient_identifier, balance_to_move, ) .await?; @@ -980,6 +1007,7 @@ impl WalletSubcommand for TokenProgramSubcommandPrivate { definition_account_id, holder_npk, holder_vpk, + holder_identifier, amount, } => { let definition_account_id: AccountId = definition_account_id.parse().unwrap(); @@ -1001,7 +1029,7 @@ impl WalletSubcommand for TokenProgramSubcommandPrivate { definition_account_id, holder_npk, holder_vpk, - 0, + holder_identifier, amount, ) .await?; @@ -1146,6 +1174,7 @@ impl WalletSubcommand for TokenProgramSubcommandShielded { sender_account_id, recipient_npk, recipient_vpk, + recipient_identifier, balance_to_move, } => { let sender_account_id: AccountId = sender_account_id.parse().unwrap(); @@ -1166,7 +1195,7 @@ impl WalletSubcommand for TokenProgramSubcommandShielded { sender_account_id, recipient_npk, recipient_vpk, - 0, + recipient_identifier, balance_to_move, ) .await?; @@ -1286,6 +1315,7 @@ impl WalletSubcommand for TokenProgramSubcommandShielded { definition_account_id, holder_npk, holder_vpk, + holder_identifier, amount, } => { let definition_account_id: AccountId = definition_account_id.parse().unwrap(); @@ -1307,7 +1337,7 @@ impl WalletSubcommand for TokenProgramSubcommandShielded { definition_account_id, holder_npk, holder_vpk, - 0, + holder_identifier, amount, ) .await?;