From 76d87aecbf5688085932a3cc771108581214c062 Mon Sep 17 00:00:00 2001 From: Uncle Stretch Date: Mon, 17 Feb 2025 13:06:11 +0300 Subject: [PATCH] make ledger responses depending on account_id Signed-off-by: Uncle Stretch --- Cargo.toml | 2 +- src/action.rs | 4 ++-- src/components/validator/withdraw_popup.rs | 5 +++-- src/components/validator/withdrawals.rs | 5 ++++- src/network/predefined_calls.rs | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5ce1e1e..d248207 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.27" +version = "0.3.28" edition = "2021" [dependencies] diff --git a/src/action.rs b/src/action.rs index dd894eb..eddb318 100644 --- a/src/action.rs +++ b/src/action.rs @@ -115,7 +115,7 @@ pub enum Action { SetStashSecret([u8; 32]), SetChoosenValidator([u8; 32], u32, u32), SetSlashingSpansLength(usize, [u8; 32]), - SetUnlockingIsEmpty(bool), + SetUnlockingIsEmpty(bool, [u8; 32]), BestBlockInformation(H256, u32), FinalizedBlockInformation(H256, u32), @@ -132,7 +132,7 @@ pub enum Action { SetValidatorEraReward(u32, u128), SetValidatorEraClaimed(u32, bool), SetValidatorEraSlash(u32, u128), - SetValidatorEraUnlocking(u32, u128), + SetValidatorEraUnlocking(u32, u128, [u8; 32]), SetIsBonded(bool), SetStakedAmountRatio(u128, u128, [u8; 32]), SetStakedRatio(u128, u128, [u8; 32]), diff --git a/src/components/validator/withdraw_popup.rs b/src/components/validator/withdraw_popup.rs index 2081158..84eddd5 100644 --- a/src/components/validator/withdraw_popup.rs +++ b/src/components/validator/withdraw_popup.rs @@ -120,14 +120,15 @@ impl Component for WithdrawPopup { fn update(&mut self, action: Action) -> Result> { match action { + Action::SetExistentialDeposit(existential_deposit) => self.existential_deposit = existential_deposit, Action::SetStashAccount(account_id) => self.stash_account = account_id, Action::SetStashSecret(secret_seed) => self.secret_seed = secret_seed, Action::SetSlashingSpansLength(length, account_id) if self.stash_account == account_id => self.slashing_spans_length = length as u32, Action::SetStakedAmountRatio(_, active_balance, account_id) if self.stash_account == account_id => self.active_balance = active_balance, - Action::SetUnlockingIsEmpty(is_empty) => self.unlocking_is_empty = is_empty, - Action::SetExistentialDeposit(existential_deposit) => self.existential_deposit = existential_deposit, + Action::SetUnlockingIsEmpty(is_empty, account_id) if self.stash_account == account_id => + self.unlocking_is_empty = is_empty, _ => {} }; Ok(None) diff --git a/src/components/validator/withdrawals.rs b/src/components/validator/withdrawals.rs index 6a177d6..77a0650 100644 --- a/src/components/validator/withdrawals.rs +++ b/src/components/validator/withdrawals.rs @@ -27,6 +27,7 @@ pub struct Withdrawals { scroll_state: ScrollbarState, table_state: TableState, unlockings: BTreeMap, + stash_account: [u8; 32], current_era: u32, } @@ -47,6 +48,7 @@ impl Withdrawals { table_state: TableState::new(), palette: StylePalette::default(), unlockings: BTreeMap::new(), + stash_account: [0u8; 32], current_era: 0, } } @@ -151,8 +153,9 @@ impl Component for Withdrawals { fn update(&mut self, action: Action) -> Result> { match action { + Action::SetStashAccount(account_id) => self.stash_account = account_id, Action::SetCurrentEra(current_era) => self.current_era = current_era, - Action::SetValidatorEraUnlocking(era_index, unlocking) => + Action::SetValidatorEraUnlocking(era_index, unlocking, account_id) if self.stash_account == account_id => self.add_new_unlocking(era_index, unlocking), _ => {} }; diff --git a/src/network/predefined_calls.rs b/src/network/predefined_calls.rs index bf3e8e4..11d66be 100644 --- a/src/network/predefined_calls.rs +++ b/src/network/predefined_calls.rs @@ -435,9 +435,9 @@ pub async fn get_validators_ledger( if let Some(ledger) = maybe_ledger { action_tx.send(Action::SetStakedAmountRatio(ledger.total, ledger.active, *account_id))?; - action_tx.send(Action::SetUnlockingIsEmpty(ledger.unlocking.0.is_empty()))?; + action_tx.send(Action::SetUnlockingIsEmpty(ledger.unlocking.0.is_empty(), *account_id))?; for chunk in ledger.unlocking.0.iter() { - action_tx.send(Action::SetValidatorEraUnlocking(chunk.era, chunk.value))?; + action_tx.send(Action::SetValidatorEraUnlocking(chunk.era, chunk.value, *account_id))?; } }