validator status detection draft added

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch 2025-02-18 17:54:20 +03:00
parent e16d319b72
commit c4f0f6f35c
Signed by: str3tch
GPG Key ID: 84F3190747EE79AA
2 changed files with 14 additions and 2 deletions

View File

@ -2,7 +2,7 @@
name = "ghost-eye"
authors = ["str3tch <stretch@ghostchain.io>"]
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
version = "0.3.39"
version = "0.3.40"
edition = "2021"
[dependencies]

View File

@ -22,6 +22,8 @@ pub struct RewardDetails {
apy: String,
inflation: String,
stash: [u8; 32],
in_staking_validators: bool,
in_session_validators: bool,
}
impl Default for RewardDetails {
@ -39,6 +41,8 @@ impl RewardDetails {
apy: String::from("0.0%"),
inflation: String::from("0.0%"),
stash: [0u8; 32],
in_staking_validators: false,
in_session_validators: false,
}
}
@ -77,6 +81,7 @@ impl Component for RewardDetails {
Action::SetStashAccount(stash) => self.stash = stash,
Action::SetValidatorPrefs(commission, disabled, account_id) if self.stash == account_id => {
self.commission = commission;
self.in_staking_validators = commission.is_some();
self.nominators_blocked = disabled;
}
Action::Apy(apy) => self.apy = apy,
@ -90,6 +95,13 @@ impl Component for RewardDetails {
let [_, _, place] = super::validator_balance_layout(area);
let (border_style, border_type) = self.palette.create_border_style(false);
let staking_status = match (self.in_staking_validators, self.in_session_validators) {
(false, false) => "Staking status: Nothing".to_string(),
(true, false) => "Staking status: Active".to_string(),
(false, true) => "Staking status: Pending".to_string(),
(true, true) => "Staking status: Active".to_string(),
};
let table = Table::new(
vec![
Row::new(vec![
@ -117,7 +129,7 @@ impl Component for RewardDetails {
.border_type(border_type)
.title_alignment(Alignment::Right)
.title_style(self.palette.create_title_style(false))
.title("Reward details"));
.title(staking_status));
frame.render_widget(table, place);