commerce_program_client/generated/instructions/
clear_payment.rs

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