Skip to main content

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