release_test_client/generated/instructions/
create_whitelist.rs1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11#[derive(Debug)]
13pub struct CreateWhitelist {
14 pub whitelist_account: solana_program::pubkey::Pubkey,
16 pub whitelist_authority: solana_program::pubkey::Pubkey,
18 pub funder: solana_program::pubkey::Pubkey,
20 pub system_program: solana_program::pubkey::Pubkey,
22}
23
24impl CreateWhitelist {
25 pub fn instruction(&self) -> solana_program::instruction::Instruction {
26 self.instruction_with_remaining_accounts(&[])
27 }
28 #[allow(clippy::vec_init_then_push)]
29 pub fn instruction_with_remaining_accounts(
30 &self,
31 remaining_accounts: &[solana_program::instruction::AccountMeta],
32 ) -> solana_program::instruction::Instruction {
33 let mut accounts = Vec::with_capacity(4 + remaining_accounts.len());
34 accounts.push(solana_program::instruction::AccountMeta::new(
35 self.whitelist_account,
36 false,
37 ));
38 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
39 self.whitelist_authority,
40 true,
41 ));
42 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
43 self.funder,
44 true,
45 ));
46 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
47 self.system_program,
48 false,
49 ));
50 accounts.extend_from_slice(remaining_accounts);
51 let data = borsh::to_vec(&CreateWhitelistInstructionData::new()).unwrap();
52
53 solana_program::instruction::Instruction {
54 program_id: crate::RELEASE_TEST_PROGRAM_ID,
55 accounts,
56 data,
57 }
58 }
59}
60
61#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
62#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
63pub struct CreateWhitelistInstructionData {
64 discriminator: u8,
65}
66
67impl CreateWhitelistInstructionData {
68 pub fn new() -> Self {
69 Self { discriminator: 0 }
70 }
71}
72
73impl Default for CreateWhitelistInstructionData {
74 fn default() -> Self {
75 Self::new()
76 }
77}
78
79#[derive(Clone, Debug, Default)]
88pub struct CreateWhitelistBuilder {
89 whitelist_account: Option<solana_program::pubkey::Pubkey>,
90 whitelist_authority: Option<solana_program::pubkey::Pubkey>,
91 funder: Option<solana_program::pubkey::Pubkey>,
92 system_program: Option<solana_program::pubkey::Pubkey>,
93 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
94}
95
96impl CreateWhitelistBuilder {
97 pub fn new() -> Self {
98 Self::default()
99 }
100 #[inline(always)]
102 pub fn whitelist_account(
103 &mut self,
104 whitelist_account: solana_program::pubkey::Pubkey,
105 ) -> &mut Self {
106 self.whitelist_account = Some(whitelist_account);
107 self
108 }
109 #[inline(always)]
111 pub fn whitelist_authority(
112 &mut self,
113 whitelist_authority: solana_program::pubkey::Pubkey,
114 ) -> &mut Self {
115 self.whitelist_authority = Some(whitelist_authority);
116 self
117 }
118 #[inline(always)]
120 pub fn funder(&mut self, funder: solana_program::pubkey::Pubkey) -> &mut Self {
121 self.funder = Some(funder);
122 self
123 }
124 #[inline(always)]
127 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
128 self.system_program = Some(system_program);
129 self
130 }
131 #[inline(always)]
133 pub fn add_remaining_account(
134 &mut self,
135 account: solana_program::instruction::AccountMeta,
136 ) -> &mut Self {
137 self.__remaining_accounts.push(account);
138 self
139 }
140 #[inline(always)]
142 pub fn add_remaining_accounts(
143 &mut self,
144 accounts: &[solana_program::instruction::AccountMeta],
145 ) -> &mut Self {
146 self.__remaining_accounts.extend_from_slice(accounts);
147 self
148 }
149 #[allow(clippy::clone_on_copy)]
150 pub fn instruction(&self) -> solana_program::instruction::Instruction {
151 let accounts = CreateWhitelist {
152 whitelist_account: self
153 .whitelist_account
154 .expect("whitelist_account is not set"),
155 whitelist_authority: self
156 .whitelist_authority
157 .expect("whitelist_authority is not set"),
158 funder: self.funder.expect("funder is not set"),
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 CreateWhitelistCpiAccounts<'a, 'b> {
170 pub whitelist_account: &'b solana_program::account_info::AccountInfo<'a>,
172 pub whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>,
174 pub funder: &'b solana_program::account_info::AccountInfo<'a>,
176 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
178}
179
180pub struct CreateWhitelistCpi<'a, 'b> {
182 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
184 pub whitelist_account: &'b solana_program::account_info::AccountInfo<'a>,
186 pub whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>,
188 pub funder: &'b solana_program::account_info::AccountInfo<'a>,
190 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
192}
193
194impl<'a, 'b> CreateWhitelistCpi<'a, 'b> {
195 pub fn new(
196 program: &'b solana_program::account_info::AccountInfo<'a>,
197 accounts: CreateWhitelistCpiAccounts<'a, 'b>,
198 ) -> Self {
199 Self {
200 __program: program,
201 whitelist_account: accounts.whitelist_account,
202 whitelist_authority: accounts.whitelist_authority,
203 funder: accounts.funder,
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.whitelist_account.key,
243 false,
244 ));
245 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
246 *self.whitelist_authority.key,
247 true,
248 ));
249 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
250 *self.funder.key,
251 true,
252 ));
253 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
254 *self.system_program.key,
255 false,
256 ));
257 remaining_accounts.iter().for_each(|remaining_account| {
258 accounts.push(solana_program::instruction::AccountMeta {
259 pubkey: *remaining_account.0.key,
260 is_signer: remaining_account.1,
261 is_writable: remaining_account.2,
262 })
263 });
264 let data = borsh::to_vec(&CreateWhitelistInstructionData::new()).unwrap();
265
266 let instruction = solana_program::instruction::Instruction {
267 program_id: crate::RELEASE_TEST_PROGRAM_ID,
268 accounts,
269 data,
270 };
271 let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len());
272 account_infos.push(self.__program.clone());
273 account_infos.push(self.whitelist_account.clone());
274 account_infos.push(self.whitelist_authority.clone());
275 account_infos.push(self.funder.clone());
276 account_infos.push(self.system_program.clone());
277 remaining_accounts
278 .iter()
279 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
280
281 if signers_seeds.is_empty() {
282 solana_program::program::invoke(&instruction, &account_infos)
283 } else {
284 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
285 }
286 }
287}
288
289#[derive(Clone, Debug)]
298pub struct CreateWhitelistCpiBuilder<'a, 'b> {
299 instruction: Box<CreateWhitelistCpiBuilderInstruction<'a, 'b>>,
300}
301
302impl<'a, 'b> CreateWhitelistCpiBuilder<'a, 'b> {
303 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
304 let instruction = Box::new(CreateWhitelistCpiBuilderInstruction {
305 __program: program,
306 whitelist_account: None,
307 whitelist_authority: None,
308 funder: None,
309 system_program: None,
310 __remaining_accounts: Vec::new(),
311 });
312 Self { instruction }
313 }
314 #[inline(always)]
316 pub fn whitelist_account(
317 &mut self,
318 whitelist_account: &'b solana_program::account_info::AccountInfo<'a>,
319 ) -> &mut Self {
320 self.instruction.whitelist_account = Some(whitelist_account);
321 self
322 }
323 #[inline(always)]
325 pub fn whitelist_authority(
326 &mut self,
327 whitelist_authority: &'b solana_program::account_info::AccountInfo<'a>,
328 ) -> &mut Self {
329 self.instruction.whitelist_authority = Some(whitelist_authority);
330 self
331 }
332 #[inline(always)]
334 pub fn funder(
335 &mut self,
336 funder: &'b solana_program::account_info::AccountInfo<'a>,
337 ) -> &mut Self {
338 self.instruction.funder = Some(funder);
339 self
340 }
341 #[inline(always)]
343 pub fn system_program(
344 &mut self,
345 system_program: &'b solana_program::account_info::AccountInfo<'a>,
346 ) -> &mut Self {
347 self.instruction.system_program = Some(system_program);
348 self
349 }
350 #[inline(always)]
352 pub fn add_remaining_account(
353 &mut self,
354 account: &'b solana_program::account_info::AccountInfo<'a>,
355 is_writable: bool,
356 is_signer: bool,
357 ) -> &mut Self {
358 self.instruction
359 .__remaining_accounts
360 .push((account, is_writable, is_signer));
361 self
362 }
363 #[inline(always)]
368 pub fn add_remaining_accounts(
369 &mut self,
370 accounts: &[(
371 &'b solana_program::account_info::AccountInfo<'a>,
372 bool,
373 bool,
374 )],
375 ) -> &mut Self {
376 self.instruction
377 .__remaining_accounts
378 .extend_from_slice(accounts);
379 self
380 }
381 #[inline(always)]
382 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
383 self.invoke_signed(&[])
384 }
385 #[allow(clippy::clone_on_copy)]
386 #[allow(clippy::vec_init_then_push)]
387 pub fn invoke_signed(
388 &self,
389 signers_seeds: &[&[&[u8]]],
390 ) -> solana_program::entrypoint::ProgramResult {
391 let instruction = CreateWhitelistCpi {
392 __program: self.instruction.__program,
393
394 whitelist_account: self
395 .instruction
396 .whitelist_account
397 .expect("whitelist_account is not set"),
398
399 whitelist_authority: self
400 .instruction
401 .whitelist_authority
402 .expect("whitelist_authority is not set"),
403
404 funder: self.instruction.funder.expect("funder is not set"),
405
406 system_program: self
407 .instruction
408 .system_program
409 .expect("system_program is not set"),
410 };
411 instruction.invoke_signed_with_remaining_accounts(
412 signers_seeds,
413 &self.instruction.__remaining_accounts,
414 )
415 }
416}
417
418#[derive(Clone, Debug)]
419struct CreateWhitelistCpiBuilderInstruction<'a, 'b> {
420 __program: &'b solana_program::account_info::AccountInfo<'a>,
421 whitelist_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
422 whitelist_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
423 funder: Option<&'b solana_program::account_info::AccountInfo<'a>>,
424 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
425 __remaining_accounts: Vec<(
427 &'b solana_program::account_info::AccountInfo<'a>,
428 bool,
429 bool,
430 )>,
431}