1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::instruction::{AccountMeta, Instruction};
use solana_program::pubkey::Pubkey;

use crate::program::PROGRAM_ID;
use crate::utils::sighash;

#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)]
pub struct UpdatePartnerArgs {
    pub new_fee_rate: Option<u16>,
    pub new_claim_authority: Option<Pubkey>,
}

pub fn new_update_partner(
    payer: Pubkey,
    partner: &Pubkey,
    new_fee_rate: &Option<u16>,
    new_claim_authority: &Option<Pubkey>,
) -> Instruction {
    let data = &UpdatePartnerArgs {
        new_fee_rate: *new_fee_rate,
        new_claim_authority: *new_claim_authority,
    };
    let mut dsa = data.try_to_vec().unwrap();
    let mut distor = sighash::sighash("global", "update_partner").to_vec();
    distor.append(&mut dsa);
    Instruction {
        program_id: PROGRAM_ID,
        accounts: vec![
            AccountMeta::new(*partner, false),
            AccountMeta::new(payer, true),
        ],
        data: distor,
    }
}