mpl_trifle/instruction/royalties/
set.rs

1use borsh::{BorshDeserialize, BorshSerialize};
2use solana_program::{
3    instruction::{AccountMeta, Instruction},
4    pubkey::Pubkey,
5    sysvar,
6};
7
8use crate::{instruction::TrifleInstruction, state::escrow_constraints::RoyaltyInstruction};
9
10#[repr(C)]
11#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
12#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
13pub struct SetRoyaltiesArgs {
14    pub name: String,
15    pub royalties: Vec<(RoyaltyInstruction, u64)>,
16}
17
18pub fn set_royalties(
19    program_id: &Pubkey,
20    escrow_constraint_model: &Pubkey,
21    payer: &Pubkey,
22    update_authority: &Pubkey,
23    name: String,
24    royalties: Vec<(RoyaltyInstruction, u64)>,
25) -> Instruction {
26    let accounts = vec![
27        AccountMeta::new(*escrow_constraint_model, false),
28        AccountMeta::new(*payer, true),
29        AccountMeta::new_readonly(*update_authority, false),
30        AccountMeta::new_readonly(solana_program::system_program::id(), false),
31        AccountMeta::new_readonly(sysvar::instructions::id(), false),
32    ];
33
34    Instruction {
35        program_id: *program_id,
36        accounts,
37        data: TrifleInstruction::SetRoyalties(SetRoyaltiesArgs { name, royalties })
38            .try_to_vec()
39            .unwrap(),
40    }
41}