tensor_marketplace/generated/instructions/
buy_wns.rs

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