make ledger responses depending on account_id

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch 2025-02-17 13:06:11 +03:00
parent 2afc38068a
commit 76d87aecbf
Signed by: str3tch
GPG Key ID: 84F3190747EE79AA
5 changed files with 12 additions and 8 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.27"
version = "0.3.28"
edition = "2021"
[dependencies]

View File

@ -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]),

View File

@ -120,14 +120,15 @@ impl Component for WithdrawPopup {
fn update(&mut self, action: Action) -> Result<Option<Action>> {
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)

View File

@ -27,6 +27,7 @@ pub struct Withdrawals {
scroll_state: ScrollbarState,
table_state: TableState,
unlockings: BTreeMap<u32, u128>,
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<Option<Action>> {
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),
_ => {}
};

View File

@ -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))?;
}
}