Skip to main content

mpl_distro/generated/instructions/
create_distribution.rs

1//! This code was AUTOGENERATED using the kinobi library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun kinobi to update it.
4//!
5//! [https://github.com/metaplex-foundation/kinobi]
6//!
7
8use crate::generated::types::AllowedDistributor;
9use crate::generated::types::DistributionType;
10use borsh::BorshDeserialize;
11use borsh::BorshSerialize;
12use solana_program::pubkey;
13use solana_program::pubkey::Pubkey;
14
15/// Accounts.
16pub struct CreateDistribution {
17    /// The address of the new distribution
18    pub distribution: solana_program::pubkey::Pubkey,
19    /// The address of the mint account
20    pub mint: solana_program::pubkey::Pubkey,
21    /// The account paying for the storage fees
22    pub payer: solana_program::pubkey::Pubkey,
23    /// The authority of the distribution
24    pub authority: Option<solana_program::pubkey::Pubkey>,
25    /// The wallet where fees are sent
26    pub fee_wallet: solana_program::pubkey::Pubkey,
27    /// The seed for the distribution
28    pub seed: solana_program::pubkey::Pubkey,
29    /// The system program
30    pub system_program: solana_program::pubkey::Pubkey,
31}
32
33impl CreateDistribution {
34    pub fn instruction(
35        &self,
36        args: CreateDistributionInstructionArgs,
37    ) -> solana_program::instruction::Instruction {
38        self.instruction_with_remaining_accounts(args, &[])
39    }
40    #[allow(clippy::vec_init_then_push)]
41    pub fn instruction_with_remaining_accounts(
42        &self,
43        args: CreateDistributionInstructionArgs,
44        remaining_accounts: &[solana_program::instruction::AccountMeta],
45    ) -> solana_program::instruction::Instruction {
46        let mut accounts = Vec::with_capacity(7 + remaining_accounts.len());
47        accounts.push(solana_program::instruction::AccountMeta::new(
48            self.distribution,
49            false,
50        ));
51        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
52            self.mint, false,
53        ));
54        accounts.push(solana_program::instruction::AccountMeta::new(
55            self.payer, true,
56        ));
57        if let Some(authority) = self.authority {
58            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
59                authority, true,
60            ));
61        } else {
62            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
63                crate::MPL_DISTRO_ID,
64                false,
65            ));
66        }
67        accounts.push(solana_program::instruction::AccountMeta::new(
68            self.fee_wallet,
69            false,
70        ));
71        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
72            self.seed, true,
73        ));
74        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
75            self.system_program,
76            false,
77        ));
78        accounts.extend_from_slice(remaining_accounts);
79        let mut data = CreateDistributionInstructionData::new()
80            .try_to_vec()
81            .unwrap();
82        let mut args = args.try_to_vec().unwrap();
83        data.append(&mut args);
84
85        solana_program::instruction::Instruction {
86            program_id: crate::MPL_DISTRO_ID,
87            accounts,
88            data,
89        }
90    }
91}
92
93#[derive(BorshDeserialize, BorshSerialize)]
94struct CreateDistributionInstructionData {
95    discriminator: u8,
96}
97
98impl CreateDistributionInstructionData {
99    fn new() -> Self {
100        Self { discriminator: 0 }
101    }
102}
103
104#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
105#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
106pub struct CreateDistributionInstructionArgs {
107    pub merkle_root: [u8; 32],
108    pub tree_height: u8,
109    pub start_time: i64,
110    pub end_time: i64,
111    pub total_claimants: u64,
112    pub name: String,
113    pub distribution_type: DistributionType,
114    pub subsidize_receipts: bool,
115    pub allowed_distributor: AllowedDistributor,
116    pub permissioned_distributor: Pubkey,
117}
118
119/// Instruction builder for `CreateDistribution`.
120///
121/// ### Accounts:
122///
123///   0. `[writable]` distribution
124///   1. `[]` mint
125///   2. `[writable, signer]` payer
126///   3. `[signer, optional]` authority
127///   4. `[writable, optional]` fee_wallet (default to `9kFjQsxtpBsaw8s7aUyiY3wazYDNgFP4Lj5rsBVVF8tb`)
128///   5. `[signer]` seed
129///   6. `[optional]` system_program (default to `11111111111111111111111111111111`)
130#[derive(Default)]
131pub struct CreateDistributionBuilder {
132    distribution: Option<solana_program::pubkey::Pubkey>,
133    mint: Option<solana_program::pubkey::Pubkey>,
134    payer: Option<solana_program::pubkey::Pubkey>,
135    authority: Option<solana_program::pubkey::Pubkey>,
136    fee_wallet: Option<solana_program::pubkey::Pubkey>,
137    seed: Option<solana_program::pubkey::Pubkey>,
138    system_program: Option<solana_program::pubkey::Pubkey>,
139    merkle_root: Option<[u8; 32]>,
140    tree_height: Option<u8>,
141    start_time: Option<i64>,
142    end_time: Option<i64>,
143    total_claimants: Option<u64>,
144    name: Option<String>,
145    distribution_type: Option<DistributionType>,
146    subsidize_receipts: Option<bool>,
147    allowed_distributor: Option<AllowedDistributor>,
148    permissioned_distributor: Option<Pubkey>,
149    __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
150}
151
152impl CreateDistributionBuilder {
153    pub fn new() -> Self {
154        Self::default()
155    }
156    /// The address of the new distribution
157    #[inline(always)]
158    pub fn distribution(&mut self, distribution: solana_program::pubkey::Pubkey) -> &mut Self {
159        self.distribution = Some(distribution);
160        self
161    }
162    /// The address of the mint account
163    #[inline(always)]
164    pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
165        self.mint = Some(mint);
166        self
167    }
168    /// The account paying for the storage fees
169    #[inline(always)]
170    pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
171        self.payer = Some(payer);
172        self
173    }
174    /// `[optional account]`
175    /// The authority of the distribution
176    #[inline(always)]
177    pub fn authority(&mut self, authority: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
178        self.authority = authority;
179        self
180    }
181    /// `[optional account, default to '9kFjQsxtpBsaw8s7aUyiY3wazYDNgFP4Lj5rsBVVF8tb']`
182    /// The wallet where fees are sent
183    #[inline(always)]
184    pub fn fee_wallet(&mut self, fee_wallet: solana_program::pubkey::Pubkey) -> &mut Self {
185        self.fee_wallet = Some(fee_wallet);
186        self
187    }
188    /// The seed for the distribution
189    #[inline(always)]
190    pub fn seed(&mut self, seed: solana_program::pubkey::Pubkey) -> &mut Self {
191        self.seed = Some(seed);
192        self
193    }
194    /// `[optional account, default to '11111111111111111111111111111111']`
195    /// The system program
196    #[inline(always)]
197    pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
198        self.system_program = Some(system_program);
199        self
200    }
201    #[inline(always)]
202    pub fn merkle_root(&mut self, merkle_root: [u8; 32]) -> &mut Self {
203        self.merkle_root = Some(merkle_root);
204        self
205    }
206    #[inline(always)]
207    pub fn tree_height(&mut self, tree_height: u8) -> &mut Self {
208        self.tree_height = Some(tree_height);
209        self
210    }
211    #[inline(always)]
212    pub fn start_time(&mut self, start_time: i64) -> &mut Self {
213        self.start_time = Some(start_time);
214        self
215    }
216    #[inline(always)]
217    pub fn end_time(&mut self, end_time: i64) -> &mut Self {
218        self.end_time = Some(end_time);
219        self
220    }
221    #[inline(always)]
222    pub fn total_claimants(&mut self, total_claimants: u64) -> &mut Self {
223        self.total_claimants = Some(total_claimants);
224        self
225    }
226    #[inline(always)]
227    pub fn name(&mut self, name: String) -> &mut Self {
228        self.name = Some(name);
229        self
230    }
231    /// `[optional argument, defaults to 'DistributionType::Wallet']`
232    #[inline(always)]
233    pub fn distribution_type(&mut self, distribution_type: DistributionType) -> &mut Self {
234        self.distribution_type = Some(distribution_type);
235        self
236    }
237    /// `[optional argument, defaults to 'false']`
238    #[inline(always)]
239    pub fn subsidize_receipts(&mut self, subsidize_receipts: bool) -> &mut Self {
240        self.subsidize_receipts = Some(subsidize_receipts);
241        self
242    }
243    /// `[optional argument, defaults to 'AllowedDistributor::Permissionless']`
244    #[inline(always)]
245    pub fn allowed_distributor(&mut self, allowed_distributor: AllowedDistributor) -> &mut Self {
246        self.allowed_distributor = Some(allowed_distributor);
247        self
248    }
249    /// `[optional argument, defaults to 'pubkey!("11111111111111111111111111111111")']`
250    #[inline(always)]
251    pub fn permissioned_distributor(&mut self, permissioned_distributor: Pubkey) -> &mut Self {
252        self.permissioned_distributor = Some(permissioned_distributor);
253        self
254    }
255    /// Add an aditional account to the instruction.
256    #[inline(always)]
257    pub fn add_remaining_account(
258        &mut self,
259        account: solana_program::instruction::AccountMeta,
260    ) -> &mut Self {
261        self.__remaining_accounts.push(account);
262        self
263    }
264    /// Add additional accounts to the instruction.
265    #[inline(always)]
266    pub fn add_remaining_accounts(
267        &mut self,
268        accounts: &[solana_program::instruction::AccountMeta],
269    ) -> &mut Self {
270        self.__remaining_accounts.extend_from_slice(accounts);
271        self
272    }
273    #[allow(clippy::clone_on_copy)]
274    pub fn instruction(&self) -> solana_program::instruction::Instruction {
275        let accounts = CreateDistribution {
276            distribution: self.distribution.expect("distribution is not set"),
277            mint: self.mint.expect("mint is not set"),
278            payer: self.payer.expect("payer is not set"),
279            authority: self.authority,
280            fee_wallet: self.fee_wallet.unwrap_or(solana_program::pubkey!(
281                "9kFjQsxtpBsaw8s7aUyiY3wazYDNgFP4Lj5rsBVVF8tb"
282            )),
283            seed: self.seed.expect("seed is not set"),
284            system_program: self
285                .system_program
286                .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
287        };
288        let args = CreateDistributionInstructionArgs {
289            merkle_root: self.merkle_root.clone().expect("merkle_root is not set"),
290            tree_height: self.tree_height.clone().expect("tree_height is not set"),
291            start_time: self.start_time.clone().expect("start_time is not set"),
292            end_time: self.end_time.clone().expect("end_time is not set"),
293            total_claimants: self
294                .total_claimants
295                .clone()
296                .expect("total_claimants is not set"),
297            name: self.name.clone().expect("name is not set"),
298            distribution_type: self
299                .distribution_type
300                .clone()
301                .unwrap_or(DistributionType::Wallet),
302            subsidize_receipts: self.subsidize_receipts.clone().unwrap_or(false),
303            allowed_distributor: self
304                .allowed_distributor
305                .clone()
306                .unwrap_or(AllowedDistributor::Permissionless),
307            permissioned_distributor: self
308                .permissioned_distributor
309                .clone()
310                .unwrap_or(pubkey!("11111111111111111111111111111111")),
311        };
312
313        accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
314    }
315}
316
317/// `create_distribution` CPI accounts.
318pub struct CreateDistributionCpiAccounts<'a, 'b> {
319    /// The address of the new distribution
320    pub distribution: &'b solana_program::account_info::AccountInfo<'a>,
321    /// The address of the mint account
322    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
323    /// The account paying for the storage fees
324    pub payer: &'b solana_program::account_info::AccountInfo<'a>,
325    /// The authority of the distribution
326    pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
327    /// The wallet where fees are sent
328    pub fee_wallet: &'b solana_program::account_info::AccountInfo<'a>,
329    /// The seed for the distribution
330    pub seed: &'b solana_program::account_info::AccountInfo<'a>,
331    /// The system program
332    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
333}
334
335/// `create_distribution` CPI instruction.
336pub struct CreateDistributionCpi<'a, 'b> {
337    /// The program to invoke.
338    pub __program: &'b solana_program::account_info::AccountInfo<'a>,
339    /// The address of the new distribution
340    pub distribution: &'b solana_program::account_info::AccountInfo<'a>,
341    /// The address of the mint account
342    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
343    /// The account paying for the storage fees
344    pub payer: &'b solana_program::account_info::AccountInfo<'a>,
345    /// The authority of the distribution
346    pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
347    /// The wallet where fees are sent
348    pub fee_wallet: &'b solana_program::account_info::AccountInfo<'a>,
349    /// The seed for the distribution
350    pub seed: &'b solana_program::account_info::AccountInfo<'a>,
351    /// The system program
352    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
353    /// The arguments for the instruction.
354    pub __args: CreateDistributionInstructionArgs,
355}
356
357impl<'a, 'b> CreateDistributionCpi<'a, 'b> {
358    pub fn new(
359        program: &'b solana_program::account_info::AccountInfo<'a>,
360        accounts: CreateDistributionCpiAccounts<'a, 'b>,
361        args: CreateDistributionInstructionArgs,
362    ) -> Self {
363        Self {
364            __program: program,
365            distribution: accounts.distribution,
366            mint: accounts.mint,
367            payer: accounts.payer,
368            authority: accounts.authority,
369            fee_wallet: accounts.fee_wallet,
370            seed: accounts.seed,
371            system_program: accounts.system_program,
372            __args: args,
373        }
374    }
375    #[inline(always)]
376    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
377        self.invoke_signed_with_remaining_accounts(&[], &[])
378    }
379    #[inline(always)]
380    pub fn invoke_with_remaining_accounts(
381        &self,
382        remaining_accounts: &[(
383            &'b solana_program::account_info::AccountInfo<'a>,
384            bool,
385            bool,
386        )],
387    ) -> solana_program::entrypoint::ProgramResult {
388        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
389    }
390    #[inline(always)]
391    pub fn invoke_signed(
392        &self,
393        signers_seeds: &[&[&[u8]]],
394    ) -> solana_program::entrypoint::ProgramResult {
395        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
396    }
397    #[allow(clippy::clone_on_copy)]
398    #[allow(clippy::vec_init_then_push)]
399    pub fn invoke_signed_with_remaining_accounts(
400        &self,
401        signers_seeds: &[&[&[u8]]],
402        remaining_accounts: &[(
403            &'b solana_program::account_info::AccountInfo<'a>,
404            bool,
405            bool,
406        )],
407    ) -> solana_program::entrypoint::ProgramResult {
408        let mut accounts = Vec::with_capacity(7 + remaining_accounts.len());
409        accounts.push(solana_program::instruction::AccountMeta::new(
410            *self.distribution.key,
411            false,
412        ));
413        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
414            *self.mint.key,
415            false,
416        ));
417        accounts.push(solana_program::instruction::AccountMeta::new(
418            *self.payer.key,
419            true,
420        ));
421        if let Some(authority) = self.authority {
422            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
423                *authority.key,
424                true,
425            ));
426        } else {
427            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
428                crate::MPL_DISTRO_ID,
429                false,
430            ));
431        }
432        accounts.push(solana_program::instruction::AccountMeta::new(
433            *self.fee_wallet.key,
434            false,
435        ));
436        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
437            *self.seed.key,
438            true,
439        ));
440        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
441            *self.system_program.key,
442            false,
443        ));
444        remaining_accounts.iter().for_each(|remaining_account| {
445            accounts.push(solana_program::instruction::AccountMeta {
446                pubkey: *remaining_account.0.key,
447                is_signer: remaining_account.1,
448                is_writable: remaining_account.2,
449            })
450        });
451        let mut data = CreateDistributionInstructionData::new()
452            .try_to_vec()
453            .unwrap();
454        let mut args = self.__args.try_to_vec().unwrap();
455        data.append(&mut args);
456
457        let instruction = solana_program::instruction::Instruction {
458            program_id: crate::MPL_DISTRO_ID,
459            accounts,
460            data,
461        };
462        let mut account_infos = Vec::with_capacity(7 + 1 + remaining_accounts.len());
463        account_infos.push(self.__program.clone());
464        account_infos.push(self.distribution.clone());
465        account_infos.push(self.mint.clone());
466        account_infos.push(self.payer.clone());
467        if let Some(authority) = self.authority {
468            account_infos.push(authority.clone());
469        }
470        account_infos.push(self.fee_wallet.clone());
471        account_infos.push(self.seed.clone());
472        account_infos.push(self.system_program.clone());
473        remaining_accounts
474            .iter()
475            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
476
477        if signers_seeds.is_empty() {
478            solana_program::program::invoke(&instruction, &account_infos)
479        } else {
480            solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
481        }
482    }
483}
484
485/// Instruction builder for `CreateDistribution` via CPI.
486///
487/// ### Accounts:
488///
489///   0. `[writable]` distribution
490///   1. `[]` mint
491///   2. `[writable, signer]` payer
492///   3. `[signer, optional]` authority
493///   4. `[writable]` fee_wallet
494///   5. `[signer]` seed
495///   6. `[]` system_program
496pub struct CreateDistributionCpiBuilder<'a, 'b> {
497    instruction: Box<CreateDistributionCpiBuilderInstruction<'a, 'b>>,
498}
499
500impl<'a, 'b> CreateDistributionCpiBuilder<'a, 'b> {
501    pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
502        let instruction = Box::new(CreateDistributionCpiBuilderInstruction {
503            __program: program,
504            distribution: None,
505            mint: None,
506            payer: None,
507            authority: None,
508            fee_wallet: None,
509            seed: None,
510            system_program: None,
511            merkle_root: None,
512            tree_height: None,
513            start_time: None,
514            end_time: None,
515            total_claimants: None,
516            name: None,
517            distribution_type: None,
518            subsidize_receipts: None,
519            allowed_distributor: None,
520            permissioned_distributor: None,
521            __remaining_accounts: Vec::new(),
522        });
523        Self { instruction }
524    }
525    /// The address of the new distribution
526    #[inline(always)]
527    pub fn distribution(
528        &mut self,
529        distribution: &'b solana_program::account_info::AccountInfo<'a>,
530    ) -> &mut Self {
531        self.instruction.distribution = Some(distribution);
532        self
533    }
534    /// The address of the mint account
535    #[inline(always)]
536    pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
537        self.instruction.mint = Some(mint);
538        self
539    }
540    /// The account paying for the storage fees
541    #[inline(always)]
542    pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
543        self.instruction.payer = Some(payer);
544        self
545    }
546    /// `[optional account]`
547    /// The authority of the distribution
548    #[inline(always)]
549    pub fn authority(
550        &mut self,
551        authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
552    ) -> &mut Self {
553        self.instruction.authority = authority;
554        self
555    }
556    /// The wallet where fees are sent
557    #[inline(always)]
558    pub fn fee_wallet(
559        &mut self,
560        fee_wallet: &'b solana_program::account_info::AccountInfo<'a>,
561    ) -> &mut Self {
562        self.instruction.fee_wallet = Some(fee_wallet);
563        self
564    }
565    /// The seed for the distribution
566    #[inline(always)]
567    pub fn seed(&mut self, seed: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
568        self.instruction.seed = Some(seed);
569        self
570    }
571    /// The system program
572    #[inline(always)]
573    pub fn system_program(
574        &mut self,
575        system_program: &'b solana_program::account_info::AccountInfo<'a>,
576    ) -> &mut Self {
577        self.instruction.system_program = Some(system_program);
578        self
579    }
580    #[inline(always)]
581    pub fn merkle_root(&mut self, merkle_root: [u8; 32]) -> &mut Self {
582        self.instruction.merkle_root = Some(merkle_root);
583        self
584    }
585    #[inline(always)]
586    pub fn tree_height(&mut self, tree_height: u8) -> &mut Self {
587        self.instruction.tree_height = Some(tree_height);
588        self
589    }
590    #[inline(always)]
591    pub fn start_time(&mut self, start_time: i64) -> &mut Self {
592        self.instruction.start_time = Some(start_time);
593        self
594    }
595    #[inline(always)]
596    pub fn end_time(&mut self, end_time: i64) -> &mut Self {
597        self.instruction.end_time = Some(end_time);
598        self
599    }
600    #[inline(always)]
601    pub fn total_claimants(&mut self, total_claimants: u64) -> &mut Self {
602        self.instruction.total_claimants = Some(total_claimants);
603        self
604    }
605    #[inline(always)]
606    pub fn name(&mut self, name: String) -> &mut Self {
607        self.instruction.name = Some(name);
608        self
609    }
610    /// `[optional argument, defaults to 'DistributionType::Wallet']`
611    #[inline(always)]
612    pub fn distribution_type(&mut self, distribution_type: DistributionType) -> &mut Self {
613        self.instruction.distribution_type = Some(distribution_type);
614        self
615    }
616    /// `[optional argument, defaults to 'false']`
617    #[inline(always)]
618    pub fn subsidize_receipts(&mut self, subsidize_receipts: bool) -> &mut Self {
619        self.instruction.subsidize_receipts = Some(subsidize_receipts);
620        self
621    }
622    /// `[optional argument, defaults to 'AllowedDistributor::Permissionless']`
623    #[inline(always)]
624    pub fn allowed_distributor(&mut self, allowed_distributor: AllowedDistributor) -> &mut Self {
625        self.instruction.allowed_distributor = Some(allowed_distributor);
626        self
627    }
628    /// `[optional argument, defaults to 'pubkey!("11111111111111111111111111111111")']`
629    #[inline(always)]
630    pub fn permissioned_distributor(&mut self, permissioned_distributor: Pubkey) -> &mut Self {
631        self.instruction.permissioned_distributor = Some(permissioned_distributor);
632        self
633    }
634    /// Add an additional account to the instruction.
635    #[inline(always)]
636    pub fn add_remaining_account(
637        &mut self,
638        account: &'b solana_program::account_info::AccountInfo<'a>,
639        is_writable: bool,
640        is_signer: bool,
641    ) -> &mut Self {
642        self.instruction
643            .__remaining_accounts
644            .push((account, is_writable, is_signer));
645        self
646    }
647    /// Add additional accounts to the instruction.
648    ///
649    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
650    /// and a `bool` indicating whether the account is a signer or not.
651    #[inline(always)]
652    pub fn add_remaining_accounts(
653        &mut self,
654        accounts: &[(
655            &'b solana_program::account_info::AccountInfo<'a>,
656            bool,
657            bool,
658        )],
659    ) -> &mut Self {
660        self.instruction
661            .__remaining_accounts
662            .extend_from_slice(accounts);
663        self
664    }
665    #[inline(always)]
666    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
667        self.invoke_signed(&[])
668    }
669    #[allow(clippy::clone_on_copy)]
670    #[allow(clippy::vec_init_then_push)]
671    pub fn invoke_signed(
672        &self,
673        signers_seeds: &[&[&[u8]]],
674    ) -> solana_program::entrypoint::ProgramResult {
675        let args = CreateDistributionInstructionArgs {
676            merkle_root: self
677                .instruction
678                .merkle_root
679                .clone()
680                .expect("merkle_root is not set"),
681            tree_height: self
682                .instruction
683                .tree_height
684                .clone()
685                .expect("tree_height is not set"),
686            start_time: self
687                .instruction
688                .start_time
689                .clone()
690                .expect("start_time is not set"),
691            end_time: self
692                .instruction
693                .end_time
694                .clone()
695                .expect("end_time is not set"),
696            total_claimants: self
697                .instruction
698                .total_claimants
699                .clone()
700                .expect("total_claimants is not set"),
701            name: self.instruction.name.clone().expect("name is not set"),
702            distribution_type: self
703                .instruction
704                .distribution_type
705                .clone()
706                .unwrap_or(DistributionType::Wallet),
707            subsidize_receipts: self.instruction.subsidize_receipts.clone().unwrap_or(false),
708            allowed_distributor: self
709                .instruction
710                .allowed_distributor
711                .clone()
712                .unwrap_or(AllowedDistributor::Permissionless),
713            permissioned_distributor: self
714                .instruction
715                .permissioned_distributor
716                .clone()
717                .unwrap_or(pubkey!("11111111111111111111111111111111")),
718        };
719        let instruction = CreateDistributionCpi {
720            __program: self.instruction.__program,
721
722            distribution: self
723                .instruction
724                .distribution
725                .expect("distribution is not set"),
726
727            mint: self.instruction.mint.expect("mint is not set"),
728
729            payer: self.instruction.payer.expect("payer is not set"),
730
731            authority: self.instruction.authority,
732
733            fee_wallet: self.instruction.fee_wallet.expect("fee_wallet is not set"),
734
735            seed: self.instruction.seed.expect("seed is not set"),
736
737            system_program: self
738                .instruction
739                .system_program
740                .expect("system_program is not set"),
741            __args: args,
742        };
743        instruction.invoke_signed_with_remaining_accounts(
744            signers_seeds,
745            &self.instruction.__remaining_accounts,
746        )
747    }
748}
749
750struct CreateDistributionCpiBuilderInstruction<'a, 'b> {
751    __program: &'b solana_program::account_info::AccountInfo<'a>,
752    distribution: Option<&'b solana_program::account_info::AccountInfo<'a>>,
753    mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
754    payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
755    authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
756    fee_wallet: Option<&'b solana_program::account_info::AccountInfo<'a>>,
757    seed: Option<&'b solana_program::account_info::AccountInfo<'a>>,
758    system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
759    merkle_root: Option<[u8; 32]>,
760    tree_height: Option<u8>,
761    start_time: Option<i64>,
762    end_time: Option<i64>,
763    total_claimants: Option<u64>,
764    name: Option<String>,
765    distribution_type: Option<DistributionType>,
766    subsidize_receipts: Option<bool>,
767    allowed_distributor: Option<AllowedDistributor>,
768    permissioned_distributor: Option<Pubkey>,
769    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
770    __remaining_accounts: Vec<(
771        &'b solana_program::account_info::AccountInfo<'a>,
772        bool,
773        bool,
774    )>,
775}