mpl_agent_tools/generated/instructions/
register_executive_v1.rs1#[cfg(feature = "anchor")]
9use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
10#[cfg(not(feature = "anchor"))]
11use borsh::{BorshDeserialize, BorshSerialize};
12
13pub struct RegisterExecutiveV1 {
15 pub executive_profile: solana_program::pubkey::Pubkey,
17 pub payer: solana_program::pubkey::Pubkey,
19 pub authority: Option<solana_program::pubkey::Pubkey>,
21 pub system_program: solana_program::pubkey::Pubkey,
23}
24
25impl RegisterExecutiveV1 {
26 pub fn instruction(&self) -> solana_program::instruction::Instruction {
27 self.instruction_with_remaining_accounts(&[])
28 }
29 #[allow(clippy::vec_init_then_push)]
30 pub fn instruction_with_remaining_accounts(
31 &self,
32 remaining_accounts: &[solana_program::instruction::AccountMeta],
33 ) -> solana_program::instruction::Instruction {
34 let mut accounts = Vec::with_capacity(4 + remaining_accounts.len());
35 accounts.push(solana_program::instruction::AccountMeta::new(
36 self.executive_profile,
37 false,
38 ));
39 accounts.push(solana_program::instruction::AccountMeta::new(
40 self.payer, true,
41 ));
42 if let Some(authority) = self.authority {
43 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
44 authority, true,
45 ));
46 } else {
47 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
48 crate::MPL_AGENT_TOOLS_ID,
49 false,
50 ));
51 }
52 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
53 self.system_program,
54 false,
55 ));
56 accounts.extend_from_slice(remaining_accounts);
57 let data = borsh::to_vec(&(RegisterExecutiveV1InstructionData::new())).unwrap();
58
59 solana_program::instruction::Instruction {
60 program_id: crate::MPL_AGENT_TOOLS_ID,
61 accounts,
62 data,
63 }
64 }
65}
66
67#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
68#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
69pub struct RegisterExecutiveV1InstructionData {
70 discriminator: u8,
71 padding: [u8; 7],
72}
73
74impl RegisterExecutiveV1InstructionData {
75 pub fn new() -> Self {
76 Self {
77 discriminator: 0,
78 padding: [0, 0, 0, 0, 0, 0, 0],
79 }
80 }
81}
82
83#[derive(Default)]
92pub struct RegisterExecutiveV1Builder {
93 executive_profile: Option<solana_program::pubkey::Pubkey>,
94 payer: Option<solana_program::pubkey::Pubkey>,
95 authority: Option<solana_program::pubkey::Pubkey>,
96 system_program: Option<solana_program::pubkey::Pubkey>,
97 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
98}
99
100impl RegisterExecutiveV1Builder {
101 pub fn new() -> Self {
102 Self::default()
103 }
104 #[inline(always)]
106 pub fn executive_profile(
107 &mut self,
108 executive_profile: solana_program::pubkey::Pubkey,
109 ) -> &mut Self {
110 self.executive_profile = Some(executive_profile);
111 self
112 }
113 #[inline(always)]
115 pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
116 self.payer = Some(payer);
117 self
118 }
119 #[inline(always)]
122 pub fn authority(&mut self, authority: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
123 self.authority = authority;
124 self
125 }
126 #[inline(always)]
129 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
130 self.system_program = Some(system_program);
131 self
132 }
133 #[inline(always)]
135 pub fn add_remaining_account(
136 &mut self,
137 account: solana_program::instruction::AccountMeta,
138 ) -> &mut Self {
139 self.__remaining_accounts.push(account);
140 self
141 }
142 #[inline(always)]
144 pub fn add_remaining_accounts(
145 &mut self,
146 accounts: &[solana_program::instruction::AccountMeta],
147 ) -> &mut Self {
148 self.__remaining_accounts.extend_from_slice(accounts);
149 self
150 }
151 #[allow(clippy::clone_on_copy)]
152 pub fn instruction(&self) -> solana_program::instruction::Instruction {
153 let accounts = RegisterExecutiveV1 {
154 executive_profile: self
155 .executive_profile
156 .expect("executive_profile is not set"),
157 payer: self.payer.expect("payer is not set"),
158 authority: self.authority,
159 system_program: self
160 .system_program
161 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
162 };
163
164 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
165 }
166}
167
168pub struct RegisterExecutiveV1CpiAccounts<'a, 'b> {
170 pub executive_profile: &'b solana_program::account_info::AccountInfo<'a>,
172 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
174 pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
176 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
178}
179
180pub struct RegisterExecutiveV1Cpi<'a, 'b> {
182 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
184 pub executive_profile: &'b solana_program::account_info::AccountInfo<'a>,
186 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
188 pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
190 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
192}
193
194impl<'a, 'b> RegisterExecutiveV1Cpi<'a, 'b> {
195 pub fn new(
196 program: &'b solana_program::account_info::AccountInfo<'a>,
197 accounts: RegisterExecutiveV1CpiAccounts<'a, 'b>,
198 ) -> Self {
199 Self {
200 __program: program,
201 executive_profile: accounts.executive_profile,
202 payer: accounts.payer,
203 authority: accounts.authority,
204 system_program: accounts.system_program,
205 }
206 }
207 #[inline(always)]
208 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
209 self.invoke_signed_with_remaining_accounts(&[], &[])
210 }
211 #[inline(always)]
212 pub fn invoke_with_remaining_accounts(
213 &self,
214 remaining_accounts: &[(
215 &'b solana_program::account_info::AccountInfo<'a>,
216 bool,
217 bool,
218 )],
219 ) -> solana_program::entrypoint::ProgramResult {
220 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
221 }
222 #[inline(always)]
223 pub fn invoke_signed(
224 &self,
225 signers_seeds: &[&[&[u8]]],
226 ) -> solana_program::entrypoint::ProgramResult {
227 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
228 }
229 #[allow(clippy::clone_on_copy)]
230 #[allow(clippy::vec_init_then_push)]
231 pub fn invoke_signed_with_remaining_accounts(
232 &self,
233 signers_seeds: &[&[&[u8]]],
234 remaining_accounts: &[(
235 &'b solana_program::account_info::AccountInfo<'a>,
236 bool,
237 bool,
238 )],
239 ) -> solana_program::entrypoint::ProgramResult {
240 let mut accounts = Vec::with_capacity(4 + remaining_accounts.len());
241 accounts.push(solana_program::instruction::AccountMeta::new(
242 *self.executive_profile.key,
243 false,
244 ));
245 accounts.push(solana_program::instruction::AccountMeta::new(
246 *self.payer.key,
247 true,
248 ));
249 if let Some(authority) = self.authority {
250 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
251 *authority.key,
252 true,
253 ));
254 } else {
255 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
256 crate::MPL_AGENT_TOOLS_ID,
257 false,
258 ));
259 }
260 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
261 *self.system_program.key,
262 false,
263 ));
264 remaining_accounts.iter().for_each(|remaining_account| {
265 accounts.push(solana_program::instruction::AccountMeta {
266 pubkey: *remaining_account.0.key,
267 is_writable: remaining_account.1,
268 is_signer: remaining_account.2,
269 })
270 });
271 let data = borsh::to_vec(&(RegisterExecutiveV1InstructionData::new())).unwrap();
272
273 let instruction = solana_program::instruction::Instruction {
274 program_id: crate::MPL_AGENT_TOOLS_ID,
275 accounts,
276 data,
277 };
278 let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len());
279 account_infos.push(self.__program.clone());
280 account_infos.push(self.executive_profile.clone());
281 account_infos.push(self.payer.clone());
282 if let Some(authority) = self.authority {
283 account_infos.push(authority.clone());
284 }
285 account_infos.push(self.system_program.clone());
286 remaining_accounts
287 .iter()
288 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
289
290 if signers_seeds.is_empty() {
291 solana_program::program::invoke(&instruction, &account_infos)
292 } else {
293 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
294 }
295 }
296}
297
298pub struct RegisterExecutiveV1CpiBuilder<'a, 'b> {
307 instruction: Box<RegisterExecutiveV1CpiBuilderInstruction<'a, 'b>>,
308}
309
310impl<'a, 'b> RegisterExecutiveV1CpiBuilder<'a, 'b> {
311 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
312 let instruction = Box::new(RegisterExecutiveV1CpiBuilderInstruction {
313 __program: program,
314 executive_profile: None,
315 payer: None,
316 authority: None,
317 system_program: None,
318 __remaining_accounts: Vec::new(),
319 });
320 Self { instruction }
321 }
322 #[inline(always)]
324 pub fn executive_profile(
325 &mut self,
326 executive_profile: &'b solana_program::account_info::AccountInfo<'a>,
327 ) -> &mut Self {
328 self.instruction.executive_profile = Some(executive_profile);
329 self
330 }
331 #[inline(always)]
333 pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
334 self.instruction.payer = Some(payer);
335 self
336 }
337 #[inline(always)]
340 pub fn authority(
341 &mut self,
342 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
343 ) -> &mut Self {
344 self.instruction.authority = authority;
345 self
346 }
347 #[inline(always)]
349 pub fn system_program(
350 &mut self,
351 system_program: &'b solana_program::account_info::AccountInfo<'a>,
352 ) -> &mut Self {
353 self.instruction.system_program = Some(system_program);
354 self
355 }
356 #[inline(always)]
358 pub fn add_remaining_account(
359 &mut self,
360 account: &'b solana_program::account_info::AccountInfo<'a>,
361 is_writable: bool,
362 is_signer: bool,
363 ) -> &mut Self {
364 self.instruction
365 .__remaining_accounts
366 .push((account, is_writable, is_signer));
367 self
368 }
369 #[inline(always)]
374 pub fn add_remaining_accounts(
375 &mut self,
376 accounts: &[(
377 &'b solana_program::account_info::AccountInfo<'a>,
378 bool,
379 bool,
380 )],
381 ) -> &mut Self {
382 self.instruction
383 .__remaining_accounts
384 .extend_from_slice(accounts);
385 self
386 }
387 #[inline(always)]
388 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
389 self.invoke_signed(&[])
390 }
391 #[allow(clippy::clone_on_copy)]
392 #[allow(clippy::vec_init_then_push)]
393 pub fn invoke_signed(
394 &self,
395 signers_seeds: &[&[&[u8]]],
396 ) -> solana_program::entrypoint::ProgramResult {
397 let instruction = RegisterExecutiveV1Cpi {
398 __program: self.instruction.__program,
399
400 executive_profile: self
401 .instruction
402 .executive_profile
403 .expect("executive_profile is not set"),
404
405 payer: self.instruction.payer.expect("payer is not set"),
406
407 authority: self.instruction.authority,
408
409 system_program: self
410 .instruction
411 .system_program
412 .expect("system_program is not set"),
413 };
414 instruction.invoke_signed_with_remaining_accounts(
415 signers_seeds,
416 &self.instruction.__remaining_accounts,
417 )
418 }
419}
420
421struct RegisterExecutiveV1CpiBuilderInstruction<'a, 'b> {
422 __program: &'b solana_program::account_info::AccountInfo<'a>,
423 executive_profile: Option<&'b solana_program::account_info::AccountInfo<'a>>,
424 payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
425 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
426 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
427 __remaining_accounts: Vec<(
429 &'b solana_program::account_info::AccountInfo<'a>,
430 bool,
431 bool,
432 )>,
433}