ghost-eye/src/network/raw_calls/babe.rs
Uncle Stinky 2e0205a581
sketch for the validators page
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
2025-01-19 18:04:02 +03:00

43 lines
1.4 KiB
Rust

use color_eyre::Result;
use subxt::{
utils::H256,
client::OnlineClient,
};
use crate::{casper_network::{self, runtime_types::sp_consensus_slots}, CasperConfig};
pub async fn current_slot(
online_client: &OnlineClient<CasperConfig>,
at_hash: Option<&H256>,
) -> Result<Option<sp_consensus_slots::Slot>> {
let storage_key = casper_network::storage().babe().current_slot();
let maybe_current_slot = super::do_storage_call(online_client, &storage_key, at_hash).await?;
Ok(maybe_current_slot)
}
pub async fn epoch_index(
online_client: &OnlineClient<CasperConfig>,
at_hash: Option<&H256>,
) -> Result<Option<u64>> {
let storage_key = casper_network::storage().babe().epoch_index();
let maybe_epoch_index = super::do_storage_call(online_client, &storage_key, at_hash).await?;
Ok(maybe_epoch_index)
}
pub async fn genesis_slot(
online_client: &OnlineClient<CasperConfig>,
at_hash: Option<&H256>,
) -> Result<Option<sp_consensus_slots::Slot>> {
let storage_key = casper_network::storage().babe().genesis_slot();
let maybe_genesis_slot = super::do_storage_call(online_client, &storage_key, at_hash).await?;
Ok(maybe_genesis_slot)
}
pub fn epoch_duration(
online_client: &OnlineClient<CasperConfig>,
) -> Result<u64> {
let constant_query = casper_network::constants().babe().epoch_duration();
let epoch_duration = super::do_constant_call(online_client, &constant_query)?;
Ok(epoch_duration)
}