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 commit provided by Entropy provider.
17    pub commit: [u8; 32],
18
19    /// Whether or not the Entropy provider should automatically sample the slot hash.
20    pub is_auto: u64,
21
22    /// The number of random variables to sample.
23    pub samples: u64,
24
25    /// The slot at which the variable should sample the slothash.
26    pub end_at: u64,
27}
28
29#[repr(C)]
30#[derive(Clone, Copy, Debug, Pod, Zeroable)]
31pub struct Close {}
32
33#[repr(C)]
34#[derive(Clone, Copy, Debug, Pod, Zeroable)]
35pub struct Next {
36    pub end_at: u64,
37}
38
39#[repr(C)]
40#[derive(Clone, Copy, Debug, Pod, Zeroable)]
41pub struct Reveal {
42    pub seed: [u8; 32],
43}
44
45#[repr(C)]
46#[derive(Clone, Copy, Debug, Pod, Zeroable)]
47pub struct Sample {}
48
49instruction!(EntropyInstruction, Open);
50instruction!(EntropyInstruction, Close);
51instruction!(EntropyInstruction, Next);
52instruction!(EntropyInstruction, Reveal);
53instruction!(EntropyInstruction, Sample);