Skip to content

Commit

Permalink
Add "Create wallet" button next to reward address
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Jul 24, 2024
1 parent a8ca670 commit 644a868
Showing 1 changed file with 50 additions and 32 deletions.
82 changes: 50 additions & 32 deletions src/frontend/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub enum DirectoryKind {
pub enum ConfigurationInput {
AddFarm,
RewardAddressChanged(String),
CreateWallet,
OpenDirectory(DirectoryKind),
DirectorySelected(PathBuf),
SubstratePortChanged(u16),
Expand Down Expand Up @@ -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)"
),
},
},
},
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 644a868

Please sign in to comment.