diff --git a/Cargo.toml b/Cargo.toml index adbfa29..62f9cb3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "ghost-eye" authors = ["str3tch "] description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost" -version = "0.3.46" +version = "0.3.47" edition = "2021" homepage = "https://git.ghostchain.io/ghostchain" repository = "https://git.ghostchain.io/ghostchain/ghost-eye" diff --git a/src/components/nominator/current_validator_details.rs b/src/components/nominator/current_validator_details.rs index 5039b95..cb51d5c 100644 --- a/src/components/nominator/current_validator_details.rs +++ b/src/components/nominator/current_validator_details.rs @@ -163,6 +163,10 @@ impl Component for CurrentValidatorDetails { Cell::from(Text::from("Forbidden".to_string()).alignment(Alignment::Left)), Cell::from(Text::from(self.is_nomination_disabled.to_string()).alignment(Alignment::Right)), ]), + Row::new(vec![ + Cell::from(Text::from("Nominators".to_string()).alignment(Alignment::Left)), + Cell::from(Text::from(self.others_len.to_string()).alignment(Alignment::Right)), + ]), Row::new(vec![ Cell::from(Text::from("Total staked".to_string()).alignment(Alignment::Left)), Cell::from(Text::from(self.prepare_u128(self.total_balance)).alignment(Alignment::Right)), @@ -172,8 +176,8 @@ impl Component for CurrentValidatorDetails { Cell::from(Text::from(self.prepare_u128(self.own_balance)).alignment(Alignment::Right)), ]), Row::new(vec![ - Cell::from(Text::from("Nominators".to_string()).alignment(Alignment::Left)), - Cell::from(Text::from(self.others_len.to_string()).alignment(Alignment::Right)), + Cell::from(Text::from("Imbalance".to_string()).alignment(Alignment::Left)), + Cell::from(Text::from(self.prepare_stake_imbalance()).alignment(Alignment::Right)), ]), Row::new(vec![ Cell::from(Text::from("Commission".to_string()).alignment(Alignment::Left)), @@ -187,10 +191,6 @@ impl Component for CurrentValidatorDetails { Cell::from(Text::from("In next era".to_string()).alignment(Alignment::Left)), Cell::from(Text::from(self.prepare_state_string()).alignment(Alignment::Right)), ]), - Row::new(vec![ - Cell::from(Text::from("Imbalance".to_string()).alignment(Alignment::Left)), - Cell::from(Text::from(self.prepare_stake_imbalance()).alignment(Alignment::Right)), - ]), Row::new(vec![ Cell::from(Text::from("Last payout".to_string()).alignment(Alignment::Left)), Cell::from(Text::from(format!("{} days ago", self.latest_era_claim)).alignment(Alignment::Right)), diff --git a/src/components/nominator/current_validators.rs b/src/components/nominator/current_validators.rs index f29515b..4834c73 100644 --- a/src/components/nominator/current_validators.rs +++ b/src/components/nominator/current_validators.rs @@ -34,6 +34,7 @@ pub struct CurrentValidators { table_state: TableState, individual: Vec, known_validators: std::collections::HashMap<[u8; 32], String>, + checked_validators: std::collections::HashSet<[u8; 32]>, total_points: u32, era_index: u32, my_stash_id: Option<[u8; 32]>, @@ -57,6 +58,7 @@ impl CurrentValidators { table_state: TableState::new(), individual: Default::default(), known_validators: Default::default(), + checked_validators: Default::default(), total_points: 0, era_index: 0, my_stash_id: None, @@ -78,6 +80,23 @@ impl CurrentValidators { } } + fn clear_choosen(&mut self) { + self.checked_validators.clear(); + } + + fn flip_validator_check(&mut self) { + if let Some(index) = self.table_state.selected() { + if let Some(indiv) = self.individual.get(index) { + let current_account_id = indiv.account_id; + if self.checked_validators.contains(¤t_account_id) { + self.checked_validators.remove(¤t_account_id); + } else { + self.checked_validators.insert(current_account_id); + } + } + } + } + fn save_validator_name(&mut self, new_name: String) { if let Some(index) = self.table_state.selected() { let account_id = self.individual[index].account_id; @@ -250,6 +269,8 @@ impl Component for CurrentValidators { KeyCode::Char('g') => self.first_row(), KeyCode::Char('G') => self.last_row(), KeyCode::Char('R') => self.update_known_validator_record(), + KeyCode::Char('C') => self.clear_choosen(), + KeyCode::Enter => self.flip_validator_check(), _ => {}, }; } @@ -266,6 +287,11 @@ impl Component for CurrentValidators { .map(|(index, info)| { let mut address_text = Text::from(info.address.clone()).alignment(Alignment::Center); let mut points_text = Text::from(info.points.to_string()).alignment(Alignment::Right); + let is_choosen_text = if self.checked_validators.contains(&info.account_id) { + ">" + } else { + "" + }; if info.disabled { address_text = address_text.add_modifier(Modifier::CROSSED_OUT); @@ -285,6 +311,7 @@ impl Component for CurrentValidators { .cloned() .unwrap_or("My stash".to_string()); Row::new(vec![ + Cell::from(Text::from(is_choosen_text).alignment(Alignment::Left)), Cell::from(Text::from(name).alignment(Alignment::Left)), Cell::from(address_text), Cell::from(points_text), @@ -295,6 +322,7 @@ impl Component for CurrentValidators { .cloned() .unwrap_or("Ghostie".to_string()); Row::new(vec![ + Cell::from(Text::from(is_choosen_text).alignment(Alignment::Left)), Cell::from(Text::from(name).alignment(Alignment::Left)), Cell::from(address_text), Cell::from(points_text), @@ -302,6 +330,7 @@ impl Component for CurrentValidators { } }), [ + Constraint::Length(1), Constraint::Length(12), Constraint::Min(0), Constraint::Length(6),