Skip to content
Snippets Groups Projects
Commit bf4ac99c authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

add some runtime constants

parent f528c49d
No related branches found
No related tags found
1 merge request!5add features and refac data
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)
);
}
......@@ -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
......
......@@ -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?,
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment