use std::str::FromStr;
use solana_client::rpc_client::RpcClient;
use solana_program::pubkey::Pubkey;
use common::command::{CliConfig, ProcessResult};
use common::contract::instructions::farming::quarry_mine::update_quarry_rewards::new_update_quarry_rewards;
use common::program::MINE_PROGRAM_ID;
use common::utils::send::send_tx;
pub fn process_farming_mine_rewarder_sync_quarry_rewards(
rpc_client: &RpcClient,
config: &CliConfig,
rewarder: Pubkey,
mint: &str,
) -> ProcessResult {
let mints = mint.split(",");
let mut mint_pks = vec![];
for m in mints {
mint_pks.push(Pubkey::from_str(m).unwrap());
}
let mut ixs = vec![];
for m in mint_pks {
let (quarry, _) = Pubkey::find_program_address(
&[
b"Quarry",
rewarder.as_ref(),
m.as_ref(),
],
&MINE_PROGRAM_ID,
);
ixs.push(new_update_quarry_rewards(
quarry,
rewarder,
));
}
let res = send_tx(rpc_client, config, &ixs)?;
Ok("signers : ".to_owned() + res.to_string().as_str())
}