From 15f6306362cc567df719d5d73fdfde93b434915f Mon Sep 17 00:00:00 2001 From: Artem Gureev Date: Wed, 1 Jul 2026 17:54:26 +0000 Subject: [PATCH] refactor(wallet): place private_accounts next to private_account --- lez/wallet/src/storage/key_chain.rs | 66 ++++++++++++++--------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/lez/wallet/src/storage/key_chain.rs b/lez/wallet/src/storage/key_chain.rs index 60df6945..50c6e68d 100644 --- a/lez/wallet/src/storage/key_chain.rs +++ b/lez/wallet/src/storage/key_chain.rs @@ -218,6 +218,39 @@ impl UserKeyChain { }) } + /// Iterates every owned private account (imported and generated), one + /// [`FoundPrivateAccount`] per identity. Excludes shared accounts. + pub fn private_accounts(&self) -> impl Iterator> { + self.imported_private_accounts + .iter() + .flat_map(|(key, data)| { + data.accounts + .iter() + .map(|(kind, account)| FoundPrivateAccount { + account, + key_chain: &key.key_chain, + kind, + chain_index: key.chain_index.clone(), + }) + }) + .chain( + self.private_key_tree + .key_map + .iter() + .flat_map(|(chain_index, data)| { + data.value + .1 + .iter() + .map(|(kind, account)| FoundPrivateAccount { + account, + key_chain: &data.value.0, + kind, + chain_index: Some(chain_index.clone()), + }) + }), + ) + } + #[must_use] pub fn private_account_key_chain_by_index( &self, @@ -253,39 +286,6 @@ impl UserKeyChain { ) } - /// Iterates every owned private account (imported and generated), one - /// [`FoundPrivateAccount`] per identity. Excludes shared accounts. - pub fn private_accounts(&self) -> impl Iterator> { - self.imported_private_accounts - .iter() - .flat_map(|(key, data)| { - data.accounts - .iter() - .map(|(kind, account)| FoundPrivateAccount { - account, - key_chain: &key.key_chain, - kind, - chain_index: key.chain_index.clone(), - }) - }) - .chain( - self.private_key_tree - .key_map - .iter() - .flat_map(|(chain_index, data)| { - data.value - .1 - .iter() - .map(|(kind, account)| FoundPrivateAccount { - account, - key_chain: &data.value.0, - kind, - chain_index: Some(chain_index.clone()), - }) - }), - ) - } - /// Re-derives the [`PrivateKeyHolder`] for a shared account `entry`, dispatching on PDA vs /// regular. `None` if the group key holder is absent or a PDA entry lacks its program id. #[must_use]