From 0a04a79c1c50f542d08dd455f94b7973029da041 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 | 20 ++++++++++++++++++-- src/components/screen_header.rs | 1 + src/core.rs | 1 + src/main.rs | 11 +++++++++++ 5 files changed, 32 insertions(+), 3 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 f57e916..74b0ac8 100644 --- a/src/components/federation_item.rs +++ b/src/components/federation_item.rs @@ -1,6 +1,6 @@ -use fedimint_core::config::FederationId; +use fedimint_core::{config::FederationId, core::ModuleKind}; use iced::{ - widget::{column, row, text}, + widget::{column, row}, Element, }; @@ -13,6 +13,7 @@ pub struct FederationItem { pub id: FederationId, pub name: String, pub guardians: Option>, + pub module_kinds: Option>, } pub fn h_federation_item(item: &FederationItem) -> Element { @@ -20,6 +21,7 @@ pub fn h_federation_item(item: &FederationItem) -> Element { id, name, guardians, + module_kinds, } = item; let name_row = row![ @@ -45,5 +47,19 @@ pub fn h_federation_item(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 f9d8904..53f5f02 100644 --- a/src/components/screen_header.rs +++ b/src/components/screen_header.rs @@ -13,6 +13,7 @@ pub fn h_screen_header(harbor: &HarborWallet, show_balance: bool) -> Element>() } diff --git a/src/main.rs b/src/main.rs index 7d7ca8a..650aa66 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ use bitcoin::Address; use components::{FederationItem, Toast, ToastManager, ToastStatus, TransactionItem}; use core::run_core; use fedimint_core::api::InviteCode; +use fedimint_core::core::ModuleKind; use fedimint_ln_common::lightning_invoice::Bolt11Invoice; use iced::widget::qr_code::Data; use routes::Route; @@ -439,6 +440,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), @@ -538,6 +540,7 @@ impl HarborWallet { } CoreUIMsg::AddFederationFailed(reason) => { self.add_federation_failure_reason = Some(reason); + self.peek_federation_item = None; Command::none() } CoreUIMsg::FederationInfo(config) => { @@ -551,6 +554,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(), @@ -560,6 +569,7 @@ impl HarborWallet { id, name, guardians: Some(guardians), + module_kinds: Some(module_kinds), }; self.peek_federation_item = Some(item); @@ -568,6 +578,7 @@ impl HarborWallet { } CoreUIMsg::AddFederationSuccess => { self.mint_invite_code_str = String::new(); + self.peek_federation_item = None; Command::none() } CoreUIMsg::FederationListUpdated(list) => {