use crate::*; use anyhow::Result; pub async fn get_balance(data: Data) -> Result<()> { let account_id = data.address(); let account_info = get_account_info(data.client(), &account_id).await?; if let Some(account_info) = account_info { println!( "{account_id} has {}", data.format_balance(account_info.data.free) ); } else { println!("account {account_id} does not exist") } Ok(()) } pub async fn get_account_info( client: &Client, account_id: &AccountId, ) -> Result<Option<AccountInfo>> { Ok(client .storage() .fetch(&runtime::storage().system().account(account_id), None) .await?) }