mpl_trifle/instruction/constraint_model/
add_collection_constraint.rs1use 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 AddCollectionConstraintToEscrowConstraintModelArgs {
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_collection_constraint_to_escrow_constraint_model(
21 program_id: &Pubkey,
22 escrow_constraint_model: &Pubkey,
23 payer: &Pubkey,
24 update_authority: &Pubkey,
25 collection_mint: &Pubkey,
26 collection_mint_metadata: &Pubkey,
27 constraint_name: String,
28 token_limit: u64,
29 transfer_effects: u16,
30) -> Instruction {
31 let accounts = vec![
32 AccountMeta::new(*escrow_constraint_model, false),
33 AccountMeta::new(*payer, true),
34 AccountMeta::new_readonly(*update_authority, true),
35 AccountMeta::new_readonly(*collection_mint, false),
36 AccountMeta::new_readonly(*collection_mint_metadata, false),
37 AccountMeta::new_readonly(solana_program::system_program::id(), false),
38 AccountMeta::new_readonly(sysvar::instructions::id(), false),
39 ];
40
41 Instruction {
42 program_id: *program_id,
43 accounts,
44 data: TrifleInstruction::AddCollectionConstraintToEscrowConstraintModel(
45 AddCollectionConstraintToEscrowConstraintModelArgs {
46 constraint_name,
47 token_limit,
48 transfer_effects,
49 },
50 )
51 .try_to_vec()
52 .unwrap(),
53 }
54}