diff --git a/integration_tests/tests/amm.rs b/integration_tests/tests/amm.rs index ce217d57..3eaf35e2 100644 --- a/integration_tests/tests/amm.rs +++ b/integration_tests/tests/amm.rs @@ -133,7 +133,7 @@ async fn amm_public() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 7, }; @@ -163,7 +163,7 @@ async fn amm_public() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 7, }; @@ -552,7 +552,7 @@ async fn amm_new_pool_using_labels() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 5, }; wallet::cli::execute_subcommand(ctx.wallet_mut(), Command::Token(subcommand)).await?; @@ -577,7 +577,7 @@ async fn amm_new_pool_using_labels() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(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 c28f47de..6f0bf05c 100644 --- a/integration_tests/tests/ata.rs +++ b/integration_tests/tests/ata.rs @@ -268,7 +268,7 @@ async fn transfer_and_burn_via_ata() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: fund_amount, }), ) @@ -501,7 +501,7 @@ async fn transfer_via_ata_private_owner() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: fund_amount, }), ) @@ -616,7 +616,7 @@ async fn burn_via_ata_private_owner() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: fund_amount, }), ) diff --git a/integration_tests/tests/auth_transfer/private.rs b/integration_tests/tests/auth_transfer/private.rs index de1025b3..67d2c5ce 100644 --- a/integration_tests/tests/auth_transfer/private.rs +++ b/integration_tests/tests/auth_transfer/private.rs @@ -30,7 +30,7 @@ async fn private_transfer_to_owned_account() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 100, }); @@ -72,7 +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, + to_identifier: Some(0), amount: 100, }); @@ -123,7 +123,7 @@ async fn deshielded_transfer_to_public_account() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 100, }); @@ -188,7 +188,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, + to_identifier: Some(to_identifier), amount: 100, }); @@ -239,7 +239,7 @@ async fn shielded_transfer_to_owned_private_account() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 100, }); @@ -284,7 +284,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, + to_identifier: Some(0), amount: 100, }); @@ -356,7 +356,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, + to_identifier: Some(to_identifier), amount: 100, }); @@ -460,7 +460,7 @@ async fn private_transfer_using_from_label() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 100, }); diff --git a/integration_tests/tests/auth_transfer/public.rs b/integration_tests/tests/auth_transfer/public.rs index d52084a1..e2b5a618 100644 --- a/integration_tests/tests/auth_transfer/public.rs +++ b/integration_tests/tests/auth_transfer/public.rs @@ -23,7 +23,7 @@ async fn successful_transfer_to_existing_account() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 100, }); @@ -82,7 +82,7 @@ pub async fn successful_transfer_to_new_account() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 100, }); @@ -121,7 +121,7 @@ async fn failed_transfer_with_insufficient_balance() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 1_000_000, }); @@ -162,7 +162,7 @@ async fn two_consecutive_successful_transfers() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 100, }); @@ -197,7 +197,7 @@ async fn two_consecutive_successful_transfers() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 100, }); @@ -283,7 +283,7 @@ async fn successful_transfer_using_from_label() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 100, }); @@ -331,7 +331,7 @@ async fn successful_transfer_using_to_label() -> Result<()> { to_label: Some(label), to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 100, }); diff --git a/integration_tests/tests/indexer.rs b/integration_tests/tests/indexer.rs index 72d0d0ed..72568e03 100644 --- a/integration_tests/tests/indexer.rs +++ b/integration_tests/tests/indexer.rs @@ -112,7 +112,7 @@ async fn indexer_state_consistency() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 100, }); @@ -149,7 +149,7 @@ async fn indexer_state_consistency() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 100, }); @@ -236,7 +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, + to_identifier: Some(0), amount: 100, }); diff --git a/integration_tests/tests/keys_restoration.rs b/integration_tests/tests/keys_restoration.rs index e08c4134..ff339120 100644 --- a/integration_tests/tests/keys_restoration.rs +++ b/integration_tests/tests/keys_restoration.rs @@ -74,7 +74,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, + to_identifier: Some(to_identifier), amount: 100, }); @@ -151,7 +151,7 @@ async fn restore_keys_from_seed() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 100, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; @@ -164,7 +164,7 @@ async fn restore_keys_from_seed() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 101, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; @@ -205,7 +205,7 @@ async fn restore_keys_from_seed() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 102, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; @@ -218,7 +218,7 @@ async fn restore_keys_from_seed() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 103, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; @@ -284,7 +284,7 @@ async fn restore_keys_from_seed() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: 10, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; @@ -296,7 +296,7 @@ async fn restore_keys_from_seed() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(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 7f270820..39ffdb8c 100644 --- a/integration_tests/tests/token.rs +++ b/integration_tests/tests/token.rs @@ -134,7 +134,7 @@ async fn create_and_transfer_public_token() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: transfer_amount, }; @@ -374,7 +374,7 @@ async fn create_and_transfer_token_with_private_supply() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: transfer_amount, }; @@ -761,7 +761,7 @@ async fn create_token_with_private_definition_and_supply() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: transfer_amount, }; @@ -893,7 +893,7 @@ async fn shielded_token_transfer() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: transfer_amount, }; @@ -1020,7 +1020,7 @@ async fn deshielded_token_transfer() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(0), amount: transfer_amount, }; @@ -1359,7 +1359,7 @@ async fn transfer_token_using_from_label() -> Result<()> { to_label: None, to_npk: None, to_vpk: None, - to_identifier: 0, + to_identifier: Some(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 17bbd38d..233ee1a4 100644 --- a/wallet/src/cli/programs/native_token_transfer.rs +++ b/wallet/src/cli/programs/native_token_transfer.rs @@ -61,8 +61,8 @@ pub enum AuthTransferSubcommand { 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, + #[arg(long)] + to_identifier: Option, /// amount - amount of balance to move. #[arg(long)] amount: u128, @@ -156,6 +156,7 @@ impl WalletSubcommand for AuthTransferSubcommand { anyhow::bail!("Provide only one of --to or --to-label") } }; + let to_identifier = to_identifier.unwrap_or(rand::random()); let underlying_subcommand = match (to, to_npk, to_vpk) { (None, None, None) => { anyhow::bail!( diff --git a/wallet/src/cli/programs/token.rs b/wallet/src/cli/programs/token.rs index 6d3e5d72..219812eb 100644 --- a/wallet/src/cli/programs/token.rs +++ b/wallet/src/cli/programs/token.rs @@ -75,8 +75,8 @@ pub enum TokenProgramAgnosticSubcommand { 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, + #[arg(long)] + to_identifier: Option, /// amount - amount of balance to move. #[arg(long)] amount: u128, @@ -256,6 +256,7 @@ impl WalletSubcommand for TokenProgramAgnosticSubcommand { anyhow::bail!("Provide only one of --to or --to-label") } }; + let to_identifier = to_identifier.unwrap_or(rand::random()); let underlying_subcommand = match (to, to_npk, to_vpk) { (None, None, None) => { anyhow::bail!(