solana_native_programs/system_program/generated/instructions/
assign.rs1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10use solana_program::pubkey::Pubkey;
11
12pub struct Assign {
14 pub account: solana_program::pubkey::Pubkey,
16}
17
18impl Assign {
19 pub fn instruction(
20 &self,
21 args: AssignInstructionArgs,
22 ) -> solana_program::instruction::Instruction {
23 self.instruction_with_remaining_accounts(args, &[])
24 }
25 #[allow(clippy::vec_init_then_push)]
26 pub fn instruction_with_remaining_accounts(
27 &self,
28 args: AssignInstructionArgs,
29 remaining_accounts: &[solana_program::instruction::AccountMeta],
30 ) -> solana_program::instruction::Instruction {
31 let mut accounts = Vec::with_capacity(1 + remaining_accounts.len());
32 accounts.push(solana_program::instruction::AccountMeta::new(
33 self.account,
34 true,
35 ));
36 accounts.extend_from_slice(remaining_accounts);
37 let mut data = AssignInstructionData::new().try_to_vec().unwrap();
38 let mut args = args.try_to_vec().unwrap();
39 data.append(&mut args);
40
41 solana_program::instruction::Instruction {
42 program_id: crate::SYSTEM_PROGRAM_ID,
43 accounts,
44 data,
45 }
46 }
47}
48
49#[derive(BorshDeserialize, BorshSerialize)]
50struct AssignInstructionData {
51 discriminator: u32,
52}
53
54impl AssignInstructionData {
55 fn new() -> Self {
56 Self { discriminator: 1 }
57 }
58}
59
60#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
61#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
62pub struct AssignInstructionArgs {
63 pub owner: Pubkey,
64}
65
66#[derive(Default)]
72pub struct AssignBuilder {
73 account: Option<solana_program::pubkey::Pubkey>,
74 owner: Option<Pubkey>,
75 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
76}
77
78impl AssignBuilder {
79 pub fn new() -> Self {
80 Self::default()
81 }
82 #[inline(always)]
84 pub fn account(&mut self, account: solana_program::pubkey::Pubkey) -> &mut Self {
85 self.account = Some(account);
86 self
87 }
88 #[inline(always)]
89 pub fn owner(&mut self, owner: Pubkey) -> &mut Self {
90 self.owner = Some(owner);
91 self
92 }
93 #[inline(always)]
95 pub fn add_remaining_account(
96 &mut self,
97 account: solana_program::instruction::AccountMeta,
98 ) -> &mut Self {
99 self.__remaining_accounts.push(account);
100 self
101 }
102 #[inline(always)]
104 pub fn add_remaining_accounts(
105 &mut self,
106 accounts: &[solana_program::instruction::AccountMeta],
107 ) -> &mut Self {
108 self.__remaining_accounts.extend_from_slice(accounts);
109 self
110 }
111 #[allow(clippy::clone_on_copy)]
112 pub fn instruction(&self) -> solana_program::instruction::Instruction {
113 let accounts = Assign {
114 account: self.account.expect("account is not set"),
115 };
116 let args = AssignInstructionArgs {
117 owner: self.owner.clone().expect("owner is not set"),
118 };
119
120 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
121 }
122}
123
124pub struct AssignCpiAccounts<'a, 'b> {
126 pub account: &'b solana_program::account_info::AccountInfo<'a>,
128}
129
130pub struct AssignCpi<'a, 'b> {
132 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
134 pub account: &'b solana_program::account_info::AccountInfo<'a>,
136 pub __args: AssignInstructionArgs,
138}
139
140impl<'a, 'b> AssignCpi<'a, 'b> {
141 pub fn new(
142 program: &'b solana_program::account_info::AccountInfo<'a>,
143 accounts: AssignCpiAccounts<'a, 'b>,
144 args: AssignInstructionArgs,
145 ) -> Self {
146 Self {
147 __program: program,
148 account: accounts.account,
149 __args: args,
150 }
151 }
152 #[inline(always)]
153 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
154 self.invoke_signed_with_remaining_accounts(&[], &[])
155 }
156 #[inline(always)]
157 pub fn invoke_with_remaining_accounts(
158 &self,
159 remaining_accounts: &[(
160 &'b solana_program::account_info::AccountInfo<'a>,
161 bool,
162 bool,
163 )],
164 ) -> solana_program::entrypoint::ProgramResult {
165 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
166 }
167 #[inline(always)]
168 pub fn invoke_signed(
169 &self,
170 signers_seeds: &[&[&[u8]]],
171 ) -> solana_program::entrypoint::ProgramResult {
172 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
173 }
174 #[allow(clippy::clone_on_copy)]
175 #[allow(clippy::vec_init_then_push)]
176 pub fn invoke_signed_with_remaining_accounts(
177 &self,
178 signers_seeds: &[&[&[u8]]],
179 remaining_accounts: &[(
180 &'b solana_program::account_info::AccountInfo<'a>,
181 bool,
182 bool,
183 )],
184 ) -> solana_program::entrypoint::ProgramResult {
185 let mut accounts = Vec::with_capacity(1 + remaining_accounts.len());
186 accounts.push(solana_program::instruction::AccountMeta::new(
187 *self.account.key,
188 true,
189 ));
190 remaining_accounts.iter().for_each(|remaining_account| {
191 accounts.push(solana_program::instruction::AccountMeta {
192 pubkey: *remaining_account.0.key,
193 is_signer: remaining_account.1,
194 is_writable: remaining_account.2,
195 })
196 });
197 let mut data = AssignInstructionData::new().try_to_vec().unwrap();
198 let mut args = self.__args.try_to_vec().unwrap();
199 data.append(&mut args);
200
201 let instruction = solana_program::instruction::Instruction {
202 program_id: crate::SYSTEM_PROGRAM_ID,
203 accounts,
204 data,
205 };
206 let mut account_infos = Vec::with_capacity(1 + 1 + remaining_accounts.len());
207 account_infos.push(self.__program.clone());
208 account_infos.push(self.account.clone());
209 remaining_accounts
210 .iter()
211 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
212
213 if signers_seeds.is_empty() {
214 solana_program::program::invoke(&instruction, &account_infos)
215 } else {
216 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
217 }
218 }
219}
220
221pub struct AssignCpiBuilder<'a, 'b> {
227 instruction: Box<AssignCpiBuilderInstruction<'a, 'b>>,
228}
229
230impl<'a, 'b> AssignCpiBuilder<'a, 'b> {
231 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
232 let instruction = Box::new(AssignCpiBuilderInstruction {
233 __program: program,
234 account: None,
235 owner: None,
236 __remaining_accounts: Vec::new(),
237 });
238 Self { instruction }
239 }
240 #[inline(always)]
242 pub fn account(
243 &mut self,
244 account: &'b solana_program::account_info::AccountInfo<'a>,
245 ) -> &mut Self {
246 self.instruction.account = Some(account);
247 self
248 }
249 #[inline(always)]
250 pub fn owner(&mut self, owner: Pubkey) -> &mut Self {
251 self.instruction.owner = Some(owner);
252 self
253 }
254 #[inline(always)]
256 pub fn add_remaining_account(
257 &mut self,
258 account: &'b solana_program::account_info::AccountInfo<'a>,
259 is_writable: bool,
260 is_signer: bool,
261 ) -> &mut Self {
262 self.instruction
263 .__remaining_accounts
264 .push((account, is_writable, is_signer));
265 self
266 }
267 #[inline(always)]
272 pub fn add_remaining_accounts(
273 &mut self,
274 accounts: &[(
275 &'b solana_program::account_info::AccountInfo<'a>,
276 bool,
277 bool,
278 )],
279 ) -> &mut Self {
280 self.instruction
281 .__remaining_accounts
282 .extend_from_slice(accounts);
283 self
284 }
285 #[inline(always)]
286 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
287 self.invoke_signed(&[])
288 }
289 #[allow(clippy::clone_on_copy)]
290 #[allow(clippy::vec_init_then_push)]
291 pub fn invoke_signed(
292 &self,
293 signers_seeds: &[&[&[u8]]],
294 ) -> solana_program::entrypoint::ProgramResult {
295 let args = AssignInstructionArgs {
296 owner: self.instruction.owner.clone().expect("owner is not set"),
297 };
298 let instruction = AssignCpi {
299 __program: self.instruction.__program,
300
301 account: self.instruction.account.expect("account is not set"),
302 __args: args,
303 };
304 instruction.invoke_signed_with_remaining_accounts(
305 signers_seeds,
306 &self.instruction.__remaining_accounts,
307 )
308 }
309}
310
311struct AssignCpiBuilderInstruction<'a, 'b> {
312 __program: &'b solana_program::account_info::AccountInfo<'a>,
313 account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
314 owner: Option<Pubkey>,
315 __remaining_accounts: Vec<(
317 &'b solana_program::account_info::AccountInfo<'a>,
318 bool,
319 bool,
320 )>,
321}