1use solana_address::Address;
9use borsh::BorshSerialize;
10use borsh::BorshDeserialize;
11
12pub const CREATE_SATRUSH_CONFIG_DISCRIMINATOR: [u8; 8] = [96, 175, 39, 171, 158, 44, 117, 18];
13
14#[derive(Debug)]
16pub struct CreateSatrushConfig {
17
18
19 pub authority: solana_address::Address,
20
21
22 pub satrush_config: solana_address::Address,
23
24
25 pub system_program: solana_address::Address,
26 }
27
28impl CreateSatrushConfig {
29 pub fn instruction(&self, args: CreateSatrushConfigInstructionArgs) -> solana_instruction::Instruction {
30 self.instruction_with_remaining_accounts(args, &[])
31 }
32 #[allow(clippy::arithmetic_side_effects)]
33 #[allow(clippy::vec_init_then_push)]
34 pub fn instruction_with_remaining_accounts(&self, args: CreateSatrushConfigInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
35 let mut accounts = Vec::with_capacity(3+ remaining_accounts.len());
36 accounts.push(solana_instruction::AccountMeta::new(
37 self.authority,
38 true
39 ));
40 accounts.push(solana_instruction::AccountMeta::new(
41 self.satrush_config,
42 false
43 ));
44 accounts.push(solana_instruction::AccountMeta::new_readonly(
45 self.system_program,
46 false
47 ));
48 accounts.extend_from_slice(remaining_accounts);
49 let mut data = CreateSatrushConfigInstructionData::new().try_to_vec().unwrap();
50 let mut args = args.try_to_vec().unwrap();
51 data.append(&mut args);
52
53 solana_instruction::Instruction {
54 program_id: crate::SATRUSH_ID,
55 accounts,
56 data,
57 }
58 }
59}
60
61#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
62 pub struct CreateSatrushConfigInstructionData {
63 discriminator: [u8; 8],
64 }
65
66impl CreateSatrushConfigInstructionData {
67 pub fn new() -> Self {
68 Self {
69 discriminator: [96, 175, 39, 171, 158, 44, 117, 18],
70 }
71 }
72
73 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
74 borsh::to_vec(self)
75 }
76 }
77
78impl Default for CreateSatrushConfigInstructionData {
79 fn default() -> Self {
80 Self::new()
81 }
82}
83
84#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
85 pub struct CreateSatrushConfigInstructionArgs {
86 pub owner_authority: Address,
87 pub admin_authority: Address,
88 pub game_authority: Address,
89 pub fee_recipient: Address,
90 pub usd_mint: Address,
91 pub btc_mint: Address,
92 pub token_mint: Address,
93 }
94
95impl CreateSatrushConfigInstructionArgs {
96 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
97 borsh::to_vec(self)
98 }
99}
100
101
102#[derive(Clone, Debug, Default)]
110pub struct CreateSatrushConfigBuilder {
111 authority: Option<solana_address::Address>,
112 satrush_config: Option<solana_address::Address>,
113 system_program: Option<solana_address::Address>,
114 owner_authority: Option<Address>,
115 admin_authority: Option<Address>,
116 game_authority: Option<Address>,
117 fee_recipient: Option<Address>,
118 usd_mint: Option<Address>,
119 btc_mint: Option<Address>,
120 token_mint: Option<Address>,
121 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
122}
123
124impl CreateSatrushConfigBuilder {
125 pub fn new() -> Self {
126 Self::default()
127 }
128 #[inline(always)]
129 pub fn authority(&mut self, authority: solana_address::Address) -> &mut Self {
130 self.authority = Some(authority);
131 self
132 }
133 #[inline(always)]
134 pub fn satrush_config(&mut self, satrush_config: solana_address::Address) -> &mut Self {
135 self.satrush_config = Some(satrush_config);
136 self
137 }
138 #[inline(always)]
140 pub fn system_program(&mut self, system_program: solana_address::Address) -> &mut Self {
141 self.system_program = Some(system_program);
142 self
143 }
144 #[inline(always)]
145 pub fn owner_authority(&mut self, owner_authority: Address) -> &mut Self {
146 self.owner_authority = Some(owner_authority);
147 self
148 }
149 #[inline(always)]
150 pub fn admin_authority(&mut self, admin_authority: Address) -> &mut Self {
151 self.admin_authority = Some(admin_authority);
152 self
153 }
154 #[inline(always)]
155 pub fn game_authority(&mut self, game_authority: Address) -> &mut Self {
156 self.game_authority = Some(game_authority);
157 self
158 }
159 #[inline(always)]
160 pub fn fee_recipient(&mut self, fee_recipient: Address) -> &mut Self {
161 self.fee_recipient = Some(fee_recipient);
162 self
163 }
164 #[inline(always)]
165 pub fn usd_mint(&mut self, usd_mint: Address) -> &mut Self {
166 self.usd_mint = Some(usd_mint);
167 self
168 }
169 #[inline(always)]
170 pub fn btc_mint(&mut self, btc_mint: Address) -> &mut Self {
171 self.btc_mint = Some(btc_mint);
172 self
173 }
174 #[inline(always)]
175 pub fn token_mint(&mut self, token_mint: Address) -> &mut Self {
176 self.token_mint = Some(token_mint);
177 self
178 }
179 #[inline(always)]
181 pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
182 self.__remaining_accounts.push(account);
183 self
184 }
185 #[inline(always)]
187 pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
188 self.__remaining_accounts.extend_from_slice(accounts);
189 self
190 }
191 #[allow(clippy::clone_on_copy)]
192 pub fn instruction(&self) -> solana_instruction::Instruction {
193 let accounts = CreateSatrushConfig {
194 authority: self.authority.expect("authority is not set"),
195 satrush_config: self.satrush_config.expect("satrush_config is not set"),
196 system_program: self.system_program.unwrap_or(solana_address::address!("11111111111111111111111111111111")),
197 };
198 let args = CreateSatrushConfigInstructionArgs {
199 owner_authority: self.owner_authority.clone().expect("owner_authority is not set"),
200 admin_authority: self.admin_authority.clone().expect("admin_authority is not set"),
201 game_authority: self.game_authority.clone().expect("game_authority is not set"),
202 fee_recipient: self.fee_recipient.clone().expect("fee_recipient is not set"),
203 usd_mint: self.usd_mint.clone().expect("usd_mint is not set"),
204 btc_mint: self.btc_mint.clone().expect("btc_mint is not set"),
205 token_mint: self.token_mint.clone().expect("token_mint is not set"),
206 };
207
208 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
209 }
210}
211
212 pub struct CreateSatrushConfigCpiAccounts<'a, 'b> {
214
215
216 pub authority: &'b solana_account_info::AccountInfo<'a>,
217
218
219 pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
220
221
222 pub system_program: &'b solana_account_info::AccountInfo<'a>,
223 }
224
225pub struct CreateSatrushConfigCpi<'a, 'b> {
227 pub __program: &'b solana_account_info::AccountInfo<'a>,
229
230
231 pub authority: &'b solana_account_info::AccountInfo<'a>,
232
233
234 pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
235
236
237 pub system_program: &'b solana_account_info::AccountInfo<'a>,
238 pub __args: CreateSatrushConfigInstructionArgs,
240 }
241
242impl<'a, 'b> CreateSatrushConfigCpi<'a, 'b> {
243 pub fn new(
244 program: &'b solana_account_info::AccountInfo<'a>,
245 accounts: CreateSatrushConfigCpiAccounts<'a, 'b>,
246 args: CreateSatrushConfigInstructionArgs,
247 ) -> Self {
248 Self {
249 __program: program,
250 authority: accounts.authority,
251 satrush_config: accounts.satrush_config,
252 system_program: accounts.system_program,
253 __args: args,
254 }
255 }
256 #[inline(always)]
257 pub fn invoke(&self) -> solana_program_error::ProgramResult {
258 self.invoke_signed_with_remaining_accounts(&[], &[])
259 }
260 #[inline(always)]
261 pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
262 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
263 }
264 #[inline(always)]
265 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
266 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
267 }
268 #[allow(clippy::arithmetic_side_effects)]
269 #[allow(clippy::clone_on_copy)]
270 #[allow(clippy::vec_init_then_push)]
271 pub fn invoke_signed_with_remaining_accounts(
272 &self,
273 signers_seeds: &[&[&[u8]]],
274 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
275 ) -> solana_program_error::ProgramResult {
276 let mut accounts = Vec::with_capacity(3+ remaining_accounts.len());
277 accounts.push(solana_instruction::AccountMeta::new(
278 *self.authority.key,
279 true
280 ));
281 accounts.push(solana_instruction::AccountMeta::new(
282 *self.satrush_config.key,
283 false
284 ));
285 accounts.push(solana_instruction::AccountMeta::new_readonly(
286 *self.system_program.key,
287 false
288 ));
289 remaining_accounts.iter().for_each(|remaining_account| {
290 accounts.push(solana_instruction::AccountMeta {
291 pubkey: *remaining_account.0.key,
292 is_signer: remaining_account.1,
293 is_writable: remaining_account.2,
294 })
295 });
296 let mut data = CreateSatrushConfigInstructionData::new().try_to_vec().unwrap();
297 let mut args = self.__args.try_to_vec().unwrap();
298 data.append(&mut args);
299
300 let instruction = solana_instruction::Instruction {
301 program_id: crate::SATRUSH_ID,
302 accounts,
303 data,
304 };
305 let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len());
306 account_infos.push(self.__program.clone());
307 account_infos.push(self.authority.clone());
308 account_infos.push(self.satrush_config.clone());
309 account_infos.push(self.system_program.clone());
310 remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
311
312 if signers_seeds.is_empty() {
313 solana_cpi::invoke(&instruction, &account_infos)
314 } else {
315 solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
316 }
317 }
318}
319
320#[derive(Clone, Debug)]
328pub struct CreateSatrushConfigCpiBuilder<'a, 'b> {
329 instruction: Box<CreateSatrushConfigCpiBuilderInstruction<'a, 'b>>,
330}
331
332impl<'a, 'b> CreateSatrushConfigCpiBuilder<'a, 'b> {
333 pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
334 let instruction = Box::new(CreateSatrushConfigCpiBuilderInstruction {
335 __program: program,
336 authority: None,
337 satrush_config: None,
338 system_program: None,
339 owner_authority: None,
340 admin_authority: None,
341 game_authority: None,
342 fee_recipient: None,
343 usd_mint: None,
344 btc_mint: None,
345 token_mint: None,
346 __remaining_accounts: Vec::new(),
347 });
348 Self { instruction }
349 }
350 #[inline(always)]
351 pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
352 self.instruction.authority = Some(authority);
353 self
354 }
355 #[inline(always)]
356 pub fn satrush_config(&mut self, satrush_config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
357 self.instruction.satrush_config = Some(satrush_config);
358 self
359 }
360 #[inline(always)]
361 pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
362 self.instruction.system_program = Some(system_program);
363 self
364 }
365 #[inline(always)]
366 pub fn owner_authority(&mut self, owner_authority: Address) -> &mut Self {
367 self.instruction.owner_authority = Some(owner_authority);
368 self
369 }
370 #[inline(always)]
371 pub fn admin_authority(&mut self, admin_authority: Address) -> &mut Self {
372 self.instruction.admin_authority = Some(admin_authority);
373 self
374 }
375 #[inline(always)]
376 pub fn game_authority(&mut self, game_authority: Address) -> &mut Self {
377 self.instruction.game_authority = Some(game_authority);
378 self
379 }
380 #[inline(always)]
381 pub fn fee_recipient(&mut self, fee_recipient: Address) -> &mut Self {
382 self.instruction.fee_recipient = Some(fee_recipient);
383 self
384 }
385 #[inline(always)]
386 pub fn usd_mint(&mut self, usd_mint: Address) -> &mut Self {
387 self.instruction.usd_mint = Some(usd_mint);
388 self
389 }
390 #[inline(always)]
391 pub fn btc_mint(&mut self, btc_mint: Address) -> &mut Self {
392 self.instruction.btc_mint = Some(btc_mint);
393 self
394 }
395 #[inline(always)]
396 pub fn token_mint(&mut self, token_mint: Address) -> &mut Self {
397 self.instruction.token_mint = Some(token_mint);
398 self
399 }
400 #[inline(always)]
402 pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
403 self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
404 self
405 }
406 #[inline(always)]
411 pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
412 self.instruction.__remaining_accounts.extend_from_slice(accounts);
413 self
414 }
415 #[inline(always)]
416 pub fn invoke(&self) -> solana_program_error::ProgramResult {
417 self.invoke_signed(&[])
418 }
419 #[allow(clippy::clone_on_copy)]
420 #[allow(clippy::vec_init_then_push)]
421 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
422 let args = CreateSatrushConfigInstructionArgs {
423 owner_authority: self.instruction.owner_authority.clone().expect("owner_authority is not set"),
424 admin_authority: self.instruction.admin_authority.clone().expect("admin_authority is not set"),
425 game_authority: self.instruction.game_authority.clone().expect("game_authority is not set"),
426 fee_recipient: self.instruction.fee_recipient.clone().expect("fee_recipient is not set"),
427 usd_mint: self.instruction.usd_mint.clone().expect("usd_mint is not set"),
428 btc_mint: self.instruction.btc_mint.clone().expect("btc_mint is not set"),
429 token_mint: self.instruction.token_mint.clone().expect("token_mint is not set"),
430 };
431 let instruction = CreateSatrushConfigCpi {
432 __program: self.instruction.__program,
433
434 authority: self.instruction.authority.expect("authority is not set"),
435
436 satrush_config: self.instruction.satrush_config.expect("satrush_config is not set"),
437
438 system_program: self.instruction.system_program.expect("system_program is not set"),
439 __args: args,
440 };
441 instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
442 }
443}
444
445#[derive(Clone, Debug)]
446struct CreateSatrushConfigCpiBuilderInstruction<'a, 'b> {
447 __program: &'b solana_account_info::AccountInfo<'a>,
448 authority: Option<&'b solana_account_info::AccountInfo<'a>>,
449 satrush_config: Option<&'b solana_account_info::AccountInfo<'a>>,
450 system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
451 owner_authority: Option<Address>,
452 admin_authority: Option<Address>,
453 game_authority: Option<Address>,
454 fee_recipient: Option<Address>,
455 usd_mint: Option<Address>,
456 btc_mint: Option<Address>,
457 token_mint: Option<Address>,
458 __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
460}
461