Apply cargo fmt (#1146)

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2023-08-28 16:03:29 +03:00
committed by GitHub
parent b413e5e84e
commit 91a56fd580
18 changed files with 157 additions and 74 deletions
+8 -2
View File
@@ -44,10 +44,16 @@ pub fn explore_calls(
};
// if specified call is wrong, show user the calls to choose from (but this time as an error):
let Some(call) = calls_enum_type_def.variants.iter().find(|variant| variant.name.to_lowercase() == call_name.to_lowercase()) else {
let Some(call) = calls_enum_type_def
.variants
.iter()
.find(|variant| variant.name.to_lowercase() == call_name.to_lowercase())
else {
let available_calls = print_available_calls(calls_enum_type_def, pallet_name);
let description = format!("Usage:\n subxt explore {pallet_name} calls <CALL>\n explore a specific call within this pallet\n\n{available_calls}", );
return Err(eyre!("\"{call_name}\" call not found in \"{pallet_name}\" pallet!\n\n{description}"));
return Err(eyre!(
"\"{call_name}\" call not found in \"{pallet_name}\" pallet!\n\n{description}"
));
};
// collect all the trailing arguments into a single string that is later into a scale_value::Value
+23 -6
View File
@@ -22,18 +22,35 @@ pub fn explore_constants(
let Some(constant_name) = command.constant else {
let available_constants = print_available_constants(pallet_metadata, pallet_name);
writeln!(output, "Usage:")?;
writeln!(output, " subxt explore {pallet_name} constants <CONSTANT>")?;
writeln!(output, " explore a specific call within this pallet\n\n{available_constants}")?;
writeln!(
output,
" subxt explore {pallet_name} constants <CONSTANT>"
)?;
writeln!(
output,
" explore a specific call within this pallet\n\n{available_constants}"
)?;
return Ok(());
};
// if specified constant is wrong, show user the constants to choose from (but this time as an error):
let Some(constant) = pallet_metadata.constants().find(|constant| constant.name().to_lowercase() == constant_name.to_lowercase()) else {
let Some(constant) = pallet_metadata
.constants()
.find(|constant| constant.name().to_lowercase() == constant_name.to_lowercase())
else {
let available_constants = print_available_constants(pallet_metadata, pallet_name);
let mut description = "Usage:".to_string();
writeln!(description, " subxt explore {pallet_name} constants <CONSTANT>")?;
writeln!(description, " explore a specific call within this pallet\n\n{available_constants}")?;
let err = eyre!("constant \"{constant_name}\" not found in \"{pallet_name}\" pallet!\n\n{description}");
writeln!(
description,
" subxt explore {pallet_name} constants <CONSTANT>"
)?;
writeln!(
description,
" explore a specific call within this pallet\n\n{available_constants}"
)?;
let err = eyre!(
"constant \"{constant_name}\" not found in \"{pallet_name}\" pallet!\n\n{description}"
);
return Err(err);
};
+21 -8
View File
@@ -88,16 +88,23 @@ pub async fn run(opts: Opts, output: &mut impl std::io::Write) -> color_eyre::Re
// if no pallet specified, show user the pallets to choose from:
let Some(pallet_name) = opts.pallet else {
let available_pallets = print_available_pallets(&metadata);
writeln!(output, "Usage:", )?;
writeln!(output, " subxt explore <PALLET>", )?;
writeln!(output, " explore a specific pallet", )?;
writeln!(output, "\n{available_pallets}", )?;
writeln!(output, "Usage:",)?;
writeln!(output, " subxt explore <PALLET>",)?;
writeln!(output, " explore a specific pallet",)?;
writeln!(output, "\n{available_pallets}",)?;
return Ok(());
};
// if specified pallet is wrong, show user the pallets to choose from (but this time as an error):
let Some(pallet_metadata) = metadata.pallets().find(|pallet| pallet.name().to_lowercase() == pallet_name.to_lowercase()) else {
return Err(eyre!("pallet \"{}\" not found in metadata!\n{}", pallet_name, print_available_pallets(&metadata)));
let Some(pallet_metadata) = metadata
.pallets()
.find(|pallet| pallet.name().to_lowercase() == pallet_name.to_lowercase())
else {
return Err(eyre!(
"pallet \"{}\" not found in metadata!\n{}",
pallet_name,
print_available_pallets(&metadata)
));
};
// if correct pallet was specified but no subcommand, instruct the user how to proceed:
@@ -108,11 +115,17 @@ pub async fn run(opts: Opts, output: &mut impl std::io::Write) -> color_eyre::Re
}
writeln!(output, "Usage:")?;
writeln!(output, " subxt explore {pallet_name} calls")?;
writeln!(output, " explore the calls that can be made into this pallet")?;
writeln!(
output,
" explore the calls that can be made into this pallet"
)?;
writeln!(output, " subxt explore {pallet_name} constants")?;
writeln!(output, " explore the constants held in this pallet")?;
writeln!(output, " subxt explore {pallet_name} storage")?;
writeln!(output, " explore the storage values held in this pallet")?;
writeln!(
output,
" explore the storage values held in this pallet"
)?;
return Ok(());
};
+9 -2
View File
@@ -35,7 +35,10 @@ pub async fn explore_storage(
let trailing_args = trailing_args.trim();
let Some(storage_metadata) = pallet_metadata.storage() else {
writeln!(output, "The \"{pallet_name}\" pallet has no storage entries.")?;
writeln!(
output,
"The \"{pallet_name}\" pallet has no storage entries."
)?;
return Ok(());
};
@@ -47,7 +50,11 @@ pub async fn explore_storage(
};
// if specified call storage entry wrong, show user the storage entries to choose from (but this time as an error):
let Some(storage) = storage_metadata.entries().iter().find(|entry| entry.name().to_lowercase() == entry_name.to_lowercase()) else {
let Some(storage) = storage_metadata
.entries()
.iter()
.find(|entry| entry.name().to_lowercase() == entry_name.to_lowercase())
else {
let storage_entries = print_available_storage_entries(storage_metadata, pallet_name);
let description = format!("Usage:\n subxt explore {pallet_name} storage <STORAGE_ENTRY>\n view details for a specific storage entry\n\n{storage_entries}");
return Err(eyre!("Storage entry \"{entry_name}\" not found in \"{pallet_name}\" pallet!\n\n{description}"));