Skip to main content

reflect_sdk/generated/instructions/
increase_admin_size.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 INCREASE_ADMIN_SIZE_DISCRIMINATOR: [u8; 8] = [27, 91, 127, 176, 61, 17, 113, 0];
12
13/// Accounts.
14#[derive(Debug)]
15pub struct IncreaseAdminSize {
16      
17              
18          pub user_permissions: solana_pubkey::Pubkey,
19          
20              
21          pub payer: solana_pubkey::Pubkey,
22          
23              
24          pub system_program: solana_pubkey::Pubkey,
25      }
26
27impl IncreaseAdminSize {
28  pub fn instruction(&self, args: IncreaseAdminSizeInstructionArgs) -> solana_instruction::Instruction {
29    self.instruction_with_remaining_accounts(args, &[])
30  }
31  #[allow(clippy::arithmetic_side_effects)]
32  #[allow(clippy::vec_init_then_push)]
33  pub fn instruction_with_remaining_accounts(&self, args: IncreaseAdminSizeInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
34    let mut accounts = Vec::with_capacity(3+ remaining_accounts.len());
35                            accounts.push(solana_instruction::AccountMeta::new(
36            self.user_permissions,
37            false
38          ));
39                                          accounts.push(solana_instruction::AccountMeta::new(
40            self.payer,
41            true
42          ));
43                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
44            self.system_program,
45            false
46          ));
47                      accounts.extend_from_slice(remaining_accounts);
48    let mut data = IncreaseAdminSizeInstructionData::new().try_to_vec().unwrap();
49          let mut args = args.try_to_vec().unwrap();
50      data.append(&mut args);
51    
52    solana_instruction::Instruction {
53      program_id: crate::REFLECT_MAIN_ID,
54      accounts,
55      data,
56    }
57  }
58}
59
60#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
61#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
62 pub struct IncreaseAdminSizeInstructionData {
63            discriminator: [u8; 8],
64            }
65
66impl IncreaseAdminSizeInstructionData {
67  pub fn new() -> Self {
68    Self {
69                        discriminator: [27, 91, 127, 176, 61, 17, 113, 0],
70                                }
71  }
72
73    pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
74    borsh::to_vec(self)
75  }
76  }
77
78impl Default for IncreaseAdminSizeInstructionData {
79  fn default() -> Self {
80    Self::new()
81  }
82}
83
84#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
85#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
86 pub struct IncreaseAdminSizeInstructionArgs {
87                  pub additional_roles: u8,
88      }
89
90impl IncreaseAdminSizeInstructionArgs {
91  pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
92    borsh::to_vec(self)
93  }
94}
95
96
97/// Instruction builder for `IncreaseAdminSize`.
98///
99/// ### Accounts:
100///
101                ///   0. `[writable]` user_permissions
102                      ///   1. `[writable, signer]` payer
103                ///   2. `[optional]` system_program (default to `11111111111111111111111111111111`)
104#[derive(Clone, Debug, Default)]
105pub struct IncreaseAdminSizeBuilder {
106            user_permissions: Option<solana_pubkey::Pubkey>,
107                payer: Option<solana_pubkey::Pubkey>,
108                system_program: Option<solana_pubkey::Pubkey>,
109                        additional_roles: Option<u8>,
110        __remaining_accounts: Vec<solana_instruction::AccountMeta>,
111}
112
113impl IncreaseAdminSizeBuilder {
114  pub fn new() -> Self {
115    Self::default()
116  }
117            #[inline(always)]
118    pub fn user_permissions(&mut self, user_permissions: solana_pubkey::Pubkey) -> &mut Self {
119                        self.user_permissions = Some(user_permissions);
120                    self
121    }
122            #[inline(always)]
123    pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self {
124                        self.payer = Some(payer);
125                    self
126    }
127            /// `[optional account, default to '11111111111111111111111111111111']`
128#[inline(always)]
129    pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self {
130                        self.system_program = Some(system_program);
131                    self
132    }
133                    #[inline(always)]
134      pub fn additional_roles(&mut self, additional_roles: u8) -> &mut Self {
135        self.additional_roles = Some(additional_roles);
136        self
137      }
138        /// Add an additional account to the instruction.
139  #[inline(always)]
140  pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
141    self.__remaining_accounts.push(account);
142    self
143  }
144  /// Add additional accounts to the instruction.
145  #[inline(always)]
146  pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
147    self.__remaining_accounts.extend_from_slice(accounts);
148    self
149  }
150  #[allow(clippy::clone_on_copy)]
151  pub fn instruction(&self) -> solana_instruction::Instruction {
152    let accounts = IncreaseAdminSize {
153                              user_permissions: self.user_permissions.expect("user_permissions is not set"),
154                                        payer: self.payer.expect("payer is not set"),
155                                        system_program: self.system_program.unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")),
156                      };
157          let args = IncreaseAdminSizeInstructionArgs {
158                                                              additional_roles: self.additional_roles.clone().expect("additional_roles is not set"),
159                                    };
160    
161    accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
162  }
163}
164
165  /// `increase_admin_size` CPI accounts.
166  pub struct IncreaseAdminSizeCpiAccounts<'a, 'b> {
167          
168                    
169              pub user_permissions: &'b solana_account_info::AccountInfo<'a>,
170                
171                    
172              pub payer: &'b solana_account_info::AccountInfo<'a>,
173                
174                    
175              pub system_program: &'b solana_account_info::AccountInfo<'a>,
176            }
177
178/// `increase_admin_size` CPI instruction.
179pub struct IncreaseAdminSizeCpi<'a, 'b> {
180  /// The program to invoke.
181  pub __program: &'b solana_account_info::AccountInfo<'a>,
182      
183              
184          pub user_permissions: &'b solana_account_info::AccountInfo<'a>,
185          
186              
187          pub payer: &'b solana_account_info::AccountInfo<'a>,
188          
189              
190          pub system_program: &'b solana_account_info::AccountInfo<'a>,
191            /// The arguments for the instruction.
192    pub __args: IncreaseAdminSizeInstructionArgs,
193  }
194
195impl<'a, 'b> IncreaseAdminSizeCpi<'a, 'b> {
196  pub fn new(
197    program: &'b solana_account_info::AccountInfo<'a>,
198          accounts: IncreaseAdminSizeCpiAccounts<'a, 'b>,
199              args: IncreaseAdminSizeInstructionArgs,
200      ) -> Self {
201    Self {
202      __program: program,
203              user_permissions: accounts.user_permissions,
204              payer: accounts.payer,
205              system_program: accounts.system_program,
206                    __args: args,
207          }
208  }
209  #[inline(always)]
210  pub fn invoke(&self) -> solana_program_error::ProgramResult {
211    self.invoke_signed_with_remaining_accounts(&[], &[])
212  }
213  #[inline(always)]
214  pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
215    self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
216  }
217  #[inline(always)]
218  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
219    self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
220  }
221  #[allow(clippy::arithmetic_side_effects)]
222  #[allow(clippy::clone_on_copy)]
223  #[allow(clippy::vec_init_then_push)]
224  pub fn invoke_signed_with_remaining_accounts(
225    &self,
226    signers_seeds: &[&[&[u8]]],
227    remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
228  ) -> solana_program_error::ProgramResult {
229    let mut accounts = Vec::with_capacity(3+ remaining_accounts.len());
230                            accounts.push(solana_instruction::AccountMeta::new(
231            *self.user_permissions.key,
232            false
233          ));
234                                          accounts.push(solana_instruction::AccountMeta::new(
235            *self.payer.key,
236            true
237          ));
238                                          accounts.push(solana_instruction::AccountMeta::new_readonly(
239            *self.system_program.key,
240            false
241          ));
242                      remaining_accounts.iter().for_each(|remaining_account| {
243      accounts.push(solana_instruction::AccountMeta {
244          pubkey: *remaining_account.0.key,
245          is_signer: remaining_account.1,
246          is_writable: remaining_account.2,
247      })
248    });
249    let mut data = IncreaseAdminSizeInstructionData::new().try_to_vec().unwrap();
250          let mut args = self.__args.try_to_vec().unwrap();
251      data.append(&mut args);
252    
253    let instruction = solana_instruction::Instruction {
254      program_id: crate::REFLECT_MAIN_ID,
255      accounts,
256      data,
257    };
258    let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len());
259    account_infos.push(self.__program.clone());
260                  account_infos.push(self.user_permissions.clone());
261                        account_infos.push(self.payer.clone());
262                        account_infos.push(self.system_program.clone());
263              remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
264
265    if signers_seeds.is_empty() {
266      solana_cpi::invoke(&instruction, &account_infos)
267    } else {
268      solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
269    }
270  }
271}
272
273/// Instruction builder for `IncreaseAdminSize` via CPI.
274///
275/// ### Accounts:
276///
277                ///   0. `[writable]` user_permissions
278                      ///   1. `[writable, signer]` payer
279          ///   2. `[]` system_program
280#[derive(Clone, Debug)]
281pub struct IncreaseAdminSizeCpiBuilder<'a, 'b> {
282  instruction: Box<IncreaseAdminSizeCpiBuilderInstruction<'a, 'b>>,
283}
284
285impl<'a, 'b> IncreaseAdminSizeCpiBuilder<'a, 'b> {
286  pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
287    let instruction = Box::new(IncreaseAdminSizeCpiBuilderInstruction {
288      __program: program,
289              user_permissions: None,
290              payer: None,
291              system_program: None,
292                                            additional_roles: None,
293                    __remaining_accounts: Vec::new(),
294    });
295    Self { instruction }
296  }
297      #[inline(always)]
298    pub fn user_permissions(&mut self, user_permissions: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
299                        self.instruction.user_permissions = Some(user_permissions);
300                    self
301    }
302      #[inline(always)]
303    pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
304                        self.instruction.payer = Some(payer);
305                    self
306    }
307      #[inline(always)]
308    pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
309                        self.instruction.system_program = Some(system_program);
310                    self
311    }
312                    #[inline(always)]
313      pub fn additional_roles(&mut self, additional_roles: u8) -> &mut Self {
314        self.instruction.additional_roles = Some(additional_roles);
315        self
316      }
317        /// Add an additional account to the instruction.
318  #[inline(always)]
319  pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
320    self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
321    self
322  }
323  /// Add additional accounts to the instruction.
324  ///
325  /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
326  /// and a `bool` indicating whether the account is a signer or not.
327  #[inline(always)]
328  pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
329    self.instruction.__remaining_accounts.extend_from_slice(accounts);
330    self
331  }
332  #[inline(always)]
333  pub fn invoke(&self) -> solana_program_error::ProgramResult {
334    self.invoke_signed(&[])
335  }
336  #[allow(clippy::clone_on_copy)]
337  #[allow(clippy::vec_init_then_push)]
338  pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
339          let args = IncreaseAdminSizeInstructionArgs {
340                                                              additional_roles: self.instruction.additional_roles.clone().expect("additional_roles is not set"),
341                                    };
342        let instruction = IncreaseAdminSizeCpi {
343        __program: self.instruction.__program,
344                  
345          user_permissions: self.instruction.user_permissions.expect("user_permissions is not set"),
346                  
347          payer: self.instruction.payer.expect("payer is not set"),
348                  
349          system_program: self.instruction.system_program.expect("system_program is not set"),
350                          __args: args,
351            };
352    instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
353  }
354}
355
356#[derive(Clone, Debug)]
357struct IncreaseAdminSizeCpiBuilderInstruction<'a, 'b> {
358  __program: &'b solana_account_info::AccountInfo<'a>,
359            user_permissions: Option<&'b solana_account_info::AccountInfo<'a>>,
360                payer: Option<&'b solana_account_info::AccountInfo<'a>>,
361                system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
362                        additional_roles: Option<u8>,
363        /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
364  __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
365}
366