use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::instruction::{AccountMeta, Instruction};
use solana_program::pubkey::Pubkey;
use crate::program::MINE_PROGRAM_ID;
use crate::utils::sighash;
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)]
pub struct TransferAdmin {
pub new_authority: Pubkey,
}
pub fn transfer_authority(rewarder: Pubkey, admin: Pubkey, next_admin: Pubkey) -> Instruction {
let data = &TransferAdmin {
new_authority: next_admin,
};
let mut dsa = data.try_to_vec().unwrap();
let mut distor = sighash::sighash("global", "transfer_authority").to_vec();
distor.append(&mut dsa);
Instruction {
program_id: MINE_PROGRAM_ID,
accounts: vec![
AccountMeta::new_readonly(admin, true),
AccountMeta::new(rewarder, false),
],
data: distor,
}
}