From 644a868966fb07d89da5dba7396f9f338c691f04 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Wed, 24 Jul 2024 14:24:37 +0300 Subject: [PATCH 1/2] Add "Create wallet" button next to reward address --- src/frontend/configuration.rs | 82 +++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 32 deletions(-) diff --git a/src/frontend/configuration.rs b/src/frontend/configuration.rs index 3cfe6e3b..12cb59c5 100644 --- a/src/frontend/configuration.rs +++ b/src/frontend/configuration.rs @@ -28,6 +28,7 @@ pub enum DirectoryKind { pub enum ConfigurationInput { AddFarm, RewardAddressChanged(String), + CreateWallet, OpenDirectory(DirectoryKind), DirectorySelected(PathBuf), SubstratePortChanged(u16), @@ -253,40 +254,50 @@ impl AsyncComponent for ConfigurationView { set_label: "Rewards address", }, - gtk::Entry { - connect_activate[sender] => move |entry| { - sender.input(ConfigurationInput::RewardAddressChanged( - entry.text().into() - )); - }, - connect_changed[sender] => move |entry| { - sender.input(ConfigurationInput::RewardAddressChanged( - entry.text().into() - )); + gtk::Box { + add_css_class: "linked", + + gtk::Entry { + connect_activate[sender] => move |entry| { + sender.input(ConfigurationInput::RewardAddressChanged( + entry.text().into() + )); + }, + connect_changed[sender] => move |entry| { + sender.input(ConfigurationInput::RewardAddressChanged( + entry.text().into() + )); + }, + #[track = "model.reward_address.changed_is_valid()"] + set_css_classes: if model.reward_address.is_valid { + &["valid-input"] + } else { + &["invalid-input"] + }, + set_hexpand: true, + set_placeholder_text: Some( + "Example: stB4S14whneyomiEa22Fu2PzVoibMB7n5PvBFUwafbCbRkC1K", + ), + set_primary_icon_name: Some(icon_name::WALLET2), + set_primary_icon_activatable: false, + set_primary_icon_sensitive: false, + #[track = "model.reward_address.changed_is_valid()"] + set_secondary_icon_name: model.reward_address.icon(), + set_secondary_icon_activatable: false, + set_secondary_icon_sensitive: false, + #[track = "model.reward_address.changed_value()"] + set_text: &model.reward_address, + set_tooltip_markup: Some( + "Use Subwallet or polkadot{.js} extension or any other \ + Substrate wallet to create it first (address for any Substrate \ + chain in SS58 format works)" + ), }, - #[track = "model.reward_address.changed_is_valid()"] - set_css_classes: if model.reward_address.is_valid { - &["valid-input"] - } else { - &["invalid-input"] + + gtk::Button { + connect_clicked => ConfigurationInput::CreateWallet, + set_label: "Create wallet", }, - set_placeholder_text: Some( - "Example: stB4S14whneyomiEa22Fu2PzVoibMB7n5PvBFUwafbCbRkC1K", - ), - set_primary_icon_name: Some(icon_name::WALLET2), - set_primary_icon_activatable: false, - set_primary_icon_sensitive: false, - #[track = "model.reward_address.changed_is_valid()"] - set_secondary_icon_name: model.reward_address.icon(), - set_secondary_icon_activatable: false, - set_secondary_icon_sensitive: false, - #[track = "model.reward_address.changed_value()"] - set_text: &model.reward_address, - set_tooltip_markup: Some( - "Use Subwallet or polkadot{.js} extension or any other \ - Substrate wallet to create it first (address for any Substrate \ - chain in SS58 format works)" - ), }, }, }, @@ -624,6 +635,13 @@ impl ConfigurationView { // Nothing }); } + ConfigurationInput::CreateWallet => { + if let Err(error) = + open::that_detached("https://docs.subspace.network/docs/category/wallets") + { + error!(%error, "Failed to open create wallet page in default browser"); + } + } ConfigurationInput::RewardAddressChanged(new_reward_address) => { let new_reward_address = new_reward_address.trim(); self.reward_address From a6612d46469de4860fe77ecb51e2a1d266510eef Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Wed, 24 Jul 2024 14:25:44 +0300 Subject: [PATCH 2/2] Bump version --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a476e91..e27dfdf5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11518,7 +11518,7 @@ dependencies = [ [[package]] name = "space-acres" -version = "0.1.28" +version = "0.1.29" dependencies = [ "anyhow", "arc-swap", diff --git a/Cargo.toml b/Cargo.toml index 7c77aba1..cb4717dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "space-acres" description = "Space Acres is an opinionated GUI application for farming on Subspace Network" license = "0BSD" -version = "0.1.28" +version = "0.1.29" authors = ["Nazar Mokrynskyi "] repository = "https://github.com/subspace/space-acres" edition = "2021"