diff --git a/src/commands/runtime.rs b/src/commands/runtime.rs index be6ee976a62940c6faebae0986751322fc26e38f..8238d8c555a804b93cdf9423b7bbc0fe234be64b 100644 --- a/src/commands/runtime.rs +++ b/src/commands/runtime.rs @@ -1,8 +1,43 @@ use crate::*; -pub async fn runtime_info(_data: Data) -> () { - // TODO get information from runtime - // certification duration for example - println!("TODO"); - () +pub async fn runtime_info(data: Data) -> () { + let api = data.client(); + + // certifications + let cert_period = api + .constants() + .at(&runtime::constants().cert().cert_period()) + .unwrap(); + let max_by_issuer = api + .constants() + .at(&runtime::constants().cert().max_by_issuer()) + .unwrap(); + let validity_period = api + .constants() + .at(&runtime::constants().cert().validity_period()) + .unwrap(); + + println!("certification period: {cert_period} blocks"); + println!("max certs by issuer: {max_by_issuer}"); + println!("certification validity: {validity_period} blocks"); + + // account + let new_account_price = api + .constants() + .at(&runtime::constants().account().new_account_price()) + .unwrap(); + // balances + let existential_deposit = api + .constants() + .at(&runtime::constants().balances().existential_deposit()) + .unwrap(); + + println!( + "new account price: {}", + data.format_balance(new_account_price) + ); + println!( + "existential deposit: {}", + data.format_balance(existential_deposit) + ); } diff --git a/src/data.rs b/src/data.rs index 58d1418bef97c2aa3bc4f50c1826eb6ec1c763e8..8639b9d62d6266b95db0bce1b280cc2d6cc5857e 100644 --- a/src/data.rs +++ b/src/data.rs @@ -103,7 +103,10 @@ impl Data { /// build a client from url // TODO get client from a pre-defined list pub async fn build_client(mut self) -> Self { - self.client = Some(Client::from_url(&self.args.url).await.expect("needed")); + self.client = Some(Client::from_url(&self.args.url).await.expect(&format!( + "could not establish connection with the server {}", + self.args.url + ))); self } /// build an indexer if not disabled diff --git a/src/main.rs b/src/main.rs index fbdf1e8db486a65c0b2bea82207bf8e94a903675..a656192afa9af2b168e91af1605cd22266167283 100644 --- a/src/main.rs +++ b/src/main.rs @@ -563,7 +563,10 @@ async fn main() -> Result<(), GcliError> { ) .await .unwrap(), - Subcommand::RuntimeInfo => commands::runtime::runtime_info(data).await, + Subcommand::RuntimeInfo => { + data = data.build_client().await.fetch_system_properties().await?; + commands::runtime::runtime_info(data).await; + } Subcommand::Indexer(subcommand) => indexer::handle_command(data, subcommand).await?, }