psibase/services/evaluations.rs
1#[crate::service(
2 name = "eval-hooks",
3 actions = "hooks_actions",
4 wrapper = "hooks_wrapper",
5 structs = "hooks_structs",
6 dispatch = false,
7 pub_constant = false,
8 psibase_mod = "crate"
9)]
10#[allow(non_snake_case, unused_variables)]
11pub mod Hooks {
12 use crate::AccountNumber;
13
14 #[action]
15 fn on_ev_reg(evaluation_id: u32, account: AccountNumber) {
16 unimplemented!()
17 }
18
19 #[action]
20 fn on_ev_unreg(evaluation_id: u32, account: AccountNumber) {
21 unimplemented!()
22 }
23
24 #[action]
25 fn on_grp_fin(evaluation_id: u32, group_number: u32, result: Vec<u8>) {
26 unimplemented!()
27 }
28
29 #[action]
30 fn on_attest(evaluation_id: u32, group_number: u32, user: AccountNumber, attestation: Vec<u8>) {
31 unimplemented!()
32 }
33
34 #[action]
35 fn on_eval_fin(evaluation_id: u32) {
36 unimplemented!()
37 }
38}
39
40#[crate::service(name = "evaluations", dispatch = false, psibase_mod = "crate")]
41#[allow(non_snake_case, unused_variables)]
42pub mod Service {
43 use crate::AccountNumber;
44
45 /// Creates and schedules a new evaluation with specified phases and parameters.
46 ///
47 /// # Arguments
48 /// * `registration` - Unix seconds timestamp for the start of the registration phase.
49 /// * `deliberation` - Unix seconds timestamp for the start of the deliberation phase.
50 /// * `submission` - Unix seconds timestamp for the start of the submission phase.
51 /// * `finish_by` - Unix seconds timestamp for the start of the evaluation completion phase.
52 /// * `allowed_group_sizes` - Vector of allowed group sizes (sizes must be greater than 0, traditionally [4, 5, 6]).
53 /// * `num_options` - Number of options available for proposals (traditionally 6).
54 /// * `use_hooks` - Flag to enable or disable hooks for the evaluation.
55 ///
56 /// # Returns
57 /// The ID of the newly created evaluation.
58 #[action]
59 fn create(
60 registration: u32,
61 deliberation: u32,
62 submission: u32,
63 finish_by: u32,
64 allowed_group_sizes: Vec<u8>,
65 num_options: u8,
66 use_hooks: bool,
67 ) -> u32 {
68 unimplemented!()
69 }
70
71 /// Starts an evaluation, sorting registrants into groups and enabling proposal submission.
72 ///
73 /// # Arguments
74 /// * `evaluation_id` - The ID of the evaluation to start.
75 #[action]
76 fn start(evaluation_id: u32) {
77 unimplemented!()
78 }
79
80 /// Sets the public key for the user to receive the symmetric key.
81 ///
82 /// # Arguments
83 /// * `key` - The public key to be set for the user.
84 #[action]
85 fn set_key(key: Vec<u8>) {
86 unimplemented!()
87 }
88
89 /// Sets the symmetric key for a group during the deliberation phase, callable only once by any group member
90 ///
91 /// # Arguments
92 /// * `owner` - The account number of the evaluation owner.
93 /// * `evaluation_id` - The ID of the evaluation.
94 /// * `keys` - Vector of keys to set for the group.
95 /// * `hash` - Hash of the keys for verification.
96 #[action]
97 fn group_key(owner: AccountNumber, evaluation_id: u32, keys: Vec<Vec<u8>>, hash: String) {
98 unimplemented!()
99 }
100
101 /// Closes an evaluation and deletes its groups.
102 ///
103 /// # Arguments
104 /// * `evaluation_id` - The ID of the evaluation to close.
105 #[action]
106 fn close(owner: AccountNumber, evaluation_id: u32) {
107 unimplemented!()
108 }
109
110 /// Deletes an evaluation, optionally forcing deletion.
111 ///
112 /// # Arguments
113 /// * `evaluation_id` - The ID of the evaluation to delete.
114 /// * `force` - If true, allows deletion regardless of the evaluation's phase.
115 #[action]
116 fn delete(evaluation_id: u32, force: bool) {
117 unimplemented!()
118 }
119
120 /// Submits an encrypted proposal for a user in a group.
121 ///
122 /// # Arguments
123 /// * `owner` - The account number of the evaluation owner.
124 /// * `evaluation_id` - The ID of the evaluation.
125 /// * `proposal` - The encrypted proposal data.
126 #[action]
127 fn propose(owner: AccountNumber, evaluation_id: u32, proposal: Vec<u8>) {
128 unimplemented!()
129 }
130
131 /// Submits an attestation for decrypted proposals, potentially triggering group result declaration.
132 ///
133 /// # Arguments
134 /// * `owner` - The account number of the evaluation owner.
135 /// * `evaluation_id` - The ID of the evaluation.
136 /// * `attestation` - The attestation data containing ranks.
137 #[action]
138 fn attest(owner: AccountNumber, evaluation_id: u32, attestation: Vec<u8>) {
139 unimplemented!()
140 }
141
142 /// Registers a user for an evaluation during the registration phase.
143 ///
144 /// # Arguments
145 /// * `owner` - The account number of the evaluation owner.
146 /// * `evaluation_id` - The ID of the evaluation.
147 /// * `registrant` - The account number of the user to register.
148 #[action]
149 fn register(owner: AccountNumber, evaluation_id: u32, registrant: AccountNumber) {
150 unimplemented!()
151 }
152
153 /// Unregisters a user from an evaluation during the registration phase.
154 ///
155 /// # Arguments
156 /// * `owner` - The account number of the evaluation owner.
157 /// * `evaluation_id` - The ID of the evaluation.
158 /// * `registrant` - The account number of the user to unregister.
159 #[action]
160 fn unregister(owner: AccountNumber, evaluation_id: u32, registrant: AccountNumber) {
161 unimplemented!()
162 }
163
164 #[event(history)]
165 pub fn keysset(
166 owner: AccountNumber,
167 evaluation_id: u32,
168 group_number: u32,
169 keys: Vec<Vec<u8>>,
170 hash: String,
171 ) {
172 }
173
174 #[event(history)]
175 pub fn evaluation_created(owner: AccountNumber, evaluation_id: u32) {}
176
177 #[event(history)]
178 pub fn evaluation_finished(owner: AccountNumber, evaluation_id: u32) {}
179
180 #[event(history)]
181 pub fn group_fin(
182 owner: AccountNumber,
183 evaluation_id: u32,
184 group_number: u32,
185 users: Vec<AccountNumber>,
186 result: Vec<u8>,
187 ) {
188 }
189
190 #[event(history)]
191 pub fn evaluation_start(owner: AccountNumber, evaluation_id: u32) {}
192
193 #[event(history)]
194 pub fn new_group(
195 owner: AccountNumber,
196 evaluation_id: u32,
197 group_number: u32,
198 users: Vec<AccountNumber>,
199 ) {
200 }
201}
202
203#[test]
204fn verify_schema() {
205 crate::assert_schema_matches_package::<Wrapper>();
206}