solana_native_programs/system_program/generated/instructions/
upgrade_nonce_account.rs1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11pub struct UpgradeNonceAccount {
13 pub nonce_account: solana_program::pubkey::Pubkey,
15}
16
17impl UpgradeNonceAccount {
18 pub fn instruction(&self) -> solana_program::instruction::Instruction {
19 self.instruction_with_remaining_accounts(&[])
20 }
21 #[allow(clippy::vec_init_then_push)]
22 pub fn instruction_with_remaining_accounts(
23 &self,
24 remaining_accounts: &[solana_program::instruction::AccountMeta],
25 ) -> solana_program::instruction::Instruction {
26 let mut accounts = Vec::with_capacity(1 + remaining_accounts.len());
27 accounts.push(solana_program::instruction::AccountMeta::new(
28 self.nonce_account,
29 false,
30 ));
31 accounts.extend_from_slice(remaining_accounts);
32 let data = UpgradeNonceAccountInstructionData::new()
33 .try_to_vec()
34 .unwrap();
35
36 solana_program::instruction::Instruction {
37 program_id: crate::SYSTEM_PROGRAM_ID,
38 accounts,
39 data,
40 }
41 }
42}
43
44#[derive(BorshDeserialize, BorshSerialize)]
45struct UpgradeNonceAccountInstructionData {
46 discriminator: u32,
47}
48
49impl UpgradeNonceAccountInstructionData {
50 fn new() -> Self {
51 Self { discriminator: 12 }
52 }
53}
54
55#[derive(Default)]
61pub struct UpgradeNonceAccountBuilder {
62 nonce_account: Option<solana_program::pubkey::Pubkey>,
63 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
64}
65
66impl UpgradeNonceAccountBuilder {
67 pub fn new() -> Self {
68 Self::default()
69 }
70 #[inline(always)]
72 pub fn nonce_account(&mut self, nonce_account: solana_program::pubkey::Pubkey) -> &mut Self {
73 self.nonce_account = Some(nonce_account);
74 self
75 }
76 #[inline(always)]
78 pub fn add_remaining_account(
79 &mut self,
80 account: solana_program::instruction::AccountMeta,
81 ) -> &mut Self {
82 self.__remaining_accounts.push(account);
83 self
84 }
85 #[inline(always)]
87 pub fn add_remaining_accounts(
88 &mut self,
89 accounts: &[solana_program::instruction::AccountMeta],
90 ) -> &mut Self {
91 self.__remaining_accounts.extend_from_slice(accounts);
92 self
93 }
94 #[allow(clippy::clone_on_copy)]
95 pub fn instruction(&self) -> solana_program::instruction::Instruction {
96 let accounts = UpgradeNonceAccount {
97 nonce_account: self.nonce_account.expect("nonce_account is not set"),
98 };
99
100 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
101 }
102}
103
104pub struct UpgradeNonceAccountCpiAccounts<'a, 'b> {
106 pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>,
108}
109
110pub struct UpgradeNonceAccountCpi<'a, 'b> {
112 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
114 pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>,
116}
117
118impl<'a, 'b> UpgradeNonceAccountCpi<'a, 'b> {
119 pub fn new(
120 program: &'b solana_program::account_info::AccountInfo<'a>,
121 accounts: UpgradeNonceAccountCpiAccounts<'a, 'b>,
122 ) -> Self {
123 Self {
124 __program: program,
125 nonce_account: accounts.nonce_account,
126 }
127 }
128 #[inline(always)]
129 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
130 self.invoke_signed_with_remaining_accounts(&[], &[])
131 }
132 #[inline(always)]
133 pub fn invoke_with_remaining_accounts(
134 &self,
135 remaining_accounts: &[(
136 &'b solana_program::account_info::AccountInfo<'a>,
137 bool,
138 bool,
139 )],
140 ) -> solana_program::entrypoint::ProgramResult {
141 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
142 }
143 #[inline(always)]
144 pub fn invoke_signed(
145 &self,
146 signers_seeds: &[&[&[u8]]],
147 ) -> solana_program::entrypoint::ProgramResult {
148 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
149 }
150 #[allow(clippy::clone_on_copy)]
151 #[allow(clippy::vec_init_then_push)]
152 pub fn invoke_signed_with_remaining_accounts(
153 &self,
154 signers_seeds: &[&[&[u8]]],
155 remaining_accounts: &[(
156 &'b solana_program::account_info::AccountInfo<'a>,
157 bool,
158 bool,
159 )],
160 ) -> solana_program::entrypoint::ProgramResult {
161 let mut accounts = Vec::with_capacity(1 + remaining_accounts.len());
162 accounts.push(solana_program::instruction::AccountMeta::new(
163 *self.nonce_account.key,
164 false,
165 ));
166 remaining_accounts.iter().for_each(|remaining_account| {
167 accounts.push(solana_program::instruction::AccountMeta {
168 pubkey: *remaining_account.0.key,
169 is_signer: remaining_account.1,
170 is_writable: remaining_account.2,
171 })
172 });
173 let data = UpgradeNonceAccountInstructionData::new()
174 .try_to_vec()
175 .unwrap();
176
177 let instruction = solana_program::instruction::Instruction {
178 program_id: crate::SYSTEM_PROGRAM_ID,
179 accounts,
180 data,
181 };
182 let mut account_infos = Vec::with_capacity(1 + 1 + remaining_accounts.len());
183 account_infos.push(self.__program.clone());
184 account_infos.push(self.nonce_account.clone());
185 remaining_accounts
186 .iter()
187 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
188
189 if signers_seeds.is_empty() {
190 solana_program::program::invoke(&instruction, &account_infos)
191 } else {
192 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
193 }
194 }
195}
196
197pub struct UpgradeNonceAccountCpiBuilder<'a, 'b> {
203 instruction: Box<UpgradeNonceAccountCpiBuilderInstruction<'a, 'b>>,
204}
205
206impl<'a, 'b> UpgradeNonceAccountCpiBuilder<'a, 'b> {
207 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
208 let instruction = Box::new(UpgradeNonceAccountCpiBuilderInstruction {
209 __program: program,
210 nonce_account: None,
211 __remaining_accounts: Vec::new(),
212 });
213 Self { instruction }
214 }
215 #[inline(always)]
217 pub fn nonce_account(
218 &mut self,
219 nonce_account: &'b solana_program::account_info::AccountInfo<'a>,
220 ) -> &mut Self {
221 self.instruction.nonce_account = Some(nonce_account);
222 self
223 }
224 #[inline(always)]
226 pub fn add_remaining_account(
227 &mut self,
228 account: &'b solana_program::account_info::AccountInfo<'a>,
229 is_writable: bool,
230 is_signer: bool,
231 ) -> &mut Self {
232 self.instruction
233 .__remaining_accounts
234 .push((account, is_writable, is_signer));
235 self
236 }
237 #[inline(always)]
242 pub fn add_remaining_accounts(
243 &mut self,
244 accounts: &[(
245 &'b solana_program::account_info::AccountInfo<'a>,
246 bool,
247 bool,
248 )],
249 ) -> &mut Self {
250 self.instruction
251 .__remaining_accounts
252 .extend_from_slice(accounts);
253 self
254 }
255 #[inline(always)]
256 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
257 self.invoke_signed(&[])
258 }
259 #[allow(clippy::clone_on_copy)]
260 #[allow(clippy::vec_init_then_push)]
261 pub fn invoke_signed(
262 &self,
263 signers_seeds: &[&[&[u8]]],
264 ) -> solana_program::entrypoint::ProgramResult {
265 let instruction = UpgradeNonceAccountCpi {
266 __program: self.instruction.__program,
267
268 nonce_account: self
269 .instruction
270 .nonce_account
271 .expect("nonce_account is not set"),
272 };
273 instruction.invoke_signed_with_remaining_accounts(
274 signers_seeds,
275 &self.instruction.__remaining_accounts,
276 )
277 }
278}
279
280struct UpgradeNonceAccountCpiBuilderInstruction<'a, 'b> {
281 __program: &'b solana_program::account_info::AccountInfo<'a>,
282 nonce_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
283 __remaining_accounts: Vec<(
285 &'b solana_program::account_info::AccountInfo<'a>,
286 bool,
287 bool,
288 )>,
289}