2020-02-29 11:39:07 -05:00
|
|
|
use crate::cli::SettingType;
|
2019-08-08 11:13:06 -06:00
|
|
|
use console::style;
|
2019-11-25 21:09:57 -08:00
|
|
|
use solana_sdk::transaction::Transaction;
|
2019-08-08 11:13:06 -06:00
|
|
|
|
|
|
|
// Pretty print a "name value"
|
|
|
|
pub fn println_name_value(name: &str, value: &str) {
|
|
|
|
let styled_value = if value == "" {
|
|
|
|
style("(not set)").italic()
|
|
|
|
} else {
|
|
|
|
style(value)
|
|
|
|
};
|
|
|
|
println!("{} {}", style(name).bold(), styled_value);
|
|
|
|
}
|
2019-09-05 10:14:23 -07:00
|
|
|
|
2020-02-29 11:39:07 -05:00
|
|
|
pub fn println_name_value_or(name: &str, value: &str, setting_type: SettingType) {
|
|
|
|
let description = match setting_type {
|
|
|
|
SettingType::Explicit => "",
|
|
|
|
SettingType::Computed => "(computed)",
|
|
|
|
SettingType::SystemDefault => "(default)",
|
2019-09-05 10:14:23 -07:00
|
|
|
};
|
2020-02-29 11:39:07 -05:00
|
|
|
|
|
|
|
println!(
|
|
|
|
"{} {} {}",
|
|
|
|
style(name).bold(),
|
|
|
|
style(value),
|
|
|
|
style(description).italic(),
|
|
|
|
);
|
2019-09-05 10:14:23 -07:00
|
|
|
}
|
2019-11-25 21:09:57 -08:00
|
|
|
|
|
|
|
pub fn println_signers(tx: &Transaction) {
|
|
|
|
println!();
|
|
|
|
println!("Blockhash: {}", tx.message.recent_blockhash);
|
|
|
|
println!("Signers (Pubkey=Signature):");
|
|
|
|
tx.signatures
|
|
|
|
.iter()
|
|
|
|
.zip(tx.message.account_keys.clone())
|
|
|
|
.for_each(|(signature, pubkey)| println!(" {:?}={:?}", pubkey, signature));
|
|
|
|
println!();
|
|
|
|
}
|