diff --git a/integration_tests/tests/auth_transfer/private.rs b/integration_tests/tests/auth_transfer/private.rs index 30225975..9508ee29 100644 --- a/integration_tests/tests/auth_transfer/private.rs +++ b/integration_tests/tests/auth_transfer/private.rs @@ -391,7 +391,7 @@ async fn initialize_private_account() -> Result<()> { }; let command = Command::AuthTransfer(AuthTransferSubcommand::Init { - account: private_mention(account_id), + account_id: private_mention(account_id), }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; @@ -488,7 +488,7 @@ async fn initialize_private_account_using_label() -> Result<()> { // Initialize using the label instead of account ID let command = Command::AuthTransfer(AuthTransferSubcommand::Init { - account: label.into(), + account_id: label.into(), }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; diff --git a/integration_tests/tests/auth_transfer/public.rs b/integration_tests/tests/auth_transfer/public.rs index 4b99c37a..54713f67 100644 --- a/integration_tests/tests/auth_transfer/public.rs +++ b/integration_tests/tests/auth_transfer/public.rs @@ -236,7 +236,7 @@ async fn initialize_public_account() -> Result<()> { }; let command = Command::AuthTransfer(AuthTransferSubcommand::Init { - account: public_mention(account_id), + account_id: public_mention(account_id), }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; diff --git a/integration_tests/tests/pinata.rs b/integration_tests/tests/pinata.rs index eef80b55..9beb5b1f 100644 --- a/integration_tests/tests/pinata.rs +++ b/integration_tests/tests/pinata.rs @@ -233,7 +233,7 @@ async fn claim_pinata_to_new_private_account() -> Result<()> { // Initialize account under auth transfer program let command = Command::AuthTransfer(AuthTransferSubcommand::Init { - account: private_mention(winner_account_id), + account_id: private_mention(winner_account_id), }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; diff --git a/integration_tests/tests/shared_accounts.rs b/integration_tests/tests/shared_accounts.rs index ba2dad08..aa1077ff 100644 --- a/integration_tests/tests/shared_accounts.rs +++ b/integration_tests/tests/shared_accounts.rs @@ -187,7 +187,7 @@ async fn fund_shared_account_from_public() -> Result<()> { // Initialize the shared account under auth-transfer let command = Command::AuthTransfer(AuthTransferSubcommand::Init { - account: private_mention(shared_id), + account_id: private_mention(shared_id), }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; diff --git a/wallet/src/cli/programs/native_token_transfer.rs b/wallet/src/cli/programs/native_token_transfer.rs index bd07f2b5..ac60534d 100644 --- a/wallet/src/cli/programs/native_token_transfer.rs +++ b/wallet/src/cli/programs/native_token_transfer.rs @@ -16,9 +16,9 @@ use crate::{ pub enum AuthTransferSubcommand { /// Initialize account under authenticated transfer program. Init { - /// Account id, label, or Keycard key path (e.g. `Public/9bKm...`, `my-label`, `m/44'/60'/0'/0/0`). + /// Either 32 byte base58 account id string with privacy prefix or a label. #[arg(long)] - account: CliAccountMention, + account_id: CliAccountMention, }, /// Send native tokens from one account to another with variable privacy. /// @@ -55,8 +55,8 @@ impl WalletSubcommand for AuthTransferSubcommand { wallet_core: &mut WalletCore, ) -> Result { match self { - Self::Init { account } => { - let resolved = account.resolve(wallet_core.storage())?; + Self::Init { account_id } => { + let resolved = account_id.resolve(wallet_core.storage())?; match resolved { AccountIdWithPrivacy::Public(account_id) => { let tx_hash = NativeTokenTransfer(wallet_core) @@ -124,13 +124,7 @@ impl WalletSubcommand for AuthTransferSubcommand { } (Some(to), None, None) => match (from, to) { (AccountIdWithPrivacy::Public(from), AccountIdWithPrivacy::Public(to)) => { - NativeTokenTransferProgramSubcommand::Public { - from, - to, - amount, - from_mention: from_account, - to_mention: to_account.expect("Some in this branch"), - } + NativeTokenTransferProgramSubcommand::Public { from, to, amount } } ( AccountIdWithPrivacy::Private(from), diff --git a/wallet/src/program_facades/native_token_transfer/public.rs b/wallet/src/program_facades/native_token_transfer/public.rs index a3083765..e819d376 100644 --- a/wallet/src/program_facades/native_token_transfer/public.rs +++ b/wallet/src/program_facades/native_token_transfer/public.rs @@ -25,15 +25,6 @@ impl NativeTokenTransfer<'_> { from_mention: &CliAccountMention, to_mention: &CliAccountMention, ) -> Result { - let balance = self - .0 - .get_account_balance(from) - .await - .map_err(ExecutionFailureKind::SequencerError)?; - - if balance < balance_to_move { - return Err(ExecutionFailureKind::InsufficientFundsError); - } let from_signer = from_mention .to_signer(self.0) @@ -102,6 +93,34 @@ impl NativeTokenTransfer<'_> { .sequencer_client .send_transaction(NSSATransaction::Public(tx)) .await?) + } else { + println!( + "Receiver's account ({to}) private key not found in wallet. Proceeding with only sender's key." + ); + } + + let message = Message::try_new( + program_id, + account_ids, + nonces, + AuthTransferInstruction::Transfer { + amount: balance_to_move, + }, + ) + .unwrap(); + let witness_set = WitnessSet::for_message(&message, &private_keys); + + let tx = PublicTransaction::new(message, witness_set); + + Ok(self + .0 + .sequencer_client + .send_transaction(NSSATransaction::Public(tx)) + .await?) + } else { + Err(ExecutionFailureKind::InsufficientFundsError) + } + } pub async fn register_account(