diff --git a/Cargo.lock b/Cargo.lock index 9367060c..f7ddb65d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4761,8 +4761,8 @@ dependencies = [ "log", "nssa", "nssa_core", - "paste", "optfield", + "paste", "rand 0.8.5", "risc0-zkvm", "serde", diff --git a/integration_tests/tests/amm.rs b/integration_tests/tests/amm.rs index 073cd03d..3edc30e1 100644 --- a/integration_tests/tests/amm.rs +++ b/integration_tests/tests/amm.rs @@ -7,7 +7,11 @@ use tokio::test; use wallet::cli::{ Command, SubcommandReturnValue, account::{AccountSubcommand, NewSubcommand}, - programs::{amm::AmmProgramAgnosticSubcommand, token::TokenProgramAgnosticSubcommand}, + programs::{ + ArgsReceiverMaybeUnowned, ArgsSenderOwned, + amm::AmmProgramAgnosticSubcommand, + token::{ArgsDefinitionOwned, ArgsSupplyOwned, TokenProgramAgnosticSubcommand}, + }, }; #[test] @@ -88,8 +92,12 @@ async fn amm_public() -> Result<()> { // Create new token let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_public_account_id(&definition_account_id_1.to_string()), - supply_account_id: format_public_account_id(&supply_account_id_1.to_string()), + definition: ArgsDefinitionOwned { + definition_account_id: format_public_account_id(&definition_account_id_1.to_string()), + }, + supply: ArgsSupplyOwned { + supply_account_id: format_public_account_id(&supply_account_id_1.to_string()), + }, name: "A NAM1".to_string(), total_supply: 37, }; @@ -99,12 +107,16 @@ async fn amm_public() -> Result<()> { // Transfer 7 tokens from `supply_acc` to the account at account_id `recipient_account_id_1` let subcommand = TokenProgramAgnosticSubcommand::Send { - from: format_public_account_id(&supply_account_id_1.to_string()), - to: Some(format_public_account_id( - &recipient_account_id_1.to_string(), - )), - to_npk: None, - to_ipk: None, + from: ArgsSenderOwned { + from: format_public_account_id(&supply_account_id_1.to_string()), + }, + to: ArgsReceiverMaybeUnowned { + to: Some(format_public_account_id( + &recipient_account_id_1.to_string(), + )), + to_npk: None, + to_ipk: None, + }, amount: 7, }; @@ -114,8 +126,12 @@ async fn amm_public() -> Result<()> { // Create new token let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_public_account_id(&definition_account_id_2.to_string()), - supply_account_id: format_public_account_id(&supply_account_id_2.to_string()), + definition: ArgsDefinitionOwned { + definition_account_id: format_public_account_id(&definition_account_id_2.to_string()), + }, + supply: ArgsSupplyOwned { + supply_account_id: format_public_account_id(&supply_account_id_2.to_string()), + }, name: "A NAM2".to_string(), total_supply: 37, }; @@ -125,12 +141,16 @@ async fn amm_public() -> Result<()> { // Transfer 7 tokens from `supply_acc` to the account at account_id `recipient_account_id_2` let subcommand = TokenProgramAgnosticSubcommand::Send { - from: format_public_account_id(&supply_account_id_2.to_string()), - to: Some(format_public_account_id( - &recipient_account_id_2.to_string(), - )), - to_npk: None, - to_ipk: None, + from: ArgsSenderOwned { + from: format_public_account_id(&supply_account_id_2.to_string()), + }, + to: ArgsReceiverMaybeUnowned { + to: Some(format_public_account_id( + &recipient_account_id_2.to_string(), + )), + to_npk: None, + to_ipk: None, + }, amount: 7, }; diff --git a/integration_tests/tests/auth_transfer/private.rs b/integration_tests/tests/auth_transfer/private.rs index 4674ed0b..ea547467 100644 --- a/integration_tests/tests/auth_transfer/private.rs +++ b/integration_tests/tests/auth_transfer/private.rs @@ -13,7 +13,9 @@ use tokio::test; use wallet::cli::{ Command, SubcommandReturnValue, account::{AccountSubcommand, NewSubcommand}, - programs::native_token_transfer::AuthTransferSubcommand, + programs::{ + ArgsReceiverMaybeUnowned, ArgsSenderOwned, native_token_transfer::AuthTransferSubcommand, + }, }; #[test] @@ -24,10 +26,14 @@ async fn private_transfer_to_owned_account() -> Result<()> { let to: AccountId = ACC_RECEIVER_PRIVATE.parse()?; let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(&from.to_string()), - to: Some(format_private_account_id(&to.to_string())), - to_npk: None, - to_ipk: None, + sender: ArgsSenderOwned { + from: format_private_account_id(&from.to_string()), + }, + receiver: ArgsReceiverMaybeUnowned { + to: Some(format_private_account_id(&to.to_string())), + to_npk: None, + to_ipk: None, + }, amount: 100, }); @@ -63,10 +69,14 @@ async fn private_transfer_to_foreign_account() -> Result<()> { let to_ipk = Secp256k1Point::from_scalar(to_npk.0); let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(&from.to_string()), - to: None, - to_npk: Some(to_npk_string), - to_ipk: Some(hex::encode(to_ipk.0)), + sender: ArgsSenderOwned { + from: format_private_account_id(&from.to_string()), + }, + receiver: ArgsReceiverMaybeUnowned { + to: None, + to_npk: Some(to_npk_string), + to_ipk: Some(hex::encode(to_ipk.0)), + }, amount: 100, }); @@ -111,10 +121,14 @@ async fn deshielded_transfer_to_public_account() -> Result<()> { assert_eq!(from_acc.balance, 10000); let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(&from.to_string()), - to: Some(format_public_account_id(&to.to_string())), - to_npk: None, - to_ipk: None, + sender: ArgsSenderOwned { + from: format_private_account_id(&from.to_string()), + }, + receiver: ArgsReceiverMaybeUnowned { + to: Some(format_public_account_id(&to.to_string())), + to_npk: None, + to_ipk: None, + }, amount: 100, }); @@ -174,10 +188,14 @@ async fn private_transfer_to_owned_account_using_claiming_path() -> Result<()> { // Send to this account using claiming path (using npk and ipk instead of account ID) let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(&from.to_string()), - to: None, - to_npk: Some(hex::encode(to_keys.nullifer_public_key.0)), - to_ipk: Some(hex::encode(to_keys.incoming_viewing_public_key.0)), + sender: ArgsSenderOwned { + from: format_private_account_id(&from.to_string()), + }, + receiver: ArgsReceiverMaybeUnowned { + to: None, + to_npk: Some(hex::encode(to_keys.nullifer_public_key.0)), + to_ipk: Some(hex::encode(to_keys.incoming_viewing_public_key.0)), + }, amount: 100, }); @@ -222,10 +240,14 @@ async fn shielded_transfer_to_owned_private_account() -> Result<()> { let to: AccountId = ACC_RECEIVER_PRIVATE.parse()?; let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(&from.to_string()), - to: Some(format_private_account_id(&to.to_string())), - to_npk: None, - to_ipk: None, + sender: ArgsSenderOwned { + from: format_public_account_id(&from.to_string()), + }, + receiver: ArgsReceiverMaybeUnowned { + to: Some(format_private_account_id(&to.to_string())), + to_npk: None, + to_ipk: None, + }, amount: 100, }); @@ -267,10 +289,14 @@ async fn shielded_transfer_to_foreign_account() -> Result<()> { let from: AccountId = ACC_SENDER.parse()?; let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(&from.to_string()), - to: None, - to_npk: Some(to_npk_string), - to_ipk: Some(hex::encode(to_ipk.0)), + sender: ArgsSenderOwned { + from: format_public_account_id(&from.to_string()), + }, + receiver: ArgsReceiverMaybeUnowned { + to: None, + to_npk: Some(to_npk_string), + to_ipk: Some(hex::encode(to_ipk.0)), + }, amount: 100, }); @@ -337,10 +363,14 @@ async fn private_transfer_to_owned_account_continuous_run_path() -> Result<()> { // Send transfer using nullifier and incoming viewing public keys let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(&from.to_string()), - to: None, - to_npk: Some(hex::encode(to_keys.nullifer_public_key.0)), - to_ipk: Some(hex::encode(to_keys.incoming_viewing_public_key.0)), + sender: ArgsSenderOwned { + from: format_private_account_id(&from.to_string()), + }, + receiver: ArgsReceiverMaybeUnowned { + to: None, + to_npk: Some(hex::encode(to_keys.nullifer_public_key.0)), + to_ipk: Some(hex::encode(to_keys.incoming_viewing_public_key.0)), + }, amount: 100, }); diff --git a/integration_tests/tests/auth_transfer/public.rs b/integration_tests/tests/auth_transfer/public.rs index 467e3ebc..c5891602 100644 --- a/integration_tests/tests/auth_transfer/public.rs +++ b/integration_tests/tests/auth_transfer/public.rs @@ -10,7 +10,9 @@ use tokio::test; use wallet::cli::{ Command, SubcommandReturnValue, account::{AccountSubcommand, NewSubcommand}, - programs::native_token_transfer::AuthTransferSubcommand, + programs::{ + ArgsReceiverMaybeUnowned, ArgsSenderOwned, native_token_transfer::AuthTransferSubcommand, + }, }; #[test] @@ -18,10 +20,14 @@ async fn successful_transfer_to_existing_account() -> Result<()> { let mut ctx = TestContext::new().await?; let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(ACC_SENDER), - to: Some(format_public_account_id(ACC_RECEIVER)), - to_npk: None, - to_ipk: None, + sender: ArgsSenderOwned { + from: format_public_account_id(ACC_SENDER), + }, + receiver: ArgsReceiverMaybeUnowned { + to: Some(format_public_account_id(ACC_RECEIVER)), + to_npk: None, + to_ipk: None, + }, amount: 100, }); @@ -73,10 +79,14 @@ pub async fn successful_transfer_to_new_account() -> Result<()> { } let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(ACC_SENDER), - to: Some(format_public_account_id(&new_persistent_account_id)), - to_npk: None, - to_ipk: None, + sender: ArgsSenderOwned { + from: format_public_account_id(ACC_SENDER), + }, + receiver: ArgsReceiverMaybeUnowned { + to: Some(format_public_account_id(&new_persistent_account_id)), + to_npk: None, + to_ipk: None, + }, amount: 100, }); @@ -109,10 +119,14 @@ async fn failed_transfer_with_insufficient_balance() -> Result<()> { let mut ctx = TestContext::new().await?; let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(ACC_SENDER), - to: Some(format_public_account_id(ACC_RECEIVER)), - to_npk: None, - to_ipk: None, + sender: ArgsSenderOwned { + from: format_public_account_id(ACC_SENDER), + }, + receiver: ArgsReceiverMaybeUnowned { + to: Some(format_public_account_id(ACC_RECEIVER)), + to_npk: None, + to_ipk: None, + }, amount: 1000000, }); @@ -147,10 +161,14 @@ async fn two_consecutive_successful_transfers() -> Result<()> { // First transfer let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(ACC_SENDER), - to: Some(format_public_account_id(ACC_RECEIVER)), - to_npk: None, - to_ipk: None, + sender: ArgsSenderOwned { + from: format_public_account_id(ACC_SENDER), + }, + receiver: ArgsReceiverMaybeUnowned { + to: Some(format_public_account_id(ACC_RECEIVER)), + to_npk: None, + to_ipk: None, + }, amount: 100, }); @@ -179,10 +197,14 @@ async fn two_consecutive_successful_transfers() -> Result<()> { // Second transfer let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(ACC_SENDER), - to: Some(format_public_account_id(ACC_RECEIVER)), - to_npk: None, - to_ipk: None, + sender: ArgsSenderOwned { + from: format_public_account_id(ACC_SENDER), + }, + receiver: ArgsReceiverMaybeUnowned { + to: Some(format_public_account_id(ACC_RECEIVER)), + to_npk: None, + to_ipk: None, + }, amount: 100, }); diff --git a/integration_tests/tests/keys_restoration.rs b/integration_tests/tests/keys_restoration.rs index 9076c87f..03bf5603 100644 --- a/integration_tests/tests/keys_restoration.rs +++ b/integration_tests/tests/keys_restoration.rs @@ -12,7 +12,9 @@ use tokio::test; use wallet::cli::{ Command, SubcommandReturnValue, account::{AccountSubcommand, NewSubcommand}, - programs::native_token_transfer::AuthTransferSubcommand, + programs::{ + ArgsReceiverMaybeUnowned, ArgsSenderOwned, native_token_transfer::AuthTransferSubcommand, + }, }; #[test] @@ -47,20 +49,28 @@ async fn restore_keys_from_seed() -> Result<()> { // Send to first private account let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(&from.to_string()), - to: Some(format_private_account_id(&to_account_id1.to_string())), - to_npk: None, - to_ipk: None, + sender: ArgsSenderOwned { + from: format_private_account_id(&from.to_string()), + }, + receiver: ArgsReceiverMaybeUnowned { + to: Some(format_private_account_id(&to_account_id1.to_string())), + to_npk: None, + to_ipk: None, + }, amount: 100, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; // Send to second private account let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(&from.to_string()), - to: Some(format_private_account_id(&to_account_id2.to_string())), - to_npk: None, - to_ipk: None, + sender: ArgsSenderOwned { + from: format_private_account_id(&from.to_string()), + }, + receiver: ArgsReceiverMaybeUnowned { + to: Some(format_private_account_id(&to_account_id2.to_string())), + to_npk: None, + to_ipk: None, + }, amount: 101, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; @@ -93,20 +103,28 @@ async fn restore_keys_from_seed() -> Result<()> { // Send to first public account let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(&from.to_string()), - to: Some(format_public_account_id(&to_account_id3.to_string())), - to_npk: None, - to_ipk: None, + sender: ArgsSenderOwned { + from: format_public_account_id(&from.to_string()), + }, + receiver: ArgsReceiverMaybeUnowned { + to: Some(format_public_account_id(&to_account_id3.to_string())), + to_npk: None, + to_ipk: None, + }, amount: 102, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; // Send to second public account let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(&from.to_string()), - to: Some(format_public_account_id(&to_account_id4.to_string())), - to_npk: None, - to_ipk: None, + sender: ArgsSenderOwned { + from: format_public_account_id(&from.to_string()), + }, + receiver: ArgsReceiverMaybeUnowned { + to: Some(format_public_account_id(&to_account_id4.to_string())), + to_npk: None, + to_ipk: None, + }, amount: 103, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; @@ -166,19 +184,27 @@ async fn restore_keys_from_seed() -> Result<()> { // Test that restored accounts can send transactions let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(&to_account_id1.to_string()), - to: Some(format_private_account_id(&to_account_id2.to_string())), - to_npk: None, - to_ipk: None, + sender: ArgsSenderOwned { + from: format_private_account_id(&to_account_id1.to_string()), + }, + receiver: ArgsReceiverMaybeUnowned { + to: Some(format_private_account_id(&to_account_id2.to_string())), + to_npk: None, + to_ipk: None, + }, amount: 10, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(&to_account_id3.to_string()), - to: Some(format_public_account_id(&to_account_id4.to_string())), - to_npk: None, - to_ipk: None, + sender: ArgsSenderOwned { + from: format_public_account_id(&to_account_id3.to_string()), + }, + receiver: ArgsReceiverMaybeUnowned { + to: Some(format_public_account_id(&to_account_id4.to_string())), + to_npk: None, + to_ipk: None, + }, 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 9a8b714a..e877a714 100644 --- a/integration_tests/tests/token.rs +++ b/integration_tests/tests/token.rs @@ -12,7 +12,13 @@ use tokio::test; use wallet::cli::{ Command, SubcommandReturnValue, account::{AccountSubcommand, NewSubcommand}, - programs::token::TokenProgramAgnosticSubcommand, + programs::{ + ArgsReceiverMaybeUnowned, ArgsSenderOwned, + token::{ + ArgsDefinitionOwned, ArgsHolderMaybeUnowned, ArgsHolderOwned, ArgsSupplyOwned, + TokenProgramAgnosticSubcommand, + }, + }, }; #[test] @@ -60,8 +66,12 @@ async fn create_and_transfer_public_token() -> Result<()> { // Create new token let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_public_account_id(&definition_account_id.to_string()), - supply_account_id: format_public_account_id(&supply_account_id.to_string()), + definition: ArgsDefinitionOwned { + definition_account_id: format_public_account_id(&definition_account_id.to_string()), + }, + supply: ArgsSupplyOwned { + supply_account_id: format_public_account_id(&supply_account_id.to_string()), + }, name: "A NAME".to_string(), total_supply: 37, }; @@ -110,10 +120,14 @@ async fn create_and_transfer_public_token() -> Result<()> { // Transfer 7 tokens from supply_acc to recipient_account_id let subcommand = TokenProgramAgnosticSubcommand::Send { - from: format_public_account_id(&supply_account_id.to_string()), - to: Some(format_public_account_id(&recipient_account_id.to_string())), - to_npk: None, - to_ipk: None, + from: ArgsSenderOwned { + from: format_public_account_id(&supply_account_id.to_string()), + }, + to: ArgsReceiverMaybeUnowned { + to: Some(format_public_account_id(&recipient_account_id.to_string())), + to_npk: None, + to_ipk: None, + }, amount: 7, }; @@ -146,8 +160,12 @@ async fn create_and_transfer_public_token() -> Result<()> { // Burn 3 tokens from recipient_acc let subcommand = TokenProgramAgnosticSubcommand::Burn { - definition: format_public_account_id(&definition_account_id.to_string()), - holder: format_public_account_id(&recipient_account_id.to_string()), + definition: ArgsDefinitionOwned { + definition_account_id: format_public_account_id(&definition_account_id.to_string()), + }, + holder: ArgsHolderOwned { + holder_account_id: format_public_account_id(&recipient_account_id.to_string()), + }, amount: 3, }; @@ -182,10 +200,14 @@ async fn create_and_transfer_public_token() -> Result<()> { // Mint 10 tokens at recipient_acc let subcommand = TokenProgramAgnosticSubcommand::Mint { - definition: format_public_account_id(&definition_account_id.to_string()), - holder: Some(format_public_account_id(&recipient_account_id.to_string())), - holder_npk: None, - holder_ipk: None, + definition: ArgsDefinitionOwned { + definition_account_id: format_public_account_id(&definition_account_id.to_string()), + }, + holder: ArgsHolderMaybeUnowned { + holder: Some(format_public_account_id(&recipient_account_id.to_string())), + holder_npk: None, + holder_ipk: None, + }, amount: 10, }; @@ -271,8 +293,12 @@ async fn create_and_transfer_token_with_private_supply() -> Result<()> { // Create new token let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_public_account_id(&definition_account_id.to_string()), - supply_account_id: format_private_account_id(&supply_account_id.to_string()), + definition: ArgsDefinitionOwned { + definition_account_id: format_public_account_id(&definition_account_id.to_string()), + }, + supply: ArgsSupplyOwned { + supply_account_id: format_private_account_id(&supply_account_id.to_string()), + }, name: "A NAME".to_string(), total_supply: 37, }; @@ -306,10 +332,14 @@ async fn create_and_transfer_token_with_private_supply() -> Result<()> { // Transfer 7 tokens from supply_acc to recipient_account_id let subcommand = TokenProgramAgnosticSubcommand::Send { - from: format_private_account_id(&supply_account_id.to_string()), - to: Some(format_private_account_id(&recipient_account_id.to_string())), - to_npk: None, - to_ipk: None, + from: ArgsSenderOwned { + from: format_private_account_id(&supply_account_id.to_string()), + }, + to: ArgsReceiverMaybeUnowned { + to: Some(format_private_account_id(&recipient_account_id.to_string())), + to_npk: None, + to_ipk: None, + }, amount: 7, }; @@ -332,8 +362,12 @@ async fn create_and_transfer_token_with_private_supply() -> Result<()> { // Burn 3 tokens from recipient_acc let subcommand = TokenProgramAgnosticSubcommand::Burn { - definition: format_public_account_id(&definition_account_id.to_string()), - holder: format_private_account_id(&recipient_account_id.to_string()), + definition: ArgsDefinitionOwned { + definition_account_id: format_public_account_id(&definition_account_id.to_string()), + }, + holder: ArgsHolderOwned { + holder_account_id: format_private_account_id(&recipient_account_id.to_string()), + }, amount: 3, }; @@ -415,8 +449,12 @@ async fn create_token_with_private_definition() -> Result<()> { // Create token with private definition let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_private_account_id(&definition_account_id.to_string()), - supply_account_id: format_public_account_id(&supply_account_id.to_string()), + definition: ArgsDefinitionOwned { + definition_account_id: format_private_account_id(&definition_account_id.to_string()), + }, + supply: ArgsSupplyOwned { + supply_account_id: format_public_account_id(&supply_account_id.to_string()), + }, name: "A NAME".to_string(), total_supply: 37, }; @@ -472,12 +510,16 @@ async fn create_token_with_private_definition() -> Result<()> { // Mint to public account let subcommand = TokenProgramAgnosticSubcommand::Mint { - definition: format_private_account_id(&definition_account_id.to_string()), - holder: Some(format_public_account_id( - &recipient_account_id_public.to_string(), - )), - holder_npk: None, - holder_ipk: None, + definition: ArgsDefinitionOwned { + definition_account_id: format_private_account_id(&definition_account_id.to_string()), + }, + holder: ArgsHolderMaybeUnowned { + holder: Some(format_public_account_id( + &recipient_account_id_public.to_string(), + )), + holder_npk: None, + holder_ipk: None, + }, amount: 10, }; @@ -511,12 +553,16 @@ async fn create_token_with_private_definition() -> Result<()> { // Mint to private account let subcommand = TokenProgramAgnosticSubcommand::Mint { - definition: format_private_account_id(&definition_account_id.to_string()), - holder: Some(format_private_account_id( - &recipient_account_id_private.to_string(), - )), - holder_npk: None, - holder_ipk: None, + definition: ArgsDefinitionOwned { + definition_account_id: format_private_account_id(&definition_account_id.to_string()), + }, + holder: ArgsHolderMaybeUnowned { + holder: Some(format_private_account_id( + &recipient_account_id_private.to_string(), + )), + holder_npk: None, + holder_ipk: None, + }, amount: 5, }; @@ -580,8 +626,12 @@ async fn create_token_with_private_definition_and_supply() -> Result<()> { // Create token with both private definition and supply let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_private_account_id(&definition_account_id.to_string()), - supply_account_id: format_private_account_id(&supply_account_id.to_string()), + definition: ArgsDefinitionOwned { + definition_account_id: format_private_account_id(&definition_account_id.to_string()), + }, + supply: ArgsSupplyOwned { + supply_account_id: format_private_account_id(&supply_account_id.to_string()), + }, name: "A NAME".to_string(), total_supply: 37, }; @@ -628,10 +678,14 @@ async fn create_token_with_private_definition_and_supply() -> Result<()> { // Transfer tokens let subcommand = TokenProgramAgnosticSubcommand::Send { - from: format_private_account_id(&supply_account_id.to_string()), - to: Some(format_private_account_id(&recipient_account_id.to_string())), - to_npk: None, - to_ipk: None, + from: ArgsSenderOwned { + from: format_private_account_id(&supply_account_id.to_string()), + }, + to: ArgsReceiverMaybeUnowned { + to: Some(format_private_account_id(&recipient_account_id.to_string())), + to_npk: None, + to_ipk: None, + }, amount: 7, }; @@ -716,8 +770,12 @@ async fn shielded_token_transfer() -> Result<()> { // Create token let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_public_account_id(&definition_account_id.to_string()), - supply_account_id: format_public_account_id(&supply_account_id.to_string()), + definition: ArgsDefinitionOwned { + definition_account_id: format_public_account_id(&definition_account_id.to_string()), + }, + supply: ArgsSupplyOwned { + supply_account_id: format_public_account_id(&supply_account_id.to_string()), + }, name: "A NAME".to_string(), total_supply: 37, }; @@ -729,13 +787,16 @@ async fn shielded_token_transfer() -> Result<()> { // Perform shielded transfer: public supply -> private recipient let subcommand = TokenProgramAgnosticSubcommand::Send { - from: format_public_account_id(&supply_account_id.to_string()), - to: Some(format_private_account_id(&recipient_account_id.to_string())), - to_npk: None, - to_ipk: None, + from: ArgsSenderOwned { + from: format_public_account_id(&supply_account_id.to_string()), + }, + to: ArgsReceiverMaybeUnowned { + to: Some(format_private_account_id(&recipient_account_id.to_string())), + to_npk: None, + to_ipk: None, + }, amount: 7, }; - wallet::cli::execute_subcommand(ctx.wallet_mut(), Command::Token(subcommand)).await?; info!("Waiting for next block creation"); @@ -813,8 +874,12 @@ async fn deshielded_token_transfer() -> Result<()> { // Create token with private supply let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_public_account_id(&definition_account_id.to_string()), - supply_account_id: format_private_account_id(&supply_account_id.to_string()), + definition: ArgsDefinitionOwned { + definition_account_id: format_public_account_id(&definition_account_id.to_string()), + }, + supply: ArgsSupplyOwned { + supply_account_id: format_private_account_id(&supply_account_id.to_string()), + }, name: "A NAME".to_string(), total_supply: 37, }; @@ -826,10 +891,14 @@ async fn deshielded_token_transfer() -> Result<()> { // Perform deshielded transfer: private supply -> public recipient let subcommand = TokenProgramAgnosticSubcommand::Send { - from: format_private_account_id(&supply_account_id.to_string()), - to: Some(format_public_account_id(&recipient_account_id.to_string())), - to_npk: None, - to_ipk: None, + from: ArgsSenderOwned { + from: format_private_account_id(&supply_account_id.to_string()), + }, + to: ArgsReceiverMaybeUnowned { + to: Some(format_public_account_id(&recipient_account_id.to_string())), + to_npk: None, + to_ipk: None, + }, amount: 7, }; @@ -897,8 +966,12 @@ async fn token_claiming_path_with_private_accounts() -> Result<()> { // Create token let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_private_account_id(&definition_account_id.to_string()), - supply_account_id: format_private_account_id(&supply_account_id.to_string()), + definition: ArgsDefinitionOwned { + definition_account_id: format_private_account_id(&definition_account_id.to_string()), + }, + supply: ArgsSupplyOwned { + supply_account_id: format_private_account_id(&supply_account_id.to_string()), + }, name: "A NAME".to_string(), total_supply: 37, }; @@ -932,10 +1005,14 @@ async fn token_claiming_path_with_private_accounts() -> Result<()> { // Mint using claiming path (foreign account) let subcommand = TokenProgramAgnosticSubcommand::Mint { - definition: format_private_account_id(&definition_account_id.to_string()), - holder: None, - holder_npk: Some(hex::encode(holder_keys.nullifer_public_key.0)), - holder_ipk: Some(hex::encode(holder_keys.incoming_viewing_public_key.0)), + definition: ArgsDefinitionOwned { + definition_account_id: format_private_account_id(&definition_account_id.to_string()), + }, + holder: ArgsHolderMaybeUnowned { + holder: None, + holder_npk: Some(hex::encode(holder_keys.nullifer_public_key.0)), + holder_ipk: Some(hex::encode(holder_keys.incoming_viewing_public_key.0)), + }, amount: 9, }; diff --git a/wallet/Cargo.toml b/wallet/Cargo.toml index 0471e63e..3ef48570 100644 --- a/wallet/Cargo.toml +++ b/wallet/Cargo.toml @@ -29,5 +29,4 @@ risc0-zkvm.workspace = true async-stream = "0.3.6" indicatif = { version = "0.18.3", features = ["improved_unicode"] } paste.workspace = true -risc0-zkvm.workspace = true optfield = "0.4.0"