mpl_trifle/instruction/constraint_model/
add_first_creator_constraint.rs

1use borsh::{BorshDeserialize, BorshSerialize};
2use solana_program::{
3    instruction::{AccountMeta, Instruction},
4    pubkey::Pubkey,
5    sysvar,
6};
7
8use crate::instruction::TrifleInstruction;
9
10#[repr(C)]
11#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
12#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
13pub struct AddFirstCreatorConstraintToEscrowConstraintModelArgs {
14    pub constraint_name: String,
15    pub token_limit: u64,
16    pub transfer_effects: u16,
17}
18
19#[allow(clippy::too_many_arguments)]
20pub fn add_first_creator_constraint_to_escrow_constraint_model(
21    program_id: &Pubkey,
22    escrow_constraint_model: &Pubkey,
23    payer: &Pubkey,
24    update_authority: &Pubkey,
25    first_creator: &Pubkey,
26    constraint_name: String,
27    token_limit: u64,
28    transfer_effects: u16,
29) -> Instruction {
30    let accounts = vec![
31        AccountMeta::new(*escrow_constraint_model, false),
32        AccountMeta::new(*payer, true),
33        AccountMeta::new_readonly(*update_authority, true),
34        AccountMeta::new_readonly(*first_creator, false),
35        AccountMeta::new_readonly(solana_program::system_program::id(), false),
36        AccountMeta::new_readonly(sysvar::instructions::id(), false),
37    ];
38
39    Instruction {
40        program_id: *program_id,
41        accounts,
42        data: TrifleInstruction::AddFirstCreatorConstraintToEscrowConstraintModel(
43            AddFirstCreatorConstraintToEscrowConstraintModelArgs {
44                constraint_name,
45                token_limit,
46                transfer_effects,
47            },
48        )
49        .try_to_vec()
50        .unwrap(),
51    }
52}