Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

Commit c848989

Browse files
committed
Fix wallet configuration API model mismatch
1 parent d1cd48c commit c848989

3 files changed

Lines changed: 20 additions & 11 deletions

File tree

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎apps/api/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ prometheus-client = { workspace = true }
1717
strum = { workspace = true }
1818
redis = { workspace = true }
1919
chrono = { workspace = true }
20+
futures = { workspace = true }
2021
gem_hash = { path = "../../crates/gem_hash" }
2122
hex = { workspace = true }
2223
reqwest = { workspace = true }

‎apps/api/src/devices/clients/wallet_configuration.rs‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::collections::HashSet;
22
use std::error::Error;
33

44
use cacher::{CacheKey, CacherClient};
5+
use futures::future::join_all;
56
use primitives::{AddressStatus, Chain, ChainAddress, WalletConfiguration, WalletConfigurationResult, WalletId};
67
use settings_chain::ChainProviders;
78
use storage::{Database, WalletsRepository};
@@ -23,19 +24,25 @@ impl WalletConfigurationClient {
2324
Ok(WalletConfigurationResult {
2425
wallet_id: wallet_identifier,
2526
configuration: WalletConfiguration {
26-
has_multi_signature_accounts: self.has_multi_signature_accounts(device_id, wallet_id).await?.then_some(true),
27+
multi_signature_accounts: self.multi_signature_accounts(device_id, wallet_id).await?,
2728
},
2829
})
2930
}
3031

31-
async fn has_multi_signature_accounts(&self, device_id: i32, wallet_id: i32) -> Result<bool, Box<dyn Error + Send + Sync>> {
32-
for address in self.subscribed_addresses(device_id, wallet_id)? {
33-
if self.get_statuses(address).await.is_some_and(|statuses| statuses.contains(&AddressStatus::MultiSignature)) {
34-
return Ok(true);
35-
}
36-
}
32+
async fn multi_signature_accounts(&self, device_id: i32, wallet_id: i32) -> Result<Vec<ChainAddress>, Box<dyn Error + Send + Sync>> {
33+
Ok(join_all(
34+
self.subscribed_addresses(device_id, wallet_id)?
35+
.into_iter()
36+
.map(|address| async move { self.has_multi_signature_status(&address).await.then_some(address) }),
37+
)
38+
.await
39+
.into_iter()
40+
.flatten()
41+
.collect())
42+
}
3743

38-
Ok(false)
44+
async fn has_multi_signature_status(&self, address: &ChainAddress) -> bool {
45+
self.get_statuses(address).await.is_some_and(|statuses| statuses.contains(&AddressStatus::MultiSignature))
3946
}
4047

4148
fn subscribed_addresses(&self, device_id: i32, wallet_id: i32) -> Result<HashSet<ChainAddress>, Box<dyn Error + Send + Sync>> {
@@ -52,10 +59,10 @@ impl WalletConfigurationClient {
5259
.collect())
5360
}
5461

55-
async fn get_statuses(&self, address: ChainAddress) -> Option<Vec<AddressStatus>> {
62+
async fn get_statuses(&self, address: &ChainAddress) -> Option<Vec<AddressStatus>> {
5663
if let Some(statuses) = self
5764
.cacher
58-
.get_cached_optional::<Vec<AddressStatus>>(cache_key(&address))
65+
.get_cached_optional::<Vec<AddressStatus>>(cache_key(address))
5966
.await
6067
.ok()
6168
.flatten()
@@ -69,7 +76,7 @@ impl WalletConfigurationClient {
6976
return None;
7077
}
7178

72-
let _ = self.cacher.set_cached(cache_key(&address), &statuses).await;
79+
let _ = self.cacher.set_cached(cache_key(address), &statuses).await;
7380

7481
Some(statuses)
7582
}

0 commit comments

Comments
 (0)