From 594e98477e2f68ff9c4a92334f198b2be5f97c84 Mon Sep 17 00:00:00 2001 From: Hansie Odendaal <39146854+hansieodendaal@users.noreply.github.com> Date: Fri, 6 Sep 2024 07:35:30 +0200 Subject: [PATCH] feat: add console wallet detail (#6531) Description --- Added console wallet detail: - Receive tab: `Node ID` => `Node ID / Public key` - Network tab: `Type, Public key` => `Type, Node ID, Public key` Motivation and Context --- To provide more useable information. How Has This Been Tested? --- System-level testing. What process can a PR reviewer use to test or verify this change? --- Code review, system-level testing. Breaking Changes --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify --- .../src/ui/components/network_tab.rs | 11 +++++++---- .../src/ui/components/receive_tab.rs | 7 ++++++- .../minotari_console_wallet/src/ui/state/app_state.rs | 3 +++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/applications/minotari_console_wallet/src/ui/components/network_tab.rs b/applications/minotari_console_wallet/src/ui/components/network_tab.rs index 35cb233f91..e87ce4c997 100644 --- a/applications/minotari_console_wallet/src/ui/components/network_tab.rs +++ b/applications/minotari_console_wallet/src/ui/components/network_tab.rs @@ -69,7 +69,7 @@ impl NetworkTab { f.render_widget(block, area); let areas = Layout::default() - .constraints([Constraint::Length(2), Constraint::Min(8)].as_ref()) + .constraints([Constraint::Length(1), Constraint::Min(8)].as_ref()) .margin(1) .split(area); @@ -91,6 +91,7 @@ impl NetworkTab { let mut column0_items = Vec::with_capacity(capacity); let mut column1_items = Vec::with_capacity(capacity); + let mut column2_items = Vec::with_capacity(capacity); let styles: HashMap = [ (true, Style::default().fg(Color::White).add_modifier(Modifier::BOLD)), @@ -107,7 +108,8 @@ impl NetworkTab { .unwrap_or(&Style::default().fg(Color::Reset)) .to_owned(); column0_items.push(ListItem::new(Span::styled(peer_type, style))); - column1_items.push(ListItem::new(Span::styled(peer.public_key.to_string(), style))); + column1_items.push(ListItem::new(Span::styled(peer.node_id.to_string(), style))); + column2_items.push(ListItem::new(Span::styled(peer.public_key.to_string(), style))); } self.base_node_list_state.set_num_items(capacity); @@ -119,8 +121,9 @@ impl NetworkTab { .highlight_style(Style::default().add_modifier(Modifier::BOLD).fg(Color::Magenta)) .heading_style(Style::default().fg(Color::Magenta)) .max_width(MAX_WIDTH) - .add_column(Some("Type"), Some(28), column0_items) - .add_column(Some("Public Key"), Some(65), column1_items); + .add_column(Some("Type"), Some(17), column0_items) + .add_column(Some("NodeID"), Some(27), column1_items) + .add_column(Some("Public Key"), Some(65), column2_items); column_list.render(f, areas[1], &mut base_node_list_state); } diff --git a/applications/minotari_console_wallet/src/ui/components/receive_tab.rs b/applications/minotari_console_wallet/src/ui/components/receive_tab.rs index 10617063d7..618ad5ee4c 100644 --- a/applications/minotari_console_wallet/src/ui/components/receive_tab.rs +++ b/applications/minotari_console_wallet/src/ui/components/receive_tab.rs @@ -61,7 +61,7 @@ impl ReceiveTab { const ITEM_01: &str = "Tari Address interactive: "; const ITEM_02: &str = "Tari Address one-sided: "; - const ITEM_03: &str = "Node ID: "; + const ITEM_03: &str = "Node ID / Public key: "; const ITEM_04: &str = "Network Address: "; const ITEM_05: &str = "Interactive emoji address: "; const ITEM_06: &str = "One-sided emoji address: "; @@ -94,6 +94,11 @@ impl ReceiveTab { app_state.get_identity().node_id.clone(), Style::default().fg(Color::White), ), + Span::styled(" / ", Style::default().fg(Color::White)), + Span::styled( + app_state.get_identity().public_key.clone(), + Style::default().fg(Color::White), + ), ]); let paragraph = Paragraph::new(node_id_text).block(Block::default()); f.render_widget(paragraph, details_chunks[2]); diff --git a/applications/minotari_console_wallet/src/ui/state/app_state.rs b/applications/minotari_console_wallet/src/ui/state/app_state.rs index 513884a3d6..686648a0ed 100644 --- a/applications/minotari_console_wallet/src/ui/state/app_state.rs +++ b/applications/minotari_console_wallet/src/ui/state/app_state.rs @@ -942,6 +942,7 @@ impl AppStateInner { .join(", "), qr_code: image, node_id: wallet_id.node_identity.node_id().to_string(), + public_key: wallet_id.node_identity.public_key().to_string(), }; self.data.my_identity = identity; self.updated = true; @@ -1301,6 +1302,7 @@ impl AppStateData { .join(", "), qr_code: image, node_id: wallet_identity.node_identity.node_id().to_string(), + public_key: wallet_identity.node_identity.public_key().to_string(), }; let base_node_previous = base_node_selected.clone(); @@ -1354,6 +1356,7 @@ pub struct MyIdentity { pub network_address: String, pub qr_code: String, pub node_id: String, + pub public_key: String, } #[derive(Clone, Debug)]