From b9c863e2eab900db55c80c52eed02c4103684e9a Mon Sep 17 00:00:00 2001 From: Uncle Stretch Date: Fri, 8 Aug 2025 02:27:40 +0300 Subject: [PATCH] align tables on validator tab with additional values Signed-off-by: Uncle Stretch --- Cargo.toml | 2 +- src/action.rs | 2 ++ src/components/validator/gatekeeper_details.rs | 10 ++-------- src/components/validator/gatekeepers.rs | 3 +-- src/components/validator/mod.rs | 6 +++--- src/components/validator/reward_details.rs | 11 +++++++++-- src/components/validator/staking_details.rs | 7 +++++++ src/network/predefined_calls.rs | 11 ++++++++--- 8 files changed, 33 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1de0cfa..35bed31 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.65" +version = "0.3.66" edition = "2021" homepage = "https://git.ghostchain.io/ghostchain" repository = "https://git.ghostchain.io/ghostchain/ghost-eye" diff --git a/src/action.rs b/src/action.rs index f59b075..a140195 100644 --- a/src/action.rs +++ b/src/action.rs @@ -78,6 +78,8 @@ pub enum Action { NominatorsNumber(u32), Inflation(String), Apy(String), + TreasuryApy(String), + NextReward(u128), GetBlockAuthor(H256, Vec), SetBlockAuthor(H256, String), diff --git a/src/components/validator/gatekeeper_details.rs b/src/components/validator/gatekeeper_details.rs index 169a6e5..a069443 100644 --- a/src/components/validator/gatekeeper_details.rs +++ b/src/components/validator/gatekeeper_details.rs @@ -20,7 +20,6 @@ use crate::{ struct Details { incoming_fee: String, outgoing_fee: String, - gatekeeper: String, } #[derive(Default)] @@ -58,9 +57,8 @@ impl Component for GatekeeperDetails { }, Action::SetGatekeepedNetwork(network) => { self.gatekeeper_details.insert(network.chain_id, Details { - incoming_fee: format!("{:.5}%", network.incoming_fee as f64 / 1_000_000_000.0), - outgoing_fee: format!("{:.5}%", network.outgoing_fee as f64 / 1_000_000_000.0), - gatekeeper: network.gatekeeper, + incoming_fee: format!("{:.5}%", network.incoming_fee as f64 / 10_000_000.0), + outgoing_fee: format!("{:.5}%", network.outgoing_fee as f64 / 10_000_000.0), }); } _ => {} @@ -100,10 +98,6 @@ impl Component for GatekeeperDetails { Cell::from(Text::from("Outgoing fee".to_string()).alignment(Alignment::Left)), Cell::from(Text::from(current_gatekeeper_details.outgoing_fee).alignment(Alignment::Right)), ]), - Row::new(vec![ - Cell::from(Text::from("Gatekeeper".to_string()).alignment(Alignment::Left)), - Cell::from(Text::from(current_gatekeeper_details.gatekeeper).alignment(Alignment::Right)), - ]), ], [ Constraint::Length(12), diff --git a/src/components/validator/gatekeepers.rs b/src/components/validator/gatekeepers.rs index e1fefd3..be7fcd8 100644 --- a/src/components/validator/gatekeepers.rs +++ b/src/components/validator/gatekeepers.rs @@ -203,9 +203,8 @@ impl Component for Gatekeepers { let list = List::new( self.gatekeepers .iter() - .map(|network| ListItem::new(format!("{} ({}) | {}", + .map(|network| ListItem::new(format!("{} (type {})", network.chain_name, - network.chain_id, network.chain_type)) ) ) diff --git a/src/components/validator/mod.rs b/src/components/validator/mod.rs index 6bf83e8..54bbd7c 100644 --- a/src/components/validator/mod.rs +++ b/src/components/validator/mod.rs @@ -287,7 +287,7 @@ impl Component for Validator { pub fn validator_layout(area: Rect) -> [Rect; 4] { Layout::vertical([ - Constraint::Length(19), + Constraint::Length(18), Constraint::Fill(1), Constraint::Fill(1), Constraint::Percentage(25), @@ -315,7 +315,7 @@ pub fn validator_gatekeeped_networks_layout(area: Rect) -> [Rect; 2] { let [_, _, place] = validator_session_and_listen_layout(area); Layout::horizontal([ Constraint::Fill(1), - Constraint::Length(57), + Constraint::Length(30), ]).areas(place) } @@ -333,6 +333,6 @@ pub fn validator_balance_layout(area: Rect) -> [Rect; 3] { Layout::vertical([ Constraint::Length(6), Constraint::Length(6), - Constraint::Length(9), + Constraint::Fill(1), ]).areas(place) } diff --git a/src/components/validator/reward_details.rs b/src/components/validator/reward_details.rs index 336bbff..dd96f31 100644 --- a/src/components/validator/reward_details.rs +++ b/src/components/validator/reward_details.rs @@ -21,6 +21,7 @@ pub struct RewardDetails { commission: Option, nominators_blocked: bool, apy: String, + treasury_apy: String, inflation: String, stash: [u8; 32], in_staking_validators: bool, @@ -43,6 +44,7 @@ impl RewardDetails { commission: None, nominators_blocked: false, apy: String::from("0.0%"), + treasury_apy: String::from("0.0%"), inflation: String::from("0.0%"), stash: [0u8; 32], in_staking_validators: false, @@ -110,6 +112,7 @@ impl Component for RewardDetails { } }, Action::Apy(apy) => self.apy = apy, + Action::TreasuryApy(apy) => self.treasury_apy = apy, Action::Inflation(inflation) => self.inflation = inflation, _ => {} }; @@ -141,16 +144,20 @@ impl Component for RewardDetails { Cell::from(Text::from(self.comission_to_string()).alignment(Alignment::Right)), ]), Row::new(vec![ - Cell::from(Text::from("Current APY".to_string()).alignment(Alignment::Left)), + Cell::from(Text::from("Validator APY".to_string()).alignment(Alignment::Left)), Cell::from(Text::from(self.apy.clone()).alignment(Alignment::Right)), ]), + Row::new(vec![ + Cell::from(Text::from("Treasury APY".to_string()).alignment(Alignment::Left)), + Cell::from(Text::from(self.treasury_apy.clone()).alignment(Alignment::Right)), + ]), Row::new(vec![ Cell::from(Text::from("Inflation".to_string()).alignment(Alignment::Left)), Cell::from(Text::from(self.inflation.clone()).alignment(Alignment::Right)), ]), ], [ - Constraint::Min(11), + Constraint::Min(13), Constraint::Min(0), ], ) diff --git a/src/components/validator/staking_details.rs b/src/components/validator/staking_details.rs index e0bf108..0dec02d 100644 --- a/src/components/validator/staking_details.rs +++ b/src/components/validator/staking_details.rs @@ -20,6 +20,7 @@ pub struct StakingDetails { palette: StylePalette, staked_own: u128, staked_total: u128, + next_reward: u128, stash: [u8; 32], reward_destination: RewardDestination, } @@ -39,6 +40,7 @@ impl StakingDetails { palette: StylePalette::default(), staked_own: 0, staked_total: 0, + next_reward: 0, stash: [0u8; 32], reward_destination: Default::default(), } @@ -89,6 +91,7 @@ impl Component for StakingDetails { fn update(&mut self, action: Action) -> Result> { match action { Action::SetStashAccount(account_id) => self.stash = account_id, + Action::NextReward(next_reward) => self.next_reward = next_reward, Action::SetStakingPayee(destination, account_id) if self.stash == account_id => self.reward_destination = destination, Action::SetStakedRatio(total, own, account_id) if self.stash == account_id => { @@ -119,6 +122,10 @@ impl Component for StakingDetails { Cell::from(Text::from("Other stake".to_string()).alignment(Alignment::Left)), Cell::from(Text::from(self.prepare_u128(self.staked_total.saturating_sub(self.staked_own))).alignment(Alignment::Right)), ]), + Row::new(vec![ + Cell::from(Text::from("Next reward".to_string()).alignment(Alignment::Left)), + Cell::from(Text::from(self.prepare_u128(self.next_reward)).alignment(Alignment::Right)), + ]), ], [ Constraint::Min(11), diff --git a/src/network/predefined_calls.rs b/src/network/predefined_calls.rs index 3cd0369..532b0b9 100644 --- a/src/network/predefined_calls.rs +++ b/src/network/predefined_calls.rs @@ -197,16 +197,21 @@ pub async fn get_inflation( let (inflation, fraction) = super::calculate_for_fraction(total_staked, adjusted_issuance); let current_ratio: f64 = 1.0 + accumulated_commission as f64 / adjusted_issuance as f64; - let yearly_current_ratio = current_ratio.powf(365.0) + 1.0; + let yearly_current_ratio = current_ratio.powf(365.0) - 1.0; - let expected_inflation = (inflation.deconstruct() as f64) * yearly_current_ratio / 1_000_000_000.0; - let expected_fraction = expected_inflation - (fraction.deconstruct() as f64) / 1_000_000_000.0; + let expected_inflation = (inflation.deconstruct() as f64) * yearly_current_ratio / 10_000_000.0; + let expected_fraction = (fraction.deconstruct() as f64) * yearly_current_ratio / 10_000_000.0; + let expected_reminder = expected_inflation - expected_fraction; let inflation_str = format!("{:.4}%", expected_inflation); let fraction_str = format!("{:.4}%", expected_fraction); + let treasury_str = format!("{:.4}%", expected_reminder); action_tx.send(Action::Inflation(inflation_str))?; action_tx.send(Action::Apy(fraction_str))?; + action_tx.send(Action::TreasuryApy(treasury_str))?; + action_tx.send(Action::NextReward(accumulated_commission))?; + Ok(()) }