This commit is contained in:
Sergio Chouhy 2026-04-24 00:37:36 -03:00
parent 9c90a6d182
commit 6f9c3b2af3
3 changed files with 20 additions and 12 deletions

View File

@ -115,12 +115,9 @@ impl KeyTreeNode for ChildKeysPrivate {
}
fn account_ids(&self) -> impl Iterator<Item = nssa::AccountId> {
self.value
.1
.iter()
.map(|(identifier, _)| {
nssa::AccountId::from((&self.value.0.nullifier_public_key, *identifier))
})
self.value.1.iter().map(|(identifier, _)| {
nssa::AccountId::from((&self.value.0.nullifier_public_key, *identifier))
})
}
}

View File

@ -17,7 +17,7 @@ pub type PublicKey = AffinePoint;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct UserPrivateAccountData {
pub key_chain: KeyChain,
pub accounts: Vec<(Identifier, Account)>
pub accounts: Vec<(Identifier, Account)>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
@ -54,7 +54,8 @@ impl NSSAUserData {
let mut check_res = true;
for (account_id, entry) in accounts_keys_map {
let any_match = entry.accounts.iter().any(|(identifier, _)| {
nssa::AccountId::from((&entry.key_chain.nullifier_public_key, *identifier)) == *account_id
nssa::AccountId::from((&entry.key_chain.nullifier_public_key, *identifier))
== *account_id
});
if !any_match {
println!("No matching entry found for account_id {account_id}");

View File

@ -79,7 +79,11 @@ impl WalletChainStore {
InitialAccountData::Private(data) => {
private_init_acc_map.insert(
data.account_id,
UserPrivateAccountData{ key_chain: data.key_chain, accounts: vec![(data.identifier, data.account)]});
UserPrivateAccountData {
key_chain: data.key_chain,
accounts: vec![(data.identifier, data.account)],
},
);
}
},
}
@ -120,7 +124,11 @@ impl WalletChainStore {
account.program_owner = Program::authenticated_transfer_program().id();
private_init_acc_map.insert(
data.account_id,
UserPrivateAccountData{key_chain: data.key_chain, accounts:vec![(data.identifier, account)]});
UserPrivateAccountData {
key_chain: data.key_chain,
accounts: vec![(data.identifier, account)],
},
);
}
}
}
@ -185,10 +193,12 @@ impl WalletChainStore {
.entry(account_id)
{
let entry = entry.get_mut();
let identifier = entry.accounts
let identifier = entry
.accounts
.iter()
.find_map(|(id, _)| {
(nssa::AccountId::from((&entry.key_chain.nullifier_public_key, *id)) == account_id)
(nssa::AccountId::from((&entry.key_chain.nullifier_public_key, *id))
== account_id)
.then_some(*id)
})
.unwrap_or(0);