1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10use solana_program::pubkey::Pubkey;
11
12#[derive(Debug)]
14pub struct RemoveEntry {
15 pub whitelist_account: solana_program::pubkey::Pubkey,
17 pub whitelist_authority: solana_program::pubkey::Pubkey,
19 pub whitelist_entry_account: solana_program::pubkey::Pubkey,
21 pub destination_account: solana_program::pubkey::Pubkey,
23 pub system_program: solana_program::pubkey::Pubkey,
25}
26
27impl RemoveEntry {
28 pub fn instruction(
29 &self,
30 args: RemoveEntryInstructionArgs,
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: RemoveEntryInstructionArgs,
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_readonly(
42 self.whitelist_account,
43 false,
44 ));
45 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
46 self.whitelist_authority,
47 true,
48 ));
49 accounts.push(solana_program::instruction::AccountMeta::new(
50 self.whitelist_entry_account,
51 false,
52 ));
53 accounts.push(solana_program::instruction::AccountMeta::new(
54 self.destination_account,
55 false,
56 ));
57 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
58 self.system_program,
59 false,
60 ));
61 accounts.extend_from_slice(remaining_accounts);
62 let mut data = borsh::to_vec(&RemoveEntryInstructionData::new()).unwrap();
63 let mut args = borsh::to_vec(&args).unwrap();
64 data.append(&mut args);
65
66 solana_program::instruction::Instruction {
67 program_id: crate::RELEASE_TEST_PROGRAM_ID,
68 accounts,
69 data,
70 }
71 }
72}
73
74#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
75#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
76pub struct RemoveEntryInstructionData {
77 discriminator: u8,
78}
79
80impl RemoveEntryInstructionData {
81 pub fn new() -> Self {
82 Self { discriminator: 5 }
83 }
84}
85
86impl Default for RemoveEntryInstructionData {
87 fn default() -> Self {
88 Self::new()
89 }
90}
91
92#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
93#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
94pub struct RemoveEntryInstructionArgs {
95 pub program_authority: Pubkey,
96}
97
98#[derive(Clone, Debug, Default)]
108pub struct RemoveEntryBuilder {
109 whitelist_account: Option<solana_program::pubkey::Pubkey>,
110 whitelist_authority: Option<solana_program::pubkey::Pubkey>,
111 whitelist_entry_account: Option<solana_program::pubkey::Pubkey>,
112 destination_account: Option<solana_program::pubkey::Pubkey>,
113 system_program: Option<solana_program::pubkey::Pubkey>,
114 program_authority: Option<Pubkey>,
115 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
116}
117
118impl RemoveEntryBuilder {
119 pub fn new() -> Self {
120 Self::default()
121 }
122 #[inline(always)]
124 pub fn whitelist_account(
125 &mut self,
126 whitelist_account: solana_program::pubkey::Pubkey,
127 ) -> &mut Self {
128 self.whitelist_account = Some(whitelist_account);
129 self
130 }
131 #[inline(always)]
133 pub fn whitelist_authority(
134 &mut self,
135 whitelist_authority: solana_program::pubkey::Pubkey,
136 ) -> &mut Self {
137 self.whitelist_authority = Some(whitelist_authority);
138 self
139 }
140 #[inline(always)]
142 pub fn whitelist_entry_account(
143 &mut self,
144 whitelist_entry_account: solana_program::pubkey::Pubkey,
145 ) -> &mut Self {
146 self.whitelist_entry_account = Some(whitelist_entry_account);
147 self
148 }
149 #[inline(always)]
151 pub fn destination_account(
152 &mut self,
153 destination_account: solana_program::pubkey::Pubkey,
154 ) -> &mut Self {
155 self.destination_account = Some(destination_account);
156 self
157 }
158 #[inline(always)]
161 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
162 self.system_program = Some(system_program);
163 self
164 }
165 #[inline(always)]
166 pub fn program_authority(&mut self, program_authority: Pubkey) -> &mut Self {
167 self.program_authority = Some(program_authority);
168 self
169 }
170 #[inline(always)]
172 pub fn add_remaining_account(
173 &mut self,
174 account: solana_program::instruction::AccountMeta,
175 ) -> &mut Self {
176 self.__remaining_accounts.push(account);
177 self
178 }
179 #[inline(always)]
181 pub fn add_remaining_accounts(
182 &mut self,
183 accounts: &[solana_program::instruction::AccountMeta],
184 ) -> &mut Self {
185 self.__remaining_accounts.extend_from_slice(accounts);
186 self
187 }
188 #[allow(clippy::clone_on_copy)]
189 pub fn instruction(&self) -> solana_program::instruction::Instruction {
190 let accounts = RemoveEntry {
191 whitelist_account: self
192 .whitelist_account
193 .expect("whitelist_account is not set"),
194 whitelist_authority: self
195 .whitelist_authority
196 .expect("whitelist_authority is not set"),
197 whitelist_entry_account: self
198 .whitelist_entry_account
199 .expect("whitelist_entry_account is not set"),
200 destination_account: self
201 .destination_account
202 .expect("destination_account is not set"),
203 system_program: self
204 .system_program
205 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
206 };
207 let args = RemoveEntryInstructionArgs {
208 program_authority: self
209 .program_authority
210 .clone()
211 .expect("program_authority is not set"),
212 };
213
214 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
215 }
216}
217
218pub struct RemoveEntryCpiAccounts<'a, 'b> {
220 pub whitelist_account: &'b solana_program::account_info::AccountInfo<'a>,
222 pub whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>,
224 pub whitelist_entry_account: &'b solana_program::account_info::AccountInfo<'a>,
226 pub destination_account: &'b solana_program::account_info::AccountInfo<'a>,
228 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
230}
231
232pub struct RemoveEntryCpi<'a, 'b> {
234 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
236 pub whitelist_account: &'b solana_program::account_info::AccountInfo<'a>,
238 pub whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>,
240 pub whitelist_entry_account: &'b solana_program::account_info::AccountInfo<'a>,
242 pub destination_account: &'b solana_program::account_info::AccountInfo<'a>,
244 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
246 pub __args: RemoveEntryInstructionArgs,
248}
249
250impl<'a, 'b> RemoveEntryCpi<'a, 'b> {
251 pub fn new(
252 program: &'b solana_program::account_info::AccountInfo<'a>,
253 accounts: RemoveEntryCpiAccounts<'a, 'b>,
254 args: RemoveEntryInstructionArgs,
255 ) -> Self {
256 Self {
257 __program: program,
258 whitelist_account: accounts.whitelist_account,
259 whitelist_authority: accounts.whitelist_authority,
260 whitelist_entry_account: accounts.whitelist_entry_account,
261 destination_account: accounts.destination_account,
262 system_program: accounts.system_program,
263 __args: args,
264 }
265 }
266 #[inline(always)]
267 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
268 self.invoke_signed_with_remaining_accounts(&[], &[])
269 }
270 #[inline(always)]
271 pub fn invoke_with_remaining_accounts(
272 &self,
273 remaining_accounts: &[(
274 &'b solana_program::account_info::AccountInfo<'a>,
275 bool,
276 bool,
277 )],
278 ) -> solana_program::entrypoint::ProgramResult {
279 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
280 }
281 #[inline(always)]
282 pub fn invoke_signed(
283 &self,
284 signers_seeds: &[&[&[u8]]],
285 ) -> solana_program::entrypoint::ProgramResult {
286 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
287 }
288 #[allow(clippy::clone_on_copy)]
289 #[allow(clippy::vec_init_then_push)]
290 pub fn invoke_signed_with_remaining_accounts(
291 &self,
292 signers_seeds: &[&[&[u8]]],
293 remaining_accounts: &[(
294 &'b solana_program::account_info::AccountInfo<'a>,
295 bool,
296 bool,
297 )],
298 ) -> solana_program::entrypoint::ProgramResult {
299 let mut accounts = Vec::with_capacity(5 + remaining_accounts.len());
300 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
301 *self.whitelist_account.key,
302 false,
303 ));
304 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
305 *self.whitelist_authority.key,
306 true,
307 ));
308 accounts.push(solana_program::instruction::AccountMeta::new(
309 *self.whitelist_entry_account.key,
310 false,
311 ));
312 accounts.push(solana_program::instruction::AccountMeta::new(
313 *self.destination_account.key,
314 false,
315 ));
316 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
317 *self.system_program.key,
318 false,
319 ));
320 remaining_accounts.iter().for_each(|remaining_account| {
321 accounts.push(solana_program::instruction::AccountMeta {
322 pubkey: *remaining_account.0.key,
323 is_signer: remaining_account.1,
324 is_writable: remaining_account.2,
325 })
326 });
327 let mut data = borsh::to_vec(&RemoveEntryInstructionData::new()).unwrap();
328 let mut args = borsh::to_vec(&self.__args).unwrap();
329 data.append(&mut args);
330
331 let instruction = solana_program::instruction::Instruction {
332 program_id: crate::RELEASE_TEST_PROGRAM_ID,
333 accounts,
334 data,
335 };
336 let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len());
337 account_infos.push(self.__program.clone());
338 account_infos.push(self.whitelist_account.clone());
339 account_infos.push(self.whitelist_authority.clone());
340 account_infos.push(self.whitelist_entry_account.clone());
341 account_infos.push(self.destination_account.clone());
342 account_infos.push(self.system_program.clone());
343 remaining_accounts
344 .iter()
345 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
346
347 if signers_seeds.is_empty() {
348 solana_program::program::invoke(&instruction, &account_infos)
349 } else {
350 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
351 }
352 }
353}
354
355#[derive(Clone, Debug)]
365pub struct RemoveEntryCpiBuilder<'a, 'b> {
366 instruction: Box<RemoveEntryCpiBuilderInstruction<'a, 'b>>,
367}
368
369impl<'a, 'b> RemoveEntryCpiBuilder<'a, 'b> {
370 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
371 let instruction = Box::new(RemoveEntryCpiBuilderInstruction {
372 __program: program,
373 whitelist_account: None,
374 whitelist_authority: None,
375 whitelist_entry_account: None,
376 destination_account: None,
377 system_program: None,
378 program_authority: None,
379 __remaining_accounts: Vec::new(),
380 });
381 Self { instruction }
382 }
383 #[inline(always)]
385 pub fn whitelist_account(
386 &mut self,
387 whitelist_account: &'b solana_program::account_info::AccountInfo<'a>,
388 ) -> &mut Self {
389 self.instruction.whitelist_account = Some(whitelist_account);
390 self
391 }
392 #[inline(always)]
394 pub fn whitelist_authority(
395 &mut self,
396 whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>,
397 ) -> &mut Self {
398 self.instruction.whitelist_authority = Some(whitelist_authority);
399 self
400 }
401 #[inline(always)]
403 pub fn whitelist_entry_account(
404 &mut self,
405 whitelist_entry_account: &'b solana_program::account_info::AccountInfo<'a>,
406 ) -> &mut Self {
407 self.instruction.whitelist_entry_account = Some(whitelist_entry_account);
408 self
409 }
410 #[inline(always)]
412 pub fn destination_account(
413 &mut self,
414 destination_account: &'b solana_program::account_info::AccountInfo<'a>,
415 ) -> &mut Self {
416 self.instruction.destination_account = Some(destination_account);
417 self
418 }
419 #[inline(always)]
421 pub fn system_program(
422 &mut self,
423 system_program: &'b solana_program::account_info::AccountInfo<'a>,
424 ) -> &mut Self {
425 self.instruction.system_program = Some(system_program);
426 self
427 }
428 #[inline(always)]
429 pub fn program_authority(&mut self, program_authority: Pubkey) -> &mut Self {
430 self.instruction.program_authority = Some(program_authority);
431 self
432 }
433 #[inline(always)]
435 pub fn add_remaining_account(
436 &mut self,
437 account: &'b solana_program::account_info::AccountInfo<'a>,
438 is_writable: bool,
439 is_signer: bool,
440 ) -> &mut Self {
441 self.instruction
442 .__remaining_accounts
443 .push((account, is_writable, is_signer));
444 self
445 }
446 #[inline(always)]
451 pub fn add_remaining_accounts(
452 &mut self,
453 accounts: &[(
454 &'b solana_program::account_info::AccountInfo<'a>,
455 bool,
456 bool,
457 )],
458 ) -> &mut Self {
459 self.instruction
460 .__remaining_accounts
461 .extend_from_slice(accounts);
462 self
463 }
464 #[inline(always)]
465 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
466 self.invoke_signed(&[])
467 }
468 #[allow(clippy::clone_on_copy)]
469 #[allow(clippy::vec_init_then_push)]
470 pub fn invoke_signed(
471 &self,
472 signers_seeds: &[&[&[u8]]],
473 ) -> solana_program::entrypoint::ProgramResult {
474 let args = RemoveEntryInstructionArgs {
475 program_authority: self
476 .instruction
477 .program_authority
478 .clone()
479 .expect("program_authority is not set"),
480 };
481 let instruction = RemoveEntryCpi {
482 __program: self.instruction.__program,
483
484 whitelist_account: self
485 .instruction
486 .whitelist_account
487 .expect("whitelist_account is not set"),
488
489 whitelist_authority: self
490 .instruction
491 .whitelist_authority
492 .expect("whitelist_authority is not set"),
493
494 whitelist_entry_account: self
495 .instruction
496 .whitelist_entry_account
497 .expect("whitelist_entry_account is not set"),
498
499 destination_account: self
500 .instruction
501 .destination_account
502 .expect("destination_account is not set"),
503
504 system_program: self
505 .instruction
506 .system_program
507 .expect("system_program is not set"),
508 __args: args,
509 };
510 instruction.invoke_signed_with_remaining_accounts(
511 signers_seeds,
512 &self.instruction.__remaining_accounts,
513 )
514 }
515}
516
517#[derive(Clone, Debug)]
518struct RemoveEntryCpiBuilderInstruction<'a, 'b> {
519 __program: &'b solana_program::account_info::AccountInfo<'a>,
520 whitelist_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
521 whitelist_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
522 whitelist_entry_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
523 destination_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
524 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
525 program_authority: Option<Pubkey>,
526 __remaining_accounts: Vec<(
528 &'b solana_program::account_info::AccountInfo<'a>,
529 bool,
530 bool,
531 )>,
532}