From c8956e5c2d645dd51ccabed550b7bc0eaa1346c4 Mon Sep 17 00:00:00 2001 From: Anton Yemelyanov Date: Thu, 7 Dec 2023 00:14:39 +0200 Subject: [PATCH] wip --- .../src/modules/account_manager/estimation.rs | 0 core/src/modules/account_manager/mod.rs | 72 ++++++++++++++----- core/src/modules/account_manager/secret.rs | 21 ++++++ core/src/modules/account_manager/send.rs | 0 core/src/modules/account_manager/transfer.rs | 0 core/src/modules/export.rs | 20 +++--- core/src/primitives/account.rs | 3 +- resources/i18n/i18n.json | 70 +++++++++++++----- 8 files changed, 139 insertions(+), 47 deletions(-) create mode 100644 core/src/modules/account_manager/estimation.rs create mode 100644 core/src/modules/account_manager/secret.rs create mode 100644 core/src/modules/account_manager/send.rs create mode 100644 core/src/modules/account_manager/transfer.rs diff --git a/core/src/modules/account_manager/estimation.rs b/core/src/modules/account_manager/estimation.rs new file mode 100644 index 0000000..e69de29 diff --git a/core/src/modules/account_manager/mod.rs b/core/src/modules/account_manager/mod.rs index abda30d..7ef11fe 100644 --- a/core/src/modules/account_manager/mod.rs +++ b/core/src/modules/account_manager/mod.rs @@ -1,6 +1,7 @@ use crate::imports::*; use crate::primitives::account; use std::borrow::Cow; +use egui_phosphor::thin::{CLOUD_ARROW_DOWN, CLOUD_SLASH}; use kaspa_wallet_core::tx::{GeneratorSummary, PaymentOutput, Fees}; use kaspa_wallet_core::api::*; use crate::primitives::descriptors::*; @@ -10,12 +11,20 @@ mod transactions; mod details; mod utxo; mod menus; +mod transfer; +mod send; +mod estimation; +mod secret; use overview::*; use transactions::*; use details::*; use utxo::*; use menus::*; +use transfer::*; +use send::*; +use estimation::*; +use secret::*; #[allow(dead_code)] @@ -35,7 +44,9 @@ pub enum AccountManagerSection { UtxoManager } -#[derive(Default, Debug, Clone, Copy, Eq, PartialEq)] +// #[derive(Default, Debug, Clone, Copy, Eq, PartialEq)] +// #[derive(Default, Debug, Clone, Eq, PartialEq)] +#[derive(Default, Debug, Clone)] enum Action { #[default] None, @@ -43,14 +54,15 @@ enum Action { Sending, // Reset, Processing, + Error(Arc), } -impl Action { - fn is_sending(&self) -> bool { - matches!(self, Action::Sending | Action::Estimating | Action::Processing) - } -} +// impl Action { +// fn is_sending(&self) -> bool { +// matches!(self, Action::Sending | Action::Estimating | Action::Processing) +// } +// } #[derive(Clone, Copy, Eq, PartialEq)] enum TransactionKind { @@ -115,6 +127,8 @@ impl ManagerContext { } fn reset_send_state(&mut self) { + self.action = Action::None; + self.zeroize() } } @@ -132,7 +146,6 @@ impl Zeroize for ManagerContext { self.priority_fees_sompi = 0; *self.estimate.lock().unwrap() = EstimatorStatus::None; self.address_status = AddressStatus::None; - self.action = Action::None; self.transaction_kind = None; self.focus.clear(); self.wallet_secret.zeroize(); @@ -192,6 +205,13 @@ impl ModuleT for AccountManager { self.state = AccountManagerState::Select; } + // fn reload(&mut self, core : &mut Core) { + // if let AccountManagerState::Overview { account } = self.state.clone() { + // let account_id = account.id(); + // core.account_collection().get() + // } + // } + fn render( &mut self, core: &mut Core, @@ -264,6 +284,32 @@ impl AccountManager { Panel::new(self) .with_caption("Select Account") .with_body(|this, ui| { + + const SPACING : f32 = 8.; + + if !core.state().is_connected() { + ui.add_space(SPACING); + ui.label( + RichText::new(CLOUD_SLASH) + .size(theme_style().icon_size_large) + .color(theme_color().icon_color_default) + ); + ui.add_space(SPACING); + ui.label("You are currently not connected to the Kaspa node."); + ui.add_space(SPACING); + } else if !core.state().is_synced() { + ui.add_space(SPACING); + ui.label( + RichText::new(CLOUD_ARROW_DOWN) + .size(theme_style().icon_size_medium) + .color(theme_color().icon_color_default) + ); + ui.add_space(SPACING); + ui.label("The node is currently syncing with the Kaspa p2p network. Account balances may be out of date."); + ui.add_space(SPACING); + } + + account_collection.iter().for_each(|account_select| { if ui.account_selector_button(account_select, &network_type, false).clicked() { this.select(Some(account_select.clone())); @@ -321,12 +367,6 @@ impl AccountManager { .exact_width(panel_width) .resizable(false) .show_separator_line(true) - // .frame( - // Frame::default() - // .inner_margin(0.) - // .outer_margin(4.) - // .fill(ui.ctx().style().visuals.panel_fill), - // ) .show_inside(ui, |ui| { Overview::new(&mut self.context).render(core,ui,rc); }); @@ -335,12 +375,6 @@ impl AccountManager { .exact_width(panel_width) .resizable(false) .show_separator_line(false) - // .frame( - // Frame::default() - // .inner_margin(0.) - // .outer_margin(4.) - // .fill(ui.ctx().style().visuals.panel_fill), - // ) .show_inside(ui, |ui| { ui.separator(); diff --git a/core/src/modules/account_manager/secret.rs b/core/src/modules/account_manager/secret.rs new file mode 100644 index 0000000..4424226 --- /dev/null +++ b/core/src/modules/account_manager/secret.rs @@ -0,0 +1,21 @@ +use crate::imports::*; +use super::*; + +pub struct AccountSecret<'render> { + core : &'render mut Core, + manager : &'render AccountManager, +} + +impl<'render> AccountSecret<'render> { + + pub fn new(core : &'render mut Core, manager : &'render AccountManager) -> Self { + Self { core, manager } + } + + pub fn render(&mut self, ui : &mut Ui, rc : &RenderContext<'_>) { + + + } + + +} diff --git a/core/src/modules/account_manager/send.rs b/core/src/modules/account_manager/send.rs new file mode 100644 index 0000000..e69de29 diff --git a/core/src/modules/account_manager/transfer.rs b/core/src/modules/account_manager/transfer.rs new file mode 100644 index 0000000..e69de29 diff --git a/core/src/modules/export.rs b/core/src/modules/export.rs index f93f039..a0d39cd 100644 --- a/core/src/modules/export.rs +++ b/core/src/modules/export.rs @@ -110,7 +110,7 @@ impl ModuleT for Export { match self.state.clone() { State::Select => { - let prv_key_data_list = core.prv_key_data_map.values().cloned().collect::>(); + // let prv_key_data_list = core.prv_key_data_map.values().cloned().collect::>(); let mut submit = false; Panel::new(self) @@ -163,8 +163,8 @@ impl ModuleT for Export { }) - .with_footer(|_this,_ui| { - }) + // .with_footer(|_this,_ui| { + // }) .render(ui); if submit { @@ -185,7 +185,7 @@ impl ModuleT for Export { } State::SelectPrvKey => { - let prv_key_data_list = core.prv_key_data_map.values().cloned().collect::>(); + let prv_key_data_map = core.prv_key_data_map.clone(); //values().cloned().collect::>(); let mut submit = false; Panel::new(self) @@ -208,12 +208,14 @@ impl ModuleT for Export { ui.label("Please select private key to export"); ui.label(""); - for prv_key_data_info in prv_key_data_list.into_iter() { - if ui.large_button(prv_key_data_info.name_or_id()).clicked() { - this.context.prv_key_data_id = Some(*prv_key_data_info.id()); - submit = true; + if let Some(prv_key_data_map) = prv_key_data_map { + for prv_key_data_info in prv_key_data_map.values() { + if ui.large_button(prv_key_data_info.name_or_id()).clicked() { + this.context.prv_key_data_id = Some(*prv_key_data_info.id()); + submit = true; + } + ui.label(""); } - ui.label(""); } }) diff --git a/core/src/primitives/account.rs b/core/src/primitives/account.rs index c633de0..0638ca8 100644 --- a/core/src/primitives/account.rs +++ b/core/src/primitives/account.rs @@ -222,7 +222,8 @@ impl AccountSelectorButtonExtension for Ui { let account_name = account.name_or_id(); let icon = if selected { - Composite::icon(egui_phosphor::thin::CHECK) + // Composite::icon(egui_phosphor::thin::CHECK) + Composite::icon(egui_phosphor::thin::ARROW_FAT_RIGHT) } else { Composite::icon(egui_phosphor::thin::LIST_DASHES) }; diff --git a/resources/i18n/i18n.json b/resources/i18n/i18n.json index 75ad107..77c01ad 100644 --- a/resources/i18n/i18n.json +++ b/resources/i18n/i18n.json @@ -13,14 +13,14 @@ "hi": "Hindi", "fi": "Finnish", "vi": "Vietnamese", + "fil": "Filipino", "fa": "Farsi", + "lt": "Lithuanian", + "sv": "Swedish", "pa": "Panjabi", "nl": "Dutch", - "sv": "Swedish", - "fil": "Filipino", - "es": "Español", - "lt": "Lithuanian", "uk": "Ukrainian", + "es": "Español", "af": "Afrikaans", "et": "Esti", "en": "English", @@ -59,22 +59,23 @@ "translations": { "pt": {}, "hi": {}, - "nl": {}, + "fi": {}, "vi": {}, + "fil": {}, "fa": {}, - "pa": {}, - "fi": {}, + "lt": {}, "sv": {}, - "fil": {}, "es": {}, + "pa": {}, + "nl": {}, "uk": {}, - "lt": {}, "af": {}, "et": {}, "en": { - "Network Rx/s": "Network Rx/s", - "Network Tx/s": "Network Tx/s", + "Very weak": "Very weak", "Mainnet (Main Kaspa network)": "Mainnet (Main Kaspa network)", + "Network Tx/s": "Network Tx/s", + "Network Rx/s": "Network Rx/s", "Market": "Market", "Submitted Blocks": "Submitted Blocks", "Credits": "Credits", @@ -82,6 +83,7 @@ "The node runs as a part of the Kaspa-NG application process. This reduces communication overhead (experimental).": "The node runs as a part of the Kaspa-NG application process. This reduces communication overhead (experimental).", "Include Priority Fees": "Include Priority Fees", "Kaspa NG on GitHub": "Kaspa NG on GitHub", + "Please note that the integrated mode is experimental and does not currently show the sync progress information.": "Please note that the integrated mode is experimental and does not currently show the sync progress information.", "wRPC Borsh Rx/s": "wRPC Borsh Rx/s", "Testnet-11 (10 BPS)": "Testnet-11 (10 BPS)", "Kaspa Discord": "Kaspa Discord", @@ -89,6 +91,8 @@ "Borsh Handshake Failures": "Borsh Handshake Failures", "Kaspa NextGen on GitHub": "Kaspa NextGen on GitHub", "Show Grid": "Show Grid", + "None": "None", + "Enables custom arguments for the Rusty Kaspa daemon": "Enables custom arguments for the Rusty Kaspa daemon", "Type": "Type", "Memory": "Memory", "Blocks": "Blocks", @@ -100,12 +104,17 @@ "Track in the background": "Track in the background", "Node Status": "Node Status", "Kaspa NG": "Kaspa NG", + "Enable custom daemon arguments": "Enable custom daemon arguments", "Storage Read/s": "Storage Read/s", + "Rusty Kaspa Daemon Path:": "Rusty Kaspa Daemon Path:", + "Connections": "Connections", + "Allows you to specify custom arguments for the Rusty Kaspa daemon": "Allows you to specify custom arguments for the Rusty Kaspa daemon", "Copied to clipboard": "Copied to clipboard", "CPU": "CPU", "Testnet-10 (1 BPS)": "Testnet-10 (1 BPS)", "Storage Write/s": "Storage Write/s", "GitHub Release": "GitHub Release", + "Screen capture": "Screen capture", "Mass Processed": "Mass Processed", "Derivation Index": "Derivation Index", "Median T": "Median T", @@ -119,14 +128,18 @@ "gRPC User Rx": "gRPC User Rx", "gRPC p2p Tx": "gRPC p2p Tx", "Inbound": "Inbound", - "Music": "Music", "Account Name": "Account Name", + "Music": "Music", "Bezier Curves": "Bezier Curves", - "gRPC p2p Tx/s": "gRPC p2p Tx/s", "Enable gRPC": "Enable gRPC", + "gRPC p2p Tx/s": "gRPC p2p Tx/s", "Enable Experimental Features": "Enable Experimental Features", "Processed Headers": "Processed Headers", "Mempool Size": "Mempool Size", + "Allow custom daemon arguments": "Allow custom daemon arguments", + "Enable Custom Kaspad Arguments": "Enable Custom Kaspad Arguments", + "wRPC URL:": "wRPC URL:", + "All": "All", "Json Connection Attempts": "Json Connection Attempts", "Tools ⏷": "Tools ⏷", "Redistributables": "Redistributables", @@ -136,12 +149,17 @@ "gRPC p2p Rx/s": "gRPC p2p Rx/s", "Not connected": "Not connected", "Copy logs to clipboard": "Copy logs to clipboard", + "Password is too weak": "Password is too weak", "Handles": "Handles", + "Please create a stronger password": "Please create a stronger password", + "Very dangerous (may be cracked within few seconds)": "Very dangerous (may be cracked within few seconds)", "Account:": "Account:", + "Good": "Good", "DAA": "DAA", "Signature Type": "Signature Type", "Time Offset:": "Time Offset:", "Net Rx/s": "Net Rx/s", + "Network": "Network", "Dependencies": "Dependencies", "Active p2p Peers": "Active p2p Peers", "Disable Password Score Restrictions": "Disable Password Score Restrictions", @@ -149,10 +167,13 @@ "GitHub Release Page for": "GitHub Release Page for", "The balance may be out of date during node sync": "The balance may be out of date during node sync", "Parent levels": "Parent levels", + "Continue": "Continue", "WASM SDK for JavaScript and TypeScript": "WASM SDK for JavaScript and TypeScript", "Kaspa p2p Node": "Kaspa p2p Node", + "Enable experimental features": "Enable experimental features", "gRPC User Tx": "gRPC User Tx", "NPM Modules for NodeJS": "NPM Modules for NodeJS", + "wRPC Encoding:": "wRPC Encoding:", "License Information": "License Information", "Storage Write": "Storage Write", "Processed Bodies": "Processed Bodies", @@ -160,22 +181,25 @@ "Processed Mass Counts": "Processed Mass Counts", "User Agent": "User Agent", "bye!": "bye!", + "The node is spawned as a child daemon process (recommended).": "The node is spawned as a child daemon process (recommended).", + "Receive Address": "Receive Address", "Json Handshake Failures": "Json Handshake Failures", "Net Tx/s": "Net Tx/s", "Storage Read": "Storage Read", - "gRPC User Rx/s": "gRPC User Rx/s", - "wRPC JSON Rx": "wRPC JSON Rx", "Network Peers": "Network Peers", "wRPC JSON Rx/s": "wRPC JSON Rx/s", - "The node is spawned as a child daemon process (recommended).": "The node is spawned as a child daemon process (recommended).", "Screen Capture": "Screen Capture", + "gRPC User Rx/s": "gRPC User Rx/s", + "wRPC JSON Rx": "wRPC JSON Rx", "Allows you to take screenshots from within the application": "Allows you to take screenshots from within the application", - "Change Address": "Change Address", "Outbound": "Outbound", - "Receive Address": "Receive Address", + "Change Address": "Change Address", "Build": "Build", "Removes security restrictions, allows for single-letter passwords": "Removes security restrictions, allows for single-letter passwords", + "Enable optional BIP39 passphrase": "Enable optional BIP39 passphrase", "gRPC p2p Rx": "gRPC p2p Rx", + "Skip": "Skip", + "Dangerous": "Dangerous", "Total Tx": "Total Tx", "Peers": "Peers", "Processed Transactions": "Processed Transactions", @@ -186,15 +210,21 @@ "wRPC Borsh Rx": "wRPC Borsh Rx", "Protocol:": "Protocol:", "Transactions": "Transactions", + "Allow Custom Rusty Kaspa Daemon Arguments": "Allow Custom Rusty Kaspa Daemon Arguments", "gRPC User Tx/s": "gRPC User Tx/s", "wRPC JSON Tx/s": "wRPC JSON Tx/s", "Virt Parents": "Virt Parents", + "Are you sure you want to reset all settings?": "Are you sure you want to reset all settings?", "DB Blocks": "DB Blocks", "File Handles": "File Handles", "Show DAA": "Show DAA", "Json Active Connections": "Json Active Connections", + "Allow Custom Rusty Kaspa Arguments": "Allow Custom Rusty Kaspa Arguments", "Tools": "Tools", + "Weak": "Weak", "wRPC Borsh Tx/s": "wRPC Borsh Tx/s", + "Passwords do not match": "Passwords do not match", + "Disable password score restrictions": "Disable password score restrictions", "Database Headers": "Database Headers", "Tip Hashes": "Tip Hashes", "Resources": "Resources", @@ -206,18 +236,22 @@ "Bodies": "Bodies", "Network Difficulty": "Network Difficulty", "IBD:": "IBD:", + "Key Perf.": "Key Perf.", "Processed Dependencies": "Processed Dependencies", + "Bandwidth": "Bandwidth", "Total Rx": "Total Rx", "Rust Wallet SDK": "Rust Wallet SDK", "Enables features currently in development": "Enables features currently in development", "Show VSPC": "Show VSPC", "Update Available": "Update Available", + "Unable to change node settings until the problem is resolved.": "Unable to change node settings until the problem is resolved.", "Enter the password to unlock your wallet": "Enter the password to unlock your wallet", "Borsh Active Connections": "Borsh Active Connections", "wRPC JSON Tx": "wRPC JSON Tx", "Virtual DAA Score": "Virtual DAA Score", "Please wait for the node to sync...": "Please wait for the node to sync...", "Wallet:": "Wallet:", + "Storage": "Storage", "Double click on the graph to re-center...": "Double click on the graph to re-center...", "Stor Read": "Stor Read", "Database Blocks": "Database Blocks",