commerce_program_client/generated/instructions/
update_merchant_authority.rs1use borsh::BorshSerialize;
9use borsh::BorshDeserialize;
10
11pub const UPDATE_MERCHANT_AUTHORITY_DISCRIMINATOR: u8 = 7;
12
13#[derive(Debug)]
15pub struct UpdateMerchantAuthority {
16
17
18 pub payer: solana_pubkey::Pubkey,
19
20
21 pub authority: solana_pubkey::Pubkey,
22 pub merchant: solana_pubkey::Pubkey,
27
28
29 pub new_authority: solana_pubkey::Pubkey,
30 }
31
32impl UpdateMerchantAuthority {
33 pub fn instruction(&self) -> solana_instruction::Instruction {
34 self.instruction_with_remaining_accounts(&[])
35 }
36 #[allow(clippy::arithmetic_side_effects)]
37 #[allow(clippy::vec_init_then_push)]
38 pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
39 let mut accounts = Vec::with_capacity(4+ remaining_accounts.len());
40 accounts.push(solana_instruction::AccountMeta::new(
41 self.payer,
42 true
43 ));
44 accounts.push(solana_instruction::AccountMeta::new(
45 self.authority,
46 true
47 ));
48 accounts.push(solana_instruction::AccountMeta::new(
49 self.merchant,
50 false
51 ));
52 accounts.push(solana_instruction::AccountMeta::new_readonly(
53 self.new_authority,
54 false
55 ));
56 accounts.extend_from_slice(remaining_accounts);
57 let data = borsh::to_vec(&UpdateMerchantAuthorityInstructionData::new()).unwrap();
58
59 solana_instruction::Instruction {
60 program_id: crate::COMMERCE_PROGRAM_ID,
61 accounts,
62 data,
63 }
64 }
65}
66
67#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
68#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
69 pub struct UpdateMerchantAuthorityInstructionData {
70 discriminator: u8,
71 }
72
73impl UpdateMerchantAuthorityInstructionData {
74 pub fn new() -> Self {
75 Self {
76 discriminator: 7,
77 }
78 }
79}
80
81impl Default for UpdateMerchantAuthorityInstructionData {
82 fn default() -> Self {
83 Self::new()
84 }
85}
86
87
88
89#[derive(Clone, Debug, Default)]
98pub struct UpdateMerchantAuthorityBuilder {
99 payer: Option<solana_pubkey::Pubkey>,
100 authority: Option<solana_pubkey::Pubkey>,
101 merchant: Option<solana_pubkey::Pubkey>,
102 new_authority: Option<solana_pubkey::Pubkey>,
103 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
104}
105
106impl UpdateMerchantAuthorityBuilder {
107 pub fn new() -> Self {
108 Self::default()
109 }
110 #[inline(always)]
111 pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self {
112 self.payer = Some(payer);
113 self
114 }
115 #[inline(always)]
116 pub fn authority(&mut self, authority: solana_pubkey::Pubkey) -> &mut Self {
117 self.authority = Some(authority);
118 self
119 }
120 #[inline(always)]
122 pub fn merchant(&mut self, merchant: solana_pubkey::Pubkey) -> &mut Self {
123 self.merchant = Some(merchant);
124 self
125 }
126 #[inline(always)]
127 pub fn new_authority(&mut self, new_authority: solana_pubkey::Pubkey) -> &mut Self {
128 self.new_authority = Some(new_authority);
129 self
130 }
131 #[inline(always)]
133 pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
134 self.__remaining_accounts.push(account);
135 self
136 }
137 #[inline(always)]
139 pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &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_instruction::Instruction {
145 let accounts = UpdateMerchantAuthority {
146 payer: self.payer.expect("payer is not set"),
147 authority: self.authority.expect("authority is not set"),
148 merchant: self.merchant.expect("merchant is not set"),
149 new_authority: self.new_authority.expect("new_authority is not set"),
150 };
151
152 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
153 }
154}
155
156 pub struct UpdateMerchantAuthorityCpiAccounts<'a, 'b> {
158
159
160 pub payer: &'b solana_account_info::AccountInfo<'a>,
161
162
163 pub authority: &'b solana_account_info::AccountInfo<'a>,
164 pub merchant: &'b solana_account_info::AccountInfo<'a>,
169
170
171 pub new_authority: &'b solana_account_info::AccountInfo<'a>,
172 }
173
174pub struct UpdateMerchantAuthorityCpi<'a, 'b> {
176 pub __program: &'b solana_account_info::AccountInfo<'a>,
178
179
180 pub payer: &'b solana_account_info::AccountInfo<'a>,
181
182
183 pub authority: &'b solana_account_info::AccountInfo<'a>,
184 pub merchant: &'b solana_account_info::AccountInfo<'a>,
189
190
191 pub new_authority: &'b solana_account_info::AccountInfo<'a>,
192 }
193
194impl<'a, 'b> UpdateMerchantAuthorityCpi<'a, 'b> {
195 pub fn new(
196 program: &'b solana_account_info::AccountInfo<'a>,
197 accounts: UpdateMerchantAuthorityCpiAccounts<'a, 'b>,
198 ) -> Self {
199 Self {
200 __program: program,
201 payer: accounts.payer,
202 authority: accounts.authority,
203 merchant: accounts.merchant,
204 new_authority: accounts.new_authority,
205 }
206 }
207 #[inline(always)]
208 pub fn invoke(&self) -> solana_program_error::ProgramResult {
209 self.invoke_signed_with_remaining_accounts(&[], &[])
210 }
211 #[inline(always)]
212 pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
213 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
214 }
215 #[inline(always)]
216 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
217 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
218 }
219 #[allow(clippy::arithmetic_side_effects)]
220 #[allow(clippy::clone_on_copy)]
221 #[allow(clippy::vec_init_then_push)]
222 pub fn invoke_signed_with_remaining_accounts(
223 &self,
224 signers_seeds: &[&[&[u8]]],
225 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
226 ) -> solana_program_error::ProgramResult {
227 let mut accounts = Vec::with_capacity(4+ remaining_accounts.len());
228 accounts.push(solana_instruction::AccountMeta::new(
229 *self.payer.key,
230 true
231 ));
232 accounts.push(solana_instruction::AccountMeta::new(
233 *self.authority.key,
234 true
235 ));
236 accounts.push(solana_instruction::AccountMeta::new(
237 *self.merchant.key,
238 false
239 ));
240 accounts.push(solana_instruction::AccountMeta::new_readonly(
241 *self.new_authority.key,
242 false
243 ));
244 remaining_accounts.iter().for_each(|remaining_account| {
245 accounts.push(solana_instruction::AccountMeta {
246 pubkey: *remaining_account.0.key,
247 is_signer: remaining_account.1,
248 is_writable: remaining_account.2,
249 })
250 });
251 let data = borsh::to_vec(&UpdateMerchantAuthorityInstructionData::new()).unwrap();
252
253 let instruction = solana_instruction::Instruction {
254 program_id: crate::COMMERCE_PROGRAM_ID,
255 accounts,
256 data,
257 };
258 let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len());
259 account_infos.push(self.__program.clone());
260 account_infos.push(self.payer.clone());
261 account_infos.push(self.authority.clone());
262 account_infos.push(self.merchant.clone());
263 account_infos.push(self.new_authority.clone());
264 remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
265
266 if signers_seeds.is_empty() {
267 solana_cpi::invoke(&instruction, &account_infos)
268 } else {
269 solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
270 }
271 }
272}
273
274#[derive(Clone, Debug)]
283pub struct UpdateMerchantAuthorityCpiBuilder<'a, 'b> {
284 instruction: Box<UpdateMerchantAuthorityCpiBuilderInstruction<'a, 'b>>,
285}
286
287impl<'a, 'b> UpdateMerchantAuthorityCpiBuilder<'a, 'b> {
288 pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
289 let instruction = Box::new(UpdateMerchantAuthorityCpiBuilderInstruction {
290 __program: program,
291 payer: None,
292 authority: None,
293 merchant: None,
294 new_authority: None,
295 __remaining_accounts: Vec::new(),
296 });
297 Self { instruction }
298 }
299 #[inline(always)]
300 pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
301 self.instruction.payer = Some(payer);
302 self
303 }
304 #[inline(always)]
305 pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
306 self.instruction.authority = Some(authority);
307 self
308 }
309 #[inline(always)]
311 pub fn merchant(&mut self, merchant: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
312 self.instruction.merchant = Some(merchant);
313 self
314 }
315 #[inline(always)]
316 pub fn new_authority(&mut self, new_authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
317 self.instruction.new_authority = Some(new_authority);
318 self
319 }
320 #[inline(always)]
322 pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
323 self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
324 self
325 }
326 #[inline(always)]
331 pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
332 self.instruction.__remaining_accounts.extend_from_slice(accounts);
333 self
334 }
335 #[inline(always)]
336 pub fn invoke(&self) -> solana_program_error::ProgramResult {
337 self.invoke_signed(&[])
338 }
339 #[allow(clippy::clone_on_copy)]
340 #[allow(clippy::vec_init_then_push)]
341 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
342 let instruction = UpdateMerchantAuthorityCpi {
343 __program: self.instruction.__program,
344
345 payer: self.instruction.payer.expect("payer is not set"),
346
347 authority: self.instruction.authority.expect("authority is not set"),
348
349 merchant: self.instruction.merchant.expect("merchant is not set"),
350
351 new_authority: self.instruction.new_authority.expect("new_authority is not set"),
352 };
353 instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
354 }
355}
356
357#[derive(Clone, Debug)]
358struct UpdateMerchantAuthorityCpiBuilderInstruction<'a, 'b> {
359 __program: &'b solana_account_info::AccountInfo<'a>,
360 payer: Option<&'b solana_account_info::AccountInfo<'a>>,
361 authority: Option<&'b solana_account_info::AccountInfo<'a>>,
362 merchant: Option<&'b solana_account_info::AccountInfo<'a>>,
363 new_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
364 __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
366}
367