solana_native_programs/system_program/generated/instructions/
authorize_nonce_account.rs1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10use solana_program::pubkey::Pubkey;
11
12pub struct AuthorizeNonceAccount {
14 pub nonce_account: solana_program::pubkey::Pubkey,
16 pub nonce_authority: solana_program::pubkey::Pubkey,
18}
19
20impl AuthorizeNonceAccount {
21 pub fn instruction(
22 &self,
23 args: AuthorizeNonceAccountInstructionArgs,
24 ) -> solana_program::instruction::Instruction {
25 self.instruction_with_remaining_accounts(args, &[])
26 }
27 #[allow(clippy::vec_init_then_push)]
28 pub fn instruction_with_remaining_accounts(
29 &self,
30 args: AuthorizeNonceAccountInstructionArgs,
31 remaining_accounts: &[solana_program::instruction::AccountMeta],
32 ) -> solana_program::instruction::Instruction {
33 let mut accounts = Vec::with_capacity(2 + remaining_accounts.len());
34 accounts.push(solana_program::instruction::AccountMeta::new(
35 self.nonce_account,
36 false,
37 ));
38 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
39 self.nonce_authority,
40 true,
41 ));
42 accounts.extend_from_slice(remaining_accounts);
43 let mut data = AuthorizeNonceAccountInstructionData::new()
44 .try_to_vec()
45 .unwrap();
46 let mut args = args.try_to_vec().unwrap();
47 data.append(&mut args);
48
49 solana_program::instruction::Instruction {
50 program_id: crate::SYSTEM_PROGRAM_ID,
51 accounts,
52 data,
53 }
54 }
55}
56
57#[derive(BorshDeserialize, BorshSerialize)]
58struct AuthorizeNonceAccountInstructionData {
59 discriminator: u32,
60}
61
62impl AuthorizeNonceAccountInstructionData {
63 fn new() -> Self {
64 Self { discriminator: 7 }
65 }
66}
67
68#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
69#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
70pub struct AuthorizeNonceAccountInstructionArgs {
71 pub new_authority: Pubkey,
72}
73
74#[derive(Default)]
81pub struct AuthorizeNonceAccountBuilder {
82 nonce_account: Option<solana_program::pubkey::Pubkey>,
83 nonce_authority: Option<solana_program::pubkey::Pubkey>,
84 new_authority: Option<Pubkey>,
85 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
86}
87
88impl AuthorizeNonceAccountBuilder {
89 pub fn new() -> Self {
90 Self::default()
91 }
92 #[inline(always)]
94 pub fn nonce_account(&mut self, nonce_account: solana_program::pubkey::Pubkey) -> &mut Self {
95 self.nonce_account = Some(nonce_account);
96 self
97 }
98 #[inline(always)]
100 pub fn nonce_authority(
101 &mut self,
102 nonce_authority: solana_program::pubkey::Pubkey,
103 ) -> &mut Self {
104 self.nonce_authority = Some(nonce_authority);
105 self
106 }
107 #[inline(always)]
108 pub fn new_authority(&mut self, new_authority: Pubkey) -> &mut Self {
109 self.new_authority = Some(new_authority);
110 self
111 }
112 #[inline(always)]
114 pub fn add_remaining_account(
115 &mut self,
116 account: solana_program::instruction::AccountMeta,
117 ) -> &mut Self {
118 self.__remaining_accounts.push(account);
119 self
120 }
121 #[inline(always)]
123 pub fn add_remaining_accounts(
124 &mut self,
125 accounts: &[solana_program::instruction::AccountMeta],
126 ) -> &mut Self {
127 self.__remaining_accounts.extend_from_slice(accounts);
128 self
129 }
130 #[allow(clippy::clone_on_copy)]
131 pub fn instruction(&self) -> solana_program::instruction::Instruction {
132 let accounts = AuthorizeNonceAccount {
133 nonce_account: self.nonce_account.expect("nonce_account is not set"),
134 nonce_authority: self.nonce_authority.expect("nonce_authority is not set"),
135 };
136 let args = AuthorizeNonceAccountInstructionArgs {
137 new_authority: self
138 .new_authority
139 .clone()
140 .expect("new_authority is not set"),
141 };
142
143 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
144 }
145}
146
147pub struct AuthorizeNonceAccountCpiAccounts<'a, 'b> {
149 pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>,
151 pub nonce_authority: &'b solana_program::account_info::AccountInfo<'a>,
153}
154
155pub struct AuthorizeNonceAccountCpi<'a, 'b> {
157 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
159 pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>,
161 pub nonce_authority: &'b solana_program::account_info::AccountInfo<'a>,
163 pub __args: AuthorizeNonceAccountInstructionArgs,
165}
166
167impl<'a, 'b> AuthorizeNonceAccountCpi<'a, 'b> {
168 pub fn new(
169 program: &'b solana_program::account_info::AccountInfo<'a>,
170 accounts: AuthorizeNonceAccountCpiAccounts<'a, 'b>,
171 args: AuthorizeNonceAccountInstructionArgs,
172 ) -> Self {
173 Self {
174 __program: program,
175 nonce_account: accounts.nonce_account,
176 nonce_authority: accounts.nonce_authority,
177 __args: args,
178 }
179 }
180 #[inline(always)]
181 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
182 self.invoke_signed_with_remaining_accounts(&[], &[])
183 }
184 #[inline(always)]
185 pub fn invoke_with_remaining_accounts(
186 &self,
187 remaining_accounts: &[(
188 &'b solana_program::account_info::AccountInfo<'a>,
189 bool,
190 bool,
191 )],
192 ) -> solana_program::entrypoint::ProgramResult {
193 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
194 }
195 #[inline(always)]
196 pub fn invoke_signed(
197 &self,
198 signers_seeds: &[&[&[u8]]],
199 ) -> solana_program::entrypoint::ProgramResult {
200 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
201 }
202 #[allow(clippy::clone_on_copy)]
203 #[allow(clippy::vec_init_then_push)]
204 pub fn invoke_signed_with_remaining_accounts(
205 &self,
206 signers_seeds: &[&[&[u8]]],
207 remaining_accounts: &[(
208 &'b solana_program::account_info::AccountInfo<'a>,
209 bool,
210 bool,
211 )],
212 ) -> solana_program::entrypoint::ProgramResult {
213 let mut accounts = Vec::with_capacity(2 + remaining_accounts.len());
214 accounts.push(solana_program::instruction::AccountMeta::new(
215 *self.nonce_account.key,
216 false,
217 ));
218 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
219 *self.nonce_authority.key,
220 true,
221 ));
222 remaining_accounts.iter().for_each(|remaining_account| {
223 accounts.push(solana_program::instruction::AccountMeta {
224 pubkey: *remaining_account.0.key,
225 is_signer: remaining_account.1,
226 is_writable: remaining_account.2,
227 })
228 });
229 let mut data = AuthorizeNonceAccountInstructionData::new()
230 .try_to_vec()
231 .unwrap();
232 let mut args = self.__args.try_to_vec().unwrap();
233 data.append(&mut args);
234
235 let instruction = solana_program::instruction::Instruction {
236 program_id: crate::SYSTEM_PROGRAM_ID,
237 accounts,
238 data,
239 };
240 let mut account_infos = Vec::with_capacity(2 + 1 + remaining_accounts.len());
241 account_infos.push(self.__program.clone());
242 account_infos.push(self.nonce_account.clone());
243 account_infos.push(self.nonce_authority.clone());
244 remaining_accounts
245 .iter()
246 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
247
248 if signers_seeds.is_empty() {
249 solana_program::program::invoke(&instruction, &account_infos)
250 } else {
251 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
252 }
253 }
254}
255
256pub struct AuthorizeNonceAccountCpiBuilder<'a, 'b> {
263 instruction: Box<AuthorizeNonceAccountCpiBuilderInstruction<'a, 'b>>,
264}
265
266impl<'a, 'b> AuthorizeNonceAccountCpiBuilder<'a, 'b> {
267 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
268 let instruction = Box::new(AuthorizeNonceAccountCpiBuilderInstruction {
269 __program: program,
270 nonce_account: None,
271 nonce_authority: None,
272 new_authority: None,
273 __remaining_accounts: Vec::new(),
274 });
275 Self { instruction }
276 }
277 #[inline(always)]
279 pub fn nonce_account(
280 &mut self,
281 nonce_account: &'b solana_program::account_info::AccountInfo<'a>,
282 ) -> &mut Self {
283 self.instruction.nonce_account = Some(nonce_account);
284 self
285 }
286 #[inline(always)]
288 pub fn nonce_authority(
289 &mut self,
290 nonce_authority: &'b solana_program::account_info::AccountInfo<'a>,
291 ) -> &mut Self {
292 self.instruction.nonce_authority = Some(nonce_authority);
293 self
294 }
295 #[inline(always)]
296 pub fn new_authority(&mut self, new_authority: Pubkey) -> &mut Self {
297 self.instruction.new_authority = Some(new_authority);
298 self
299 }
300 #[inline(always)]
302 pub fn add_remaining_account(
303 &mut self,
304 account: &'b solana_program::account_info::AccountInfo<'a>,
305 is_writable: bool,
306 is_signer: bool,
307 ) -> &mut Self {
308 self.instruction
309 .__remaining_accounts
310 .push((account, is_writable, is_signer));
311 self
312 }
313 #[inline(always)]
318 pub fn add_remaining_accounts(
319 &mut self,
320 accounts: &[(
321 &'b solana_program::account_info::AccountInfo<'a>,
322 bool,
323 bool,
324 )],
325 ) -> &mut Self {
326 self.instruction
327 .__remaining_accounts
328 .extend_from_slice(accounts);
329 self
330 }
331 #[inline(always)]
332 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
333 self.invoke_signed(&[])
334 }
335 #[allow(clippy::clone_on_copy)]
336 #[allow(clippy::vec_init_then_push)]
337 pub fn invoke_signed(
338 &self,
339 signers_seeds: &[&[&[u8]]],
340 ) -> solana_program::entrypoint::ProgramResult {
341 let args = AuthorizeNonceAccountInstructionArgs {
342 new_authority: self
343 .instruction
344 .new_authority
345 .clone()
346 .expect("new_authority is not set"),
347 };
348 let instruction = AuthorizeNonceAccountCpi {
349 __program: self.instruction.__program,
350
351 nonce_account: self
352 .instruction
353 .nonce_account
354 .expect("nonce_account is not set"),
355
356 nonce_authority: self
357 .instruction
358 .nonce_authority
359 .expect("nonce_authority is not set"),
360 __args: args,
361 };
362 instruction.invoke_signed_with_remaining_accounts(
363 signers_seeds,
364 &self.instruction.__remaining_accounts,
365 )
366 }
367}
368
369struct AuthorizeNonceAccountCpiBuilderInstruction<'a, 'b> {
370 __program: &'b solana_program::account_info::AccountInfo<'a>,
371 nonce_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
372 nonce_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
373 new_authority: Option<Pubkey>,
374 __remaining_accounts: Vec<(
376 &'b solana_program::account_info::AccountInfo<'a>,
377 bool,
378 bool,
379 )>,
380}