satrush_client/generated/instructions/
close_one_btc_ticket.rs1use borsh::BorshSerialize;
9use borsh::BorshDeserialize;
10
11pub const CLOSE_ONE_BTC_TICKET_DISCRIMINATOR: [u8; 8] = [251, 62, 143, 106, 218, 1, 162, 181];
12
13#[derive(Debug)]
15pub struct CloseOneBtcTicket {
16
17
18 pub authority: solana_address::Address,
19
20
21 pub one_btc_vault_iteration: solana_address::Address,
22
23
24 pub ticket: solana_address::Address,
25 }
26
27impl CloseOneBtcTicket {
28 pub fn instruction(&self) -> solana_instruction::Instruction {
29 self.instruction_with_remaining_accounts(&[])
30 }
31 #[allow(clippy::arithmetic_side_effects)]
32 #[allow(clippy::vec_init_then_push)]
33 pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
34 let mut accounts = Vec::with_capacity(3+ remaining_accounts.len());
35 accounts.push(solana_instruction::AccountMeta::new(
36 self.authority,
37 true
38 ));
39 accounts.push(solana_instruction::AccountMeta::new_readonly(
40 self.one_btc_vault_iteration,
41 false
42 ));
43 accounts.push(solana_instruction::AccountMeta::new(
44 self.ticket,
45 false
46 ));
47 accounts.extend_from_slice(remaining_accounts);
48 let data = CloseOneBtcTicketInstructionData::new().try_to_vec().unwrap();
49
50 solana_instruction::Instruction {
51 program_id: crate::SATRUSH_ID,
52 accounts,
53 data,
54 }
55 }
56}
57
58#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
59 pub struct CloseOneBtcTicketInstructionData {
60 discriminator: [u8; 8],
61 }
62
63impl CloseOneBtcTicketInstructionData {
64 pub fn new() -> Self {
65 Self {
66 discriminator: [251, 62, 143, 106, 218, 1, 162, 181],
67 }
68 }
69
70 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
71 borsh::to_vec(self)
72 }
73 }
74
75impl Default for CloseOneBtcTicketInstructionData {
76 fn default() -> Self {
77 Self::new()
78 }
79}
80
81
82
83#[derive(Clone, Debug, Default)]
91pub struct CloseOneBtcTicketBuilder {
92 authority: Option<solana_address::Address>,
93 one_btc_vault_iteration: Option<solana_address::Address>,
94 ticket: Option<solana_address::Address>,
95 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
96}
97
98impl CloseOneBtcTicketBuilder {
99 pub fn new() -> Self {
100 Self::default()
101 }
102 #[inline(always)]
103 pub fn authority(&mut self, authority: solana_address::Address) -> &mut Self {
104 self.authority = Some(authority);
105 self
106 }
107 #[inline(always)]
108 pub fn one_btc_vault_iteration(&mut self, one_btc_vault_iteration: solana_address::Address) -> &mut Self {
109 self.one_btc_vault_iteration = Some(one_btc_vault_iteration);
110 self
111 }
112 #[inline(always)]
113 pub fn ticket(&mut self, ticket: solana_address::Address) -> &mut Self {
114 self.ticket = Some(ticket);
115 self
116 }
117 #[inline(always)]
119 pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
120 self.__remaining_accounts.push(account);
121 self
122 }
123 #[inline(always)]
125 pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
126 self.__remaining_accounts.extend_from_slice(accounts);
127 self
128 }
129 #[allow(clippy::clone_on_copy)]
130 pub fn instruction(&self) -> solana_instruction::Instruction {
131 let accounts = CloseOneBtcTicket {
132 authority: self.authority.expect("authority is not set"),
133 one_btc_vault_iteration: self.one_btc_vault_iteration.expect("one_btc_vault_iteration is not set"),
134 ticket: self.ticket.expect("ticket is not set"),
135 };
136
137 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
138 }
139}
140
141 pub struct CloseOneBtcTicketCpiAccounts<'a, 'b> {
143
144
145 pub authority: &'b solana_account_info::AccountInfo<'a>,
146
147
148 pub one_btc_vault_iteration: &'b solana_account_info::AccountInfo<'a>,
149
150
151 pub ticket: &'b solana_account_info::AccountInfo<'a>,
152 }
153
154pub struct CloseOneBtcTicketCpi<'a, 'b> {
156 pub __program: &'b solana_account_info::AccountInfo<'a>,
158
159
160 pub authority: &'b solana_account_info::AccountInfo<'a>,
161
162
163 pub one_btc_vault_iteration: &'b solana_account_info::AccountInfo<'a>,
164
165
166 pub ticket: &'b solana_account_info::AccountInfo<'a>,
167 }
168
169impl<'a, 'b> CloseOneBtcTicketCpi<'a, 'b> {
170 pub fn new(
171 program: &'b solana_account_info::AccountInfo<'a>,
172 accounts: CloseOneBtcTicketCpiAccounts<'a, 'b>,
173 ) -> Self {
174 Self {
175 __program: program,
176 authority: accounts.authority,
177 one_btc_vault_iteration: accounts.one_btc_vault_iteration,
178 ticket: accounts.ticket,
179 }
180 }
181 #[inline(always)]
182 pub fn invoke(&self) -> solana_program_error::ProgramResult {
183 self.invoke_signed_with_remaining_accounts(&[], &[])
184 }
185 #[inline(always)]
186 pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
187 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
188 }
189 #[inline(always)]
190 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
191 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
192 }
193 #[allow(clippy::arithmetic_side_effects)]
194 #[allow(clippy::clone_on_copy)]
195 #[allow(clippy::vec_init_then_push)]
196 pub fn invoke_signed_with_remaining_accounts(
197 &self,
198 signers_seeds: &[&[&[u8]]],
199 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
200 ) -> solana_program_error::ProgramResult {
201 let mut accounts = Vec::with_capacity(3+ remaining_accounts.len());
202 accounts.push(solana_instruction::AccountMeta::new(
203 *self.authority.key,
204 true
205 ));
206 accounts.push(solana_instruction::AccountMeta::new_readonly(
207 *self.one_btc_vault_iteration.key,
208 false
209 ));
210 accounts.push(solana_instruction::AccountMeta::new(
211 *self.ticket.key,
212 false
213 ));
214 remaining_accounts.iter().for_each(|remaining_account| {
215 accounts.push(solana_instruction::AccountMeta {
216 pubkey: *remaining_account.0.key,
217 is_signer: remaining_account.1,
218 is_writable: remaining_account.2,
219 })
220 });
221 let data = CloseOneBtcTicketInstructionData::new().try_to_vec().unwrap();
222
223 let instruction = solana_instruction::Instruction {
224 program_id: crate::SATRUSH_ID,
225 accounts,
226 data,
227 };
228 let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len());
229 account_infos.push(self.__program.clone());
230 account_infos.push(self.authority.clone());
231 account_infos.push(self.one_btc_vault_iteration.clone());
232 account_infos.push(self.ticket.clone());
233 remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
234
235 if signers_seeds.is_empty() {
236 solana_cpi::invoke(&instruction, &account_infos)
237 } else {
238 solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
239 }
240 }
241}
242
243#[derive(Clone, Debug)]
251pub struct CloseOneBtcTicketCpiBuilder<'a, 'b> {
252 instruction: Box<CloseOneBtcTicketCpiBuilderInstruction<'a, 'b>>,
253}
254
255impl<'a, 'b> CloseOneBtcTicketCpiBuilder<'a, 'b> {
256 pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
257 let instruction = Box::new(CloseOneBtcTicketCpiBuilderInstruction {
258 __program: program,
259 authority: None,
260 one_btc_vault_iteration: None,
261 ticket: None,
262 __remaining_accounts: Vec::new(),
263 });
264 Self { instruction }
265 }
266 #[inline(always)]
267 pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
268 self.instruction.authority = Some(authority);
269 self
270 }
271 #[inline(always)]
272 pub fn one_btc_vault_iteration(&mut self, one_btc_vault_iteration: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
273 self.instruction.one_btc_vault_iteration = Some(one_btc_vault_iteration);
274 self
275 }
276 #[inline(always)]
277 pub fn ticket(&mut self, ticket: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
278 self.instruction.ticket = Some(ticket);
279 self
280 }
281 #[inline(always)]
283 pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
284 self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
285 self
286 }
287 #[inline(always)]
292 pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
293 self.instruction.__remaining_accounts.extend_from_slice(accounts);
294 self
295 }
296 #[inline(always)]
297 pub fn invoke(&self) -> solana_program_error::ProgramResult {
298 self.invoke_signed(&[])
299 }
300 #[allow(clippy::clone_on_copy)]
301 #[allow(clippy::vec_init_then_push)]
302 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
303 let instruction = CloseOneBtcTicketCpi {
304 __program: self.instruction.__program,
305
306 authority: self.instruction.authority.expect("authority is not set"),
307
308 one_btc_vault_iteration: self.instruction.one_btc_vault_iteration.expect("one_btc_vault_iteration is not set"),
309
310 ticket: self.instruction.ticket.expect("ticket is not set"),
311 };
312 instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
313 }
314}
315
316#[derive(Clone, Debug)]
317struct CloseOneBtcTicketCpiBuilderInstruction<'a, 'b> {
318 __program: &'b solana_account_info::AccountInfo<'a>,
319 authority: Option<&'b solana_account_info::AccountInfo<'a>>,
320 one_btc_vault_iteration: Option<&'b solana_account_info::AccountInfo<'a>>,
321 ticket: Option<&'b solana_account_info::AccountInfo<'a>>,
322 __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
324}
325