Skip to main content

meteora_dbc_client/generated/instructions/
create_partner_metadata.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 CREATE_PARTNER_METADATA_DISCRIMINATOR: [u8; 8] = [192, 168, 234, 191, 188, 226, 227, 255];
12
13/// Accounts.
14#[derive(Debug)]
15pub struct CreatePartnerMetadata {
16            /// Partner metadata
17
18    
19              
20          pub partner_metadata: solana_pubkey::Pubkey,
21                /// Payer of the partner metadata.
22
23    
24              
25          pub payer: solana_pubkey::Pubkey,
26                /// Fee claimer for partner
27
28    
29              
30          pub fee_claimer: solana_pubkey::Pubkey,
31                /// System program.
32
33    
34              
35          pub system_program: solana_pubkey::Pubkey,
36          
37              
38          pub event_authority: solana_pubkey::Pubkey,
39          
40              
41          pub program: solana_pubkey::Pubkey,
42      }
43
44impl CreatePartnerMetadata {
45  pub fn instruction(&self, args: CreatePartnerMetadataInstructionArgs) -> solana_instruction::Instruction {
46    self.instruction_with_remaining_accounts(args, &[])
47  }
48  #[allow(clippy::arithmetic_side_effects)]
49  #[allow(clippy::vec_init_then_push)]
50  pub fn instruction_with_remaining_accounts(&self, args: CreatePartnerMetadataInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
51    let mut accounts = Vec::with_capacity(6+ remaining_accounts.len());
52                            accounts.push(solana_instruction::AccountMeta::new(
53            self.partner_metadata,
54            false
55          ));
56                                          accounts.push(solana_instruction::AccountMeta::new(
57            self.payer,
58            true
59          ));
60                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
61            self.fee_claimer,
62            true
63          ));
64                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
65            self.system_program,
66            false
67          ));
68                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
69            self.event_authority,
70            false
71          ));
72                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
73            self.program,
74            false
75          ));
76                      accounts.extend_from_slice(remaining_accounts);
77    let mut data = CreatePartnerMetadataInstructionData::new().try_to_vec().unwrap();
78          let mut args = args.try_to_vec().unwrap();
79      data.append(&mut args);
80    
81    solana_instruction::Instruction {
82      program_id: crate::DYNAMIC_BONDING_CURVE_ID,
83      accounts,
84      data,
85    }
86  }
87}
88
89#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
90#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
91 pub struct CreatePartnerMetadataInstructionData {
92            discriminator: [u8; 8],
93                              }
94
95impl CreatePartnerMetadataInstructionData {
96  pub fn new() -> Self {
97    Self {
98                        discriminator: [192, 168, 234, 191, 188, 226, 227, 255],
99                                                                          }
100  }
101
102    pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
103    borsh::to_vec(self)
104  }
105  }
106
107impl Default for CreatePartnerMetadataInstructionData {
108  fn default() -> Self {
109    Self::new()
110  }
111}
112
113#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
114#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
115 pub struct CreatePartnerMetadataInstructionArgs {
116                  pub padding: [u8; 96],
117                pub name: String,
118                pub website: String,
119                pub logo: String,
120      }
121
122impl CreatePartnerMetadataInstructionArgs {
123  pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
124    borsh::to_vec(self)
125  }
126}
127
128
129/// Instruction builder for `CreatePartnerMetadata`.
130///
131/// ### Accounts:
132///
133                ///   0. `[writable]` partner_metadata
134                      ///   1. `[writable, signer]` payer
135                ///   2. `[signer]` fee_claimer
136                ///   3. `[optional]` system_program (default to `11111111111111111111111111111111`)
137          ///   4. `[]` event_authority
138          ///   5. `[]` program
139#[derive(Clone, Debug, Default)]
140pub struct CreatePartnerMetadataBuilder {
141            partner_metadata: Option<solana_pubkey::Pubkey>,
142                payer: Option<solana_pubkey::Pubkey>,
143                fee_claimer: Option<solana_pubkey::Pubkey>,
144                system_program: Option<solana_pubkey::Pubkey>,
145                event_authority: Option<solana_pubkey::Pubkey>,
146                program: Option<solana_pubkey::Pubkey>,
147                        padding: Option<[u8; 96]>,
148                name: Option<String>,
149                website: Option<String>,
150                logo: Option<String>,
151        __remaining_accounts: Vec<solana_instruction::AccountMeta>,
152}
153
154impl CreatePartnerMetadataBuilder {
155  pub fn new() -> Self {
156    Self::default()
157  }
158            /// Partner metadata
159#[inline(always)]
160    pub fn partner_metadata(&mut self, partner_metadata: solana_pubkey::Pubkey) -> &mut Self {
161                        self.partner_metadata = Some(partner_metadata);
162                    self
163    }
164            /// Payer of the partner metadata.
165#[inline(always)]
166    pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self {
167                        self.payer = Some(payer);
168                    self
169    }
170            /// Fee claimer for partner
171#[inline(always)]
172    pub fn fee_claimer(&mut self, fee_claimer: solana_pubkey::Pubkey) -> &mut Self {
173                        self.fee_claimer = Some(fee_claimer);
174                    self
175    }
176            /// `[optional account, default to '11111111111111111111111111111111']`
177/// System program.
178#[inline(always)]
179    pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self {
180                        self.system_program = Some(system_program);
181                    self
182    }
183            #[inline(always)]
184    pub fn event_authority(&mut self, event_authority: solana_pubkey::Pubkey) -> &mut Self {
185                        self.event_authority = Some(event_authority);
186                    self
187    }
188            #[inline(always)]
189    pub fn program(&mut self, program: solana_pubkey::Pubkey) -> &mut Self {
190                        self.program = Some(program);
191                    self
192    }
193                    #[inline(always)]
194      pub fn padding(&mut self, padding: [u8; 96]) -> &mut Self {
195        self.padding = Some(padding);
196        self
197      }
198                #[inline(always)]
199      pub fn name(&mut self, name: String) -> &mut Self {
200        self.name = Some(name);
201        self
202      }
203                #[inline(always)]
204      pub fn website(&mut self, website: String) -> &mut Self {
205        self.website = Some(website);
206        self
207      }
208                #[inline(always)]
209      pub fn logo(&mut self, logo: String) -> &mut Self {
210        self.logo = Some(logo);
211        self
212      }
213        /// Add an additional account to the instruction.
214  #[inline(always)]
215  pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
216    self.__remaining_accounts.push(account);
217    self
218  }
219  /// Add additional accounts to the instruction.
220  #[inline(always)]
221  pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
222    self.__remaining_accounts.extend_from_slice(accounts);
223    self
224  }
225  #[allow(clippy::clone_on_copy)]
226  pub fn instruction(&self) -> solana_instruction::Instruction {
227    let accounts = CreatePartnerMetadata {
228                              partner_metadata: self.partner_metadata.expect("partner_metadata is not set"),
229                                        payer: self.payer.expect("payer is not set"),
230                                        fee_claimer: self.fee_claimer.expect("fee_claimer is not set"),
231                                        system_program: self.system_program.unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")),
232                                        event_authority: self.event_authority.expect("event_authority is not set"),
233                                        program: self.program.expect("program is not set"),
234                      };
235          let args = CreatePartnerMetadataInstructionArgs {
236                                                              padding: self.padding.clone().expect("padding is not set"),
237                                                                  name: self.name.clone().expect("name is not set"),
238                                                                  website: self.website.clone().expect("website is not set"),
239                                                                  logo: self.logo.clone().expect("logo is not set"),
240                                    };
241    
242    accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
243  }
244}
245
246  /// `create_partner_metadata` CPI accounts.
247  pub struct CreatePartnerMetadataCpiAccounts<'a, 'b> {
248                  /// Partner metadata
249
250      
251                    
252              pub partner_metadata: &'b solana_account_info::AccountInfo<'a>,
253                        /// Payer of the partner metadata.
254
255      
256                    
257              pub payer: &'b solana_account_info::AccountInfo<'a>,
258                        /// Fee claimer for partner
259
260      
261                    
262              pub fee_claimer: &'b solana_account_info::AccountInfo<'a>,
263                        /// System program.
264
265      
266                    
267              pub system_program: &'b solana_account_info::AccountInfo<'a>,
268                
269                    
270              pub event_authority: &'b solana_account_info::AccountInfo<'a>,
271                
272                    
273              pub program: &'b solana_account_info::AccountInfo<'a>,
274            }
275
276/// `create_partner_metadata` CPI instruction.
277pub struct CreatePartnerMetadataCpi<'a, 'b> {
278  /// The program to invoke.
279  pub __program: &'b solana_account_info::AccountInfo<'a>,
280            /// Partner metadata
281
282    
283              
284          pub partner_metadata: &'b solana_account_info::AccountInfo<'a>,
285                /// Payer of the partner metadata.
286
287    
288              
289          pub payer: &'b solana_account_info::AccountInfo<'a>,
290                /// Fee claimer for partner
291
292    
293              
294          pub fee_claimer: &'b solana_account_info::AccountInfo<'a>,
295                /// System program.
296
297    
298              
299          pub system_program: &'b solana_account_info::AccountInfo<'a>,
300          
301              
302          pub event_authority: &'b solana_account_info::AccountInfo<'a>,
303          
304              
305          pub program: &'b solana_account_info::AccountInfo<'a>,
306            /// The arguments for the instruction.
307    pub __args: CreatePartnerMetadataInstructionArgs,
308  }
309
310impl<'a, 'b> CreatePartnerMetadataCpi<'a, 'b> {
311  pub fn new(
312    program: &'b solana_account_info::AccountInfo<'a>,
313          accounts: CreatePartnerMetadataCpiAccounts<'a, 'b>,
314              args: CreatePartnerMetadataInstructionArgs,
315      ) -> Self {
316    Self {
317      __program: program,
318              partner_metadata: accounts.partner_metadata,
319              payer: accounts.payer,
320              fee_claimer: accounts.fee_claimer,
321              system_program: accounts.system_program,
322              event_authority: accounts.event_authority,
323              program: accounts.program,
324                    __args: args,
325          }
326  }
327  #[inline(always)]
328  pub fn invoke(&self) -> solana_program_error::ProgramResult {
329    self.invoke_signed_with_remaining_accounts(&[], &[])
330  }
331  #[inline(always)]
332  pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
333    self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
334  }
335  #[inline(always)]
336  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
337    self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
338  }
339  #[allow(clippy::arithmetic_side_effects)]
340  #[allow(clippy::clone_on_copy)]
341  #[allow(clippy::vec_init_then_push)]
342  pub fn invoke_signed_with_remaining_accounts(
343    &self,
344    signers_seeds: &[&[&[u8]]],
345    remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
346  ) -> solana_program_error::ProgramResult {
347    let mut accounts = Vec::with_capacity(6+ remaining_accounts.len());
348                            accounts.push(solana_instruction::AccountMeta::new(
349            *self.partner_metadata.key,
350            false
351          ));
352                                          accounts.push(solana_instruction::AccountMeta::new(
353            *self.payer.key,
354            true
355          ));
356                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
357            *self.fee_claimer.key,
358            true
359          ));
360                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
361            *self.system_program.key,
362            false
363          ));
364                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
365            *self.event_authority.key,
366            false
367          ));
368                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
369            *self.program.key,
370            false
371          ));
372                      remaining_accounts.iter().for_each(|remaining_account| {
373      accounts.push(solana_instruction::AccountMeta {
374          pubkey: *remaining_account.0.key,
375          is_signer: remaining_account.1,
376          is_writable: remaining_account.2,
377      })
378    });
379    let mut data = CreatePartnerMetadataInstructionData::new().try_to_vec().unwrap();
380          let mut args = self.__args.try_to_vec().unwrap();
381      data.append(&mut args);
382    
383    let instruction = solana_instruction::Instruction {
384      program_id: crate::DYNAMIC_BONDING_CURVE_ID,
385      accounts,
386      data,
387    };
388    let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len());
389    account_infos.push(self.__program.clone());
390                  account_infos.push(self.partner_metadata.clone());
391                        account_infos.push(self.payer.clone());
392                        account_infos.push(self.fee_claimer.clone());
393                        account_infos.push(self.system_program.clone());
394                        account_infos.push(self.event_authority.clone());
395                        account_infos.push(self.program.clone());
396              remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
397
398    if signers_seeds.is_empty() {
399      solana_cpi::invoke(&instruction, &account_infos)
400    } else {
401      solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
402    }
403  }
404}
405
406/// Instruction builder for `CreatePartnerMetadata` via CPI.
407///
408/// ### Accounts:
409///
410                ///   0. `[writable]` partner_metadata
411                      ///   1. `[writable, signer]` payer
412                ///   2. `[signer]` fee_claimer
413          ///   3. `[]` system_program
414          ///   4. `[]` event_authority
415          ///   5. `[]` program
416#[derive(Clone, Debug)]
417pub struct CreatePartnerMetadataCpiBuilder<'a, 'b> {
418  instruction: Box<CreatePartnerMetadataCpiBuilderInstruction<'a, 'b>>,
419}
420
421impl<'a, 'b> CreatePartnerMetadataCpiBuilder<'a, 'b> {
422  pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
423    let instruction = Box::new(CreatePartnerMetadataCpiBuilderInstruction {
424      __program: program,
425              partner_metadata: None,
426              payer: None,
427              fee_claimer: None,
428              system_program: None,
429              event_authority: None,
430              program: None,
431                                            padding: None,
432                                name: None,
433                                website: None,
434                                logo: None,
435                    __remaining_accounts: Vec::new(),
436    });
437    Self { instruction }
438  }
439      /// Partner metadata
440#[inline(always)]
441    pub fn partner_metadata(&mut self, partner_metadata: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
442                        self.instruction.partner_metadata = Some(partner_metadata);
443                    self
444    }
445      /// Payer of the partner metadata.
446#[inline(always)]
447    pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
448                        self.instruction.payer = Some(payer);
449                    self
450    }
451      /// Fee claimer for partner
452#[inline(always)]
453    pub fn fee_claimer(&mut self, fee_claimer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
454                        self.instruction.fee_claimer = Some(fee_claimer);
455                    self
456    }
457      /// System program.
458#[inline(always)]
459    pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
460                        self.instruction.system_program = Some(system_program);
461                    self
462    }
463      #[inline(always)]
464    pub fn event_authority(&mut self, event_authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
465                        self.instruction.event_authority = Some(event_authority);
466                    self
467    }
468      #[inline(always)]
469    pub fn program(&mut self, program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
470                        self.instruction.program = Some(program);
471                    self
472    }
473                    #[inline(always)]
474      pub fn padding(&mut self, padding: [u8; 96]) -> &mut Self {
475        self.instruction.padding = Some(padding);
476        self
477      }
478                #[inline(always)]
479      pub fn name(&mut self, name: String) -> &mut Self {
480        self.instruction.name = Some(name);
481        self
482      }
483                #[inline(always)]
484      pub fn website(&mut self, website: String) -> &mut Self {
485        self.instruction.website = Some(website);
486        self
487      }
488                #[inline(always)]
489      pub fn logo(&mut self, logo: String) -> &mut Self {
490        self.instruction.logo = Some(logo);
491        self
492      }
493        /// Add an additional account to the instruction.
494  #[inline(always)]
495  pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
496    self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
497    self
498  }
499  /// Add additional accounts to the instruction.
500  ///
501  /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
502  /// and a `bool` indicating whether the account is a signer or not.
503  #[inline(always)]
504  pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
505    self.instruction.__remaining_accounts.extend_from_slice(accounts);
506    self
507  }
508  #[inline(always)]
509  pub fn invoke(&self) -> solana_program_error::ProgramResult {
510    self.invoke_signed(&[])
511  }
512  #[allow(clippy::clone_on_copy)]
513  #[allow(clippy::vec_init_then_push)]
514  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
515          let args = CreatePartnerMetadataInstructionArgs {
516                                                              padding: self.instruction.padding.clone().expect("padding is not set"),
517                                                                  name: self.instruction.name.clone().expect("name is not set"),
518                                                                  website: self.instruction.website.clone().expect("website is not set"),
519                                                                  logo: self.instruction.logo.clone().expect("logo is not set"),
520                                    };
521        let instruction = CreatePartnerMetadataCpi {
522        __program: self.instruction.__program,
523                  
524          partner_metadata: self.instruction.partner_metadata.expect("partner_metadata is not set"),
525                  
526          payer: self.instruction.payer.expect("payer is not set"),
527                  
528          fee_claimer: self.instruction.fee_claimer.expect("fee_claimer is not set"),
529                  
530          system_program: self.instruction.system_program.expect("system_program is not set"),
531                  
532          event_authority: self.instruction.event_authority.expect("event_authority is not set"),
533                  
534          program: self.instruction.program.expect("program is not set"),
535                          __args: args,
536            };
537    instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
538  }
539}
540
541#[derive(Clone, Debug)]
542struct CreatePartnerMetadataCpiBuilderInstruction<'a, 'b> {
543  __program: &'b solana_account_info::AccountInfo<'a>,
544            partner_metadata: Option<&'b solana_account_info::AccountInfo<'a>>,
545                payer: Option<&'b solana_account_info::AccountInfo<'a>>,
546                fee_claimer: Option<&'b solana_account_info::AccountInfo<'a>>,
547                system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
548                event_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
549                program: Option<&'b solana_account_info::AccountInfo<'a>>,
550                        padding: Option<[u8; 96]>,
551                name: Option<String>,
552                website: Option<String>,
553                logo: Option<String>,
554        /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
555  __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
556}
557