Skip to content

Commit

Permalink
feat: added modules to peek
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlwn123 committed Jun 1, 2024
1 parent d6efa59 commit 0a04a79
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
diesel migration revert --all --database-url=harbor.sqlite && diesel migration run --database-url=harbor.sqlite
20 changes: 18 additions & 2 deletions src/components/federation_item.rs
Original file line number Diff line number Diff line change
@@ -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,
};

Expand All @@ -13,13 +13,15 @@ pub struct FederationItem {
pub id: FederationId,
pub name: String,
pub guardians: Option<Vec<String>>,
pub module_kinds: Option<Vec<ModuleKind>>,
}

pub fn h_federation_item(item: &FederationItem) -> Element<Message> {
let FederationItem {
id,
name,
guardians,
module_kinds,
} = item;

let name_row = row![
Expand All @@ -45,5 +47,19 @@ pub fn h_federation_item(item: &FederationItem) -> Element<Message> {
column = column.push(guardians_row);
}

if let Some(module_kinds) = module_kinds {
let module_str = module_kinds
.iter()
.map(|m| m.to_string())
.collect::<Vec<String>>()
.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()
}
1 change: 1 addition & 0 deletions src/components/screen_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub fn h_screen_header(harbor: &HarborWallet, show_balance: bool) -> Element<Mes
name,
id: _id,
guardians: _guardians,
module_kinds: _module_kinds,
} = item;
let people_icon = map_icon(SvgIcon::People, 24., 24.);
let current_federation = row![people_icon, text(name).size(24)]
Expand Down
1 change: 1 addition & 0 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ impl HarborCore {
.get_meta("federation_name")
.unwrap_or("Unknown".to_string()),
guardians: None,
module_kinds: None,
})
.collect::<Vec<FederationItem>>()
}
Expand Down
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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) => {
Expand All @@ -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::<Vec<ModuleKind>>();

let name = match name {
Ok(Some(n)) => n,
_ => "Unknown".to_string(),
Expand All @@ -560,6 +569,7 @@ impl HarborWallet {
id,
name,
guardians: Some(guardians),
module_kinds: Some(module_kinds),
};

self.peek_federation_item = Some(item);
Expand All @@ -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) => {
Expand Down

0 comments on commit 0a04a79

Please sign in to comment.