2020-09-30 20:17:29 -07:00
|
|
|
use crate::cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult};
|
|
|
|
use clap::{App, ArgMatches, SubCommand};
|
|
|
|
use solana_clap_utils::keypair::*;
|
2021-01-09 17:02:22 -07:00
|
|
|
use solana_cli_output::CliInflation;
|
2020-09-30 20:17:29 -07:00
|
|
|
use solana_client::rpc_client::RpcClient;
|
|
|
|
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub enum InflationCliCommand {
|
|
|
|
Show,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait InflationSubCommands {
|
|
|
|
fn inflation_subcommands(self) -> Self;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl InflationSubCommands for App<'_, '_> {
|
|
|
|
fn inflation_subcommands(self) -> Self {
|
|
|
|
self.subcommand(SubCommand::with_name("inflation").about("Show inflation information"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn parse_inflation_subcommand(
|
|
|
|
_matches: &ArgMatches<'_>,
|
|
|
|
_default_signer: &DefaultSigner,
|
|
|
|
_wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
|
|
|
) -> Result<CliCommandInfo, CliError> {
|
|
|
|
Ok(CliCommandInfo {
|
|
|
|
command: CliCommand::Inflation(InflationCliCommand::Show),
|
|
|
|
signers: vec![],
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn process_inflation_subcommand(
|
|
|
|
rpc_client: &RpcClient,
|
2021-01-09 17:02:22 -07:00
|
|
|
config: &CliConfig,
|
2020-09-30 20:17:29 -07:00
|
|
|
inflation_subcommand: &InflationCliCommand,
|
|
|
|
) -> ProcessResult {
|
|
|
|
assert_eq!(*inflation_subcommand, InflationCliCommand::Show);
|
|
|
|
|
|
|
|
let governor = rpc_client.get_inflation_governor()?;
|
2021-01-09 17:02:22 -07:00
|
|
|
let current_rate = rpc_client.get_inflation_rate()?;
|
2020-09-30 20:17:29 -07:00
|
|
|
|
2021-01-09 17:02:22 -07:00
|
|
|
let inflation = CliInflation {
|
|
|
|
governor,
|
|
|
|
current_rate,
|
|
|
|
};
|
2020-09-30 20:17:29 -07:00
|
|
|
|
2021-01-09 17:02:22 -07:00
|
|
|
Ok(config.output_format.formatted_string(&inflation))
|
2020-09-30 20:17:29 -07:00
|
|
|
}
|