-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinstruction.rs
More file actions
112 lines (99 loc) · 2.94 KB
/
Copy pathinstruction.rs
File metadata and controls
112 lines (99 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
use crate::prelude::SerializableAccountMeta;
use crate::steel::*;
use borsh::{BorshDeserialize, BorshSerialize};
use solana_curve25519::ristretto::PodRistrettoPoint;
use solana_curve25519::scalar::PodScalar;
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
pub enum SolanaVrfInstruction {
Initialize = 0,
ModifyOracle = 1,
InitializeOracleQueue = 2,
RequestHighPriorityRandomness = 3,
ProvideRandomness = 4,
DelegateOracleQueue = 5,
CloseOracleQueue = 7,
RequestRandomness = 8,
PurgeExpiredRequests = 9,
RequestRandomnessScoped = 10,
RequestHighPriorityRandomnessScoped = 11,
SetQueuePaused = 12,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Initialize {}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct ModifyOracle {
pub identity: Pubkey,
pub oracle_pubkey: PodRistrettoPoint,
pub operation: u8,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct InitializeOracleQueue {
pub target_size: u32,
pub index: u8,
pub _padding: [u8; 3],
}
impl InitializeOracleQueue {
pub(crate) fn new(index: u8, target_size: u32) -> Self {
Self {
target_size,
index,
_padding: [0; 3],
}
}
}
#[derive(BorshSerialize, BorshDeserialize, Debug, PartialEq, Default)]
pub struct RequestRandomness {
pub caller_seed: [u8; 32],
pub callback_program_id: Pubkey,
pub callback_discriminator: Vec<u8>,
pub callback_accounts_metas: Vec<SerializableAccountMeta>,
pub callback_args: Vec<u8>,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct ProvideRandomness {
pub input: [u8; 32],
pub output: PodRistrettoPoint,
pub commitment_base_compressed: PodRistrettoPoint,
pub commitment_hash_compressed: PodRistrettoPoint,
pub scalar: PodScalar,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct DelegateOracleQueue {
pub index: u8,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct CloseOracleQueue {
pub index: u8,
}
#[repr(C, packed)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct PurgeExpiredRequests {
pub index: u8,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct SetQueuePaused {
pub index: u8,
/// 1 = pause, 0 = unpause; any other value is rejected.
pub paused: u8,
}
instruction8!(SolanaVrfInstruction, Initialize);
instruction8!(SolanaVrfInstruction, ModifyOracle);
instruction8!(SolanaVrfInstruction, InitializeOracleQueue);
instruction8!(SolanaVrfInstruction, ProvideRandomness);
instruction8!(SolanaVrfInstruction, DelegateOracleQueue);
instruction8!(SolanaVrfInstruction, CloseOracleQueue);
instruction8!(SolanaVrfInstruction, PurgeExpiredRequests);
instruction8!(SolanaVrfInstruction, SetQueuePaused);
impl RequestRandomness {
pub fn try_from_bytes(mut bytes: &[u8]) -> Result<Self, std::io::Error> {
Self::deserialize(&mut bytes)
}
}