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