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