diff --git a/wallet/src/lib.rs b/wallet/src/lib.rs index ac4cf6d..9f2fb20 100644 --- a/wallet/src/lib.rs +++ b/wallet/src/lib.rs @@ -13,7 +13,7 @@ use log::info; use nssa::{Account, Address}; use clap::{Parser, Subcommand}; -use nssa_core::Commitment; +use nssa_core::{Commitment, MembershipProof}; use crate::cli::WalletSubcommand; use crate::{ @@ -135,16 +135,17 @@ impl WalletCore { Ok(NSSATransaction::try_from(&pub_tx)?) } - pub async fn check_private_account_initialized(&self, addr: &Address) -> bool { + pub async fn check_private_account_initialized( + &self, + addr: &Address, + ) -> Result> { if let Some(acc_comm) = self.get_private_account_commitment(addr) { - matches!( - self.sequencer_client - .get_proof_for_commitment(acc_comm) - .await, - Ok(Some(_)) - ) + self.sequencer_client + .get_proof_for_commitment(acc_comm) + .await + .map_err(anyhow::Error::from) } else { - false + Ok(None) } } @@ -691,16 +692,17 @@ pub async fn execute_subcommand(command: Command) -> Result Result<(SendTxResponse, [SharedSecretKey; 1]), ExecutionFailureKind> { let Some((winner_keys, winner_acc)) = self .storage @@ -46,8 +47,6 @@ impl WalletCore { let program = nssa::program::Program::pinata(); - let winner_commitment = Commitment::new(&winner_npk, &winner_acc); - let pinata_pre = AccountWithMetadata::new(pinata_acc.clone(), false, pinata_addr); let winner_pre = AccountWithMetadata::new(winner_acc.clone(), true, &winner_npk); @@ -62,11 +61,7 @@ impl WalletCore { &[(winner_npk.clone(), shared_secret_winner.clone())], &[( winner_keys.private_key_holder.nullifier_secret_key, - self.sequencer_client - .get_proof_for_commitment(winner_commitment) - .await - .unwrap() - .unwrap(), + winner_proof, )], &program, )