solana_native_programs/system_program/generated/instructions/
advance_nonce_account.rs1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11pub struct AdvanceNonceAccount {
13 pub nonce_account: solana_program::pubkey::Pubkey,
15 pub recent_blockhashes: solana_program::pubkey::Pubkey,
17 pub nonce_authority: solana_program::pubkey::Pubkey,
19}
20
21impl AdvanceNonceAccount {
22 pub fn instruction(&self) -> solana_program::instruction::Instruction {
23 self.instruction_with_remaining_accounts(&[])
24 }
25 #[allow(clippy::vec_init_then_push)]
26 pub fn instruction_with_remaining_accounts(
27 &self,
28 remaining_accounts: &[solana_program::instruction::AccountMeta],
29 ) -> solana_program::instruction::Instruction {
30 let mut accounts = Vec::with_capacity(3 + remaining_accounts.len());
31 accounts.push(solana_program::instruction::AccountMeta::new(
32 self.nonce_account,
33 false,
34 ));
35 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
36 self.recent_blockhashes,
37 false,
38 ));
39 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
40 self.nonce_authority,
41 true,
42 ));
43 accounts.extend_from_slice(remaining_accounts);
44 let data = AdvanceNonceAccountInstructionData::new()
45 .try_to_vec()
46 .unwrap();
47
48 solana_program::instruction::Instruction {
49 program_id: crate::SYSTEM_PROGRAM_ID,
50 accounts,
51 data,
52 }
53 }
54}
55
56#[derive(BorshDeserialize, BorshSerialize)]
57struct AdvanceNonceAccountInstructionData {
58 discriminator: u32,
59}
60
61impl AdvanceNonceAccountInstructionData {
62 fn new() -> Self {
63 Self { discriminator: 4 }
64 }
65}
66
67#[derive(Default)]
75pub struct AdvanceNonceAccountBuilder {
76 nonce_account: Option<solana_program::pubkey::Pubkey>,
77 recent_blockhashes: Option<solana_program::pubkey::Pubkey>,
78 nonce_authority: Option<solana_program::pubkey::Pubkey>,
79 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
80}
81
82impl AdvanceNonceAccountBuilder {
83 pub fn new() -> Self {
84 Self::default()
85 }
86 #[inline(always)]
88 pub fn nonce_account(&mut self, nonce_account: solana_program::pubkey::Pubkey) -> &mut Self {
89 self.nonce_account = Some(nonce_account);
90 self
91 }
92 #[inline(always)]
94 pub fn recent_blockhashes(
95 &mut self,
96 recent_blockhashes: solana_program::pubkey::Pubkey,
97 ) -> &mut Self {
98 self.recent_blockhashes = Some(recent_blockhashes);
99 self
100 }
101 #[inline(always)]
103 pub fn nonce_authority(
104 &mut self,
105 nonce_authority: solana_program::pubkey::Pubkey,
106 ) -> &mut Self {
107 self.nonce_authority = Some(nonce_authority);
108 self
109 }
110 #[inline(always)]
112 pub fn add_remaining_account(
113 &mut self,
114 account: solana_program::instruction::AccountMeta,
115 ) -> &mut Self {
116 self.__remaining_accounts.push(account);
117 self
118 }
119 #[inline(always)]
121 pub fn add_remaining_accounts(
122 &mut self,
123 accounts: &[solana_program::instruction::AccountMeta],
124 ) -> &mut Self {
125 self.__remaining_accounts.extend_from_slice(accounts);
126 self
127 }
128 #[allow(clippy::clone_on_copy)]
129 pub fn instruction(&self) -> solana_program::instruction::Instruction {
130 let accounts = AdvanceNonceAccount {
131 nonce_account: self.nonce_account.expect("nonce_account is not set"),
132 recent_blockhashes: self
133 .recent_blockhashes
134 .expect("recent_blockhashes is not set"),
135 nonce_authority: self.nonce_authority.expect("nonce_authority is not set"),
136 };
137
138 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
139 }
140}
141
142pub struct AdvanceNonceAccountCpiAccounts<'a, 'b> {
144 pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>,
146 pub recent_blockhashes: &'b solana_program::account_info::AccountInfo<'a>,
148 pub nonce_authority: &'b solana_program::account_info::AccountInfo<'a>,
150}
151
152pub struct AdvanceNonceAccountCpi<'a, 'b> {
154 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
156 pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>,
158 pub recent_blockhashes: &'b solana_program::account_info::AccountInfo<'a>,
160 pub nonce_authority: &'b solana_program::account_info::AccountInfo<'a>,
162}
163
164impl<'a, 'b> AdvanceNonceAccountCpi<'a, 'b> {
165 pub fn new(
166 program: &'b solana_program::account_info::AccountInfo<'a>,
167 accounts: AdvanceNonceAccountCpiAccounts<'a, 'b>,
168 ) -> Self {
169 Self {
170 __program: program,
171 nonce_account: accounts.nonce_account,
172 recent_blockhashes: accounts.recent_blockhashes,
173 nonce_authority: accounts.nonce_authority,
174 }
175 }
176 #[inline(always)]
177 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
178 self.invoke_signed_with_remaining_accounts(&[], &[])
179 }
180 #[inline(always)]
181 pub fn invoke_with_remaining_accounts(
182 &self,
183 remaining_accounts: &[(
184 &'b solana_program::account_info::AccountInfo<'a>,
185 bool,
186 bool,
187 )],
188 ) -> solana_program::entrypoint::ProgramResult {
189 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
190 }
191 #[inline(always)]
192 pub fn invoke_signed(
193 &self,
194 signers_seeds: &[&[&[u8]]],
195 ) -> solana_program::entrypoint::ProgramResult {
196 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
197 }
198 #[allow(clippy::clone_on_copy)]
199 #[allow(clippy::vec_init_then_push)]
200 pub fn invoke_signed_with_remaining_accounts(
201 &self,
202 signers_seeds: &[&[&[u8]]],
203 remaining_accounts: &[(
204 &'b solana_program::account_info::AccountInfo<'a>,
205 bool,
206 bool,
207 )],
208 ) -> solana_program::entrypoint::ProgramResult {
209 let mut accounts = Vec::with_capacity(3 + remaining_accounts.len());
210 accounts.push(solana_program::instruction::AccountMeta::new(
211 *self.nonce_account.key,
212 false,
213 ));
214 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
215 *self.recent_blockhashes.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 data = AdvanceNonceAccountInstructionData::new()
230 .try_to_vec()
231 .unwrap();
232
233 let instruction = solana_program::instruction::Instruction {
234 program_id: crate::SYSTEM_PROGRAM_ID,
235 accounts,
236 data,
237 };
238 let mut account_infos = Vec::with_capacity(3 + 1 + remaining_accounts.len());
239 account_infos.push(self.__program.clone());
240 account_infos.push(self.nonce_account.clone());
241 account_infos.push(self.recent_blockhashes.clone());
242 account_infos.push(self.nonce_authority.clone());
243 remaining_accounts
244 .iter()
245 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
246
247 if signers_seeds.is_empty() {
248 solana_program::program::invoke(&instruction, &account_infos)
249 } else {
250 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
251 }
252 }
253}
254
255pub struct AdvanceNonceAccountCpiBuilder<'a, 'b> {
263 instruction: Box<AdvanceNonceAccountCpiBuilderInstruction<'a, 'b>>,
264}
265
266impl<'a, 'b> AdvanceNonceAccountCpiBuilder<'a, 'b> {
267 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
268 let instruction = Box::new(AdvanceNonceAccountCpiBuilderInstruction {
269 __program: program,
270 nonce_account: None,
271 recent_blockhashes: None,
272 nonce_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 recent_blockhashes(
289 &mut self,
290 recent_blockhashes: &'b solana_program::account_info::AccountInfo<'a>,
291 ) -> &mut Self {
292 self.instruction.recent_blockhashes = Some(recent_blockhashes);
293 self
294 }
295 #[inline(always)]
297 pub fn nonce_authority(
298 &mut self,
299 nonce_authority: &'b solana_program::account_info::AccountInfo<'a>,
300 ) -> &mut Self {
301 self.instruction.nonce_authority = Some(nonce_authority);
302 self
303 }
304 #[inline(always)]
306 pub fn add_remaining_account(
307 &mut self,
308 account: &'b solana_program::account_info::AccountInfo<'a>,
309 is_writable: bool,
310 is_signer: bool,
311 ) -> &mut Self {
312 self.instruction
313 .__remaining_accounts
314 .push((account, is_writable, is_signer));
315 self
316 }
317 #[inline(always)]
322 pub fn add_remaining_accounts(
323 &mut self,
324 accounts: &[(
325 &'b solana_program::account_info::AccountInfo<'a>,
326 bool,
327 bool,
328 )],
329 ) -> &mut Self {
330 self.instruction
331 .__remaining_accounts
332 .extend_from_slice(accounts);
333 self
334 }
335 #[inline(always)]
336 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
337 self.invoke_signed(&[])
338 }
339 #[allow(clippy::clone_on_copy)]
340 #[allow(clippy::vec_init_then_push)]
341 pub fn invoke_signed(
342 &self,
343 signers_seeds: &[&[&[u8]]],
344 ) -> solana_program::entrypoint::ProgramResult {
345 let instruction = AdvanceNonceAccountCpi {
346 __program: self.instruction.__program,
347
348 nonce_account: self
349 .instruction
350 .nonce_account
351 .expect("nonce_account is not set"),
352
353 recent_blockhashes: self
354 .instruction
355 .recent_blockhashes
356 .expect("recent_blockhashes is not set"),
357
358 nonce_authority: self
359 .instruction
360 .nonce_authority
361 .expect("nonce_authority is not set"),
362 };
363 instruction.invoke_signed_with_remaining_accounts(
364 signers_seeds,
365 &self.instruction.__remaining_accounts,
366 )
367 }
368}
369
370struct AdvanceNonceAccountCpiBuilderInstruction<'a, 'b> {
371 __program: &'b solana_program::account_info::AccountInfo<'a>,
372 nonce_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
373 recent_blockhashes: Option<&'b solana_program::account_info::AccountInfo<'a>>,
374 nonce_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
375 __remaining_accounts: Vec<(
377 &'b solana_program::account_info::AccountInfo<'a>,
378 bool,
379 bool,
380 )>,
381}