mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-05 23:03:06 +00:00
fix: suggestion fix 2
This commit is contained in:
parent
d556c9b699
commit
1428dc4a90
@ -14,7 +14,7 @@ use log::info;
|
|||||||
use nssa::{Account, Address};
|
use nssa::{Account, Address};
|
||||||
|
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use nssa_core::Commitment;
|
use nssa_core::{Commitment, MembershipProof};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
helperfunctions::{
|
helperfunctions::{
|
||||||
@ -189,16 +189,17 @@ impl WalletCore {
|
|||||||
Ok(NSSATransaction::try_from(&pub_tx)?)
|
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<Option<MembershipProof>> {
|
||||||
if let Some(acc_comm) = self.get_private_account_commitment(addr) {
|
if let Some(acc_comm) = self.get_private_account_commitment(addr) {
|
||||||
matches!(
|
self.sequencer_client
|
||||||
self.sequencer_client
|
.get_proof_for_commitment(acc_comm)
|
||||||
.get_proof_for_commitment(acc_comm)
|
.await
|
||||||
.await,
|
.map_err(anyhow::Error::from)
|
||||||
Ok(Some(_))
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
false
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -799,16 +800,17 @@ pub async fn execute_subcommand(command: Command) -> Result<SubcommandReturnValu
|
|||||||
let pinata_addr = pinata_addr.parse().unwrap();
|
let pinata_addr = pinata_addr.parse().unwrap();
|
||||||
let winner_addr = winner_addr.parse().unwrap();
|
let winner_addr = winner_addr.parse().unwrap();
|
||||||
|
|
||||||
let winner_intialized = wallet_core
|
let winner_initialization = wallet_core
|
||||||
.check_private_account_initialized(&winner_addr)
|
.check_private_account_initialized(&winner_addr)
|
||||||
.await;
|
.await?;
|
||||||
|
|
||||||
let (res, [secret_winner]) = if winner_intialized {
|
let (res, [secret_winner]) = if let Some(winner_proof) = winner_initialization {
|
||||||
wallet_core
|
wallet_core
|
||||||
.claim_pinata_private_owned_account_already_initialized(
|
.claim_pinata_private_owned_account_already_initialized(
|
||||||
pinata_addr,
|
pinata_addr,
|
||||||
winner_addr,
|
winner_addr,
|
||||||
solution,
|
solution,
|
||||||
|
winner_proof,
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use common::{ExecutionFailureKind, sequencer_client::json::SendTxResponse};
|
use common::{ExecutionFailureKind, sequencer_client::json::SendTxResponse};
|
||||||
use key_protocol::key_management::ephemeral_key_holder::EphemeralKeyHolder;
|
use key_protocol::key_management::ephemeral_key_holder::EphemeralKeyHolder;
|
||||||
use nssa::{Address, privacy_preserving_transaction::circuit};
|
use nssa::{Address, privacy_preserving_transaction::circuit};
|
||||||
use nssa_core::{Commitment, SharedSecretKey, account::AccountWithMetadata};
|
use nssa_core::{MembershipProof, SharedSecretKey, account::AccountWithMetadata};
|
||||||
|
|
||||||
use crate::{WalletCore, helperfunctions::produce_random_nonces};
|
use crate::{WalletCore, helperfunctions::produce_random_nonces};
|
||||||
|
|
||||||
@ -29,6 +29,7 @@ impl WalletCore {
|
|||||||
pinata_addr: Address,
|
pinata_addr: Address,
|
||||||
winner_addr: Address,
|
winner_addr: Address,
|
||||||
solution: u128,
|
solution: u128,
|
||||||
|
winner_proof: MembershipProof,
|
||||||
) -> Result<(SendTxResponse, [SharedSecretKey; 1]), ExecutionFailureKind> {
|
) -> Result<(SendTxResponse, [SharedSecretKey; 1]), ExecutionFailureKind> {
|
||||||
let Some((winner_keys, winner_acc)) = self
|
let Some((winner_keys, winner_acc)) = self
|
||||||
.storage
|
.storage
|
||||||
@ -46,8 +47,6 @@ impl WalletCore {
|
|||||||
|
|
||||||
let program = nssa::program::Program::pinata();
|
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 pinata_pre = AccountWithMetadata::new(pinata_acc.clone(), false, pinata_addr);
|
||||||
let winner_pre = AccountWithMetadata::new(winner_acc.clone(), true, &winner_npk);
|
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_npk.clone(), shared_secret_winner.clone())],
|
||||||
&[(
|
&[(
|
||||||
winner_keys.private_key_holder.nullifier_secret_key,
|
winner_keys.private_key_holder.nullifier_secret_key,
|
||||||
self.sequencer_client
|
winner_proof,
|
||||||
.get_proof_for_commitment(winner_commitment)
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.unwrap(),
|
|
||||||
)],
|
)],
|
||||||
&program,
|
&program,
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user