use std::str::FromStr;
use std::sync::Arc;
use clap::ArgMatches;
use solana_clap_utils::keypair::DefaultSigner;
use solana_client::rpc_client::RpcClient;
use solana_program::pubkey::Pubkey;
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use crate::check_and_update_err;
use crate::command::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult};
use crate::contract::instructions::farming::quarry_mine::set_annual_rewards::new_set_annual_rewards;
use crate::utils::send::send_tx;
pub fn parse_farming_mine_rewarder_set_annual_rate<'a>(matches: &'a ArgMatches, default_signer: &DefaultSigner, wallet_manager: &mut Option<Arc<RemoteWalletManager>>) -> Result<CliCommandInfo<'a>, CliError> {
let rewarder = matches.value_of("rewarder");
let rate = matches.value_of("rate");
Ok(CliCommandInfo {
command: CliCommand::FarmingMineRewarderSetAnnualRate {
rewarder: Pubkey::from_str(rewarder.unwrap()).unwrap(),
rate: rate.unwrap().parse::<u64>().unwrap()
},
signers: vec![check_and_update_err!(default_signer.signer_from_path(matches, wallet_manager), CliError::RpcRequestError("owner key is invalid".to_string()))?],
})
}
pub fn process_farming_mine_rewarder_set_annual_rate(
rpc_client: &RpcClient,
config: &CliConfig,
rewarder: Pubkey,
rate: u64,
) -> ProcessResult {
let ixs = [
new_set_annual_rewards(
rewarder,
config.pubkey().unwrap(),
rate,
)
];
let res = send_tx(rpc_client, config, &ixs)?;
Ok("signers : ".to_owned() + res.to_string().as_str())
}