tensor_marketplace/generated/instructions/
take_bid_t22.rs

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