From 043aec2b65e6fc8546c39c7013ec481b0e8b36c5 Mon Sep 17 00:00:00 2001 From: Alex Lewin Date: Sat, 1 Jun 2024 16:54:13 -0400 Subject: [PATCH] feat: added modules to peek --- justfile | 2 +- src/components/federation_item.rs | 19 ++++++++++++++++++- src/components/screen_header.rs | 1 + src/core.rs | 1 + src/fedimint_client.rs | 1 + src/main.rs | 11 +++++++++++ 6 files changed, 33 insertions(+), 2 deletions(-) diff --git a/justfile b/justfile index f74d5dc..de244f9 100644 --- a/justfile +++ b/justfile @@ -20,4 +20,4 @@ clippy: cargo clippy --all-features --tests -- -D warnings reset-db: - diesel migration revert --all --database-url=harbor.sqlite && diesel migration run --database-url=harbor.sqlite \ No newline at end of file + diesel migration revert --all --database-url=harbor.sqlite && diesel migration run --database-url=harbor.sqlite diff --git a/src/components/federation_item.rs b/src/components/federation_item.rs index 941e569..a6e5689 100644 --- a/src/components/federation_item.rs +++ b/src/components/federation_item.rs @@ -1,4 +1,4 @@ -use fedimint_core::config::FederationId; +use fedimint_core::{config::FederationId, core::ModuleKind}; use iced::{ widget::{column, row, text}, Alignment, Element, @@ -15,6 +15,7 @@ pub struct FederationItem { pub name: String, pub balance: u64, pub guardians: Option>, + pub module_kinds: Option>, } pub fn h_federation_item(item: &FederationItem) -> Element { @@ -23,6 +24,7 @@ pub fn h_federation_item(item: &FederationItem) -> Element { name, balance, guardians: _, + module_kinds: _, } = item; let title = row![map_icon(SvgIcon::People, 24., 24.), text(name).size(24)] .align_items(Alignment::Center) @@ -42,6 +44,7 @@ pub fn h_federation_item2(item: &FederationItem) -> Element { name, balance: _, guardians, + module_kinds, } = item; let name_row = row![ @@ -67,5 +70,19 @@ pub fn h_federation_item2(item: &FederationItem) -> Element { column = column.push(guardians_row); } + if let Some(module_kinds) = module_kinds { + let module_str = module_kinds + .iter() + .map(|m| m.to_string()) + .collect::>() + .join(", "); + let modules_row = row![ + bold_text("Modules: ".to_string(), 24), + regular_text(module_str, 24), + ] + .spacing(8); + column = column.push(modules_row); + } + column.into() } diff --git a/src/components/screen_header.rs b/src/components/screen_header.rs index c75df84..ef34ee2 100644 --- a/src/components/screen_header.rs +++ b/src/components/screen_header.rs @@ -14,6 +14,7 @@ pub fn h_screen_header(harbor: &HarborWallet, show_balance: bool) -> Element>() } diff --git a/src/fedimint_client.rs b/src/fedimint_client.rs index fc90a90..aa09118 100644 --- a/src/fedimint_client.rs +++ b/src/fedimint_client.rs @@ -44,6 +44,7 @@ pub(crate) struct FedimintClient { stop: Arc, } +#[allow(dead_code)] #[derive(Debug, Clone)] pub enum FederationInviteOrId { Invite(InviteCode), diff --git a/src/main.rs b/src/main.rs index b7fdc37..743f3ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ use components::{FederationItem, Toast, ToastManager, ToastStatus, TransactionIt use core::run_core; use fedimint_core::api::InviteCode; use fedimint_core::config::FederationId; +use fedimint_core::core::ModuleKind; use fedimint_ln_common::lightning_invoice::Bolt11Invoice; use iced::widget::qr_code::Data; use routes::Route; @@ -459,6 +460,7 @@ impl HarborWallet { Message::PeekFederation(invite_code) => { let invite = InviteCode::from_str(&invite_code); if let Ok(invite) = invite { + self.add_federation_failure_reason = None; let id = Uuid::new_v4(); // todo use this id somewhere Command::perform( Self::async_peek_federation(self.ui_handle.clone(), id, invite), @@ -558,6 +560,7 @@ impl HarborWallet { } CoreUIMsg::AddFederationFailed(reason) => { self.add_federation_failure_reason = Some(reason); + self.peek_federation_item = None; Command::none() } CoreUIMsg::FederationInfo(config) => { @@ -571,6 +574,12 @@ impl HarborWallet { .map(|url| url.name.clone()) .collect(); + let module_kinds = config + .modules + .into_values() + .map(|module_config| module_config.kind().to_owned()) + .collect::>(); + let name = match name { Ok(Some(n)) => n, _ => "Unknown".to_string(), @@ -582,6 +591,7 @@ impl HarborWallet { name, balance: 0, guardians: Some(guardians), + module_kinds: Some(module_kinds), }; self.peek_federation_item = Some(item); @@ -591,6 +601,7 @@ impl HarborWallet { CoreUIMsg::AddFederationSuccess => { self.mint_invite_code_str = String::new(); self.active_route = Route::Mints(routes::MintSubroute::List); + self.peek_federation_item = None; Command::none() } CoreUIMsg::FederationListUpdated(list) => {