tensor_marketplace/generated/instructions/
buy_legacy.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 crate::generated::types::AuthorizationDataLocal;
9use borsh::BorshDeserialize;
10use borsh::BorshSerialize;
11
12/// Accounts.
13pub struct BuyLegacy {
14    pub fee_vault: solana_program::pubkey::Pubkey,
15
16    pub buyer: solana_program::pubkey::Pubkey,
17
18    pub buyer_ta: solana_program::pubkey::Pubkey,
19
20    pub list_ta: solana_program::pubkey::Pubkey,
21
22    pub list_state: solana_program::pubkey::Pubkey,
23
24    pub mint: solana_program::pubkey::Pubkey,
25
26    pub owner: solana_program::pubkey::Pubkey,
27
28    pub payer: solana_program::pubkey::Pubkey,
29
30    pub taker_broker: Option<solana_program::pubkey::Pubkey>,
31
32    pub maker_broker: Option<solana_program::pubkey::Pubkey>,
33
34    pub rent_destination: solana_program::pubkey::Pubkey,
35
36    pub token_program: solana_program::pubkey::Pubkey,
37
38    pub associated_token_program: solana_program::pubkey::Pubkey,
39
40    pub marketplace_program: solana_program::pubkey::Pubkey,
41
42    pub system_program: solana_program::pubkey::Pubkey,
43
44    pub metadata: solana_program::pubkey::Pubkey,
45
46    pub edition: solana_program::pubkey::Pubkey,
47
48    pub buyer_token_record: Option<solana_program::pubkey::Pubkey>,
49
50    pub list_token_record: Option<solana_program::pubkey::Pubkey>,
51
52    pub authorization_rules: Option<solana_program::pubkey::Pubkey>,
53
54    pub authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
55
56    pub token_metadata_program: Option<solana_program::pubkey::Pubkey>,
57
58    pub sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
59
60    pub cosigner: Option<solana_program::pubkey::Pubkey>,
61}
62
63impl BuyLegacy {
64    pub fn instruction(
65        &self,
66        args: BuyLegacyInstructionArgs,
67    ) -> solana_program::instruction::Instruction {
68        self.instruction_with_remaining_accounts(args, &[])
69    }
70    #[allow(clippy::vec_init_then_push)]
71    pub fn instruction_with_remaining_accounts(
72        &self,
73        args: BuyLegacyInstructionArgs,
74        remaining_accounts: &[solana_program::instruction::AccountMeta],
75    ) -> solana_program::instruction::Instruction {
76        let mut accounts = Vec::with_capacity(24 + remaining_accounts.len());
77        accounts.push(solana_program::instruction::AccountMeta::new(
78            self.fee_vault,
79            false,
80        ));
81        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
82            self.buyer, false,
83        ));
84        accounts.push(solana_program::instruction::AccountMeta::new(
85            self.buyer_ta,
86            false,
87        ));
88        accounts.push(solana_program::instruction::AccountMeta::new(
89            self.list_ta,
90            false,
91        ));
92        accounts.push(solana_program::instruction::AccountMeta::new(
93            self.list_state,
94            false,
95        ));
96        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
97            self.mint, false,
98        ));
99        accounts.push(solana_program::instruction::AccountMeta::new(
100            self.owner, false,
101        ));
102        accounts.push(solana_program::instruction::AccountMeta::new(
103            self.payer, true,
104        ));
105        if let Some(taker_broker) = self.taker_broker {
106            accounts.push(solana_program::instruction::AccountMeta::new(
107                taker_broker,
108                false,
109            ));
110        } else {
111            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
112                crate::TENSOR_MARKETPLACE_ID,
113                false,
114            ));
115        }
116        if let Some(maker_broker) = self.maker_broker {
117            accounts.push(solana_program::instruction::AccountMeta::new(
118                maker_broker,
119                false,
120            ));
121        } else {
122            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
123                crate::TENSOR_MARKETPLACE_ID,
124                false,
125            ));
126        }
127        accounts.push(solana_program::instruction::AccountMeta::new(
128            self.rent_destination,
129            false,
130        ));
131        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
132            self.token_program,
133            false,
134        ));
135        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
136            self.associated_token_program,
137            false,
138        ));
139        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
140            self.marketplace_program,
141            false,
142        ));
143        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
144            self.system_program,
145            false,
146        ));
147        accounts.push(solana_program::instruction::AccountMeta::new(
148            self.metadata,
149            false,
150        ));
151        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
152            self.edition,
153            false,
154        ));
155        if let Some(buyer_token_record) = self.buyer_token_record {
156            accounts.push(solana_program::instruction::AccountMeta::new(
157                buyer_token_record,
158                false,
159            ));
160        } else {
161            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
162                crate::TENSOR_MARKETPLACE_ID,
163                false,
164            ));
165        }
166        if let Some(list_token_record) = self.list_token_record {
167            accounts.push(solana_program::instruction::AccountMeta::new(
168                list_token_record,
169                false,
170            ));
171        } else {
172            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
173                crate::TENSOR_MARKETPLACE_ID,
174                false,
175            ));
176        }
177        if let Some(authorization_rules) = self.authorization_rules {
178            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
179                authorization_rules,
180                false,
181            ));
182        } else {
183            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
184                crate::TENSOR_MARKETPLACE_ID,
185                false,
186            ));
187        }
188        if let Some(authorization_rules_program) = self.authorization_rules_program {
189            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
190                authorization_rules_program,
191                false,
192            ));
193        } else {
194            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
195                crate::TENSOR_MARKETPLACE_ID,
196                false,
197            ));
198        }
199        if let Some(token_metadata_program) = self.token_metadata_program {
200            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
201                token_metadata_program,
202                false,
203            ));
204        } else {
205            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
206                crate::TENSOR_MARKETPLACE_ID,
207                false,
208            ));
209        }
210        if let Some(sysvar_instructions) = self.sysvar_instructions {
211            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
212                sysvar_instructions,
213                false,
214            ));
215        } else {
216            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
217                crate::TENSOR_MARKETPLACE_ID,
218                false,
219            ));
220        }
221        if let Some(cosigner) = self.cosigner {
222            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
223                cosigner, true,
224            ));
225        } else {
226            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
227                crate::TENSOR_MARKETPLACE_ID,
228                false,
229            ));
230        }
231        accounts.extend_from_slice(remaining_accounts);
232        let mut data = BuyLegacyInstructionData::new().try_to_vec().unwrap();
233        let mut args = args.try_to_vec().unwrap();
234        data.append(&mut args);
235
236        solana_program::instruction::Instruction {
237            program_id: crate::TENSOR_MARKETPLACE_ID,
238            accounts,
239            data,
240        }
241    }
242}
243
244#[derive(BorshDeserialize, BorshSerialize)]
245pub struct BuyLegacyInstructionData {
246    discriminator: [u8; 8],
247}
248
249impl BuyLegacyInstructionData {
250    pub fn new() -> Self {
251        Self {
252            discriminator: [68, 127, 43, 8, 212, 31, 249, 114],
253        }
254    }
255}
256
257impl Default for BuyLegacyInstructionData {
258    fn default() -> Self {
259        Self::new()
260    }
261}
262
263#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
264#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
265pub struct BuyLegacyInstructionArgs {
266    pub max_amount: u64,
267    pub optional_royalty_pct: Option<u16>,
268    pub authorization_data: Option<AuthorizationDataLocal>,
269}
270
271/// Instruction builder for `BuyLegacy`.
272///
273/// ### Accounts:
274///
275///   0. `[writable]` fee_vault
276///   1. `[]` buyer
277///   2. `[writable]` buyer_ta
278///   3. `[writable]` list_ta
279///   4. `[writable]` list_state
280///   5. `[]` mint
281///   6. `[writable]` owner
282///   7. `[writable, signer]` payer
283///   8. `[writable, optional]` taker_broker
284///   9. `[writable, optional]` maker_broker
285///   10. `[writable]` rent_destination
286///   11. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`)
287///   12. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`)
288///   13. `[optional]` marketplace_program (default to `TCMPhJdwDryooaGtiocG1u3xcYbRpiJzb283XfCZsDp`)
289///   14. `[optional]` system_program (default to `11111111111111111111111111111111`)
290///   15. `[writable]` metadata
291///   16. `[]` edition
292///   17. `[writable, optional]` buyer_token_record
293///   18. `[writable, optional]` list_token_record
294///   19. `[optional]` authorization_rules
295///   20. `[optional]` authorization_rules_program
296///   21. `[optional]` token_metadata_program
297///   22. `[optional]` sysvar_instructions
298///   23. `[signer, optional]` cosigner (default to `TCMPhJdwDryooaGtiocG1u3xcYbRpiJzb283XfCZsDp`)
299#[derive(Clone, Debug, Default)]
300pub struct BuyLegacyBuilder {
301    fee_vault: Option<solana_program::pubkey::Pubkey>,
302    buyer: Option<solana_program::pubkey::Pubkey>,
303    buyer_ta: Option<solana_program::pubkey::Pubkey>,
304    list_ta: Option<solana_program::pubkey::Pubkey>,
305    list_state: Option<solana_program::pubkey::Pubkey>,
306    mint: Option<solana_program::pubkey::Pubkey>,
307    owner: Option<solana_program::pubkey::Pubkey>,
308    payer: Option<solana_program::pubkey::Pubkey>,
309    taker_broker: Option<solana_program::pubkey::Pubkey>,
310    maker_broker: Option<solana_program::pubkey::Pubkey>,
311    rent_destination: Option<solana_program::pubkey::Pubkey>,
312    token_program: Option<solana_program::pubkey::Pubkey>,
313    associated_token_program: Option<solana_program::pubkey::Pubkey>,
314    marketplace_program: Option<solana_program::pubkey::Pubkey>,
315    system_program: Option<solana_program::pubkey::Pubkey>,
316    metadata: Option<solana_program::pubkey::Pubkey>,
317    edition: Option<solana_program::pubkey::Pubkey>,
318    buyer_token_record: Option<solana_program::pubkey::Pubkey>,
319    list_token_record: Option<solana_program::pubkey::Pubkey>,
320    authorization_rules: Option<solana_program::pubkey::Pubkey>,
321    authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
322    token_metadata_program: Option<solana_program::pubkey::Pubkey>,
323    sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
324    cosigner: Option<solana_program::pubkey::Pubkey>,
325    max_amount: Option<u64>,
326    optional_royalty_pct: Option<u16>,
327    authorization_data: Option<AuthorizationDataLocal>,
328    __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
329}
330
331impl BuyLegacyBuilder {
332    pub fn new() -> Self {
333        Self::default()
334    }
335    #[inline(always)]
336    pub fn fee_vault(&mut self, fee_vault: solana_program::pubkey::Pubkey) -> &mut Self {
337        self.fee_vault = Some(fee_vault);
338        self
339    }
340    #[inline(always)]
341    pub fn buyer(&mut self, buyer: solana_program::pubkey::Pubkey) -> &mut Self {
342        self.buyer = Some(buyer);
343        self
344    }
345    #[inline(always)]
346    pub fn buyer_ta(&mut self, buyer_ta: solana_program::pubkey::Pubkey) -> &mut Self {
347        self.buyer_ta = Some(buyer_ta);
348        self
349    }
350    #[inline(always)]
351    pub fn list_ta(&mut self, list_ta: solana_program::pubkey::Pubkey) -> &mut Self {
352        self.list_ta = Some(list_ta);
353        self
354    }
355    #[inline(always)]
356    pub fn list_state(&mut self, list_state: solana_program::pubkey::Pubkey) -> &mut Self {
357        self.list_state = Some(list_state);
358        self
359    }
360    #[inline(always)]
361    pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
362        self.mint = Some(mint);
363        self
364    }
365    #[inline(always)]
366    pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self {
367        self.owner = Some(owner);
368        self
369    }
370    #[inline(always)]
371    pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
372        self.payer = Some(payer);
373        self
374    }
375    /// `[optional account]`
376    #[inline(always)]
377    pub fn taker_broker(
378        &mut self,
379        taker_broker: Option<solana_program::pubkey::Pubkey>,
380    ) -> &mut Self {
381        self.taker_broker = taker_broker;
382        self
383    }
384    /// `[optional account]`
385    #[inline(always)]
386    pub fn maker_broker(
387        &mut self,
388        maker_broker: Option<solana_program::pubkey::Pubkey>,
389    ) -> &mut Self {
390        self.maker_broker = maker_broker;
391        self
392    }
393    #[inline(always)]
394    pub fn rent_destination(
395        &mut self,
396        rent_destination: solana_program::pubkey::Pubkey,
397    ) -> &mut Self {
398        self.rent_destination = Some(rent_destination);
399        self
400    }
401    /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']`
402    #[inline(always)]
403    pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self {
404        self.token_program = Some(token_program);
405        self
406    }
407    /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']`
408    #[inline(always)]
409    pub fn associated_token_program(
410        &mut self,
411        associated_token_program: solana_program::pubkey::Pubkey,
412    ) -> &mut Self {
413        self.associated_token_program = Some(associated_token_program);
414        self
415    }
416    /// `[optional account, default to 'TCMPhJdwDryooaGtiocG1u3xcYbRpiJzb283XfCZsDp']`
417    #[inline(always)]
418    pub fn marketplace_program(
419        &mut self,
420        marketplace_program: solana_program::pubkey::Pubkey,
421    ) -> &mut Self {
422        self.marketplace_program = Some(marketplace_program);
423        self
424    }
425    /// `[optional account, default to '11111111111111111111111111111111']`
426    #[inline(always)]
427    pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
428        self.system_program = Some(system_program);
429        self
430    }
431    #[inline(always)]
432    pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self {
433        self.metadata = Some(metadata);
434        self
435    }
436    #[inline(always)]
437    pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self {
438        self.edition = Some(edition);
439        self
440    }
441    /// `[optional account]`
442    #[inline(always)]
443    pub fn buyer_token_record(
444        &mut self,
445        buyer_token_record: Option<solana_program::pubkey::Pubkey>,
446    ) -> &mut Self {
447        self.buyer_token_record = buyer_token_record;
448        self
449    }
450    /// `[optional account]`
451    #[inline(always)]
452    pub fn list_token_record(
453        &mut self,
454        list_token_record: Option<solana_program::pubkey::Pubkey>,
455    ) -> &mut Self {
456        self.list_token_record = list_token_record;
457        self
458    }
459    /// `[optional account]`
460    #[inline(always)]
461    pub fn authorization_rules(
462        &mut self,
463        authorization_rules: Option<solana_program::pubkey::Pubkey>,
464    ) -> &mut Self {
465        self.authorization_rules = authorization_rules;
466        self
467    }
468    /// `[optional account]`
469    #[inline(always)]
470    pub fn authorization_rules_program(
471        &mut self,
472        authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
473    ) -> &mut Self {
474        self.authorization_rules_program = authorization_rules_program;
475        self
476    }
477    /// `[optional account]`
478    #[inline(always)]
479    pub fn token_metadata_program(
480        &mut self,
481        token_metadata_program: Option<solana_program::pubkey::Pubkey>,
482    ) -> &mut Self {
483        self.token_metadata_program = token_metadata_program;
484        self
485    }
486    /// `[optional account]`
487    #[inline(always)]
488    pub fn sysvar_instructions(
489        &mut self,
490        sysvar_instructions: Option<solana_program::pubkey::Pubkey>,
491    ) -> &mut Self {
492        self.sysvar_instructions = sysvar_instructions;
493        self
494    }
495    /// `[optional account]`
496    #[inline(always)]
497    pub fn cosigner(&mut self, cosigner: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
498        self.cosigner = cosigner;
499        self
500    }
501    #[inline(always)]
502    pub fn max_amount(&mut self, max_amount: u64) -> &mut Self {
503        self.max_amount = Some(max_amount);
504        self
505    }
506    /// `[optional argument]`
507    #[inline(always)]
508    pub fn optional_royalty_pct(&mut self, optional_royalty_pct: u16) -> &mut Self {
509        self.optional_royalty_pct = Some(optional_royalty_pct);
510        self
511    }
512    /// `[optional argument]`
513    #[inline(always)]
514    pub fn authorization_data(&mut self, authorization_data: AuthorizationDataLocal) -> &mut Self {
515        self.authorization_data = Some(authorization_data);
516        self
517    }
518    /// Add an aditional account to the instruction.
519    #[inline(always)]
520    pub fn add_remaining_account(
521        &mut self,
522        account: solana_program::instruction::AccountMeta,
523    ) -> &mut Self {
524        self.__remaining_accounts.push(account);
525        self
526    }
527    /// Add additional accounts to the instruction.
528    #[inline(always)]
529    pub fn add_remaining_accounts(
530        &mut self,
531        accounts: &[solana_program::instruction::AccountMeta],
532    ) -> &mut Self {
533        self.__remaining_accounts.extend_from_slice(accounts);
534        self
535    }
536    #[allow(clippy::clone_on_copy)]
537    pub fn instruction(&self) -> solana_program::instruction::Instruction {
538        let accounts = BuyLegacy {
539            fee_vault: self.fee_vault.expect("fee_vault is not set"),
540            buyer: self.buyer.expect("buyer is not set"),
541            buyer_ta: self.buyer_ta.expect("buyer_ta is not set"),
542            list_ta: self.list_ta.expect("list_ta is not set"),
543            list_state: self.list_state.expect("list_state is not set"),
544            mint: self.mint.expect("mint is not set"),
545            owner: self.owner.expect("owner is not set"),
546            payer: self.payer.expect("payer is not set"),
547            taker_broker: self.taker_broker,
548            maker_broker: self.maker_broker,
549            rent_destination: self.rent_destination.expect("rent_destination is not set"),
550            token_program: self.token_program.unwrap_or(solana_program::pubkey!(
551                "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
552            )),
553            associated_token_program: self.associated_token_program.unwrap_or(
554                solana_program::pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),
555            ),
556            marketplace_program: self.marketplace_program.unwrap_or(solana_program::pubkey!(
557                "TCMPhJdwDryooaGtiocG1u3xcYbRpiJzb283XfCZsDp"
558            )),
559            system_program: self
560                .system_program
561                .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
562            metadata: self.metadata.expect("metadata is not set"),
563            edition: self.edition.expect("edition is not set"),
564            buyer_token_record: self.buyer_token_record,
565            list_token_record: self.list_token_record,
566            authorization_rules: self.authorization_rules,
567            authorization_rules_program: self.authorization_rules_program,
568            token_metadata_program: self.token_metadata_program,
569            sysvar_instructions: self.sysvar_instructions,
570            cosigner: self.cosigner,
571        };
572        let args = BuyLegacyInstructionArgs {
573            max_amount: self.max_amount.clone().expect("max_amount is not set"),
574            optional_royalty_pct: self.optional_royalty_pct.clone(),
575            authorization_data: self.authorization_data.clone(),
576        };
577
578        accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
579    }
580}
581
582/// `buy_legacy` CPI accounts.
583pub struct BuyLegacyCpiAccounts<'a, 'b> {
584    pub fee_vault: &'b solana_program::account_info::AccountInfo<'a>,
585
586    pub buyer: &'b solana_program::account_info::AccountInfo<'a>,
587
588    pub buyer_ta: &'b solana_program::account_info::AccountInfo<'a>,
589
590    pub list_ta: &'b solana_program::account_info::AccountInfo<'a>,
591
592    pub list_state: &'b solana_program::account_info::AccountInfo<'a>,
593
594    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
595
596    pub owner: &'b solana_program::account_info::AccountInfo<'a>,
597
598    pub payer: &'b solana_program::account_info::AccountInfo<'a>,
599
600    pub taker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
601
602    pub maker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
603
604    pub rent_destination: &'b solana_program::account_info::AccountInfo<'a>,
605
606    pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
607
608    pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
609
610    pub marketplace_program: &'b solana_program::account_info::AccountInfo<'a>,
611
612    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
613
614    pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
615
616    pub edition: &'b solana_program::account_info::AccountInfo<'a>,
617
618    pub buyer_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
619
620    pub list_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
621
622    pub authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
623
624    pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
625
626    pub token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
627
628    pub sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
629
630    pub cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
631}
632
633/// `buy_legacy` CPI instruction.
634pub struct BuyLegacyCpi<'a, 'b> {
635    /// The program to invoke.
636    pub __program: &'b solana_program::account_info::AccountInfo<'a>,
637
638    pub fee_vault: &'b solana_program::account_info::AccountInfo<'a>,
639
640    pub buyer: &'b solana_program::account_info::AccountInfo<'a>,
641
642    pub buyer_ta: &'b solana_program::account_info::AccountInfo<'a>,
643
644    pub list_ta: &'b solana_program::account_info::AccountInfo<'a>,
645
646    pub list_state: &'b solana_program::account_info::AccountInfo<'a>,
647
648    pub mint: &'b solana_program::account_info::AccountInfo<'a>,
649
650    pub owner: &'b solana_program::account_info::AccountInfo<'a>,
651
652    pub payer: &'b solana_program::account_info::AccountInfo<'a>,
653
654    pub taker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
655
656    pub maker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
657
658    pub rent_destination: &'b solana_program::account_info::AccountInfo<'a>,
659
660    pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
661
662    pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
663
664    pub marketplace_program: &'b solana_program::account_info::AccountInfo<'a>,
665
666    pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
667
668    pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
669
670    pub edition: &'b solana_program::account_info::AccountInfo<'a>,
671
672    pub buyer_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
673
674    pub list_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
675
676    pub authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
677
678    pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
679
680    pub token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
681
682    pub sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
683
684    pub cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
685    /// The arguments for the instruction.
686    pub __args: BuyLegacyInstructionArgs,
687}
688
689impl<'a, 'b> BuyLegacyCpi<'a, 'b> {
690    pub fn new(
691        program: &'b solana_program::account_info::AccountInfo<'a>,
692        accounts: BuyLegacyCpiAccounts<'a, 'b>,
693        args: BuyLegacyInstructionArgs,
694    ) -> Self {
695        Self {
696            __program: program,
697            fee_vault: accounts.fee_vault,
698            buyer: accounts.buyer,
699            buyer_ta: accounts.buyer_ta,
700            list_ta: accounts.list_ta,
701            list_state: accounts.list_state,
702            mint: accounts.mint,
703            owner: accounts.owner,
704            payer: accounts.payer,
705            taker_broker: accounts.taker_broker,
706            maker_broker: accounts.maker_broker,
707            rent_destination: accounts.rent_destination,
708            token_program: accounts.token_program,
709            associated_token_program: accounts.associated_token_program,
710            marketplace_program: accounts.marketplace_program,
711            system_program: accounts.system_program,
712            metadata: accounts.metadata,
713            edition: accounts.edition,
714            buyer_token_record: accounts.buyer_token_record,
715            list_token_record: accounts.list_token_record,
716            authorization_rules: accounts.authorization_rules,
717            authorization_rules_program: accounts.authorization_rules_program,
718            token_metadata_program: accounts.token_metadata_program,
719            sysvar_instructions: accounts.sysvar_instructions,
720            cosigner: accounts.cosigner,
721            __args: args,
722        }
723    }
724    #[inline(always)]
725    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
726        self.invoke_signed_with_remaining_accounts(&[], &[])
727    }
728    #[inline(always)]
729    pub fn invoke_with_remaining_accounts(
730        &self,
731        remaining_accounts: &[(
732            &'b solana_program::account_info::AccountInfo<'a>,
733            bool,
734            bool,
735        )],
736    ) -> solana_program::entrypoint::ProgramResult {
737        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
738    }
739    #[inline(always)]
740    pub fn invoke_signed(
741        &self,
742        signers_seeds: &[&[&[u8]]],
743    ) -> solana_program::entrypoint::ProgramResult {
744        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
745    }
746    #[allow(clippy::clone_on_copy)]
747    #[allow(clippy::vec_init_then_push)]
748    pub fn invoke_signed_with_remaining_accounts(
749        &self,
750        signers_seeds: &[&[&[u8]]],
751        remaining_accounts: &[(
752            &'b solana_program::account_info::AccountInfo<'a>,
753            bool,
754            bool,
755        )],
756    ) -> solana_program::entrypoint::ProgramResult {
757        let mut accounts = Vec::with_capacity(24 + remaining_accounts.len());
758        accounts.push(solana_program::instruction::AccountMeta::new(
759            *self.fee_vault.key,
760            false,
761        ));
762        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
763            *self.buyer.key,
764            false,
765        ));
766        accounts.push(solana_program::instruction::AccountMeta::new(
767            *self.buyer_ta.key,
768            false,
769        ));
770        accounts.push(solana_program::instruction::AccountMeta::new(
771            *self.list_ta.key,
772            false,
773        ));
774        accounts.push(solana_program::instruction::AccountMeta::new(
775            *self.list_state.key,
776            false,
777        ));
778        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
779            *self.mint.key,
780            false,
781        ));
782        accounts.push(solana_program::instruction::AccountMeta::new(
783            *self.owner.key,
784            false,
785        ));
786        accounts.push(solana_program::instruction::AccountMeta::new(
787            *self.payer.key,
788            true,
789        ));
790        if let Some(taker_broker) = self.taker_broker {
791            accounts.push(solana_program::instruction::AccountMeta::new(
792                *taker_broker.key,
793                false,
794            ));
795        } else {
796            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
797                crate::TENSOR_MARKETPLACE_ID,
798                false,
799            ));
800        }
801        if let Some(maker_broker) = self.maker_broker {
802            accounts.push(solana_program::instruction::AccountMeta::new(
803                *maker_broker.key,
804                false,
805            ));
806        } else {
807            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
808                crate::TENSOR_MARKETPLACE_ID,
809                false,
810            ));
811        }
812        accounts.push(solana_program::instruction::AccountMeta::new(
813            *self.rent_destination.key,
814            false,
815        ));
816        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
817            *self.token_program.key,
818            false,
819        ));
820        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
821            *self.associated_token_program.key,
822            false,
823        ));
824        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
825            *self.marketplace_program.key,
826            false,
827        ));
828        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
829            *self.system_program.key,
830            false,
831        ));
832        accounts.push(solana_program::instruction::AccountMeta::new(
833            *self.metadata.key,
834            false,
835        ));
836        accounts.push(solana_program::instruction::AccountMeta::new_readonly(
837            *self.edition.key,
838            false,
839        ));
840        if let Some(buyer_token_record) = self.buyer_token_record {
841            accounts.push(solana_program::instruction::AccountMeta::new(
842                *buyer_token_record.key,
843                false,
844            ));
845        } else {
846            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
847                crate::TENSOR_MARKETPLACE_ID,
848                false,
849            ));
850        }
851        if let Some(list_token_record) = self.list_token_record {
852            accounts.push(solana_program::instruction::AccountMeta::new(
853                *list_token_record.key,
854                false,
855            ));
856        } else {
857            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
858                crate::TENSOR_MARKETPLACE_ID,
859                false,
860            ));
861        }
862        if let Some(authorization_rules) = self.authorization_rules {
863            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
864                *authorization_rules.key,
865                false,
866            ));
867        } else {
868            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
869                crate::TENSOR_MARKETPLACE_ID,
870                false,
871            ));
872        }
873        if let Some(authorization_rules_program) = self.authorization_rules_program {
874            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
875                *authorization_rules_program.key,
876                false,
877            ));
878        } else {
879            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
880                crate::TENSOR_MARKETPLACE_ID,
881                false,
882            ));
883        }
884        if let Some(token_metadata_program) = self.token_metadata_program {
885            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
886                *token_metadata_program.key,
887                false,
888            ));
889        } else {
890            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
891                crate::TENSOR_MARKETPLACE_ID,
892                false,
893            ));
894        }
895        if let Some(sysvar_instructions) = self.sysvar_instructions {
896            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
897                *sysvar_instructions.key,
898                false,
899            ));
900        } else {
901            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
902                crate::TENSOR_MARKETPLACE_ID,
903                false,
904            ));
905        }
906        if let Some(cosigner) = self.cosigner {
907            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
908                *cosigner.key,
909                true,
910            ));
911        } else {
912            accounts.push(solana_program::instruction::AccountMeta::new_readonly(
913                crate::TENSOR_MARKETPLACE_ID,
914                false,
915            ));
916        }
917        remaining_accounts.iter().for_each(|remaining_account| {
918            accounts.push(solana_program::instruction::AccountMeta {
919                pubkey: *remaining_account.0.key,
920                is_signer: remaining_account.1,
921                is_writable: remaining_account.2,
922            })
923        });
924        let mut data = BuyLegacyInstructionData::new().try_to_vec().unwrap();
925        let mut args = self.__args.try_to_vec().unwrap();
926        data.append(&mut args);
927
928        let instruction = solana_program::instruction::Instruction {
929            program_id: crate::TENSOR_MARKETPLACE_ID,
930            accounts,
931            data,
932        };
933        let mut account_infos = Vec::with_capacity(24 + 1 + remaining_accounts.len());
934        account_infos.push(self.__program.clone());
935        account_infos.push(self.fee_vault.clone());
936        account_infos.push(self.buyer.clone());
937        account_infos.push(self.buyer_ta.clone());
938        account_infos.push(self.list_ta.clone());
939        account_infos.push(self.list_state.clone());
940        account_infos.push(self.mint.clone());
941        account_infos.push(self.owner.clone());
942        account_infos.push(self.payer.clone());
943        if let Some(taker_broker) = self.taker_broker {
944            account_infos.push(taker_broker.clone());
945        }
946        if let Some(maker_broker) = self.maker_broker {
947            account_infos.push(maker_broker.clone());
948        }
949        account_infos.push(self.rent_destination.clone());
950        account_infos.push(self.token_program.clone());
951        account_infos.push(self.associated_token_program.clone());
952        account_infos.push(self.marketplace_program.clone());
953        account_infos.push(self.system_program.clone());
954        account_infos.push(self.metadata.clone());
955        account_infos.push(self.edition.clone());
956        if let Some(buyer_token_record) = self.buyer_token_record {
957            account_infos.push(buyer_token_record.clone());
958        }
959        if let Some(list_token_record) = self.list_token_record {
960            account_infos.push(list_token_record.clone());
961        }
962        if let Some(authorization_rules) = self.authorization_rules {
963            account_infos.push(authorization_rules.clone());
964        }
965        if let Some(authorization_rules_program) = self.authorization_rules_program {
966            account_infos.push(authorization_rules_program.clone());
967        }
968        if let Some(token_metadata_program) = self.token_metadata_program {
969            account_infos.push(token_metadata_program.clone());
970        }
971        if let Some(sysvar_instructions) = self.sysvar_instructions {
972            account_infos.push(sysvar_instructions.clone());
973        }
974        if let Some(cosigner) = self.cosigner {
975            account_infos.push(cosigner.clone());
976        }
977        remaining_accounts
978            .iter()
979            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
980
981        if signers_seeds.is_empty() {
982            solana_program::program::invoke(&instruction, &account_infos)
983        } else {
984            solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
985        }
986    }
987}
988
989/// Instruction builder for `BuyLegacy` via CPI.
990///
991/// ### Accounts:
992///
993///   0. `[writable]` fee_vault
994///   1. `[]` buyer
995///   2. `[writable]` buyer_ta
996///   3. `[writable]` list_ta
997///   4. `[writable]` list_state
998///   5. `[]` mint
999///   6. `[writable]` owner
1000///   7. `[writable, signer]` payer
1001///   8. `[writable, optional]` taker_broker
1002///   9. `[writable, optional]` maker_broker
1003///   10. `[writable]` rent_destination
1004///   11. `[]` token_program
1005///   12. `[]` associated_token_program
1006///   13. `[]` marketplace_program
1007///   14. `[]` system_program
1008///   15. `[writable]` metadata
1009///   16. `[]` edition
1010///   17. `[writable, optional]` buyer_token_record
1011///   18. `[writable, optional]` list_token_record
1012///   19. `[optional]` authorization_rules
1013///   20. `[optional]` authorization_rules_program
1014///   21. `[optional]` token_metadata_program
1015///   22. `[optional]` sysvar_instructions
1016///   23. `[signer, optional]` cosigner
1017#[derive(Clone, Debug)]
1018pub struct BuyLegacyCpiBuilder<'a, 'b> {
1019    instruction: Box<BuyLegacyCpiBuilderInstruction<'a, 'b>>,
1020}
1021
1022impl<'a, 'b> BuyLegacyCpiBuilder<'a, 'b> {
1023    pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
1024        let instruction = Box::new(BuyLegacyCpiBuilderInstruction {
1025            __program: program,
1026            fee_vault: None,
1027            buyer: None,
1028            buyer_ta: None,
1029            list_ta: None,
1030            list_state: None,
1031            mint: None,
1032            owner: None,
1033            payer: None,
1034            taker_broker: None,
1035            maker_broker: None,
1036            rent_destination: None,
1037            token_program: None,
1038            associated_token_program: None,
1039            marketplace_program: None,
1040            system_program: None,
1041            metadata: None,
1042            edition: None,
1043            buyer_token_record: None,
1044            list_token_record: None,
1045            authorization_rules: None,
1046            authorization_rules_program: None,
1047            token_metadata_program: None,
1048            sysvar_instructions: None,
1049            cosigner: None,
1050            max_amount: None,
1051            optional_royalty_pct: None,
1052            authorization_data: None,
1053            __remaining_accounts: Vec::new(),
1054        });
1055        Self { instruction }
1056    }
1057    #[inline(always)]
1058    pub fn fee_vault(
1059        &mut self,
1060        fee_vault: &'b solana_program::account_info::AccountInfo<'a>,
1061    ) -> &mut Self {
1062        self.instruction.fee_vault = Some(fee_vault);
1063        self
1064    }
1065    #[inline(always)]
1066    pub fn buyer(&mut self, buyer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
1067        self.instruction.buyer = Some(buyer);
1068        self
1069    }
1070    #[inline(always)]
1071    pub fn buyer_ta(
1072        &mut self,
1073        buyer_ta: &'b solana_program::account_info::AccountInfo<'a>,
1074    ) -> &mut Self {
1075        self.instruction.buyer_ta = Some(buyer_ta);
1076        self
1077    }
1078    #[inline(always)]
1079    pub fn list_ta(
1080        &mut self,
1081        list_ta: &'b solana_program::account_info::AccountInfo<'a>,
1082    ) -> &mut Self {
1083        self.instruction.list_ta = Some(list_ta);
1084        self
1085    }
1086    #[inline(always)]
1087    pub fn list_state(
1088        &mut self,
1089        list_state: &'b solana_program::account_info::AccountInfo<'a>,
1090    ) -> &mut Self {
1091        self.instruction.list_state = Some(list_state);
1092        self
1093    }
1094    #[inline(always)]
1095    pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
1096        self.instruction.mint = Some(mint);
1097        self
1098    }
1099    #[inline(always)]
1100    pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
1101        self.instruction.owner = Some(owner);
1102        self
1103    }
1104    #[inline(always)]
1105    pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
1106        self.instruction.payer = Some(payer);
1107        self
1108    }
1109    /// `[optional account]`
1110    #[inline(always)]
1111    pub fn taker_broker(
1112        &mut self,
1113        taker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1114    ) -> &mut Self {
1115        self.instruction.taker_broker = taker_broker;
1116        self
1117    }
1118    /// `[optional account]`
1119    #[inline(always)]
1120    pub fn maker_broker(
1121        &mut self,
1122        maker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1123    ) -> &mut Self {
1124        self.instruction.maker_broker = maker_broker;
1125        self
1126    }
1127    #[inline(always)]
1128    pub fn rent_destination(
1129        &mut self,
1130        rent_destination: &'b solana_program::account_info::AccountInfo<'a>,
1131    ) -> &mut Self {
1132        self.instruction.rent_destination = Some(rent_destination);
1133        self
1134    }
1135    #[inline(always)]
1136    pub fn token_program(
1137        &mut self,
1138        token_program: &'b solana_program::account_info::AccountInfo<'a>,
1139    ) -> &mut Self {
1140        self.instruction.token_program = Some(token_program);
1141        self
1142    }
1143    #[inline(always)]
1144    pub fn associated_token_program(
1145        &mut self,
1146        associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
1147    ) -> &mut Self {
1148        self.instruction.associated_token_program = Some(associated_token_program);
1149        self
1150    }
1151    #[inline(always)]
1152    pub fn marketplace_program(
1153        &mut self,
1154        marketplace_program: &'b solana_program::account_info::AccountInfo<'a>,
1155    ) -> &mut Self {
1156        self.instruction.marketplace_program = Some(marketplace_program);
1157        self
1158    }
1159    #[inline(always)]
1160    pub fn system_program(
1161        &mut self,
1162        system_program: &'b solana_program::account_info::AccountInfo<'a>,
1163    ) -> &mut Self {
1164        self.instruction.system_program = Some(system_program);
1165        self
1166    }
1167    #[inline(always)]
1168    pub fn metadata(
1169        &mut self,
1170        metadata: &'b solana_program::account_info::AccountInfo<'a>,
1171    ) -> &mut Self {
1172        self.instruction.metadata = Some(metadata);
1173        self
1174    }
1175    #[inline(always)]
1176    pub fn edition(
1177        &mut self,
1178        edition: &'b solana_program::account_info::AccountInfo<'a>,
1179    ) -> &mut Self {
1180        self.instruction.edition = Some(edition);
1181        self
1182    }
1183    /// `[optional account]`
1184    #[inline(always)]
1185    pub fn buyer_token_record(
1186        &mut self,
1187        buyer_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1188    ) -> &mut Self {
1189        self.instruction.buyer_token_record = buyer_token_record;
1190        self
1191    }
1192    /// `[optional account]`
1193    #[inline(always)]
1194    pub fn list_token_record(
1195        &mut self,
1196        list_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1197    ) -> &mut Self {
1198        self.instruction.list_token_record = list_token_record;
1199        self
1200    }
1201    /// `[optional account]`
1202    #[inline(always)]
1203    pub fn authorization_rules(
1204        &mut self,
1205        authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1206    ) -> &mut Self {
1207        self.instruction.authorization_rules = authorization_rules;
1208        self
1209    }
1210    /// `[optional account]`
1211    #[inline(always)]
1212    pub fn authorization_rules_program(
1213        &mut self,
1214        authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1215    ) -> &mut Self {
1216        self.instruction.authorization_rules_program = authorization_rules_program;
1217        self
1218    }
1219    /// `[optional account]`
1220    #[inline(always)]
1221    pub fn token_metadata_program(
1222        &mut self,
1223        token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1224    ) -> &mut Self {
1225        self.instruction.token_metadata_program = token_metadata_program;
1226        self
1227    }
1228    /// `[optional account]`
1229    #[inline(always)]
1230    pub fn sysvar_instructions(
1231        &mut self,
1232        sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1233    ) -> &mut Self {
1234        self.instruction.sysvar_instructions = sysvar_instructions;
1235        self
1236    }
1237    /// `[optional account]`
1238    #[inline(always)]
1239    pub fn cosigner(
1240        &mut self,
1241        cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1242    ) -> &mut Self {
1243        self.instruction.cosigner = cosigner;
1244        self
1245    }
1246    #[inline(always)]
1247    pub fn max_amount(&mut self, max_amount: u64) -> &mut Self {
1248        self.instruction.max_amount = Some(max_amount);
1249        self
1250    }
1251    /// `[optional argument]`
1252    #[inline(always)]
1253    pub fn optional_royalty_pct(&mut self, optional_royalty_pct: u16) -> &mut Self {
1254        self.instruction.optional_royalty_pct = Some(optional_royalty_pct);
1255        self
1256    }
1257    /// `[optional argument]`
1258    #[inline(always)]
1259    pub fn authorization_data(&mut self, authorization_data: AuthorizationDataLocal) -> &mut Self {
1260        self.instruction.authorization_data = Some(authorization_data);
1261        self
1262    }
1263    /// Add an additional account to the instruction.
1264    #[inline(always)]
1265    pub fn add_remaining_account(
1266        &mut self,
1267        account: &'b solana_program::account_info::AccountInfo<'a>,
1268        is_writable: bool,
1269        is_signer: bool,
1270    ) -> &mut Self {
1271        self.instruction
1272            .__remaining_accounts
1273            .push((account, is_writable, is_signer));
1274        self
1275    }
1276    /// Add additional accounts to the instruction.
1277    ///
1278    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
1279    /// and a `bool` indicating whether the account is a signer or not.
1280    #[inline(always)]
1281    pub fn add_remaining_accounts(
1282        &mut self,
1283        accounts: &[(
1284            &'b solana_program::account_info::AccountInfo<'a>,
1285            bool,
1286            bool,
1287        )],
1288    ) -> &mut Self {
1289        self.instruction
1290            .__remaining_accounts
1291            .extend_from_slice(accounts);
1292        self
1293    }
1294    #[inline(always)]
1295    pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
1296        self.invoke_signed(&[])
1297    }
1298    #[allow(clippy::clone_on_copy)]
1299    #[allow(clippy::vec_init_then_push)]
1300    pub fn invoke_signed(
1301        &self,
1302        signers_seeds: &[&[&[u8]]],
1303    ) -> solana_program::entrypoint::ProgramResult {
1304        let args = BuyLegacyInstructionArgs {
1305            max_amount: self
1306                .instruction
1307                .max_amount
1308                .clone()
1309                .expect("max_amount is not set"),
1310            optional_royalty_pct: self.instruction.optional_royalty_pct.clone(),
1311            authorization_data: self.instruction.authorization_data.clone(),
1312        };
1313        let instruction = BuyLegacyCpi {
1314            __program: self.instruction.__program,
1315
1316            fee_vault: self.instruction.fee_vault.expect("fee_vault is not set"),
1317
1318            buyer: self.instruction.buyer.expect("buyer is not set"),
1319
1320            buyer_ta: self.instruction.buyer_ta.expect("buyer_ta is not set"),
1321
1322            list_ta: self.instruction.list_ta.expect("list_ta is not set"),
1323
1324            list_state: self.instruction.list_state.expect("list_state is not set"),
1325
1326            mint: self.instruction.mint.expect("mint is not set"),
1327
1328            owner: self.instruction.owner.expect("owner is not set"),
1329
1330            payer: self.instruction.payer.expect("payer is not set"),
1331
1332            taker_broker: self.instruction.taker_broker,
1333
1334            maker_broker: self.instruction.maker_broker,
1335
1336            rent_destination: self
1337                .instruction
1338                .rent_destination
1339                .expect("rent_destination is not set"),
1340
1341            token_program: self
1342                .instruction
1343                .token_program
1344                .expect("token_program is not set"),
1345
1346            associated_token_program: self
1347                .instruction
1348                .associated_token_program
1349                .expect("associated_token_program is not set"),
1350
1351            marketplace_program: self
1352                .instruction
1353                .marketplace_program
1354                .expect("marketplace_program is not set"),
1355
1356            system_program: self
1357                .instruction
1358                .system_program
1359                .expect("system_program is not set"),
1360
1361            metadata: self.instruction.metadata.expect("metadata is not set"),
1362
1363            edition: self.instruction.edition.expect("edition is not set"),
1364
1365            buyer_token_record: self.instruction.buyer_token_record,
1366
1367            list_token_record: self.instruction.list_token_record,
1368
1369            authorization_rules: self.instruction.authorization_rules,
1370
1371            authorization_rules_program: self.instruction.authorization_rules_program,
1372
1373            token_metadata_program: self.instruction.token_metadata_program,
1374
1375            sysvar_instructions: self.instruction.sysvar_instructions,
1376
1377            cosigner: self.instruction.cosigner,
1378            __args: args,
1379        };
1380        instruction.invoke_signed_with_remaining_accounts(
1381            signers_seeds,
1382            &self.instruction.__remaining_accounts,
1383        )
1384    }
1385}
1386
1387#[derive(Clone, Debug)]
1388struct BuyLegacyCpiBuilderInstruction<'a, 'b> {
1389    __program: &'b solana_program::account_info::AccountInfo<'a>,
1390    fee_vault: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1391    buyer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1392    buyer_ta: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1393    list_ta: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1394    list_state: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1395    mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1396    owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1397    payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1398    taker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1399    maker_broker: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1400    rent_destination: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1401    token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1402    associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1403    marketplace_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1404    system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1405    metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1406    edition: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1407    buyer_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1408    list_token_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1409    authorization_rules: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1410    authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1411    token_metadata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1412    sysvar_instructions: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1413    cosigner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
1414    max_amount: Option<u64>,
1415    optional_royalty_pct: Option<u16>,
1416    authorization_data: Option<AuthorizationDataLocal>,
1417    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
1418    __remaining_accounts: Vec<(
1419        &'b solana_program::account_info::AccountInfo<'a>,
1420        bool,
1421        bool,
1422    )>,
1423}