Compare commits
No commits in common. "29622e6ec3ee8ae671d94ed0ccb14bd4d160f0da" and "0d329e4340f52162be5751f0e6d51c79840176b0" have entirely different histories.
29622e6ec3
...
0d329e4340
@ -2,7 +2,7 @@
|
|||||||
name = "ghost-eye"
|
name = "ghost-eye"
|
||||||
authors = ["str3tch <stretch@ghostchain.io>"]
|
authors = ["str3tch <stretch@ghostchain.io>"]
|
||||||
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
|
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
|
||||||
version = "0.3.63"
|
version = "0.3.61"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
homepage = "https://git.ghostchain.io/ghostchain"
|
homepage = "https://git.ghostchain.io/ghostchain"
|
||||||
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"
|
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"
|
||||||
|
@ -68,7 +68,7 @@ impl History {
|
|||||||
fn payout_all_available(&mut self) {
|
fn payout_all_available(&mut self) {
|
||||||
let unclaimed_keys = self.rewards
|
let unclaimed_keys = self.rewards
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(k, v)| (!v.is_claimed && v.reward > 0).then(|| *k))
|
.filter_map(|(k, v)| (!v.is_claimed).then(|| *k))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
if let Some(action_tx) = &self.action_tx {
|
if let Some(action_tx) = &self.action_tx {
|
||||||
@ -219,10 +219,7 @@ impl History {
|
|||||||
impl PartialComponent for History {
|
impl PartialComponent for History {
|
||||||
fn set_active(&mut self, current_tab: CurrentTab) {
|
fn set_active(&mut self, current_tab: CurrentTab) {
|
||||||
match current_tab {
|
match current_tab {
|
||||||
CurrentTab::History => {
|
CurrentTab::History => self.is_active = true,
|
||||||
self.is_active = true;
|
|
||||||
self.pending_payout = Default::default();
|
|
||||||
},
|
|
||||||
_ => self.is_active = false,
|
_ => self.is_active = false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ use subxt::{
|
|||||||
backend::rpc::RpcClient,
|
backend::rpc::RpcClient,
|
||||||
client::OnlineClient,
|
client::OnlineClient,
|
||||||
config::substrate::DigestItem,
|
config::substrate::DigestItem,
|
||||||
ext::{sp_core::crypto::{
|
ext::sp_core::crypto::{
|
||||||
AccountId32, Ss58AddressFormat, Ss58Codec,
|
AccountId32, Ss58AddressFormat, Ss58Codec,
|
||||||
}, sp_runtime::{traits::Saturating, Perbill}},
|
},
|
||||||
rpc_params,
|
rpc_params,
|
||||||
utils::H256,
|
utils::H256,
|
||||||
};
|
};
|
||||||
@ -183,28 +183,9 @@ pub async fn get_inflation(
|
|||||||
.await?
|
.await?
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let adjusted_issuance = super::raw_calls::networks::bridged_imbalance(api, None)
|
let (inflation, fraction) = super::calculate_for_fraction(total_staked, total_issuance);
|
||||||
.await?
|
let inflation_str = super::prepare_perbill_fraction_string(inflation);
|
||||||
.map(|imbalance| total_issuance
|
let fraction_str = super::prepare_perbill_fraction_string(fraction);
|
||||||
.saturating_add(imbalance.bridged_out)
|
|
||||||
.saturating_sub(imbalance.bridged_in)
|
|
||||||
)
|
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
let accumulated_commission = super::raw_calls::networks::accumulated_commission(api, None)
|
|
||||||
.await?
|
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
let (inflation, fraction) = super::calculate_for_fraction(total_staked, adjusted_issuance);
|
|
||||||
let current_ratio = Perbill::from_rational(accumulated_commission, adjusted_issuance);
|
|
||||||
let expected_inflation = inflation
|
|
||||||
.saturating_mul(Perbill::one().saturating_add(current_ratio))
|
|
||||||
.saturating_pow(365)
|
|
||||||
.saturating_sub(Perbill::one());
|
|
||||||
let expected_fraction = expected_inflation.saturating_mul(fraction);
|
|
||||||
|
|
||||||
let inflation_str = super::prepare_perbill_fraction_string(expected_inflation);
|
|
||||||
let fraction_str = super::prepare_perbill_fraction_string(expected_fraction);
|
|
||||||
|
|
||||||
action_tx.send(Action::Inflation(inflation_str))?;
|
action_tx.send(Action::Inflation(inflation_str))?;
|
||||||
action_tx.send(Action::Apy(fraction_str))?;
|
action_tx.send(Action::Apy(fraction_str))?;
|
||||||
@ -308,7 +289,9 @@ pub async fn get_validator_staking_results(
|
|||||||
|
|
||||||
let start = current_era.saturating_sub(era_depth);
|
let start = current_era.saturating_sub(era_depth);
|
||||||
for era_index in (start..current_era).rev() {
|
for era_index in (start..current_era).rev() {
|
||||||
get_validator_staking_result(action_tx, api, account_id, era_index).await?;
|
if get_validator_staking_result(action_tx, api, account_id, era_index).await? {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -318,11 +301,11 @@ pub async fn get_validator_staking_result(
|
|||||||
api: &OnlineClient<CasperConfig>,
|
api: &OnlineClient<CasperConfig>,
|
||||||
account_id: &[u8; 32],
|
account_id: &[u8; 32],
|
||||||
era_index: u32,
|
era_index: u32,
|
||||||
) -> Result<()> {
|
) -> Result<bool> {
|
||||||
get_validator_reward_in_era(action_tx, api, account_id, era_index).await?;
|
let no_more_rewards = get_validator_reward_in_era(action_tx, api, account_id, era_index).await?;
|
||||||
get_validator_claims_in_era(action_tx, api, account_id, era_index).await?;
|
get_validator_claims_in_era(action_tx, api, account_id, era_index).await?;
|
||||||
get_validator_slashes_in_era(action_tx, api, account_id, era_index).await?;
|
get_validator_slashes_in_era(action_tx, api, account_id, era_index).await?;
|
||||||
Ok(())
|
Ok(no_more_rewards)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_current_validator_reward_in_era(
|
pub async fn get_current_validator_reward_in_era(
|
||||||
@ -375,7 +358,7 @@ async fn get_validator_reward_in_era(
|
|||||||
api: &OnlineClient<CasperConfig>,
|
api: &OnlineClient<CasperConfig>,
|
||||||
account_id: &[u8; 32],
|
account_id: &[u8; 32],
|
||||||
era_index: u32,
|
era_index: u32,
|
||||||
) -> Result<()> {
|
) -> Result<bool> {
|
||||||
let maybe_era_reward_points = super::raw_calls::staking::eras_reward_points(api, None, era_index).await?;
|
let maybe_era_reward_points = super::raw_calls::staking::eras_reward_points(api, None, era_index).await?;
|
||||||
let era_reward = super::raw_calls::staking::eras_validator_reward(api, None, era_index).await?.unwrap_or_default();
|
let era_reward = super::raw_calls::staking::eras_validator_reward(api, None, era_index).await?.unwrap_or_default();
|
||||||
|
|
||||||
@ -393,9 +376,14 @@ async fn get_validator_reward_in_era(
|
|||||||
None => 0u128,
|
None => 0u128,
|
||||||
};
|
};
|
||||||
|
|
||||||
action_tx.send(Action::SetValidatorEraReward(era_index, my_reward))?;
|
let no_more_rewards = if my_reward > 0 {
|
||||||
|
action_tx.send(Action::SetValidatorEraReward(era_index, my_reward))?;
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
};
|
||||||
|
|
||||||
Ok(())
|
Ok(no_more_rewards)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_validator_claims_in_era(
|
async fn get_validator_claims_in_era(
|
||||||
|
@ -12,7 +12,6 @@ pub mod staking;
|
|||||||
pub mod system;
|
pub mod system;
|
||||||
pub mod babe;
|
pub mod babe;
|
||||||
pub mod balances;
|
pub mod balances;
|
||||||
pub mod networks;
|
|
||||||
|
|
||||||
pub async fn do_storage_call<'address, Addr>(
|
pub async fn do_storage_call<'address, Addr>(
|
||||||
online_client: &OnlineClient<CasperConfig>,
|
online_client: &OnlineClient<CasperConfig>,
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
use color_eyre::Result;
|
|
||||||
use subxt::{
|
|
||||||
utils::H256,
|
|
||||||
client::OnlineClient,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
casper_network::{
|
|
||||||
self,
|
|
||||||
runtime_types::ghost_networks::BridgeAdjustment,
|
|
||||||
},
|
|
||||||
CasperConfig,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub async fn bridged_imbalance(
|
|
||||||
online_client: &OnlineClient<CasperConfig>,
|
|
||||||
at_hash: Option<&H256>,
|
|
||||||
) -> Result<Option<BridgeAdjustment<u128>>> {
|
|
||||||
let storage_key = casper_network::storage().ghost_networks().bridged_imbalance();
|
|
||||||
let maybe_bridged_imbalance = super::do_storage_call(online_client, &storage_key, at_hash).await?;
|
|
||||||
Ok(maybe_bridged_imbalance)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn accumulated_commission(
|
|
||||||
online_client: &OnlineClient<CasperConfig>,
|
|
||||||
at_hash: Option<&H256>,
|
|
||||||
) -> Result<Option<u128>> {
|
|
||||||
let storage_key = casper_network::storage().ghost_networks().accumulated_commission();
|
|
||||||
let maybe_accumulated_commission = super::do_storage_call(online_client, &storage_key, at_hash).await?;
|
|
||||||
Ok(maybe_accumulated_commission)
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user