1use steel::*;
2
3use crate::prelude::*;
4
5pub fn open(
6 signer: Pubkey,
7 payer: Pubkey,
8 id: u64,
9 provider: Pubkey,
10 commit: [u8; 32],
11 is_auto: bool,
12 samples: u64,
13 end_at: u64,
14) -> Instruction {
15 Instruction {
16 program_id: crate::ID,
17 accounts: vec![
18 AccountMeta::new(signer, true),
19 AccountMeta::new(payer, true),
20 AccountMeta::new(provider, false),
21 AccountMeta::new(var_pda(signer, id).0, false),
22 AccountMeta::new_readonly(system_program::ID, false),
23 ],
24 data: Open {
25 id: id.to_le_bytes(),
26 is_auto: (is_auto as u64).to_le_bytes(),
27 commit,
28 samples: samples.to_le_bytes(),
29 end_at: end_at.to_le_bytes(),
30 }
31 .to_bytes(),
32 }
33}
34
35pub fn next(signer: Pubkey, var: Pubkey, end_at: u64) -> Instruction {
36 Instruction {
37 program_id: crate::ID,
38 accounts: vec![AccountMeta::new(signer, true), AccountMeta::new(var, false)],
39 data: Next {
40 end_at: end_at.to_le_bytes(),
41 }
42 .to_bytes(),
43 }
44}
45
46pub fn update(signer: Pubkey, var: Pubkey, end_at: u64) -> Instruction {
47 Instruction {
48 program_id: crate::ID,
49 accounts: vec![AccountMeta::new(signer, true), AccountMeta::new(var, false)],
50 data: Update {
51 end_at: end_at.to_le_bytes(),
52 }
53 .to_bytes(),
54 }
55}
56
57pub fn reveal(signer: Pubkey, var: Pubkey, seed: [u8; 32]) -> Instruction {
58 Instruction {
59 program_id: crate::ID,
60 accounts: vec![AccountMeta::new(signer, true), AccountMeta::new(var, false)],
61 data: Reveal { seed }.to_bytes(),
62 }
63}
64
65pub fn sample(signer: Pubkey, var: Pubkey) -> Instruction {
66 Instruction {
67 program_id: crate::ID,
68 accounts: vec![
69 AccountMeta::new(signer, true),
70 AccountMeta::new(var, false),
71 AccountMeta::new_readonly(sysvar::slot_hashes::ID, false),
72 ],
73 data: Sample {}.to_bytes(),
74 }
75}