Skip to content
Snippets Groups Projects
Commit f72566bd authored by Nicolas80's avatar Nicolas80
Browse files

* changes from `cargo fmt`

parent c4f8f3dd
No related branches found
No related tags found
No related merge requests found
......@@ -88,7 +88,9 @@ pub async fn get_balance(data: Data) -> Result<(), GcliError> {
let view = BalanceView {
account_id: account_id.to_string(),
free_balance: account_info.as_ref().map_or(0, |info| info.data.free),
formatted_balance: account_info.as_ref().map_or("0".to_string(), |info| data.format_balance(info.data.free)),
formatted_balance: account_info
.as_ref()
.map_or("0".to_string(), |info| data.format_balance(info.data.free)),
exists: account_info.is_some(),
};
println!("{}", serde_json::to_string(&view).map_err(|e| anyhow!(e))?);
......
......@@ -76,7 +76,8 @@ struct OneshotBalanceView {
/// get balance of oneshot account
pub async fn oneshot_account_balance(data: &Data) -> Result<(), GcliError> {
let account_id = data.address();
let balance = data.client()
let balance = data
.client()
.storage()
.at_latest()
.await?
......@@ -90,11 +91,7 @@ pub async fn oneshot_account_balance(data: &Data) -> Result<(), GcliError> {
match data.args.output_format {
OutputFormat::Human => {
println!(
"balance of oneshot account {} is: {}",
account_id,
balance
);
println!("balance of oneshot account {} is: {}", account_id, balance);
}
OutputFormat::Json => {
let view = OneshotBalanceView {
......
......@@ -168,59 +168,149 @@ pub async fn runtime_info(data: Data) -> Result<(), GcliError> {
OutputFormat::Json => {
// Create HashMaps for each section
let mut identity = HashMap::new();
identity.insert("confirm_period".to_string(), getu32(consts.identity().confirm_period()));
identity.insert("validation_period".to_string(), getu32(consts.identity().validation_period()));
identity.insert("autorevocation_period".to_string(), getu32(consts.identity().autorevocation_period()));
identity.insert("deletion_period".to_string(), getu32(consts.identity().deletion_period()));
identity.insert("change_owner_key_period".to_string(), getu32(consts.identity().change_owner_key_period()));
identity.insert("idty_creation_period".to_string(), getu32(consts.identity().idty_creation_period()));
identity.insert(
"confirm_period".to_string(),
getu32(consts.identity().confirm_period()),
);
identity.insert(
"validation_period".to_string(),
getu32(consts.identity().validation_period()),
);
identity.insert(
"autorevocation_period".to_string(),
getu32(consts.identity().autorevocation_period()),
);
identity.insert(
"deletion_period".to_string(),
getu32(consts.identity().deletion_period()),
);
identity.insert(
"change_owner_key_period".to_string(),
getu32(consts.identity().change_owner_key_period()),
);
identity.insert(
"idty_creation_period".to_string(),
getu32(consts.identity().idty_creation_period()),
);
let mut certification = HashMap::new();
certification.insert("cert_period".to_string(), getu32(consts.certification().cert_period()));
certification.insert("max_by_issuer".to_string(), getu32(consts.certification().max_by_issuer()));
certification.insert("min_received_cert_to_be_able_to_issue_cert".to_string(),
getu32(consts.certification().min_received_cert_to_be_able_to_issue_cert()));
certification.insert("validity_period".to_string(), getu32(consts.certification().validity_period()));
certification.insert(
"cert_period".to_string(),
getu32(consts.certification().cert_period()),
);
certification.insert(
"max_by_issuer".to_string(),
getu32(consts.certification().max_by_issuer()),
);
certification.insert(
"min_received_cert_to_be_able_to_issue_cert".to_string(),
getu32(
consts
.certification()
.min_received_cert_to_be_able_to_issue_cert(),
),
);
certification.insert(
"validity_period".to_string(),
getu32(consts.certification().validity_period()),
);
let mut wot = HashMap::new();
wot.insert("first_issuable_on".to_string(), getu32(consts.wot().first_issuable_on()));
wot.insert("min_cert_for_membership".to_string(), getu32(consts.wot().min_cert_for_membership()));
wot.insert("min_cert_for_create_idty_right".to_string(), getu32(consts.wot().min_cert_for_create_idty_right()));
wot.insert(
"first_issuable_on".to_string(),
getu32(consts.wot().first_issuable_on()),
);
wot.insert(
"min_cert_for_membership".to_string(),
getu32(consts.wot().min_cert_for_membership()),
);
wot.insert(
"min_cert_for_create_idty_right".to_string(),
getu32(consts.wot().min_cert_for_create_idty_right()),
);
let mut membership = HashMap::new();
membership.insert("membership_period".to_string(), getu32(consts.membership().membership_period()));
membership.insert(
"membership_period".to_string(),
getu32(consts.membership().membership_period()),
);
let mut smith_members = HashMap::new();
smith_members.insert("max_by_issuer".to_string(), getu32(consts.smith_members().max_by_issuer()));
smith_members.insert("min_cert_for_membership".to_string(), getu32(consts.smith_members().min_cert_for_membership()));
smith_members.insert("smith_inactivity_max_duration".to_string(), getu32(consts.smith_members().smith_inactivity_max_duration()));
smith_members.insert(
"max_by_issuer".to_string(),
getu32(consts.smith_members().max_by_issuer()),
);
smith_members.insert(
"min_cert_for_membership".to_string(),
getu32(consts.smith_members().min_cert_for_membership()),
);
smith_members.insert(
"smith_inactivity_max_duration".to_string(),
getu32(consts.smith_members().smith_inactivity_max_duration()),
);
let mut distance = HashMap::new();
distance.insert("max_referee_distance".to_string(),
serde_json::to_value(getu32(consts.distance().max_referee_distance())).map_err(|e| anyhow!(e))?);
distance.insert("min_accessible_referees".to_string(),
serde_json::to_value(format!("{:?}", getp(consts.distance().min_accessible_referees()))).map_err(|e| anyhow!(e))?);
distance.insert("evaluation_price".to_string(),
serde_json::to_value(getf(consts.distance().evaluation_price())).map_err(|e| anyhow!(e))?);
distance.insert(
"max_referee_distance".to_string(),
serde_json::to_value(getu32(consts.distance().max_referee_distance()))
.map_err(|e| anyhow!(e))?,
);
distance.insert(
"min_accessible_referees".to_string(),
serde_json::to_value(format!(
"{:?}",
getp(consts.distance().min_accessible_referees())
))
.map_err(|e| anyhow!(e))?,
);
distance.insert(
"evaluation_price".to_string(),
serde_json::to_value(getf(consts.distance().evaluation_price()))
.map_err(|e| anyhow!(e))?,
);
let mut currency = HashMap::new();
currency.insert("existential_deposit".to_string(), getf(consts.balances().existential_deposit()));
currency.insert(
"existential_deposit".to_string(),
getf(consts.balances().existential_deposit()),
);
let mut provide_randomness = HashMap::new();
provide_randomness.insert("max_requests".to_string(),
serde_json::to_value(getu32(consts.provide_randomness().max_requests())).map_err(|e| anyhow!(e))?);
provide_randomness.insert("request_price".to_string(),
serde_json::to_value(getf(consts.provide_randomness().request_price())).map_err(|e| anyhow!(e))?);
provide_randomness.insert(
"max_requests".to_string(),
serde_json::to_value(getu32(consts.provide_randomness().max_requests()))
.map_err(|e| anyhow!(e))?,
);
provide_randomness.insert(
"request_price".to_string(),
serde_json::to_value(getf(consts.provide_randomness().request_price()))
.map_err(|e| anyhow!(e))?,
);
let mut universal_dividend = HashMap::new();
universal_dividend.insert("max_past_reeval".to_string(),
serde_json::to_value(getu32(consts.universal_dividend().max_past_reeval())).map_err(|e| anyhow!(e))?);
universal_dividend.insert("square_money_growth_rate".to_string(),
serde_json::to_value(format!("{:?}", getp(consts.universal_dividend().square_money_growth_rate()))).map_err(|e| anyhow!(e))?);
universal_dividend.insert("ud_creation_period".to_string(),
serde_json::to_value(getu64(consts.universal_dividend().ud_creation_period())).map_err(|e| anyhow!(e))?);
universal_dividend.insert("ud_reeval_period".to_string(),
serde_json::to_value(getu64(consts.universal_dividend().ud_reeval_period())).map_err(|e| anyhow!(e))?);
universal_dividend.insert(
"max_past_reeval".to_string(),
serde_json::to_value(getu32(consts.universal_dividend().max_past_reeval()))
.map_err(|e| anyhow!(e))?,
);
universal_dividend.insert(
"square_money_growth_rate".to_string(),
serde_json::to_value(format!(
"{:?}",
getp(consts.universal_dividend().square_money_growth_rate())
))
.map_err(|e| anyhow!(e))?,
);
universal_dividend.insert(
"ud_creation_period".to_string(),
serde_json::to_value(getu64(consts.universal_dividend().ud_creation_period()))
.map_err(|e| anyhow!(e))?,
);
universal_dividend.insert(
"ud_reeval_period".to_string(),
serde_json::to_value(getu64(consts.universal_dividend().ud_reeval_period()))
.map_err(|e| anyhow!(e))?,
);
// Create the view
let view = RuntimeInfoView {
......@@ -235,7 +325,10 @@ pub async fn runtime_info(data: Data) -> Result<(), GcliError> {
universal_dividend,
};
println!("{}", serde_json::to_string_pretty(&view).map_err(|e| anyhow!(e))?);
println!(
"{}",
serde_json::to_string_pretty(&view).map_err(|e| anyhow!(e))?
);
}
}
......
use crate::*;
use anyhow::anyhow;
use commands::identity::try_get_idty_index_by_name;
#[cfg(feature = "gdev")]
use runtime::runtime_types::gdev_runtime::opaque::SessionKeys as RuntimeSessionKeys;
use serde::Serialize;
use std::collections::HashMap;
use std::ops::Deref;
use anyhow::anyhow;
use serde::Serialize;
type SessionKeys = [u8; 128];
......@@ -309,7 +309,8 @@ pub async fn online(data: &Data) -> Result<(), GcliError> {
online_authorities.clone(),
incoming_authorities.clone(),
outgoing_authorities.clone(),
].concat();
]
.concat();
indexer
.names_by_indexes(&all_authorities)
......
......@@ -232,8 +232,14 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
println!("{table}");
}
OutputFormat::Json => {
let json_view = display::compute_vault_accounts_json(&all_account_tree_node_hierarchies, show_g1v1);
println!("{}", serde_json::to_string(&json_view).map_err(|e| anyhow!(e))?);
let json_view = display::compute_vault_accounts_json(
&all_account_tree_node_hierarchies,
show_g1v1,
);
println!(
"{}",
serde_json::to_string(&json_view).map_err(|e| anyhow!(e))?
);
}
}
}
......@@ -251,8 +257,14 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
println!("{table}");
}
OutputFormat::Json => {
let json_view = display::compute_vault_accounts_json(&base_account_tree_nodes, show_g1v1);
println!("{}", serde_json::to_string(&json_view).map_err(|e| anyhow!(e))?);
let json_view = display::compute_vault_accounts_json(
&base_account_tree_nodes,
show_g1v1,
);
println!(
"{}",
serde_json::to_string(&json_view).map_err(|e| anyhow!(e))?
);
}
}
}
......@@ -279,8 +291,14 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
println!("{table}");
}
OutputFormat::Json => {
let json_view = display::compute_vault_accounts_json(&[base_account_tree_node], show_g1v1);
println!("{}", serde_json::to_string(&json_view).map_err(|e| anyhow!(e))?);
let json_view = display::compute_vault_accounts_json(
&[base_account_tree_node],
show_g1v1,
);
println!(
"{}",
serde_json::to_string(&json_view).map_err(|e| anyhow!(e))?
);
}
}
}
......@@ -295,7 +313,10 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
println!("{table}");
}
OutputFormat::Json => {
println!("{}", serde_json::to_string(&vault_key_addresses).map_err(|e| anyhow!(e))?);
println!(
"{}",
serde_json::to_string(&vault_key_addresses).map_err(|e| anyhow!(e))?
);
}
}
}
......@@ -313,7 +334,10 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
//FIXME Probably not the display we would expect
"address": account.to_string()
});
println!("{}", serde_json::to_string(&json_view).map_err(|e| anyhow!(e))?);
println!(
"{}",
serde_json::to_string(&json_view).map_err(|e| anyhow!(e))?
);
}
}
......@@ -612,7 +636,10 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
let json_view = serde_json::json!({
"substrate_uri": account_to_derive_secret_suri
});
println!("{}", serde_json::to_string(&json_view).map_err(|e| anyhow!(e))?);
println!(
"{}",
serde_json::to_string(&json_view).map_err(|e| anyhow!(e))?
);
}
}
}
......@@ -693,7 +720,10 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
let json_view = serde_json::json!({
"data_dir": data_dir
});
println!("{}", serde_json::to_string(&json_view).map_err(|e| anyhow!(e))?);
println!(
"{}",
serde_json::to_string(&json_view).map_err(|e| anyhow!(e))?
);
}
}
}
......
use crate::entities::vault_account;
use crate::entities::vault_account::DbAccountId;
use crate::*;
use serde::{Deserialize, Serialize};
use anyhow::anyhow;
use serde::{Deserialize, Serialize};
const APP_NAME: &str = "gcli";
......@@ -93,8 +93,7 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
confy::get_configuration_file_path(APP_NAME, None)?.display()
);
}
Subcommand::Show => {
match data.args.output_format {
Subcommand::Show => match data.args.output_format {
OutputFormat::Human => {
println!("{}", data.cfg);
if let Some(ref account_id) = data.cfg.address {
......@@ -130,8 +129,7 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
println!("{}", serde_json::to_string(&view).map_err(|e| anyhow!(e))?);
}
}
}
},
Subcommand::Save => {
save(&data.cfg);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment