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