25 lines
695 B
Rust
25 lines
695 B
Rust
use color_eyre::Result;
|
|
use subxt::{
|
|
utils::H256,
|
|
client::OnlineClient,
|
|
};
|
|
|
|
use crate::{
|
|
casper_network::{
|
|
self,
|
|
runtime_types::{frame_system::AccountInfo, pallet_balances::types::AccountData},
|
|
},
|
|
CasperConfig,
|
|
};
|
|
|
|
pub async fn balance(
|
|
online_client: &OnlineClient<CasperConfig>,
|
|
at_hash: Option<&H256>,
|
|
account: &[u8; 32],
|
|
) -> Result<Option<AccountInfo<u32, AccountData<u128>>>> {
|
|
let account_id = super::convert_array_to_account_id(account);
|
|
let storage_key = casper_network::storage().system().account(account_id);
|
|
let maybe_balance = super::do_storage_call(online_client, &storage_key, at_hash).await?;
|
|
Ok(maybe_balance)
|
|
}
|