td_program_sdk/instructions/
update_player_authority.rs

1use solana_sdk::{
2    instruction::{AccountMeta, Instruction},
3    pubkey::Pubkey,
4};
5
6use crate::PROGRAM_ID;
7
8use super::InstructionDiscriminator;
9
10#[inline(always)]
11pub fn update_player_authority(
12    player: &Pubkey,
13    signer: &Pubkey,
14    new_authority: &Pubkey,
15) -> Instruction {
16    let account_metas: [AccountMeta; 3] = [
17        AccountMeta::new(*player, false),
18        AccountMeta::new(*signer, true),
19        AccountMeta::new(*new_authority, false),
20    ];
21
22    // Instruction data layout:
23    // -  [0]: instruction discriminator (1 byte, u8)
24    let data_len = 1;
25    let instruction_data = vec![InstructionDiscriminator::UpdatePlayerAuthority as u8; data_len];
26
27    Instruction {
28        program_id: PROGRAM_ID,
29        accounts: account_metas.to_vec(),
30        data: instruction_data,
31    }
32}