diff --git a/Cargo.toml b/Cargo.toml index 2f90cd6..b500431 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.25" +version = "0.3.26" edition = "2021" [dependencies] diff --git a/src/components/validator/reward_details.rs b/src/components/validator/reward_details.rs index 1263265..aa6bb04 100644 --- a/src/components/validator/reward_details.rs +++ b/src/components/validator/reward_details.rs @@ -8,6 +8,7 @@ use ratatui::{ }; use super::{PartialComponent, Component, CurrentTab}; +use crate::widgets::DotSpinner; use crate::{ action::Action, config::Config, @@ -16,7 +17,7 @@ use crate::{ pub struct RewardDetails { palette: StylePalette, - commission: u32, + commission: Option, nominators_blocked: bool, apy: String, inflation: String, @@ -33,7 +34,7 @@ impl RewardDetails { pub fn new() -> Self { Self { palette: StylePalette::default(), - commission: 0, + commission: None, nominators_blocked: false, apy: String::from("0.0%"), inflation: String::from("0.0%"), @@ -42,11 +43,12 @@ impl RewardDetails { } fn comission_to_string(&self) -> String { - if self.nominators_blocked { - "blocked".to_string() - } else { - let result = self.commission as f64 / 1_000_000_000.0; - format!("{:.2}%", result) + match self.commission { + Some(commission) => { + if self.nominators_blocked { "blocked".to_string() } + else { format!("{:.2}%", commission as f64 / 1_000_000_000.0) } + }, + None => DotSpinner::default().to_string(), } } } @@ -74,7 +76,7 @@ impl Component for RewardDetails { match action { Action::SetStashAccount(stash) => self.stash = stash, Action::SetValidatorPrefs(commission, disabled, account_id) if self.stash == account_id => { - self.commission = commission; + self.commission = Some(commission); self.nominators_blocked = disabled; } Action::Apy(apy) => self.apy = apy, diff --git a/src/network/predefined_calls.rs b/src/network/predefined_calls.rs index 66e5828..b64d2ac 100644 --- a/src/network/predefined_calls.rs +++ b/src/network/predefined_calls.rs @@ -514,12 +514,12 @@ pub async fn get_validator_prefs( ) -> Result<()> { let maybe_validator_prefs = super::raw_calls::staking::validators(api, None, account_id) .await?; - let (comission, blocked) = match maybe_validator_prefs { - Some(prefs) => (prefs.commission.0, prefs.blocked), - None => (0, false), - }; - - action_tx.send(Action::SetValidatorPrefs(comission, blocked, *account_id))?; + if let Some(prefs) = maybe_validator_prefs { + action_tx.send(Action::SetValidatorPrefs( + prefs.commission.0, + prefs.blocked, + *account_id))?; + } Ok(()) }