ghost-eye/src/network/raw_calls/networks.rs
Uncle Stretch 9afda5a701
ability to see basic gatekeeped network information
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2025-08-07 23:07:56 +03:00

42 lines
1.3 KiB
Rust

use color_eyre::Result;
use subxt::{
utils::H256,
client::OnlineClient,
};
use crate::{
casper_network::{
self,
runtime_types::ghost_networks::{BridgeAdjustment, NetworkData},
},
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)
}
pub async fn networks(
online_client: &OnlineClient<CasperConfig>,
at_hash: Option<&H256>,
chain_id: u64,
) -> Result<Option<NetworkData>> {
let storage_key = casper_network::storage().ghost_networks().networks(chain_id);
let maybe_network = super::do_storage_call(online_client, &storage_key, at_hash).await?;
Ok(maybe_network)
}