entropy_api/
instruction.rs

1use steel::*;
2
3#[repr(u8)]
4#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
5pub enum EntropyInstruction {
6    Open = 0,
7    Close = 1,
8    Next = 2,
9    Reveal = 4,
10    Sample = 5,
11}
12
13#[repr(C)]
14#[derive(Clone, Copy, Debug, Pod, Zeroable)]
15pub struct Open {
16    /// The id of the variable.
17    pub id: [u8; 8],
18
19    /// The commit provided by Entropy provider.
20    pub commit: [u8; 32],
21
22    /// Whether or not the Entropy provider should automatically sample the slot hash.
23    pub is_auto: [u8; 8],
24
25    /// The number of random variables to sample.
26    pub samples: [u8; 8],
27
28    /// The slot at which the variable should sample the slothash.
29    pub end_at: [u8; 8],
30}
31
32#[repr(C)]
33#[derive(Clone, Copy, Debug, Pod, Zeroable)]
34pub struct Close {}
35
36#[repr(C)]
37#[derive(Clone, Copy, Debug, Pod, Zeroable)]
38pub struct Next {
39    pub end_at: [u8; 8],
40}
41
42#[repr(C)]
43#[derive(Clone, Copy, Debug, Pod, Zeroable)]
44pub struct Reveal {
45    pub seed: [u8; 32],
46}
47
48#[repr(C)]
49#[derive(Clone, Copy, Debug, Pod, Zeroable)]
50pub struct Sample {}
51
52instruction!(EntropyInstruction, Open);
53instruction!(EntropyInstruction, Close);
54instruction!(EntropyInstruction, Next);
55instruction!(EntropyInstruction, Reveal);
56instruction!(EntropyInstruction, Sample);