tensor_marketplace/generated/instructions/
buy_t22.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/kinobi-so/kinobi>
6//!
7
8use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11/// Accounts.
12pub struct BuyT22 {
13    pub fee_vault: solana_program::pubkey::Pubkey,
14
15    pub buyer: solana_program::pubkey::Pubkey,
16
17    pub buyer_ta: solana_program::pubkey::Pubkey,
18
19    pub list_state: solana_program::pubkey::Pubkey,
20
21    pub list_ta: solana_program::pubkey::Pubkey,
22
23    pub mint: solana_program::pubkey::Pubkey,
24
25    pub owner: solana_program::pubkey::Pubkey,
26
27    pub payer: solana_program::pubkey::Pubkey,
28
29    pub taker_broker: Option<solana_program::pubkey::Pubkey>,
30
31    pub maker_broker: Option<solana_program::pubkey::Pubkey>,
32
33    pub rent_destination: solana_program::pubkey::Pubkey,
34
35    pub token_program: solana_program::pubkey::Pubkey,
36
37    pub associated_token_program: solana_program::pubkey::Pubkey,
38
39    pub marketplace_program: solana_program::pubkey::Pubkey,
40
41    pub system_program: solana_program::pubkey::Pubkey,
42
43    pub cosigner: Option<solana_program::pubkey::Pubkey>,
44}
45
46impl BuyT22 {
47    pub fn instruction(
48        &self,
49        args: BuyT22InstructionArgs,
50    ) -> solana_program::instruction::Instruction {
51        self.instruction_with_remaining_accounts(args, &[])
52    }
53    #[allow(clippy::vec_init_then_push)]
54    pub fn instruction_with_remaining_accounts(
55        &self,
56        args: BuyT22InstructionArgs,
57        remaining_accounts: &[solana_program::instruction::AccountMeta],
58    ) -> solana_program::instruction::Instruction {
59        let mut accounts = Vec::with_capacity(16 + remaining_accounts.len());
60        accounts.push(solana_program::instruction::AccountMeta::new(
61            self.fee_vault,
62            false,
63        ));
64        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
65            self.buyer, false,
66        ));
67        accounts.push(solana_program::instruction::AccountMeta::new(
68            self.buyer_ta,
69            false,
70        ));
71        accounts.push(solana_program::instruction::AccountMeta::new(
72            self.list_state,
73            false,
74        ));
75        accounts.push(solana_program::instruction::AccountMeta::new(
76            self.list_ta,
77            false,
78        ));
79        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
80            self.mint, false,
81        ));
82        accounts.push(solana_program::instruction::AccountMeta::new(
83            self.owner, false,
84        ));
85        accounts.push(solana_program::instruction::AccountMeta::new(
86            self.payer, true,
87        ));
88        if let Some(taker_broker) = self.taker_broker {
89            accounts.push(solana_program::instruction::AccountMeta::new(
90                taker_broker,
91                false,
92            ));
93        } else {
94            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
95                crate::TENSOR_MARKETPLACE_ID,
96                false,
97            ));
98        }
99        if let Some(maker_broker) = self.maker_broker {
100            accounts.push(solana_program::instruction::AccountMeta::new(
101                maker_broker,
102                false,
103            ));
104        } else {
105            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
106                crate::TENSOR_MARKETPLACE_ID,
107                false,
108            ));
109        }
110        accounts.push(solana_program::instruction::AccountMeta::new(
111            self.rent_destination,
112            false,
113        ));
114        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
115            self.token_program,
116            false,
117        ));
118        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
119            self.associated_token_program,
120            false,
121        ));
122        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
123            self.marketplace_program,
124            false,
125        ));
126        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
127            self.system_program,
128            false,
129        ));
130        if let Some(cosigner) = self.cosigner {
131            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
132                cosigner, true,
133            ));
134        } else {
135            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
136                crate::TENSOR_MARKETPLACE_ID,
137                false,
138            ));
139        }
140        accounts.extend_from_slice(remaining_accounts);
141        let mut data = BuyT22InstructionData::new().try_to_vec().unwrap();
142        let mut args = args.try_to_vec().unwrap();
143        data.append(&mut args);
144
145        solana_program::instruction::Instruction {
146            program_id: crate::TENSOR_MARKETPLACE_ID,
147            accounts,
148            data,
149        }
150    }
151}
152
153#[derive(BorshDeserialize, BorshSerialize)]
154pub struct BuyT22InstructionData {
155    discriminator: [u8; 8],
156}
157
158impl BuyT22InstructionData {
159    pub fn new() -> Self {
160        Self {
161            discriminator: [81, 98, 227, 171, 201, 105, 180, 216],
162        }
163    }
164}
165
166impl Default for BuyT22InstructionData {
167    fn default() -> Self {
168        Self::new()
169    }
170}
171
172#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
173#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
174pub struct BuyT22InstructionArgs {
175    pub max_amount: u64,
176}
177
178/// Instruction builder for `BuyT22`.
179///
180/// ### Accounts:
181///
182///   0. `[writable]` fee_vault
183///   1. `[]` buyer
184///   2. `[writable]` buyer_ta
185///   3. `[writable]` list_state
186///   4. `[writable]` list_ta
187///   5. `[]` mint
188///   6. `[writable]` owner
189///   7. `[writable, signer]` payer
190///   8. `[writable, optional]` taker_broker
191///   9. `[writable, optional]` maker_broker
192///   10. `[writable]` rent_destination
193///   11. `[optional]` token_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`)
194///   12. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`)
195///   13. `[optional]` marketplace_program (default to `TCMPhJdwDryooaGtiocG1u3xcYbRpiJzb283XfCZsDp`)
196///   14. `[optional]` system_program (default to `11111111111111111111111111111111`)
197///   15. `[signer, optional]` cosigner
198#[derive(Clone, Debug, Default)]
199pub struct BuyT22Builder {
200    fee_vault: Option<solana_program::pubkey::Pubkey>,
201    buyer: Option<solana_program::pubkey::Pubkey>,
202    buyer_ta: Option<solana_program::pubkey::Pubkey>,
203    list_state: Option<solana_program::pubkey::Pubkey>,
204    list_ta: Option<solana_program::pubkey::Pubkey>,
205    mint: Option<solana_program::pubkey::Pubkey>,
206    owner: Option<solana_program::pubkey::Pubkey>,
207    payer: Option<solana_program::pubkey::Pubkey>,
208    taker_broker: Option<solana_program::pubkey::Pubkey>,
209    maker_broker: Option<solana_program::pubkey::Pubkey>,
210    rent_destination: Option<solana_program::pubkey::Pubkey>,
211    token_program: Option<solana_program::pubkey::Pubkey>,
212    associated_token_program: Option<solana_program::pubkey::Pubkey>,
213    marketplace_program: Option<solana_program::pubkey::Pubkey>,
214    system_program: Option<solana_program::pubkey::Pubkey>,
215    cosigner: Option<solana_program::pubkey::Pubkey>,
216    max_amount: Option<u64>,
217    __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
218}
219
220impl BuyT22Builder {
221    pub fn new() -> Self {
222        Self::default()
223    }
224    #[inline(always)]
225    pub fn fee_vault(&mut self, fee_vault: solana_program::pubkey::Pubkey) -> &mut Self {
226        self.fee_vault = Some(fee_vault);
227        self
228    }
229    #[inline(always)]
230    pub fn buyer(&mut self, buyer: solana_program::pubkey::Pubkey) -> &mut Self {
231        self.buyer = Some(buyer);
232        self
233    }
234    #[inline(always)]
235    pub fn buyer_ta(&mut self, buyer_ta: solana_program::pubkey::Pubkey) -> &mut Self {
236        self.buyer_ta = Some(buyer_ta);
237        self
238    }
239    #[inline(always)]
240    pub fn list_state(&mut self, list_state: solana_program::pubkey::Pubkey) -> &mut Self {
241        self.list_state = Some(list_state);
242        self
243    }
244    #[inline(always)]
245    pub fn list_ta(&mut self, list_ta: solana_program::pubkey::Pubkey) -> &mut Self {
246        self.list_ta = Some(list_ta);
247        self
248    }
249    #[inline(always)]
250    pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
251        self.mint = Some(mint);
252        self
253    }
254    #[inline(always)]
255    pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self {
256        self.owner = Some(owner);
257        self
258    }
259    #[inline(always)]
260    pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
261        self.payer = Some(payer);
262        self
263    }
264    /// `[optional account]`
265    #[inline(always)]
266    pub fn taker_broker(
267        &mut self,
268        taker_broker: Option<solana_program::pubkey::Pubkey>,
269    ) -> &mut Self {
270        self.taker_broker = taker_broker;
271        self
272    }
273    /// `[optional account]`
274    #[inline(always)]
275    pub fn maker_broker(
276        &mut self,
277        maker_broker: Option<solana_program::pubkey::Pubkey>,
278    ) -> &mut Self {
279        self.maker_broker = maker_broker;
280        self
281    }
282    #[inline(always)]
283    pub fn rent_destination(
284        &mut self,
285        rent_destination: solana_program::pubkey::Pubkey,
286    ) -> &mut Self {
287        self.rent_destination = Some(rent_destination);
288        self
289    }
290    /// `[optional account, default to 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb']`
291    #[inline(always)]
292    pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self {
293        self.token_program = Some(token_program);
294        self
295    }
296    /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']`
297    #[inline(always)]
298    pub fn associated_token_program(
299        &mut self,
300        associated_token_program: solana_program::pubkey::Pubkey,
301    ) -> &mut Self {
302        self.associated_token_program = Some(associated_token_program);
303        self
304    }
305    /// `[optional account, default to 'TCMPhJdwDryooaGtiocG1u3xcYbRpiJzb283XfCZsDp']`
306    #[inline(always)]
307    pub fn marketplace_program(
308        &mut self,
309        marketplace_program: solana_program::pubkey::Pubkey,
310    ) -> &mut Self {
311        self.marketplace_program = Some(marketplace_program);
312        self
313    }
314    /// `[optional account, default to '11111111111111111111111111111111']`
315    #[inline(always)]
316    pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
317        self.system_program = Some(system_program);
318        self
319    }
320    /// `[optional account]`
321    #[inline(always)]
322    pub fn cosigner(&mut self, cosigner: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
323        self.cosigner = cosigner;
324        self
325    }
326    #[inline(always)]
327    pub fn max_amount(&mut self, max_amount: u64) -> &mut Self {
328        self.max_amount = Some(max_amount);
329        self
330    }
331    /// Add an aditional account to the instruction.
332    #[inline(always)]
333    pub fn add_remaining_account(
334        &mut self,
335        account: solana_program::instruction::AccountMeta,
336    ) -> &mut Self {
337        self.__remaining_accounts.push(account);
338        self
339    }
340    /// Add additional accounts to the instruction.
341    #[inline(always)]
342    pub fn add_remaining_accounts(
343        &mut self,
344        accounts: &[solana_program::instruction::AccountMeta],
345    ) -> &mut Self {
346        self.__remaining_accounts.extend_from_slice(accounts);
347        self
348    }
349    #[allow(clippy::clone_on_copy)]
350    pub fn instruction(&self) -> solana_program::instruction::Instruction {
351        let accounts = BuyT22 {
352            fee_vault: self.fee_vault.expect("fee_vault is not set"),
353            buyer: self.buyer.expect("buyer is not set"),
354            buyer_ta: self.buyer_ta.expect("buyer_ta is not set"),
355            list_state: self.list_state.expect("list_state is not set"),
356            list_ta: self.list_ta.expect("list_ta is not set"),
357            mint: self.mint.expect("mint is not set"),
358            owner: self.owner.expect("owner is not set"),
359            payer: self.payer.expect("payer is not set"),
360            taker_broker: self.taker_broker,
361            maker_broker: self.maker_broker,
362            rent_destination: self.rent_destination.expect("rent_destination is not set"),
363            token_program: self.token_program.unwrap_or(solana_program::pubkey!(
364                "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
365            )),
366            associated_token_program: self.associated_token_program.unwrap_or(
367                solana_program::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),
368            ),
369            marketplace_program: self.marketplace_program.unwrap_or(solana_program::pubkey!(
370                "TCMPhJdwDryooaGtiocG1u3xcYbRpiJzb283XfCZsDp"
371            )),
372            system_program: self
373                .system_program
374                .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
375            cosigner: self.cosigner,
376        };
377        let args = BuyT22InstructionArgs {
378            max_amount: self.max_amount.clone().expect("max_amount is not set"),
379        };
380
381        accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
382    }
383}
384
385/// `buy_t22` CPI accounts.
386pub struct BuyT22CpiAccounts<'a, 'b> {
387    pub fee_vault: &'b solana_program::account_info::AccountInfo<'a>,
388
389    pub buyer: &'b solana_program::account_info::AccountInfo<'a>,
390
391    pub buyer_ta: &'b solana_program::account_info::AccountInfo<'a>,
392
393    pub list_state: &'b solana_program::account_info::AccountInfo<'a>,
394
395    pub list_ta: &'b solana_program::account_info::AccountInfo<'a>,
396
397    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
398
399    pub owner: &'b solana_program::account_info::AccountInfo<'a>,
400
401    pub payer: &'b solana_program::account_info::AccountInfo<'a>,
402
403    pub taker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
404
405    pub maker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
406
407    pub rent_destination: &'b solana_program::account_info::AccountInfo<'a>,
408
409    pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
410
411    pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
412
413    pub marketplace_program: &'b solana_program::account_info::AccountInfo<'a>,
414
415    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
416
417    pub cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
418}
419
420/// `buy_t22` CPI instruction.
421pub struct BuyT22Cpi<'a, 'b> {
422    /// The program to invoke.
423    pub __program: &'b solana_program::account_info::AccountInfo<'a>,
424
425    pub fee_vault: &'b solana_program::account_info::AccountInfo<'a>,
426
427    pub buyer: &'b solana_program::account_info::AccountInfo<'a>,
428
429    pub buyer_ta: &'b solana_program::account_info::AccountInfo<'a>,
430
431    pub list_state: &'b solana_program::account_info::AccountInfo<'a>,
432
433    pub list_ta: &'b solana_program::account_info::AccountInfo<'a>,
434
435    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
436
437    pub owner: &'b solana_program::account_info::AccountInfo<'a>,
438
439    pub payer: &'b solana_program::account_info::AccountInfo<'a>,
440
441    pub taker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
442
443    pub maker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
444
445    pub rent_destination: &'b solana_program::account_info::AccountInfo<'a>,
446
447    pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
448
449    pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
450
451    pub marketplace_program: &'b solana_program::account_info::AccountInfo<'a>,
452
453    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
454
455    pub cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
456    /// The arguments for the instruction.
457    pub __args: BuyT22InstructionArgs,
458}
459
460impl<'a, 'b> BuyT22Cpi<'a, 'b> {
461    pub fn new(
462        program: &'b solana_program::account_info::AccountInfo<'a>,
463        accounts: BuyT22CpiAccounts<'a, 'b>,
464        args: BuyT22InstructionArgs,
465    ) -> Self {
466        Self {
467            __program: program,
468            fee_vault: accounts.fee_vault,
469            buyer: accounts.buyer,
470            buyer_ta: accounts.buyer_ta,
471            list_state: accounts.list_state,
472            list_ta: accounts.list_ta,
473            mint: accounts.mint,
474            owner: accounts.owner,
475            payer: accounts.payer,
476            taker_broker: accounts.taker_broker,
477            maker_broker: accounts.maker_broker,
478            rent_destination: accounts.rent_destination,
479            token_program: accounts.token_program,
480            associated_token_program: accounts.associated_token_program,
481            marketplace_program: accounts.marketplace_program,
482            system_program: accounts.system_program,
483            cosigner: accounts.cosigner,
484            __args: args,
485        }
486    }
487    #[inline(always)]
488    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
489        self.invoke_signed_with_remaining_accounts(&[], &[])
490    }
491    #[inline(always)]
492    pub fn invoke_with_remaining_accounts(
493        &self,
494        remaining_accounts: &[(
495            &'b solana_program::account_info::AccountInfo<'a>,
496            bool,
497            bool,
498        )],
499    ) -> solana_program::entrypoint::ProgramResult {
500        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
501    }
502    #[inline(always)]
503    pub fn invoke_signed(
504        &self,
505        signers_seeds: &[&[&[u8]]],
506    ) -> solana_program::entrypoint::ProgramResult {
507        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
508    }
509    #[allow(clippy::clone_on_copy)]
510    #[allow(clippy::vec_init_then_push)]
511    pub fn invoke_signed_with_remaining_accounts(
512        &self,
513        signers_seeds: &[&[&[u8]]],
514        remaining_accounts: &[(
515            &'b solana_program::account_info::AccountInfo<'a>,
516            bool,
517            bool,
518        )],
519    ) -> solana_program::entrypoint::ProgramResult {
520        let mut accounts = Vec::with_capacity(16 + remaining_accounts.len());
521        accounts.push(solana_program::instruction::AccountMeta::new(
522            *self.fee_vault.key,
523            false,
524        ));
525        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
526            *self.buyer.key,
527            false,
528        ));
529        accounts.push(solana_program::instruction::AccountMeta::new(
530            *self.buyer_ta.key,
531            false,
532        ));
533        accounts.push(solana_program::instruction::AccountMeta::new(
534            *self.list_state.key,
535            false,
536        ));
537        accounts.push(solana_program::instruction::AccountMeta::new(
538            *self.list_ta.key,
539            false,
540        ));
541        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
542            *self.mint.key,
543            false,
544        ));
545        accounts.push(solana_program::instruction::AccountMeta::new(
546            *self.owner.key,
547            false,
548        ));
549        accounts.push(solana_program::instruction::AccountMeta::new(
550            *self.payer.key,
551            true,
552        ));
553        if let Some(taker_broker) = self.taker_broker {
554            accounts.push(solana_program::instruction::AccountMeta::new(
555                *taker_broker.key,
556                false,
557            ));
558        } else {
559            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
560                crate::TENSOR_MARKETPLACE_ID,
561                false,
562            ));
563        }
564        if let Some(maker_broker) = self.maker_broker {
565            accounts.push(solana_program::instruction::AccountMeta::new(
566                *maker_broker.key,
567                false,
568            ));
569        } else {
570            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
571                crate::TENSOR_MARKETPLACE_ID,
572                false,
573            ));
574        }
575        accounts.push(solana_program::instruction::AccountMeta::new(
576            *self.rent_destination.key,
577            false,
578        ));
579        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
580            *self.token_program.key,
581            false,
582        ));
583        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
584            *self.associated_token_program.key,
585            false,
586        ));
587        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
588            *self.marketplace_program.key,
589            false,
590        ));
591        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
592            *self.system_program.key,
593            false,
594        ));
595        if let Some(cosigner) = self.cosigner {
596            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
597                *cosigner.key,
598                true,
599            ));
600        } else {
601            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
602                crate::TENSOR_MARKETPLACE_ID,
603                false,
604            ));
605        }
606        remaining_accounts.iter().for_each(|remaining_account| {
607            accounts.push(solana_program::instruction::AccountMeta {
608                pubkey: *remaining_account.0.key,
609                is_signer: remaining_account.1,
610                is_writable: remaining_account.2,
611            })
612        });
613        let mut data = BuyT22InstructionData::new().try_to_vec().unwrap();
614        let mut args = self.__args.try_to_vec().unwrap();
615        data.append(&mut args);
616
617        let instruction = solana_program::instruction::Instruction {
618            program_id: crate::TENSOR_MARKETPLACE_ID,
619            accounts,
620            data,
621        };
622        let mut account_infos = Vec::with_capacity(16 + 1 + remaining_accounts.len());
623        account_infos.push(self.__program.clone());
624        account_infos.push(self.fee_vault.clone());
625        account_infos.push(self.buyer.clone());
626        account_infos.push(self.buyer_ta.clone());
627        account_infos.push(self.list_state.clone());
628        account_infos.push(self.list_ta.clone());
629        account_infos.push(self.mint.clone());
630        account_infos.push(self.owner.clone());
631        account_infos.push(self.payer.clone());
632        if let Some(taker_broker) = self.taker_broker {
633            account_infos.push(taker_broker.clone());
634        }
635        if let Some(maker_broker) = self.maker_broker {
636            account_infos.push(maker_broker.clone());
637        }
638        account_infos.push(self.rent_destination.clone());
639        account_infos.push(self.token_program.clone());
640        account_infos.push(self.associated_token_program.clone());
641        account_infos.push(self.marketplace_program.clone());
642        account_infos.push(self.system_program.clone());
643        if let Some(cosigner) = self.cosigner {
644            account_infos.push(cosigner.clone());
645        }
646        remaining_accounts
647            .iter()
648            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
649
650        if signers_seeds.is_empty() {
651            solana_program::program::invoke(&instruction, &account_infos)
652        } else {
653            solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
654        }
655    }
656}
657
658/// Instruction builder for `BuyT22` via CPI.
659///
660/// ### Accounts:
661///
662///   0. `[writable]` fee_vault
663///   1. `[]` buyer
664///   2. `[writable]` buyer_ta
665///   3. `[writable]` list_state
666///   4. `[writable]` list_ta
667///   5. `[]` mint
668///   6. `[writable]` owner
669///   7. `[writable, signer]` payer
670///   8. `[writable, optional]` taker_broker
671///   9. `[writable, optional]` maker_broker
672///   10. `[writable]` rent_destination
673///   11. `[]` token_program
674///   12. `[]` associated_token_program
675///   13. `[]` marketplace_program
676///   14. `[]` system_program
677///   15. `[signer, optional]` cosigner
678#[derive(Clone, Debug)]
679pub struct BuyT22CpiBuilder<'a, 'b> {
680    instruction: Box<BuyT22CpiBuilderInstruction<'a, 'b>>,
681}
682
683impl<'a, 'b> BuyT22CpiBuilder<'a, 'b> {
684    pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
685        let instruction = Box::new(BuyT22CpiBuilderInstruction {
686            __program: program,
687            fee_vault: None,
688            buyer: None,
689            buyer_ta: None,
690            list_state: None,
691            list_ta: None,
692            mint: None,
693            owner: None,
694            payer: None,
695            taker_broker: None,
696            maker_broker: None,
697            rent_destination: None,
698            token_program: None,
699            associated_token_program: None,
700            marketplace_program: None,
701            system_program: None,
702            cosigner: None,
703            max_amount: None,
704            __remaining_accounts: Vec::new(),
705        });
706        Self { instruction }
707    }
708    #[inline(always)]
709    pub fn fee_vault(
710        &mut self,
711        fee_vault: &'b solana_program::account_info::AccountInfo<'a>,
712    ) -> &mut Self {
713        self.instruction.fee_vault = Some(fee_vault);
714        self
715    }
716    #[inline(always)]
717    pub fn buyer(&mut self, buyer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
718        self.instruction.buyer = Some(buyer);
719        self
720    }
721    #[inline(always)]
722    pub fn buyer_ta(
723        &mut self,
724        buyer_ta: &'b solana_program::account_info::AccountInfo<'a>,
725    ) -> &mut Self {
726        self.instruction.buyer_ta = Some(buyer_ta);
727        self
728    }
729    #[inline(always)]
730    pub fn list_state(
731        &mut self,
732        list_state: &'b solana_program::account_info::AccountInfo<'a>,
733    ) -> &mut Self {
734        self.instruction.list_state = Some(list_state);
735        self
736    }
737    #[inline(always)]
738    pub fn list_ta(
739        &mut self,
740        list_ta: &'b solana_program::account_info::AccountInfo<'a>,
741    ) -> &mut Self {
742        self.instruction.list_ta = Some(list_ta);
743        self
744    }
745    #[inline(always)]
746    pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
747        self.instruction.mint = Some(mint);
748        self
749    }
750    #[inline(always)]
751    pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
752        self.instruction.owner = Some(owner);
753        self
754    }
755    #[inline(always)]
756    pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
757        self.instruction.payer = Some(payer);
758        self
759    }
760    /// `[optional account]`
761    #[inline(always)]
762    pub fn taker_broker(
763        &mut self,
764        taker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
765    ) -> &mut Self {
766        self.instruction.taker_broker = taker_broker;
767        self
768    }
769    /// `[optional account]`
770    #[inline(always)]
771    pub fn maker_broker(
772        &mut self,
773        maker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
774    ) -> &mut Self {
775        self.instruction.maker_broker = maker_broker;
776        self
777    }
778    #[inline(always)]
779    pub fn rent_destination(
780        &mut self,
781        rent_destination: &'b solana_program::account_info::AccountInfo<'a>,
782    ) -> &mut Self {
783        self.instruction.rent_destination = Some(rent_destination);
784        self
785    }
786    #[inline(always)]
787    pub fn token_program(
788        &mut self,
789        token_program: &'b solana_program::account_info::AccountInfo<'a>,
790    ) -> &mut Self {
791        self.instruction.token_program = Some(token_program);
792        self
793    }
794    #[inline(always)]
795    pub fn associated_token_program(
796        &mut self,
797        associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
798    ) -> &mut Self {
799        self.instruction.associated_token_program = Some(associated_token_program);
800        self
801    }
802    #[inline(always)]
803    pub fn marketplace_program(
804        &mut self,
805        marketplace_program: &'b solana_program::account_info::AccountInfo<'a>,
806    ) -> &mut Self {
807        self.instruction.marketplace_program = Some(marketplace_program);
808        self
809    }
810    #[inline(always)]
811    pub fn system_program(
812        &mut self,
813        system_program: &'b solana_program::account_info::AccountInfo<'a>,
814    ) -> &mut Self {
815        self.instruction.system_program = Some(system_program);
816        self
817    }
818    /// `[optional account]`
819    #[inline(always)]
820    pub fn cosigner(
821        &mut self,
822        cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
823    ) -> &mut Self {
824        self.instruction.cosigner = cosigner;
825        self
826    }
827    #[inline(always)]
828    pub fn max_amount(&mut self, max_amount: u64) -> &mut Self {
829        self.instruction.max_amount = Some(max_amount);
830        self
831    }
832    /// Add an additional account to the instruction.
833    #[inline(always)]
834    pub fn add_remaining_account(
835        &mut self,
836        account: &'b solana_program::account_info::AccountInfo<'a>,
837        is_writable: bool,
838        is_signer: bool,
839    ) -> &mut Self {
840        self.instruction
841            .__remaining_accounts
842            .push((account, is_writable, is_signer));
843        self
844    }
845    /// Add additional accounts to the instruction.
846    ///
847    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
848    /// and a `bool` indicating whether the account is a signer or not.
849    #[inline(always)]
850    pub fn add_remaining_accounts(
851        &mut self,
852        accounts: &[(
853            &'b solana_program::account_info::AccountInfo<'a>,
854            bool,
855            bool,
856        )],
857    ) -> &mut Self {
858        self.instruction
859            .__remaining_accounts
860            .extend_from_slice(accounts);
861        self
862    }
863    #[inline(always)]
864    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
865        self.invoke_signed(&[])
866    }
867    #[allow(clippy::clone_on_copy)]
868    #[allow(clippy::vec_init_then_push)]
869    pub fn invoke_signed(
870        &self,
871        signers_seeds: &[&[&[u8]]],
872    ) -> solana_program::entrypoint::ProgramResult {
873        let args = BuyT22InstructionArgs {
874            max_amount: self
875                .instruction
876                .max_amount
877                .clone()
878                .expect("max_amount is not set"),
879        };
880        let instruction = BuyT22Cpi {
881            __program: self.instruction.__program,
882
883            fee_vault: self.instruction.fee_vault.expect("fee_vault is not set"),
884
885            buyer: self.instruction.buyer.expect("buyer is not set"),
886
887            buyer_ta: self.instruction.buyer_ta.expect("buyer_ta is not set"),
888
889            list_state: self.instruction.list_state.expect("list_state is not set"),
890
891            list_ta: self.instruction.list_ta.expect("list_ta is not set"),
892
893            mint: self.instruction.mint.expect("mint is not set"),
894
895            owner: self.instruction.owner.expect("owner is not set"),
896
897            payer: self.instruction.payer.expect("payer is not set"),
898
899            taker_broker: self.instruction.taker_broker,
900
901            maker_broker: self.instruction.maker_broker,
902
903            rent_destination: self
904                .instruction
905                .rent_destination
906                .expect("rent_destination is not set"),
907
908            token_program: self
909                .instruction
910                .token_program
911                .expect("token_program is not set"),
912
913            associated_token_program: self
914                .instruction
915                .associated_token_program
916                .expect("associated_token_program is not set"),
917
918            marketplace_program: self
919                .instruction
920                .marketplace_program
921                .expect("marketplace_program is not set"),
922
923            system_program: self
924                .instruction
925                .system_program
926                .expect("system_program is not set"),
927
928            cosigner: self.instruction.cosigner,
929            __args: args,
930        };
931        instruction.invoke_signed_with_remaining_accounts(
932            signers_seeds,
933            &self.instruction.__remaining_accounts,
934        )
935    }
936}
937
938#[derive(Clone, Debug)]
939struct BuyT22CpiBuilderInstruction<'a, 'b> {
940    __program: &'b solana_program::account_info::AccountInfo<'a>,
941    fee_vault: Option<&'b solana_program::account_info::AccountInfo<'a>>,
942    buyer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
943    buyer_ta: Option<&'b solana_program::account_info::AccountInfo<'a>>,
944    list_state: Option<&'b solana_program::account_info::AccountInfo<'a>>,
945    list_ta: Option<&'b solana_program::account_info::AccountInfo<'a>>,
946    mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
947    owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
948    payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
949    taker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
950    maker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
951    rent_destination: Option<&'b solana_program::account_info::AccountInfo<'a>>,
952    token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
953    associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
954    marketplace_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
955    system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
956    cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
957    max_amount: Option<u64>,
958    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
959    __remaining_accounts: Vec<(
960        &'b solana_program::account_info::AccountInfo<'a>,
961        bool,
962        bool,
963    )>,
964}