validator details from nominator page added
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
a2584f8212
commit
c7cdafe3b6
@ -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.23"
|
||||
version = "0.3.24"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
@ -84,8 +84,8 @@ pub enum Action {
|
||||
GetChainVersion,
|
||||
GetPendingExtrinsics,
|
||||
GetConnectedPeers,
|
||||
GetSessionKeys([u8; 32]),
|
||||
GetQueuedSessionKeys([u8; 32]),
|
||||
GetSessionKeys([u8; 32], bool),
|
||||
GetQueuedSessionKeys([u8; 32], bool),
|
||||
GetListenAddresses,
|
||||
GetLocalIdentity,
|
||||
|
||||
@ -97,13 +97,13 @@ pub enum Action {
|
||||
GetValidatorsNumber,
|
||||
GetNominatorsNumber,
|
||||
GetInflation,
|
||||
GetNominatorsByValidator([u8; 32]),
|
||||
GetValidatorAllRewards([u8; 32]),
|
||||
GetValidatorLedger([u8; 32]),
|
||||
GetIsStashBonded([u8; 32]),
|
||||
GetErasStakersOverview([u8; 32]),
|
||||
GetValidatorPrefs([u8; 32]),
|
||||
GetSlashingSpans([u8; 32]),
|
||||
GetNominatorsByValidator([u8; 32], bool),
|
||||
GetValidatorAllRewards([u8; 32], bool),
|
||||
GetValidatorLedger([u8; 32], bool),
|
||||
GetIsStashBonded([u8; 32], bool),
|
||||
GetErasStakersOverview([u8; 32], bool),
|
||||
GetValidatorPrefs([u8; 32], bool),
|
||||
GetSlashingSpans([u8; 32], bool),
|
||||
GetCurrentValidatorEraRewards,
|
||||
|
||||
SetNodeName(Option<String>),
|
||||
@ -113,6 +113,7 @@ pub enum Action {
|
||||
SetChainVersion(Option<String>),
|
||||
SetStashAccount([u8; 32]),
|
||||
SetStashSecret([u8; 32]),
|
||||
SetChoosenValidator([u8; 32], u32, u32),
|
||||
SetSlashingSpansLength(usize),
|
||||
SetUnlockingIsEmpty(bool),
|
||||
|
||||
@ -127,15 +128,15 @@ pub enum Action {
|
||||
SetSessionKey(String, SessionKeyInfo),
|
||||
SetListenAddresses(Vec<String>),
|
||||
SetLocalIdentity(String),
|
||||
SetNominatorsByValidator(Vec<Nominator>),
|
||||
SetNominatorsByValidator(Vec<Nominator>, [u8; 32]),
|
||||
SetValidatorEraReward(u32, u128),
|
||||
SetValidatorEraClaimed(u32, bool),
|
||||
SetValidatorEraSlash(u32, u128),
|
||||
SetValidatorEraUnlocking(u32, u128),
|
||||
SetIsBonded(bool),
|
||||
SetStakedAmountRatio(u128, u128),
|
||||
SetStakedRatio(u128, u128),
|
||||
SetValidatorPrefs(u32, bool),
|
||||
SetStakedRatio(u128, u128, [u8; 32]),
|
||||
SetValidatorPrefs(u32, bool, [u8; 32]),
|
||||
SetCurrentValidatorEraRewards(u32, u32, Vec<EraRewardPoints>),
|
||||
|
||||
GetTotalIssuance,
|
||||
|
154
src/components/nominator/current_validator_details.rs
Normal file
154
src/components/nominator/current_validator_details.rs
Normal file
@ -0,0 +1,154 @@
|
||||
use std::sync::mpsc::Sender;
|
||||
|
||||
use color_eyre::Result;
|
||||
use ratatui::{
|
||||
layout::{Alignment, Constraint, Rect},
|
||||
text::Text,
|
||||
widgets::{Block, Cell, Row, Table},
|
||||
Frame
|
||||
};
|
||||
|
||||
use super::{Component, PartialComponent, CurrentTab};
|
||||
use crate::{action::Action, config::Config, palette::StylePalette};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CurrentValidatorDetails {
|
||||
network_tx: Option<Sender<Action>>,
|
||||
is_active: bool,
|
||||
palette: StylePalette,
|
||||
choosen: [u8; 32],
|
||||
total_balance: u128,
|
||||
own_balance: u128,
|
||||
others_len: usize,
|
||||
commission: f64,
|
||||
points_ratio: f64,
|
||||
}
|
||||
|
||||
impl Default for CurrentValidatorDetails {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl CurrentValidatorDetails {
|
||||
const TICKER: &str = " CSPR";
|
||||
const DECIMALS: usize = 5;
|
||||
|
||||
pub fn new() -> Self {
|
||||
CurrentValidatorDetails {
|
||||
network_tx: None,
|
||||
is_active: false,
|
||||
choosen: [0u8; 32],
|
||||
total_balance: 0,
|
||||
own_balance: 0,
|
||||
others_len: 0,
|
||||
commission: 0.0,
|
||||
points_ratio: 0.0,
|
||||
palette: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
fn prepare_u128(&self, value: u128) -> String {
|
||||
let value = value as f64 / 10f64.powi(18);
|
||||
let after = Self::DECIMALS;
|
||||
format!("{:.after$}{}", value, Self::TICKER)
|
||||
}
|
||||
|
||||
fn update_choosen_validator(&mut self, account_id: [u8; 32], individual: u32, total: u32) {
|
||||
self.choosen = account_id;
|
||||
self.points_ratio = match total {
|
||||
0 => 0.0,
|
||||
_ => individual as f64 / total as f64,
|
||||
};
|
||||
if let Some(network_tx) = &self.network_tx {
|
||||
let _ = network_tx.send(Action::GetErasStakersOverview(account_id, false));
|
||||
let _ = network_tx.send(Action::GetNominatorsByValidator(account_id, false));
|
||||
let _ = network_tx.send(Action::GetValidatorPrefs(account_id, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialComponent for CurrentValidatorDetails {
|
||||
fn set_active(&mut self, _current_tab: CurrentTab) {}
|
||||
}
|
||||
|
||||
impl Component for CurrentValidatorDetails {
|
||||
fn register_network_handler(&mut self, tx: Sender<Action>) -> Result<()> {
|
||||
self.network_tx = Some(tx);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Nominator) {
|
||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||
self.palette.with_hover_style(style.get("hover_style").copied());
|
||||
self.palette.with_normal_border_style(style.get("normal_border_style").copied());
|
||||
self.palette.with_hover_border_style(style.get("hover_border_style").copied());
|
||||
self.palette.with_normal_title_style(style.get("normal_title_style").copied());
|
||||
self.palette.with_hover_title_style(style.get("hover_title_style").copied());
|
||||
self.palette.with_highlight_style(style.get("highlight_style").copied());
|
||||
self.palette.with_scrollbar_style(style.get("scrollbar_style").copied());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
||||
match action {
|
||||
Action::SetChoosenValidator(account_id, individual, total) => self.update_choosen_validator(account_id, individual, total),
|
||||
Action::SetNominatorsByValidator(noms, account_id) if self.choosen == account_id => self.others_len = noms.len(),
|
||||
Action::SetValidatorPrefs(commission, _, account_id) if self.choosen == account_id =>
|
||||
self.commission = commission as f64 / 1_000_000_000.0,
|
||||
Action::SetStakedRatio(total, own, account_id) if self.choosen == account_id => {
|
||||
self.total_balance = total;
|
||||
self.own_balance = own;
|
||||
},
|
||||
_ => {}
|
||||
};
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
||||
let [_, place] = super::validator_details_layout(area);
|
||||
let (border_style, border_type) = self.palette.create_border_style(self.is_active);
|
||||
|
||||
let table = Table::new(
|
||||
vec![
|
||||
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)),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Cell::from(Text::from("Own stake".to_string()).alignment(Alignment::Left)),
|
||||
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)),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Cell::from(Text::from("Commission".to_string()).alignment(Alignment::Left)),
|
||||
Cell::from(Text::from(format!("{:.4}%", self.commission)).alignment(Alignment::Right)),
|
||||
]),
|
||||
Row::new(vec![
|
||||
Cell::from(Text::from("Points ratio".to_string()).alignment(Alignment::Left)),
|
||||
Cell::from(Text::from(format!("{:.4}%", self.points_ratio)).alignment(Alignment::Right)),
|
||||
]),
|
||||
],
|
||||
[
|
||||
Constraint::Max(12),
|
||||
Constraint::Min(0),
|
||||
],
|
||||
)
|
||||
.column_spacing(1)
|
||||
.highlight_style(self.palette.create_highlight_style())
|
||||
.block(Block::bordered()
|
||||
.border_style(border_style)
|
||||
.border_type(border_type)
|
||||
.title_alignment(Alignment::Right)
|
||||
.title_style(self.palette.create_title_style(false))
|
||||
.title("Validator details"));
|
||||
|
||||
frame.render_widget(table, place);
|
||||
Ok(())
|
||||
}
|
||||
}
|
@ -64,6 +64,15 @@ impl CurrentValidators {
|
||||
}
|
||||
}
|
||||
|
||||
fn update_choosen_details(&self, index: usize) {
|
||||
if let Some(action_tx) = &self.action_tx {
|
||||
let _ = action_tx.send(Action::SetChoosenValidator(
|
||||
self.individual[index].account_id,
|
||||
self.individual[index].points,
|
||||
self.total_points));
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@ -88,8 +97,7 @@ impl CurrentValidators {
|
||||
}
|
||||
|
||||
fn read_known_validators(&mut self, file_path: &PathBuf) -> Result<()> {
|
||||
match File::open(file_path) {
|
||||
Ok(file) => {
|
||||
if let Ok(file) = File::open(file_path) {
|
||||
let reader = BufReader::new(file);
|
||||
for line in reader.lines() {
|
||||
let line = line?.replace("\n", "");
|
||||
@ -105,8 +113,6 @@ impl CurrentValidators {
|
||||
|
||||
let _ = self.known_validators.insert(account_id, name.to_string());
|
||||
}
|
||||
},
|
||||
Err(_) => { }
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -115,6 +121,7 @@ impl CurrentValidators {
|
||||
if self.individual.len() > 0 {
|
||||
self.table_state.select(Some(0));
|
||||
self.scroll_state = self.scroll_state.position(0);
|
||||
self.update_choosen_details(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,6 +138,7 @@ impl CurrentValidators {
|
||||
};
|
||||
self.table_state.select(Some(i));
|
||||
self.scroll_state = self.scroll_state.position(i);
|
||||
self.update_choosen_details(i);
|
||||
}
|
||||
|
||||
fn last_row(&mut self) {
|
||||
@ -138,6 +146,7 @@ impl CurrentValidators {
|
||||
let last = self.individual.len() - 1;
|
||||
self.table_state.select(Some(last));
|
||||
self.scroll_state = self.scroll_state.position(last);
|
||||
self.update_choosen_details(last);
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,6 +163,7 @@ impl CurrentValidators {
|
||||
};
|
||||
self.table_state.select(Some(i));
|
||||
self.scroll_state = self.scroll_state.position(i);
|
||||
self.update_choosen_details(i);
|
||||
}
|
||||
|
||||
fn update_era_rewards(
|
||||
@ -176,11 +186,10 @@ impl CurrentValidators {
|
||||
}
|
||||
}
|
||||
|
||||
let index = self.table_state
|
||||
.selected()
|
||||
.unwrap_or_default();
|
||||
self.scroll_state = self.scroll_state.content_length(self.individual.len());
|
||||
self.scroll_state = self.scroll_state.position(index);
|
||||
if let Some(index) = self.table_state.selected() {
|
||||
self.update_choosen_details(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,7 +209,7 @@ impl Component for CurrentValidators {
|
||||
}
|
||||
|
||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Validator) {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Nominator) {
|
||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||
self.palette.with_hover_style(style.get("hover_style").copied());
|
||||
self.palette.with_normal_border_style(style.get("normal_border_style").copied());
|
||||
|
@ -130,7 +130,7 @@ impl PartialComponent for EventLogs {
|
||||
|
||||
impl Component for EventLogs {
|
||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Validator) {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Nominator) {
|
||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||
self.palette.with_hover_style(style.get("hover_style").copied());
|
||||
self.palette.with_normal_border_style(style.get("normal_border_style").copied());
|
||||
|
@ -14,9 +14,11 @@ use crate::{action::Action, app::Mode, config::Config};
|
||||
mod event_log;
|
||||
mod current_validators;
|
||||
mod rename_known_validator;
|
||||
mod current_validator_details;
|
||||
|
||||
use event_log::EventLogs;
|
||||
use current_validators::CurrentValidators;
|
||||
use current_validator_details::CurrentValidatorDetails;
|
||||
use rename_known_validator::RenameKnownValidator;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
@ -44,6 +46,7 @@ impl Default for Nominator {
|
||||
current_tab: CurrentTab::Nothing,
|
||||
components: vec![
|
||||
Box::new(CurrentValidators::default()),
|
||||
Box::new(CurrentValidatorDetails::default()),
|
||||
Box::new(EventLogs::default()),
|
||||
Box::new(RenameKnownValidator::default()),
|
||||
],
|
||||
@ -176,7 +179,7 @@ pub fn nominator_layout(area: Rect) -> [Rect; 3] {
|
||||
pub fn validator_details_layout(area: Rect) -> [Rect; 2] {
|
||||
let [place, _, _] = nominator_layout(area);
|
||||
Layout::horizontal([
|
||||
Constraint::Percentage(70),
|
||||
Constraint::Percentage(30),
|
||||
Constraint::Percentage(60),
|
||||
Constraint::Percentage(40),
|
||||
]).areas(place)
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ impl Component for RenameKnownValidator {
|
||||
}
|
||||
|
||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Nominator) {
|
||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||
self.palette.with_normal_border_style(style.get("normal_border_style").copied());
|
||||
self.palette.with_normal_title_style(style.get("normal_title_style").copied());
|
||||
|
@ -27,6 +27,7 @@ pub struct NominatorsByValidator {
|
||||
scroll_state: ScrollbarState,
|
||||
table_state: TableState,
|
||||
nominators: Vec<Nominator>,
|
||||
stash: [u8; 32],
|
||||
}
|
||||
|
||||
impl Default for NominatorsByValidator {
|
||||
@ -46,6 +47,7 @@ impl NominatorsByValidator {
|
||||
scroll_state: ScrollbarState::new(0),
|
||||
table_state: TableState::new(),
|
||||
nominators: Vec::new(),
|
||||
stash: [0u8; 32],
|
||||
palette: StylePalette::default(),
|
||||
}
|
||||
}
|
||||
@ -147,7 +149,9 @@ impl Component for NominatorsByValidator {
|
||||
|
||||
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
||||
match action {
|
||||
Action::SetNominatorsByValidator(nominators) => self.update_nominators(nominators),
|
||||
Action::SetStashAccount(stash) => self.stash = stash,
|
||||
Action::SetNominatorsByValidator(nominators, account_id) if self.stash == account_id =>
|
||||
self.update_nominators(nominators),
|
||||
_ => {}
|
||||
};
|
||||
Ok(None)
|
||||
|
@ -20,6 +20,7 @@ pub struct RewardDetails {
|
||||
nominators_blocked: bool,
|
||||
apy: String,
|
||||
inflation: String,
|
||||
stash: [u8; 32],
|
||||
}
|
||||
|
||||
impl Default for RewardDetails {
|
||||
@ -36,6 +37,7 @@ impl RewardDetails {
|
||||
nominators_blocked: false,
|
||||
apy: String::from("0.0%"),
|
||||
inflation: String::from("0.0%"),
|
||||
stash: [0u8; 32],
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +72,8 @@ impl Component for RewardDetails {
|
||||
|
||||
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
||||
match action {
|
||||
Action::SetValidatorPrefs(commission, disabled) => {
|
||||
Action::SetStashAccount(stash) => self.stash = stash,
|
||||
Action::SetValidatorPrefs(commission, disabled, account_id) if self.stash == account_id => {
|
||||
self.commission = commission;
|
||||
self.nominators_blocked = disabled;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ pub struct StakingDetails {
|
||||
palette: StylePalette,
|
||||
staked_own: u128,
|
||||
staked_total: u128,
|
||||
stash: [u8; 32],
|
||||
}
|
||||
|
||||
impl Default for StakingDetails {
|
||||
@ -35,6 +36,7 @@ impl StakingDetails {
|
||||
palette: StylePalette::default(),
|
||||
staked_own: 0,
|
||||
staked_total: 0,
|
||||
stash: [0u8; 32],
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +68,8 @@ impl Component for StakingDetails {
|
||||
|
||||
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
||||
match action {
|
||||
Action::SetStakedRatio(total, own) => {
|
||||
Action::SetStashAccount(account_id) => self.stash = account_id,
|
||||
Action::SetStakedRatio(total, own, account_id) if self.stash == account_id => {
|
||||
self.staked_total = total;
|
||||
self.staked_own = own;
|
||||
}
|
||||
|
@ -203,15 +203,15 @@ impl StashInfo {
|
||||
|
||||
if let Some(network_tx) = &self.network_tx {
|
||||
let _ = network_tx.send(Action::BalanceRequest(account_id, false));
|
||||
let _ = network_tx.send(Action::GetValidatorLedger(account_id));
|
||||
let _ = network_tx.send(Action::GetIsStashBonded(account_id));
|
||||
let _ = network_tx.send(Action::GetErasStakersOverview(account_id));
|
||||
let _ = network_tx.send(Action::GetValidatorPrefs(account_id));
|
||||
let _ = network_tx.send(Action::GetNominatorsByValidator(account_id));
|
||||
let _ = network_tx.send(Action::GetQueuedSessionKeys(account_id));
|
||||
let _ = network_tx.send(Action::GetSessionKeys(account_id));
|
||||
let _ = network_tx.send(Action::GetValidatorAllRewards(account_id));
|
||||
let _ = network_tx.send(Action::GetSlashingSpans(account_id));
|
||||
let _ = network_tx.send(Action::GetValidatorLedger(account_id, true));
|
||||
let _ = network_tx.send(Action::GetIsStashBonded(account_id, true));
|
||||
let _ = network_tx.send(Action::GetErasStakersOverview(account_id, true));
|
||||
let _ = network_tx.send(Action::GetValidatorPrefs(account_id, true));
|
||||
let _ = network_tx.send(Action::GetNominatorsByValidator(account_id, true));
|
||||
let _ = network_tx.send(Action::GetQueuedSessionKeys(account_id, true));
|
||||
let _ = network_tx.send(Action::GetSessionKeys(account_id, true));
|
||||
let _ = network_tx.send(Action::GetValidatorAllRewards(account_id, true));
|
||||
let _ = network_tx.send(Action::GetSlashingSpans(account_id, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ pub struct Network {
|
||||
best_hash: Option<H256>,
|
||||
finalized_hash: Option<H256>,
|
||||
stash_to_watch: Option<[u8; 32]>,
|
||||
validator_details_to_watch: Option<[u8; 32]>,
|
||||
accounts_to_watch: std::collections::HashSet<[u8; 32]>,
|
||||
transactions_to_watch: Vec<TxToWatch>,
|
||||
eras_to_watch: std::collections::HashSet<u32>,
|
||||
@ -56,6 +57,7 @@ impl Network {
|
||||
best_hash: None,
|
||||
finalized_hash: None,
|
||||
stash_to_watch: None,
|
||||
validator_details_to_watch: None,
|
||||
accounts_to_watch: Default::default(),
|
||||
transactions_to_watch: Default::default(),
|
||||
eras_to_watch: Default::default(),
|
||||
@ -63,10 +65,17 @@ impl Network {
|
||||
}
|
||||
}
|
||||
|
||||
fn store_stash_if_possible(&mut self, new_stash: [u8; 32]) {
|
||||
fn store_stash_or_validator_if_possible(&mut self, account_id: [u8; 32], is_stash: bool) {
|
||||
if is_stash {
|
||||
match self.stash_to_watch {
|
||||
Some(stash) if stash == new_stash => {},
|
||||
_ => self.stash_to_watch = Some(new_stash),
|
||||
Some(stash) if stash == account_id => {},
|
||||
_ => self.stash_to_watch = Some(account_id),
|
||||
}
|
||||
} else {
|
||||
match self.validator_details_to_watch {
|
||||
Some(stash) if stash == account_id => {},
|
||||
_ => self.validator_details_to_watch = Some(account_id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,6 +123,11 @@ impl Network {
|
||||
predefined_calls::get_validator_staking_result(&self.action_tx, &self.online_client_api, &stash_to_watch, *era_index).await?;
|
||||
}
|
||||
}
|
||||
if let Some(validator_details_to_watch) = self.validator_details_to_watch {
|
||||
predefined_calls::get_nominators_by_validator(&self.action_tx, &self.online_client_api, &validator_details_to_watch).await?;
|
||||
predefined_calls::get_validator_prefs(&self.action_tx, &self.online_client_api, &validator_details_to_watch).await?;
|
||||
predefined_calls::get_staking_value_ratio(&self.action_tx, &self.online_client_api, &validator_details_to_watch).await?;
|
||||
}
|
||||
for account_id in self.accounts_to_watch.iter() {
|
||||
predefined_calls::get_balance(&self.action_tx, &self.online_client_api, &account_id).await?;
|
||||
}
|
||||
@ -191,41 +205,41 @@ impl Network {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Action::GetSlashingSpans(stash) => {
|
||||
self.store_stash_if_possible(stash);
|
||||
predefined_calls::get_slashing_spans(&self.action_tx, &self.online_client_api, &stash).await
|
||||
Action::GetSlashingSpans(account_id, is_stash) => {
|
||||
self.store_stash_or_validator_if_possible(account_id, is_stash);
|
||||
predefined_calls::get_slashing_spans(&self.action_tx, &self.online_client_api, &account_id).await
|
||||
}
|
||||
Action::GetValidatorLedger(stash) => {
|
||||
self.store_stash_if_possible(stash);
|
||||
predefined_calls::get_validators_ledger(&self.action_tx, &self.online_client_api, &stash).await
|
||||
Action::GetValidatorLedger(account_id, is_stash) => {
|
||||
self.store_stash_or_validator_if_possible(account_id, is_stash);
|
||||
predefined_calls::get_validators_ledger(&self.action_tx, &self.online_client_api, &account_id).await
|
||||
}
|
||||
Action::GetIsStashBonded(stash) => {
|
||||
self.store_stash_if_possible(stash);
|
||||
predefined_calls::get_is_stash_bonded(&self.action_tx, &self.online_client_api, &stash).await
|
||||
Action::GetIsStashBonded(account_id, is_stash) => {
|
||||
self.store_stash_or_validator_if_possible(account_id, is_stash);
|
||||
predefined_calls::get_is_stash_bonded(&self.action_tx, &self.online_client_api, &account_id).await
|
||||
},
|
||||
Action::GetErasStakersOverview(stash) => {
|
||||
self.store_stash_if_possible(stash);
|
||||
predefined_calls::get_staking_value_ratio(&self.action_tx, &self.online_client_api, &stash).await
|
||||
Action::GetErasStakersOverview(account_id, is_stash) => {
|
||||
self.store_stash_or_validator_if_possible(account_id, is_stash);
|
||||
predefined_calls::get_staking_value_ratio(&self.action_tx, &self.online_client_api, &account_id).await
|
||||
},
|
||||
Action::GetValidatorPrefs(stash) => {
|
||||
self.store_stash_if_possible(stash);
|
||||
predefined_calls::get_validator_prefs(&self.action_tx, &self.online_client_api, &stash).await
|
||||
Action::GetValidatorPrefs(account_id, is_stash) => {
|
||||
self.store_stash_or_validator_if_possible(account_id, is_stash);
|
||||
predefined_calls::get_validator_prefs(&self.action_tx, &self.online_client_api, &account_id).await
|
||||
},
|
||||
Action::GetValidatorAllRewards(stash) => {
|
||||
self.store_stash_if_possible(stash);
|
||||
predefined_calls::get_validator_staking_results(&self.action_tx, &self.online_client_api, &stash).await
|
||||
Action::GetNominatorsByValidator(account_id, is_stash) => {
|
||||
self.store_stash_or_validator_if_possible(account_id, is_stash);
|
||||
predefined_calls::get_nominators_by_validator(&self.action_tx, &self.online_client_api, &account_id).await
|
||||
},
|
||||
Action::GetNominatorsByValidator(stash) => {
|
||||
self.store_stash_if_possible(stash);
|
||||
predefined_calls::get_nominators_by_validator(&self.action_tx, &self.online_client_api, &stash).await
|
||||
Action::GetValidatorAllRewards(account_id, is_stash) => {
|
||||
self.store_stash_or_validator_if_possible(account_id, is_stash);
|
||||
predefined_calls::get_validator_staking_results(&self.action_tx, &self.online_client_api, &account_id).await
|
||||
},
|
||||
Action::GetQueuedSessionKeys(stash) => {
|
||||
self.store_stash_if_possible(stash);
|
||||
predefined_calls::get_queued_session_keys(&self.action_tx, &self.online_client_api, &self.rpc_client, &stash).await
|
||||
Action::GetQueuedSessionKeys(account_id, is_stash) => {
|
||||
self.store_stash_or_validator_if_possible(account_id, is_stash);
|
||||
predefined_calls::get_queued_session_keys(&self.action_tx, &self.online_client_api, &self.rpc_client, &account_id).await
|
||||
},
|
||||
Action::GetSessionKeys(stash) => {
|
||||
self.store_stash_if_possible(stash);
|
||||
predefined_calls::get_session_keys(&self.action_tx, &self.online_client_api, &self.rpc_client, &stash).await
|
||||
Action::GetSessionKeys(account_id, is_stash) => {
|
||||
self.store_stash_or_validator_if_possible(account_id, is_stash);
|
||||
predefined_calls::get_session_keys(&self.action_tx, &self.online_client_api, &self.rpc_client, &account_id).await
|
||||
},
|
||||
Action::BalanceRequest(account_id, remove) => {
|
||||
if remove {
|
||||
|
@ -472,7 +472,7 @@ pub async fn get_nominators_by_validator(
|
||||
None => Vec::new(),
|
||||
};
|
||||
|
||||
action_tx.send(Action::SetNominatorsByValidator(nominators))?;
|
||||
action_tx.send(Action::SetNominatorsByValidator(nominators, *account_id))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -503,7 +503,7 @@ pub async fn get_staking_value_ratio(
|
||||
Some(overview) => (overview.total, overview.own),
|
||||
None => (0, 0),
|
||||
};
|
||||
action_tx.send(Action::SetStakedRatio(total, own))?;
|
||||
action_tx.send(Action::SetStakedRatio(total, own, *account_id))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -519,7 +519,7 @@ pub async fn get_validator_prefs(
|
||||
None => (0, false),
|
||||
};
|
||||
|
||||
action_tx.send(Action::SetValidatorPrefs(comission, blocked))?;
|
||||
action_tx.send(Action::SetValidatorPrefs(comission, blocked, *account_id))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user