mpl_token_metadata/generated/instructions/
revoke_collection_authority.rs1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11pub struct RevokeCollectionAuthority {
13 pub collection_authority_record: solana_program::pubkey::Pubkey,
15 pub delegate_authority: solana_program::pubkey::Pubkey,
17 pub revoke_authority: solana_program::pubkey::Pubkey,
19 pub metadata: solana_program::pubkey::Pubkey,
21 pub mint: solana_program::pubkey::Pubkey,
23}
24
25impl RevokeCollectionAuthority {
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(5 + remaining_accounts.len());
35 accounts.push(solana_program::instruction::AccountMeta::new(
36 self.collection_authority_record,
37 false,
38 ));
39 accounts.push(solana_program::instruction::AccountMeta::new(
40 self.delegate_authority,
41 false,
42 ));
43 accounts.push(solana_program::instruction::AccountMeta::new(
44 self.revoke_authority,
45 true,
46 ));
47 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
48 self.metadata,
49 false,
50 ));
51 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
52 self.mint, false,
53 ));
54 accounts.extend_from_slice(remaining_accounts);
55 let data = RevokeCollectionAuthorityInstructionData::new()
56 .try_to_vec()
57 .unwrap();
58
59 solana_program::instruction::Instruction {
60 program_id: crate::MPL_TOKEN_METADATA_ID,
61 accounts,
62 data,
63 }
64 }
65}
66
67#[derive(BorshDeserialize, BorshSerialize)]
68struct RevokeCollectionAuthorityInstructionData {
69 discriminator: u8,
70}
71
72impl RevokeCollectionAuthorityInstructionData {
73 fn new() -> Self {
74 Self { discriminator: 24 }
75 }
76}
77
78#[derive(Default)]
88pub struct RevokeCollectionAuthorityBuilder {
89 collection_authority_record: Option<solana_program::pubkey::Pubkey>,
90 delegate_authority: Option<solana_program::pubkey::Pubkey>,
91 revoke_authority: Option<solana_program::pubkey::Pubkey>,
92 metadata: Option<solana_program::pubkey::Pubkey>,
93 mint: Option<solana_program::pubkey::Pubkey>,
94 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
95}
96
97impl RevokeCollectionAuthorityBuilder {
98 pub fn new() -> Self {
99 Self::default()
100 }
101 #[inline(always)]
103 pub fn collection_authority_record(
104 &mut self,
105 collection_authority_record: solana_program::pubkey::Pubkey,
106 ) -> &mut Self {
107 self.collection_authority_record = Some(collection_authority_record);
108 self
109 }
110 #[inline(always)]
112 pub fn delegate_authority(
113 &mut self,
114 delegate_authority: solana_program::pubkey::Pubkey,
115 ) -> &mut Self {
116 self.delegate_authority = Some(delegate_authority);
117 self
118 }
119 #[inline(always)]
121 pub fn revoke_authority(
122 &mut self,
123 revoke_authority: solana_program::pubkey::Pubkey,
124 ) -> &mut Self {
125 self.revoke_authority = Some(revoke_authority);
126 self
127 }
128 #[inline(always)]
130 pub fn metadata(&mut self, metadata: solana_program::pubkey::Pubkey) -> &mut Self {
131 self.metadata = Some(metadata);
132 self
133 }
134 #[inline(always)]
136 pub fn mint(&mut self, mint: solana_program::pubkey::Pubkey) -> &mut Self {
137 self.mint = Some(mint);
138 self
139 }
140 #[inline(always)]
142 pub fn add_remaining_account(
143 &mut self,
144 account: solana_program::instruction::AccountMeta,
145 ) -> &mut Self {
146 self.__remaining_accounts.push(account);
147 self
148 }
149 #[inline(always)]
151 pub fn add_remaining_accounts(
152 &mut self,
153 accounts: &[solana_program::instruction::AccountMeta],
154 ) -> &mut Self {
155 self.__remaining_accounts.extend_from_slice(accounts);
156 self
157 }
158 #[allow(clippy::clone_on_copy)]
159 pub fn instruction(&self) -> solana_program::instruction::Instruction {
160 let accounts = RevokeCollectionAuthority {
161 collection_authority_record: self
162 .collection_authority_record
163 .expect("collection_authority_record is not set"),
164 delegate_authority: self
165 .delegate_authority
166 .expect("delegate_authority is not set"),
167 revoke_authority: self.revoke_authority.expect("revoke_authority is not set"),
168 metadata: self.metadata.expect("metadata is not set"),
169 mint: self.mint.expect("mint is not set"),
170 };
171
172 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
173 }
174}
175
176pub struct RevokeCollectionAuthorityCpiAccounts<'a, 'b> {
178 pub collection_authority_record: &'b solana_program::account_info::AccountInfo<'a>,
180 pub delegate_authority: &'b solana_program::account_info::AccountInfo<'a>,
182 pub revoke_authority: &'b solana_program::account_info::AccountInfo<'a>,
184 pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
186 pub mint: &'b solana_program::account_info::AccountInfo<'a>,
188}
189
190pub struct RevokeCollectionAuthorityCpi<'a, 'b> {
192 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
194 pub collection_authority_record: &'b solana_program::account_info::AccountInfo<'a>,
196 pub delegate_authority: &'b solana_program::account_info::AccountInfo<'a>,
198 pub revoke_authority: &'b solana_program::account_info::AccountInfo<'a>,
200 pub metadata: &'b solana_program::account_info::AccountInfo<'a>,
202 pub mint: &'b solana_program::account_info::AccountInfo<'a>,
204}
205
206impl<'a, 'b> RevokeCollectionAuthorityCpi<'a, 'b> {
207 pub fn new(
208 program: &'b solana_program::account_info::AccountInfo<'a>,
209 accounts: RevokeCollectionAuthorityCpiAccounts<'a, 'b>,
210 ) -> Self {
211 Self {
212 __program: program,
213 collection_authority_record: accounts.collection_authority_record,
214 delegate_authority: accounts.delegate_authority,
215 revoke_authority: accounts.revoke_authority,
216 metadata: accounts.metadata,
217 mint: accounts.mint,
218 }
219 }
220 #[inline(always)]
221 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
222 self.invoke_signed_with_remaining_accounts(&[], &[])
223 }
224 #[inline(always)]
225 pub fn invoke_with_remaining_accounts(
226 &self,
227 remaining_accounts: &[(
228 &'b solana_program::account_info::AccountInfo<'a>,
229 bool,
230 bool,
231 )],
232 ) -> solana_program::entrypoint::ProgramResult {
233 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
234 }
235 #[inline(always)]
236 pub fn invoke_signed(
237 &self,
238 signers_seeds: &[&[&[u8]]],
239 ) -> solana_program::entrypoint::ProgramResult {
240 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
241 }
242 #[allow(clippy::clone_on_copy)]
243 #[allow(clippy::vec_init_then_push)]
244 pub fn invoke_signed_with_remaining_accounts(
245 &self,
246 signers_seeds: &[&[&[u8]]],
247 remaining_accounts: &[(
248 &'b solana_program::account_info::AccountInfo<'a>,
249 bool,
250 bool,
251 )],
252 ) -> solana_program::entrypoint::ProgramResult {
253 let mut accounts = Vec::with_capacity(5 + remaining_accounts.len());
254 accounts.push(solana_program::instruction::AccountMeta::new(
255 *self.collection_authority_record.key,
256 false,
257 ));
258 accounts.push(solana_program::instruction::AccountMeta::new(
259 *self.delegate_authority.key,
260 false,
261 ));
262 accounts.push(solana_program::instruction::AccountMeta::new(
263 *self.revoke_authority.key,
264 true,
265 ));
266 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
267 *self.metadata.key,
268 false,
269 ));
270 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
271 *self.mint.key,
272 false,
273 ));
274 remaining_accounts.iter().for_each(|remaining_account| {
275 accounts.push(solana_program::instruction::AccountMeta {
276 pubkey: *remaining_account.0.key,
277 is_signer: remaining_account.1,
278 is_writable: remaining_account.2,
279 })
280 });
281 let data = RevokeCollectionAuthorityInstructionData::new()
282 .try_to_vec()
283 .unwrap();
284
285 let instruction = solana_program::instruction::Instruction {
286 program_id: crate::MPL_TOKEN_METADATA_ID,
287 accounts,
288 data,
289 };
290 let mut account_infos = Vec::with_capacity(5 + 1 + remaining_accounts.len());
291 account_infos.push(self.__program.clone());
292 account_infos.push(self.collection_authority_record.clone());
293 account_infos.push(self.delegate_authority.clone());
294 account_infos.push(self.revoke_authority.clone());
295 account_infos.push(self.metadata.clone());
296 account_infos.push(self.mint.clone());
297 remaining_accounts
298 .iter()
299 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
300
301 if signers_seeds.is_empty() {
302 solana_program::program::invoke(&instruction, &account_infos)
303 } else {
304 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
305 }
306 }
307}
308
309pub struct RevokeCollectionAuthorityCpiBuilder<'a, 'b> {
319 instruction: Box<RevokeCollectionAuthorityCpiBuilderInstruction<'a, 'b>>,
320}
321
322impl<'a, 'b> RevokeCollectionAuthorityCpiBuilder<'a, 'b> {
323 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
324 let instruction = Box::new(RevokeCollectionAuthorityCpiBuilderInstruction {
325 __program: program,
326 collection_authority_record: None,
327 delegate_authority: None,
328 revoke_authority: None,
329 metadata: None,
330 mint: None,
331 __remaining_accounts: Vec::new(),
332 });
333 Self { instruction }
334 }
335 #[inline(always)]
337 pub fn collection_authority_record(
338 &mut self,
339 collection_authority_record: &'b solana_program::account_info::AccountInfo<'a>,
340 ) -> &mut Self {
341 self.instruction.collection_authority_record = Some(collection_authority_record);
342 self
343 }
344 #[inline(always)]
346 pub fn delegate_authority(
347 &mut self,
348 delegate_authority: &'b solana_program::account_info::AccountInfo<'a>,
349 ) -> &mut Self {
350 self.instruction.delegate_authority = Some(delegate_authority);
351 self
352 }
353 #[inline(always)]
355 pub fn revoke_authority(
356 &mut self,
357 revoke_authority: &'b solana_program::account_info::AccountInfo<'a>,
358 ) -> &mut Self {
359 self.instruction.revoke_authority = Some(revoke_authority);
360 self
361 }
362 #[inline(always)]
364 pub fn metadata(
365 &mut self,
366 metadata: &'b solana_program::account_info::AccountInfo<'a>,
367 ) -> &mut Self {
368 self.instruction.metadata = Some(metadata);
369 self
370 }
371 #[inline(always)]
373 pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
374 self.instruction.mint = Some(mint);
375 self
376 }
377 #[inline(always)]
379 pub fn add_remaining_account(
380 &mut self,
381 account: &'b solana_program::account_info::AccountInfo<'a>,
382 is_writable: bool,
383 is_signer: bool,
384 ) -> &mut Self {
385 self.instruction
386 .__remaining_accounts
387 .push((account, is_writable, is_signer));
388 self
389 }
390 #[inline(always)]
395 pub fn add_remaining_accounts(
396 &mut self,
397 accounts: &[(
398 &'b solana_program::account_info::AccountInfo<'a>,
399 bool,
400 bool,
401 )],
402 ) -> &mut Self {
403 self.instruction
404 .__remaining_accounts
405 .extend_from_slice(accounts);
406 self
407 }
408 #[inline(always)]
409 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
410 self.invoke_signed(&[])
411 }
412 #[allow(clippy::clone_on_copy)]
413 #[allow(clippy::vec_init_then_push)]
414 pub fn invoke_signed(
415 &self,
416 signers_seeds: &[&[&[u8]]],
417 ) -> solana_program::entrypoint::ProgramResult {
418 let instruction = RevokeCollectionAuthorityCpi {
419 __program: self.instruction.__program,
420
421 collection_authority_record: self
422 .instruction
423 .collection_authority_record
424 .expect("collection_authority_record is not set"),
425
426 delegate_authority: self
427 .instruction
428 .delegate_authority
429 .expect("delegate_authority is not set"),
430
431 revoke_authority: self
432 .instruction
433 .revoke_authority
434 .expect("revoke_authority is not set"),
435
436 metadata: self.instruction.metadata.expect("metadata is not set"),
437
438 mint: self.instruction.mint.expect("mint is not set"),
439 };
440 instruction.invoke_signed_with_remaining_accounts(
441 signers_seeds,
442 &self.instruction.__remaining_accounts,
443 )
444 }
445}
446
447struct RevokeCollectionAuthorityCpiBuilderInstruction<'a, 'b> {
448 __program: &'b solana_program::account_info::AccountInfo<'a>,
449 collection_authority_record: Option<&'b solana_program::account_info::AccountInfo<'a>>,
450 delegate_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
451 revoke_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
452 metadata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
453 mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
454 __remaining_accounts: Vec<(
456 &'b solana_program::account_info::AccountInfo<'a>,
457 bool,
458 bool,
459 )>,
460}