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