use account with metadata constructor

This commit is contained in:
Sergio Chouhy 2025-10-03 08:44:15 -03:00
parent 46f899ac95
commit b6e7019588
3 changed files with 13 additions and 32 deletions

View File

@ -1,6 +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; use nssa::Address;
use nssa_core::account::AccountWithMetadata;
use crate::{WalletCore, helperfunctions::produce_random_nonces}; use crate::{WalletCore, helperfunctions::produce_random_nonces};
@ -29,13 +30,8 @@ impl WalletCore {
let sender_commitment = nssa_core::Commitment::new(&npk_from, &from_acc); let sender_commitment = nssa_core::Commitment::new(&npk_from, &from_acc);
let sender_pre = let sender_pre = AccountWithMetadata::new(from_acc.clone(), true, &npk_from);
nssa_core::account::AccountWithMetadata::new(from_acc.clone(), true, &npk_from); let recipient_pre = AccountWithMetadata::new(to_acc.clone(), false, to);
let recipient_pre = nssa_core::account::AccountWithMetadata {
account: to_acc.clone(),
is_authorized: false,
account_id: to,
};
let eph_holder = EphemeralKeyHolder::new(&npk_from); let eph_holder = EphemeralKeyHolder::new(&npk_from);
let shared_secret = eph_holder.calculate_shared_secret_sender(&ipk_from); let shared_secret = eph_holder.calculate_shared_secret_sender(&ipk_from);

View File

@ -1,6 +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; use nssa::Address;
use nssa_core::account::AccountWithMetadata;
use crate::{WalletCore, helperfunctions::produce_random_nonces}; use crate::{WalletCore, helperfunctions::produce_random_nonces};
@ -129,10 +130,8 @@ impl WalletCore {
let sender_commitment = nssa_core::Commitment::new(&from_npk, &from_acc); let sender_commitment = nssa_core::Commitment::new(&from_npk, &from_acc);
let receiver_commitment = nssa_core::Commitment::new(&to_npk, &to_acc); let receiver_commitment = nssa_core::Commitment::new(&to_npk, &to_acc);
let sender_pre = let sender_pre = AccountWithMetadata::new(from_acc.clone(), true, &from_npk);
nssa_core::account::AccountWithMetadata::new(from_acc.clone(), true, &from_npk); let recipient_pre = AccountWithMetadata::new(to_acc.clone(), true, &to_npk);
let recipient_pre =
nssa_core::account::AccountWithMetadata::new(to_acc.clone(), true, &to_npk);
let eph_holder_from = EphemeralKeyHolder::new(&from_npk); let eph_holder_from = EphemeralKeyHolder::new(&from_npk);
let shared_secret_from = eph_holder_from.calculate_shared_secret_sender(&from_ipk); let shared_secret_from = eph_holder_from.calculate_shared_secret_sender(&from_ipk);

View File

@ -1,6 +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; use nssa::Address;
use nssa_core::account::AccountWithMetadata;
use crate::{WalletCore, helperfunctions::produce_random_nonces}; use crate::{WalletCore, helperfunctions::produce_random_nonces};
@ -29,16 +30,10 @@ impl WalletCore {
let receiver_commitment = let receiver_commitment =
nssa_core::Commitment::new(&to_keys.nullifer_public_key, &to_acc); nssa_core::Commitment::new(&to_keys.nullifer_public_key, &to_acc);
let sender_pre = nssa_core::account::AccountWithMetadata { let sender_pre =
account: from_acc.clone(), nssa_core::account::AccountWithMetadata::new(from_acc.clone(), true, from);
is_authorized: true, let recipient_pre =
account_id: from, nssa_core::account::AccountWithMetadata::new(to_acc.clone(), true, &to_npk);
};
let recipient_pre = nssa_core::account::AccountWithMetadata {
account: to_acc.clone(),
is_authorized: true,
account_id: (&to_npk).into(),
};
let eph_holder = EphemeralKeyHolder::new(&to_npk); let eph_holder = EphemeralKeyHolder::new(&to_npk);
let shared_secret = eph_holder.calculate_shared_secret_sender(&to_ipk); let shared_secret = eph_holder.calculate_shared_secret_sender(&to_ipk);
@ -117,17 +112,8 @@ impl WalletCore {
if from_acc.balance >= balance_to_move { if from_acc.balance >= balance_to_move {
let program = nssa::program::Program::authenticated_transfer_program(); let program = nssa::program::Program::authenticated_transfer_program();
let sender_pre = nssa_core::account::AccountWithMetadata { let sender_pre = AccountWithMetadata::new(from_acc.clone(), true, from);
account: from_acc.clone(), let recipient_pre = AccountWithMetadata::new(to_acc.clone(), false, &to_npk);
is_authorized: true,
account_id: from,
};
let recipient_pre = nssa_core::account::AccountWithMetadata {
account: to_acc.clone(),
is_authorized: false,
account_id: (&to_npk).into(),
};
let eph_holder = EphemeralKeyHolder::new(&to_npk); let eph_holder = EphemeralKeyHolder::new(&to_npk);
let shared_secret = eph_holder.calculate_shared_secret_sender(&to_ipk); let shared_secret = eph_holder.calculate_shared_secret_sender(&to_ipk);