entropy_api/
sdk.rs

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