reflect_sdk/generated/instructions/
migrate_s1.rs1use borsh::BorshSerialize;
9use borsh::BorshDeserialize;
10
11pub const MIGRATE_S1_DISCRIMINATOR: [u8; 8] = [30, 99, 75, 12, 51, 66, 195, 135];
12
13#[derive(Debug)]
15pub struct MigrateS1 {
16
17
18 pub usdc_controller: solana_pubkey::Pubkey,
19
20
21 pub main: solana_pubkey::Pubkey,
22
23
24 pub admin_permissions: solana_pubkey::Pubkey,
25
26
27 pub admin: solana_pubkey::Pubkey,
28
29
30 pub system_program: solana_pubkey::Pubkey,
31 }
32
33impl MigrateS1 {
34 pub fn instruction(&self) -> solana_instruction::Instruction {
35 self.instruction_with_remaining_accounts(&[])
36 }
37 #[allow(clippy::arithmetic_side_effects)]
38 #[allow(clippy::vec_init_then_push)]
39 pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
40 let mut accounts = Vec::with_capacity(5+ remaining_accounts.len());
41 accounts.push(solana_instruction::AccountMeta::new(
42 self.usdc_controller,
43 false
44 ));
45 accounts.push(solana_instruction::AccountMeta::new(
46 self.main,
47 false
48 ));
49 accounts.push(solana_instruction::AccountMeta::new_readonly(
50 self.admin_permissions,
51 false
52 ));
53 accounts.push(solana_instruction::AccountMeta::new(
54 self.admin,
55 true
56 ));
57 accounts.push(solana_instruction::AccountMeta::new_readonly(
58 self.system_program,
59 false
60 ));
61 accounts.extend_from_slice(remaining_accounts);
62 let data = MigrateS1InstructionData::new().try_to_vec().unwrap();
63
64 solana_instruction::Instruction {
65 program_id: crate::REFLECT_MAIN_ID,
66 accounts,
67 data,
68 }
69 }
70}
71
72#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
73#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
74 pub struct MigrateS1InstructionData {
75 discriminator: [u8; 8],
76 }
77
78impl MigrateS1InstructionData {
79 pub fn new() -> Self {
80 Self {
81 discriminator: [30, 99, 75, 12, 51, 66, 195, 135],
82 }
83 }
84
85 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
86 borsh::to_vec(self)
87 }
88 }
89
90impl Default for MigrateS1InstructionData {
91 fn default() -> Self {
92 Self::new()
93 }
94}
95
96
97
98#[derive(Clone, Debug, Default)]
108pub struct MigrateS1Builder {
109 usdc_controller: Option<solana_pubkey::Pubkey>,
110 main: Option<solana_pubkey::Pubkey>,
111 admin_permissions: Option<solana_pubkey::Pubkey>,
112 admin: Option<solana_pubkey::Pubkey>,
113 system_program: Option<solana_pubkey::Pubkey>,
114 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
115}
116
117impl MigrateS1Builder {
118 pub fn new() -> Self {
119 Self::default()
120 }
121 #[inline(always)]
122 pub fn usdc_controller(&mut self, usdc_controller: solana_pubkey::Pubkey) -> &mut Self {
123 self.usdc_controller = Some(usdc_controller);
124 self
125 }
126 #[inline(always)]
127 pub fn main(&mut self, main: solana_pubkey::Pubkey) -> &mut Self {
128 self.main = Some(main);
129 self
130 }
131 #[inline(always)]
132 pub fn admin_permissions(&mut self, admin_permissions: solana_pubkey::Pubkey) -> &mut Self {
133 self.admin_permissions = Some(admin_permissions);
134 self
135 }
136 #[inline(always)]
137 pub fn admin(&mut self, admin: solana_pubkey::Pubkey) -> &mut Self {
138 self.admin = Some(admin);
139 self
140 }
141 #[inline(always)]
143 pub fn system_program(&mut self, system_program: solana_pubkey::Pubkey) -> &mut Self {
144 self.system_program = Some(system_program);
145 self
146 }
147 #[inline(always)]
149 pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
150 self.__remaining_accounts.push(account);
151 self
152 }
153 #[inline(always)]
155 pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
156 self.__remaining_accounts.extend_from_slice(accounts);
157 self
158 }
159 #[allow(clippy::clone_on_copy)]
160 pub fn instruction(&self) -> solana_instruction::Instruction {
161 let accounts = MigrateS1 {
162 usdc_controller: self.usdc_controller.expect("usdc_controller is not set"),
163 main: self.main.expect("main is not set"),
164 admin_permissions: self.admin_permissions.expect("admin_permissions is not set"),
165 admin: self.admin.expect("admin is not set"),
166 system_program: self.system_program.unwrap_or(solana_pubkey::pubkey!("11111111111111111111111111111111")),
167 };
168
169 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
170 }
171}
172
173 pub struct MigrateS1CpiAccounts<'a, 'b> {
175
176
177 pub usdc_controller: &'b solana_account_info::AccountInfo<'a>,
178
179
180 pub main: &'b solana_account_info::AccountInfo<'a>,
181
182
183 pub admin_permissions: &'b solana_account_info::AccountInfo<'a>,
184
185
186 pub admin: &'b solana_account_info::AccountInfo<'a>,
187
188
189 pub system_program: &'b solana_account_info::AccountInfo<'a>,
190 }
191
192pub struct MigrateS1Cpi<'a, 'b> {
194 pub __program: &'b solana_account_info::AccountInfo<'a>,
196
197
198 pub usdc_controller: &'b solana_account_info::AccountInfo<'a>,
199
200
201 pub main: &'b solana_account_info::AccountInfo<'a>,
202
203
204 pub admin_permissions: &'b solana_account_info::AccountInfo<'a>,
205
206
207 pub admin: &'b solana_account_info::AccountInfo<'a>,
208
209
210 pub system_program: &'b solana_account_info::AccountInfo<'a>,
211 }
212
213impl<'a, 'b> MigrateS1Cpi<'a, 'b> {
214 pub fn new(
215 program: &'b solana_account_info::AccountInfo<'a>,
216 accounts: MigrateS1CpiAccounts<'a, 'b>,
217 ) -> Self {
218 Self {
219 __program: program,
220 usdc_controller: accounts.usdc_controller,
221 main: accounts.main,
222 admin_permissions: accounts.admin_permissions,
223 admin: accounts.admin,
224 system_program: accounts.system_program,
225 }
226 }
227 #[inline(always)]
228 pub fn invoke(&self) -> solana_program_error::ProgramResult {
229 self.invoke_signed_with_remaining_accounts(&[], &[])
230 }
231 #[inline(always)]
232 pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
233 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
234 }
235 #[inline(always)]
236 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
237 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
238 }
239 #[allow(clippy::arithmetic_side_effects)]
240 #[allow(clippy::clone_on_copy)]
241 #[allow(clippy::vec_init_then_push)]
242 pub fn invoke_signed_with_remaining_accounts(
243 &self,
244 signers_seeds: &[&[&[u8]]],
245 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
246 ) -> solana_program_error::ProgramResult {
247 let mut accounts = Vec::with_capacity(5+ remaining_accounts.len());
248 accounts.push(solana_instruction::AccountMeta::new(
249 *self.usdc_controller.key,
250 false
251 ));
252 accounts.push(solana_instruction::AccountMeta::new(
253 *self.main.key,
254 false
255 ));
256 accounts.push(solana_instruction::AccountMeta::new_readonly(
257 *self.admin_permissions.key,
258 false
259 ));
260 accounts.push(solana_instruction::AccountMeta::new(
261 *self.admin.key,
262 true
263 ));
264 accounts.push(solana_instruction::AccountMeta::new_readonly(
265 *self.system_program.key,
266 false
267 ));
268 remaining_accounts.iter().for_each(|remaining_account| {
269 accounts.push(solana_instruction::AccountMeta {
270 pubkey: *remaining_account.0.key,
271 is_signer: remaining_account.1,
272 is_writable: remaining_account.2,
273 })
274 });
275 let data = MigrateS1InstructionData::new().try_to_vec().unwrap();
276
277 let instruction = solana_instruction::Instruction {
278 program_id: crate::REFLECT_MAIN_ID,
279 accounts,
280 data,
281 };
282 let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len());
283 account_infos.push(self.__program.clone());
284 account_infos.push(self.usdc_controller.clone());
285 account_infos.push(self.main.clone());
286 account_infos.push(self.admin_permissions.clone());
287 account_infos.push(self.admin.clone());
288 account_infos.push(self.system_program.clone());
289 remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
290
291 if signers_seeds.is_empty() {
292 solana_cpi::invoke(&instruction, &account_infos)
293 } else {
294 solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
295 }
296 }
297}
298
299#[derive(Clone, Debug)]
309pub struct MigrateS1CpiBuilder<'a, 'b> {
310 instruction: Box<MigrateS1CpiBuilderInstruction<'a, 'b>>,
311}
312
313impl<'a, 'b> MigrateS1CpiBuilder<'a, 'b> {
314 pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
315 let instruction = Box::new(MigrateS1CpiBuilderInstruction {
316 __program: program,
317 usdc_controller: None,
318 main: None,
319 admin_permissions: None,
320 admin: None,
321 system_program: None,
322 __remaining_accounts: Vec::new(),
323 });
324 Self { instruction }
325 }
326 #[inline(always)]
327 pub fn usdc_controller(&mut self, usdc_controller: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
328 self.instruction.usdc_controller = Some(usdc_controller);
329 self
330 }
331 #[inline(always)]
332 pub fn main(&mut self, main: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
333 self.instruction.main = Some(main);
334 self
335 }
336 #[inline(always)]
337 pub fn admin_permissions(&mut self, admin_permissions: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
338 self.instruction.admin_permissions = Some(admin_permissions);
339 self
340 }
341 #[inline(always)]
342 pub fn admin(&mut self, admin: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
343 self.instruction.admin = Some(admin);
344 self
345 }
346 #[inline(always)]
347 pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
348 self.instruction.system_program = Some(system_program);
349 self
350 }
351 #[inline(always)]
353 pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
354 self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
355 self
356 }
357 #[inline(always)]
362 pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
363 self.instruction.__remaining_accounts.extend_from_slice(accounts);
364 self
365 }
366 #[inline(always)]
367 pub fn invoke(&self) -> solana_program_error::ProgramResult {
368 self.invoke_signed(&[])
369 }
370 #[allow(clippy::clone_on_copy)]
371 #[allow(clippy::vec_init_then_push)]
372 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
373 let instruction = MigrateS1Cpi {
374 __program: self.instruction.__program,
375
376 usdc_controller: self.instruction.usdc_controller.expect("usdc_controller is not set"),
377
378 main: self.instruction.main.expect("main is not set"),
379
380 admin_permissions: self.instruction.admin_permissions.expect("admin_permissions is not set"),
381
382 admin: self.instruction.admin.expect("admin is not set"),
383
384 system_program: self.instruction.system_program.expect("system_program is not set"),
385 };
386 instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
387 }
388}
389
390#[derive(Clone, Debug)]
391struct MigrateS1CpiBuilderInstruction<'a, 'b> {
392 __program: &'b solana_account_info::AccountInfo<'a>,
393 usdc_controller: Option<&'b solana_account_info::AccountInfo<'a>>,
394 main: Option<&'b solana_account_info::AccountInfo<'a>>,
395 admin_permissions: Option<&'b solana_account_info::AccountInfo<'a>>,
396 admin: Option<&'b solana_account_info::AccountInfo<'a>>,
397 system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
398 __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
400}
401