1#[cfg(feature = "anchor")]
9use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
10#[cfg(not(feature = "anchor"))]
11use borsh::{BorshDeserialize, BorshSerialize};
12
13pub struct UpdateGroupV1 {
15 pub group: solana_program::pubkey::Pubkey,
17 pub payer: solana_program::pubkey::Pubkey,
19 pub authority: Option<solana_program::pubkey::Pubkey>,
21 pub new_update_authority: Option<solana_program::pubkey::Pubkey>,
23 pub system_program: solana_program::pubkey::Pubkey,
25}
26
27impl UpdateGroupV1 {
28 pub fn instruction(
29 &self,
30 args: UpdateGroupV1InstructionArgs,
31 ) -> solana_program::instruction::Instruction {
32 self.instruction_with_remaining_accounts(args, &[])
33 }
34 #[allow(clippy::vec_init_then_push)]
35 pub fn instruction_with_remaining_accounts(
36 &self,
37 args: UpdateGroupV1InstructionArgs,
38 remaining_accounts: &[solana_program::instruction::AccountMeta],
39 ) -> solana_program::instruction::Instruction {
40 let mut accounts = Vec::with_capacity(5 + remaining_accounts.len());
41 accounts.push(solana_program::instruction::AccountMeta::new(
42 self.group, false,
43 ));
44 accounts.push(solana_program::instruction::AccountMeta::new(
45 self.payer, true,
46 ));
47 if let Some(authority) = self.authority {
48 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
49 authority, true,
50 ));
51 } else {
52 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
53 crate::MPL_CORE_ID,
54 false,
55 ));
56 }
57 if let Some(new_update_authority) = self.new_update_authority {
58 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
59 new_update_authority,
60 false,
61 ));
62 } else {
63 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
64 crate::MPL_CORE_ID,
65 false,
66 ));
67 }
68 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
69 self.system_program,
70 false,
71 ));
72 accounts.extend_from_slice(remaining_accounts);
73 let mut data = borsh::to_vec(&(UpdateGroupV1InstructionData::new())).unwrap();
74 let mut args = borsh::to_vec(&args).unwrap();
75 data.append(&mut args);
76
77 solana_program::instruction::Instruction {
78 program_id: crate::MPL_CORE_ID,
79 accounts,
80 data,
81 }
82 }
83}
84
85#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
86#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
87pub struct UpdateGroupV1InstructionData {
88 discriminator: u8,
89}
90
91impl UpdateGroupV1InstructionData {
92 pub fn new() -> Self {
93 Self { discriminator: 41 }
94 }
95}
96
97#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
98#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
99#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
100#[derive(Clone, Debug, Eq, PartialEq)]
101pub struct UpdateGroupV1InstructionArgs {
102 pub new_name: Option<String>,
103 pub new_uri: Option<String>,
104}
105
106#[derive(Default)]
116pub struct UpdateGroupV1Builder {
117 group: Option<solana_program::pubkey::Pubkey>,
118 payer: Option<solana_program::pubkey::Pubkey>,
119 authority: Option<solana_program::pubkey::Pubkey>,
120 new_update_authority: Option<solana_program::pubkey::Pubkey>,
121 system_program: Option<solana_program::pubkey::Pubkey>,
122 new_name: Option<String>,
123 new_uri: Option<String>,
124 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
125}
126
127impl UpdateGroupV1Builder {
128 pub fn new() -> Self {
129 Self::default()
130 }
131 #[inline(always)]
133 pub fn group(&mut self, group: solana_program::pubkey::Pubkey) -> &mut Self {
134 self.group = Some(group);
135 self
136 }
137 #[inline(always)]
139 pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
140 self.payer = Some(payer);
141 self
142 }
143 #[inline(always)]
146 pub fn authority(&mut self, authority: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
147 self.authority = authority;
148 self
149 }
150 #[inline(always)]
153 pub fn new_update_authority(
154 &mut self,
155 new_update_authority: Option<solana_program::pubkey::Pubkey>,
156 ) -> &mut Self {
157 self.new_update_authority = new_update_authority;
158 self
159 }
160 #[inline(always)]
163 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
164 self.system_program = Some(system_program);
165 self
166 }
167 #[inline(always)]
169 pub fn new_name(&mut self, new_name: String) -> &mut Self {
170 self.new_name = Some(new_name);
171 self
172 }
173 #[inline(always)]
175 pub fn new_uri(&mut self, new_uri: String) -> &mut Self {
176 self.new_uri = Some(new_uri);
177 self
178 }
179 #[inline(always)]
181 pub fn add_remaining_account(
182 &mut self,
183 account: solana_program::instruction::AccountMeta,
184 ) -> &mut Self {
185 self.__remaining_accounts.push(account);
186 self
187 }
188 #[inline(always)]
190 pub fn add_remaining_accounts(
191 &mut self,
192 accounts: &[solana_program::instruction::AccountMeta],
193 ) -> &mut Self {
194 self.__remaining_accounts.extend_from_slice(accounts);
195 self
196 }
197 #[allow(clippy::clone_on_copy)]
198 pub fn instruction(&self) -> solana_program::instruction::Instruction {
199 let accounts = UpdateGroupV1 {
200 group: self.group.expect("group is not set"),
201 payer: self.payer.expect("payer is not set"),
202 authority: self.authority,
203 new_update_authority: self.new_update_authority,
204 system_program: self
205 .system_program
206 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
207 };
208 let args = UpdateGroupV1InstructionArgs {
209 new_name: self.new_name.clone(),
210 new_uri: self.new_uri.clone(),
211 };
212
213 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
214 }
215}
216
217pub struct UpdateGroupV1CpiAccounts<'a, 'b> {
219 pub group: &'b solana_program::account_info::AccountInfo<'a>,
221 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
223 pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
225 pub new_update_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
227 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
229}
230
231pub struct UpdateGroupV1Cpi<'a, 'b> {
233 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
235 pub group: &'b solana_program::account_info::AccountInfo<'a>,
237 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
239 pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
241 pub new_update_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
243 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
245 pub __args: UpdateGroupV1InstructionArgs,
247}
248
249impl<'a, 'b> UpdateGroupV1Cpi<'a, 'b> {
250 pub fn new(
251 program: &'b solana_program::account_info::AccountInfo<'a>,
252 accounts: UpdateGroupV1CpiAccounts<'a, 'b>,
253 args: UpdateGroupV1InstructionArgs,
254 ) -> Self {
255 Self {
256 __program: program,
257 group: accounts.group,
258 payer: accounts.payer,
259 authority: accounts.authority,
260 new_update_authority: accounts.new_update_authority,
261 system_program: accounts.system_program,
262 __args: args,
263 }
264 }
265 #[inline(always)]
266 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
267 self.invoke_signed_with_remaining_accounts(&[], &[])
268 }
269 #[inline(always)]
270 pub fn invoke_with_remaining_accounts(
271 &self,
272 remaining_accounts: &[(
273 &'b solana_program::account_info::AccountInfo<'a>,
274 bool,
275 bool,
276 )],
277 ) -> solana_program::entrypoint::ProgramResult {
278 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
279 }
280 #[inline(always)]
281 pub fn invoke_signed(
282 &self,
283 signers_seeds: &[&[&[u8]]],
284 ) -> solana_program::entrypoint::ProgramResult {
285 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
286 }
287 #[allow(clippy::clone_on_copy)]
288 #[allow(clippy::vec_init_then_push)]
289 pub fn invoke_signed_with_remaining_accounts(
290 &self,
291 signers_seeds: &[&[&[u8]]],
292 remaining_accounts: &[(
293 &'b solana_program::account_info::AccountInfo<'a>,
294 bool,
295 bool,
296 )],
297 ) -> solana_program::entrypoint::ProgramResult {
298 let mut accounts = Vec::with_capacity(5 + remaining_accounts.len());
299 accounts.push(solana_program::instruction::AccountMeta::new(
300 *self.group.key,
301 false,
302 ));
303 accounts.push(solana_program::instruction::AccountMeta::new(
304 *self.payer.key,
305 true,
306 ));
307 if let Some(authority) = self.authority {
308 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
309 *authority.key,
310 true,
311 ));
312 } else {
313 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
314 crate::MPL_CORE_ID,
315 false,
316 ));
317 }
318 if let Some(new_update_authority) = self.new_update_authority {
319 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
320 *new_update_authority.key,
321 false,
322 ));
323 } else {
324 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
325 crate::MPL_CORE_ID,
326 false,
327 ));
328 }
329 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
330 *self.system_program.key,
331 false,
332 ));
333 remaining_accounts.iter().for_each(|remaining_account| {
334 accounts.push(solana_program::instruction::AccountMeta {
335 pubkey: *remaining_account.0.key,
336 is_writable: remaining_account.1,
337 is_signer: remaining_account.2,
338 })
339 });
340 let mut data = borsh::to_vec(&(UpdateGroupV1InstructionData::new())).unwrap();
341 let mut args = borsh::to_vec(&self.__args).unwrap();
342 data.append(&mut args);
343
344 let instruction = solana_program::instruction::Instruction {
345 program_id: crate::MPL_CORE_ID,
346 accounts,
347 data,
348 };
349 let mut account_infos = Vec::with_capacity(5 + 1 + remaining_accounts.len());
350 account_infos.push(self.__program.clone());
351 account_infos.push(self.group.clone());
352 account_infos.push(self.payer.clone());
353 if let Some(authority) = self.authority {
354 account_infos.push(authority.clone());
355 }
356 if let Some(new_update_authority) = self.new_update_authority {
357 account_infos.push(new_update_authority.clone());
358 }
359 account_infos.push(self.system_program.clone());
360 remaining_accounts
361 .iter()
362 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
363
364 if signers_seeds.is_empty() {
365 solana_program::program::invoke(&instruction, &account_infos)
366 } else {
367 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
368 }
369 }
370}
371
372pub struct UpdateGroupV1CpiBuilder<'a, 'b> {
382 instruction: Box<UpdateGroupV1CpiBuilderInstruction<'a, 'b>>,
383}
384
385impl<'a, 'b> UpdateGroupV1CpiBuilder<'a, 'b> {
386 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
387 let instruction = Box::new(UpdateGroupV1CpiBuilderInstruction {
388 __program: program,
389 group: None,
390 payer: None,
391 authority: None,
392 new_update_authority: None,
393 system_program: None,
394 new_name: None,
395 new_uri: None,
396 __remaining_accounts: Vec::new(),
397 });
398 Self { instruction }
399 }
400 #[inline(always)]
402 pub fn group(&mut self, group: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
403 self.instruction.group = Some(group);
404 self
405 }
406 #[inline(always)]
408 pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
409 self.instruction.payer = Some(payer);
410 self
411 }
412 #[inline(always)]
415 pub fn authority(
416 &mut self,
417 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
418 ) -> &mut Self {
419 self.instruction.authority = authority;
420 self
421 }
422 #[inline(always)]
425 pub fn new_update_authority(
426 &mut self,
427 new_update_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
428 ) -> &mut Self {
429 self.instruction.new_update_authority = new_update_authority;
430 self
431 }
432 #[inline(always)]
434 pub fn system_program(
435 &mut self,
436 system_program: &'b solana_program::account_info::AccountInfo<'a>,
437 ) -> &mut Self {
438 self.instruction.system_program = Some(system_program);
439 self
440 }
441 #[inline(always)]
443 pub fn new_name(&mut self, new_name: String) -> &mut Self {
444 self.instruction.new_name = Some(new_name);
445 self
446 }
447 #[inline(always)]
449 pub fn new_uri(&mut self, new_uri: String) -> &mut Self {
450 self.instruction.new_uri = Some(new_uri);
451 self
452 }
453 #[inline(always)]
455 pub fn add_remaining_account(
456 &mut self,
457 account: &'b solana_program::account_info::AccountInfo<'a>,
458 is_writable: bool,
459 is_signer: bool,
460 ) -> &mut Self {
461 self.instruction
462 .__remaining_accounts
463 .push((account, is_writable, is_signer));
464 self
465 }
466 #[inline(always)]
471 pub fn add_remaining_accounts(
472 &mut self,
473 accounts: &[(
474 &'b solana_program::account_info::AccountInfo<'a>,
475 bool,
476 bool,
477 )],
478 ) -> &mut Self {
479 self.instruction
480 .__remaining_accounts
481 .extend_from_slice(accounts);
482 self
483 }
484 #[inline(always)]
485 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
486 self.invoke_signed(&[])
487 }
488 #[allow(clippy::clone_on_copy)]
489 #[allow(clippy::vec_init_then_push)]
490 pub fn invoke_signed(
491 &self,
492 signers_seeds: &[&[&[u8]]],
493 ) -> solana_program::entrypoint::ProgramResult {
494 let args = UpdateGroupV1InstructionArgs {
495 new_name: self.instruction.new_name.clone(),
496 new_uri: self.instruction.new_uri.clone(),
497 };
498 let instruction = UpdateGroupV1Cpi {
499 __program: self.instruction.__program,
500
501 group: self.instruction.group.expect("group is not set"),
502
503 payer: self.instruction.payer.expect("payer is not set"),
504
505 authority: self.instruction.authority,
506
507 new_update_authority: self.instruction.new_update_authority,
508
509 system_program: self
510 .instruction
511 .system_program
512 .expect("system_program is not set"),
513 __args: args,
514 };
515 instruction.invoke_signed_with_remaining_accounts(
516 signers_seeds,
517 &self.instruction.__remaining_accounts,
518 )
519 }
520}
521
522struct UpdateGroupV1CpiBuilderInstruction<'a, 'b> {
523 __program: &'b solana_program::account_info::AccountInfo<'a>,
524 group: Option<&'b solana_program::account_info::AccountInfo<'a>>,
525 payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
526 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
527 new_update_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
528 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
529 new_name: Option<String>,
530 new_uri: Option<String>,
531 __remaining_accounts: Vec<(
533 &'b solana_program::account_info::AccountInfo<'a>,
534 bool,
535 bool,
536 )>,
537}