mpl_distro/generated/instructions/
migrate_distribution.rs1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11pub struct MigrateDistribution {
13 pub distribution: solana_program::pubkey::Pubkey,
15 pub payer: solana_program::pubkey::Pubkey,
17 pub authority: Option<solana_program::pubkey::Pubkey>,
19 pub system_program: solana_program::pubkey::Pubkey,
21}
22
23impl MigrateDistribution {
24 pub fn instruction(&self) -> solana_program::instruction::Instruction {
25 self.instruction_with_remaining_accounts(&[])
26 }
27 #[allow(clippy::vec_init_then_push)]
28 pub fn instruction_with_remaining_accounts(
29 &self,
30 remaining_accounts: &[solana_program::instruction::AccountMeta],
31 ) -> solana_program::instruction::Instruction {
32 let mut accounts = Vec::with_capacity(4 + remaining_accounts.len());
33 accounts.push(solana_program::instruction::AccountMeta::new(
34 self.distribution,
35 false,
36 ));
37 accounts.push(solana_program::instruction::AccountMeta::new(
38 self.payer, true,
39 ));
40 if let Some(authority) = self.authority {
41 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
42 authority, true,
43 ));
44 } else {
45 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
46 crate::MPL_DISTRO_ID,
47 false,
48 ));
49 }
50 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
51 self.system_program,
52 false,
53 ));
54 accounts.extend_from_slice(remaining_accounts);
55 let data = MigrateDistributionInstructionData::new()
56 .try_to_vec()
57 .unwrap();
58
59 solana_program::instruction::Instruction {
60 program_id: crate::MPL_DISTRO_ID,
61 accounts,
62 data,
63 }
64 }
65}
66
67#[derive(BorshDeserialize, BorshSerialize)]
68struct MigrateDistributionInstructionData {
69 discriminator: u8,
70}
71
72impl MigrateDistributionInstructionData {
73 fn new() -> Self {
74 Self { discriminator: 7 }
75 }
76}
77
78#[derive(Default)]
87pub struct MigrateDistributionBuilder {
88 distribution: Option<solana_program::pubkey::Pubkey>,
89 payer: Option<solana_program::pubkey::Pubkey>,
90 authority: Option<solana_program::pubkey::Pubkey>,
91 system_program: Option<solana_program::pubkey::Pubkey>,
92 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
93}
94
95impl MigrateDistributionBuilder {
96 pub fn new() -> Self {
97 Self::default()
98 }
99 #[inline(always)]
101 pub fn distribution(&mut self, distribution: solana_program::pubkey::Pubkey) -> &mut Self {
102 self.distribution = Some(distribution);
103 self
104 }
105 #[inline(always)]
107 pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self {
108 self.payer = Some(payer);
109 self
110 }
111 #[inline(always)]
114 pub fn authority(&mut self, authority: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
115 self.authority = authority;
116 self
117 }
118 #[inline(always)]
121 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
122 self.system_program = Some(system_program);
123 self
124 }
125 #[inline(always)]
127 pub fn add_remaining_account(
128 &mut self,
129 account: solana_program::instruction::AccountMeta,
130 ) -> &mut Self {
131 self.__remaining_accounts.push(account);
132 self
133 }
134 #[inline(always)]
136 pub fn add_remaining_accounts(
137 &mut self,
138 accounts: &[solana_program::instruction::AccountMeta],
139 ) -> &mut Self {
140 self.__remaining_accounts.extend_from_slice(accounts);
141 self
142 }
143 #[allow(clippy::clone_on_copy)]
144 pub fn instruction(&self) -> solana_program::instruction::Instruction {
145 let accounts = MigrateDistribution {
146 distribution: self.distribution.expect("distribution is not set"),
147 payer: self.payer.expect("payer is not set"),
148 authority: self.authority,
149 system_program: self
150 .system_program
151 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
152 };
153
154 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
155 }
156}
157
158pub struct MigrateDistributionCpiAccounts<'a, 'b> {
160 pub distribution: &'b solana_program::account_info::AccountInfo<'a>,
162 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
164 pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
166 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
168}
169
170pub struct MigrateDistributionCpi<'a, 'b> {
172 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
174 pub distribution: &'b solana_program::account_info::AccountInfo<'a>,
176 pub payer: &'b solana_program::account_info::AccountInfo<'a>,
178 pub authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
180 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
182}
183
184impl<'a, 'b> MigrateDistributionCpi<'a, 'b> {
185 pub fn new(
186 program: &'b solana_program::account_info::AccountInfo<'a>,
187 accounts: MigrateDistributionCpiAccounts<'a, 'b>,
188 ) -> Self {
189 Self {
190 __program: program,
191 distribution: accounts.distribution,
192 payer: accounts.payer,
193 authority: accounts.authority,
194 system_program: accounts.system_program,
195 }
196 }
197 #[inline(always)]
198 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
199 self.invoke_signed_with_remaining_accounts(&[], &[])
200 }
201 #[inline(always)]
202 pub fn invoke_with_remaining_accounts(
203 &self,
204 remaining_accounts: &[(
205 &'b solana_program::account_info::AccountInfo<'a>,
206 bool,
207 bool,
208 )],
209 ) -> solana_program::entrypoint::ProgramResult {
210 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
211 }
212 #[inline(always)]
213 pub fn invoke_signed(
214 &self,
215 signers_seeds: &[&[&[u8]]],
216 ) -> solana_program::entrypoint::ProgramResult {
217 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
218 }
219 #[allow(clippy::clone_on_copy)]
220 #[allow(clippy::vec_init_then_push)]
221 pub fn invoke_signed_with_remaining_accounts(
222 &self,
223 signers_seeds: &[&[&[u8]]],
224 remaining_accounts: &[(
225 &'b solana_program::account_info::AccountInfo<'a>,
226 bool,
227 bool,
228 )],
229 ) -> solana_program::entrypoint::ProgramResult {
230 let mut accounts = Vec::with_capacity(4 + remaining_accounts.len());
231 accounts.push(solana_program::instruction::AccountMeta::new(
232 *self.distribution.key,
233 false,
234 ));
235 accounts.push(solana_program::instruction::AccountMeta::new(
236 *self.payer.key,
237 true,
238 ));
239 if let Some(authority) = self.authority {
240 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
241 *authority.key,
242 true,
243 ));
244 } else {
245 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
246 crate::MPL_DISTRO_ID,
247 false,
248 ));
249 }
250 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
251 *self.system_program.key,
252 false,
253 ));
254 remaining_accounts.iter().for_each(|remaining_account| {
255 accounts.push(solana_program::instruction::AccountMeta {
256 pubkey: *remaining_account.0.key,
257 is_signer: remaining_account.1,
258 is_writable: remaining_account.2,
259 })
260 });
261 let data = MigrateDistributionInstructionData::new()
262 .try_to_vec()
263 .unwrap();
264
265 let instruction = solana_program::instruction::Instruction {
266 program_id: crate::MPL_DISTRO_ID,
267 accounts,
268 data,
269 };
270 let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len());
271 account_infos.push(self.__program.clone());
272 account_infos.push(self.distribution.clone());
273 account_infos.push(self.payer.clone());
274 if let Some(authority) = self.authority {
275 account_infos.push(authority.clone());
276 }
277 account_infos.push(self.system_program.clone());
278 remaining_accounts
279 .iter()
280 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
281
282 if signers_seeds.is_empty() {
283 solana_program::program::invoke(&instruction, &account_infos)
284 } else {
285 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
286 }
287 }
288}
289
290pub struct MigrateDistributionCpiBuilder<'a, 'b> {
299 instruction: Box<MigrateDistributionCpiBuilderInstruction<'a, 'b>>,
300}
301
302impl<'a, 'b> MigrateDistributionCpiBuilder<'a, 'b> {
303 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
304 let instruction = Box::new(MigrateDistributionCpiBuilderInstruction {
305 __program: program,
306 distribution: None,
307 payer: None,
308 authority: None,
309 system_program: None,
310 __remaining_accounts: Vec::new(),
311 });
312 Self { instruction }
313 }
314 #[inline(always)]
316 pub fn distribution(
317 &mut self,
318 distribution: &'b solana_program::account_info::AccountInfo<'a>,
319 ) -> &mut Self {
320 self.instruction.distribution = Some(distribution);
321 self
322 }
323 #[inline(always)]
325 pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
326 self.instruction.payer = Some(payer);
327 self
328 }
329 #[inline(always)]
332 pub fn authority(
333 &mut self,
334 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
335 ) -> &mut Self {
336 self.instruction.authority = authority;
337 self
338 }
339 #[inline(always)]
341 pub fn system_program(
342 &mut self,
343 system_program: &'b solana_program::account_info::AccountInfo<'a>,
344 ) -> &mut Self {
345 self.instruction.system_program = Some(system_program);
346 self
347 }
348 #[inline(always)]
350 pub fn add_remaining_account(
351 &mut self,
352 account: &'b solana_program::account_info::AccountInfo<'a>,
353 is_writable: bool,
354 is_signer: bool,
355 ) -> &mut Self {
356 self.instruction
357 .__remaining_accounts
358 .push((account, is_writable, is_signer));
359 self
360 }
361 #[inline(always)]
366 pub fn add_remaining_accounts(
367 &mut self,
368 accounts: &[(
369 &'b solana_program::account_info::AccountInfo<'a>,
370 bool,
371 bool,
372 )],
373 ) -> &mut Self {
374 self.instruction
375 .__remaining_accounts
376 .extend_from_slice(accounts);
377 self
378 }
379 #[inline(always)]
380 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
381 self.invoke_signed(&[])
382 }
383 #[allow(clippy::clone_on_copy)]
384 #[allow(clippy::vec_init_then_push)]
385 pub fn invoke_signed(
386 &self,
387 signers_seeds: &[&[&[u8]]],
388 ) -> solana_program::entrypoint::ProgramResult {
389 let instruction = MigrateDistributionCpi {
390 __program: self.instruction.__program,
391
392 distribution: self
393 .instruction
394 .distribution
395 .expect("distribution is not set"),
396
397 payer: self.instruction.payer.expect("payer is not set"),
398
399 authority: self.instruction.authority,
400
401 system_program: self
402 .instruction
403 .system_program
404 .expect("system_program is not set"),
405 };
406 instruction.invoke_signed_with_remaining_accounts(
407 signers_seeds,
408 &self.instruction.__remaining_accounts,
409 )
410 }
411}
412
413struct MigrateDistributionCpiBuilderInstruction<'a, 'b> {
414 __program: &'b solana_program::account_info::AccountInfo<'a>,
415 distribution: Option<&'b solana_program::account_info::AccountInfo<'a>>,
416 payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
417 authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
418 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
419 __remaining_accounts: Vec<(
421 &'b solana_program::account_info::AccountInfo<'a>,
422 bool,
423 bool,
424 )>,
425}