ghost-eye/src/network/raw_calls/session.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

37 lines
1.3 KiB
Rust

use color_eyre::Result;
use subxt::{
utils::{AccountId32, H256},
client::OnlineClient,
};
use crate::{casper_network::{self, runtime_types::casper_runtime::opaque}, CasperConfig};
pub async fn validators(
online_client: &OnlineClient<CasperConfig>,
at_hash: Option<&H256>,
) -> Result<Option<Vec<AccountId32>>> {
let storage_key = casper_network::storage().session().validators();
let maybe_validators = super::do_storage_call(online_client, &storage_key, at_hash).await?;
Ok(maybe_validators)
}
pub async fn next_keys(
online_client: &OnlineClient<CasperConfig>,
at_hash: Option<&H256>,
account: &[u8; 32],
) -> Result<Option<opaque::SessionKeys>> {
let account_id = super::convert_array_to_account_id(account);
let storage_key = casper_network::storage().session().next_keys(account_id);
let maybe_next_keys = super::do_storage_call(online_client, &storage_key, at_hash).await?;
Ok(maybe_next_keys)
}
pub async fn queued_keys(
online_client: &OnlineClient<CasperConfig>,
at_hash: Option<&H256>,
) -> Result<Option<Vec<(AccountId32, opaque::SessionKeys)>>> {
let storage_key = casper_network::storage().session().queued_keys();
let maybe_queued_keys = super::do_storage_call(online_client, &storage_key, at_hash).await?;
Ok(maybe_queued_keys)
}