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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
pub mod constants;
pub mod distribute;
pub mod weighted_normalization;
use crate::abort_message;
#[crate::service(
name = "eval-hooks",
actions = "hooks_actions",
wrapper = "hooks_wrapper",
structs = "hooks_structs",
dispatch = false,
pub_constant = false,
psibase_mod = "crate"
)]
#[allow(non_snake_case, unused_variables)]
pub mod Hooks {
use crate::AccountNumber;
#[action]
fn on_ev_reg(evaluation_id: u32, account: AccountNumber) {
unimplemented!()
}
#[action]
fn on_ev_unreg(evaluation_id: u32, account: AccountNumber) {
unimplemented!()
}
#[action]
fn on_grp_fin(evaluation_id: u32, group_number: u32, result: Vec<u8>) {
unimplemented!()
}
#[action]
fn on_attest(evaluation_id: u32, group_number: u32, user: AccountNumber, attestation: Vec<u8>) {
unimplemented!()
}
#[action]
fn on_eval_fin(evaluation_id: u32) {
unimplemented!()
}
}
#[crate::service(
name = "occupation",
actions = "occu_actions",
wrapper = "occu_wrapper",
structs = "occu_structs",
dispatch = false,
pub_constant = false,
psibase_mod = "crate"
)]
#[allow(non_snake_case, unused_variables)]
pub mod Occupation {
use crate::{services::auth_dyn, AccountNumber};
/// Get scores for a fractal
///
/// Returns a vector of accounts and their corresponding scores for a fractal.
/// Scores are PPM shares (parts per million) and must not sum to more than 1,000,000.
/// These scores are used by the Fractals service to determine distribution amounts for each member.
///
/// # Arguments
/// * `fractal` - The account of the fractal.
#[action]
fn get_scores(fractal: AccountNumber) -> Vec<(AccountNumber, u32)> {
unimplemented!()
}
/// Check if an account is considered active in an occupation
///
/// # Arguments
/// * `fractal` - The account of the fractal.
/// * `member` - The member account to check.
#[action]
fn is_active(fractal: AccountNumber, member: AccountNumber) -> bool {
unimplemented!()
}
/// Check if a role ID is supported for a fractal.
///
/// Returning false will cause the Fractals service to reject changing a role to this occupation.
///
/// # Arguments
/// * `fractal` - The account number of the fractal.
/// * `role_id` - Role ID to check.
#[action]
fn is_role_ok(fractal: AccountNumber, role_id: u8) -> bool {
unimplemented!()
}
/// Get policy action used by AuthDyn service.
///
/// Returns authorisers for a given role in a fractal.
///
/// # Arguments
/// * `fractal` - The account of the fractal.
/// * `role_id` - The role ID to check.
#[action]
fn role_policy(fractal: AccountNumber, role_id: u8) -> auth_dyn::policy::DynamicAuthPolicy {
unimplemented!()
}
}
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum FractalRole {
Legislature = 1,
Judiciary = 2,
Executive = 3,
Recruitment = 4,
}
impl From<u8> for FractalRole {
fn from(value: u8) -> Self {
match value {
1 => FractalRole::Legislature,
2 => FractalRole::Judiciary,
3 => FractalRole::Executive,
4 => FractalRole::Recruitment,
_ => abort_message(&format!("Invalid FractalRole value: {}", value)),
}
}
}
impl From<FractalRole> for u8 {
fn from(value: FractalRole) -> Self {
value as u8
}
}
#[crate::service(name = "fractals", dispatch = false, psibase_mod = "crate")]
#[allow(non_snake_case, unused_variables)]
pub mod Service {
use crate::services::auth_dyn::policy::DynamicAuthPolicy;
use crate::services::transact::ServiceMethod;
use crate::AccountNumber;
/// Creates a new account and fractal.
///
/// # Arguments
/// * `fractal_account` - The account number for the new fractal.
/// * `legislature` - Legislature role account.
/// * `judiciary` - Judiciary role account.
/// * `executive` - Executive role account
/// * `recruitment` - Recruitment role account.
/// * `name` - The name of the fractal.
/// * `mission` - The mission statement of the fractal.
#[action]
fn create_frac(
fractal_account: AccountNumber,
legislature: AccountNumber,
judiciary: AccountNumber,
executive: AccountNumber,
recruitment: AccountNumber,
name: String,
mission: String,
) {
unimplemented!()
}
/// Add fractal member
///
/// Adds an account to a fractal.
///
/// # Arguments
/// * `member` - Account to be added as a member
/// * `recruiter` - Account of the fractal member that recruited this new member, if applicable.
#[action]
fn add_mem(member: AccountNumber, recruiter: Option<AccountNumber>) {
unimplemented!()
}
/// Claim member rewards
///
/// Sends any vested token rewards to the fractal member after applying any pending levies.
///
/// # Arguments
/// * `fractal` - The account number of the fractal.
/// * `member` - The fractal member claiming rewards.
#[action]
fn claim_rew(fractal: AccountNumber, member: AccountNumber) {
unimplemented!()
}
/// Set genesis time for a fractal
///
/// Genesis time sets the starting point of when fractal token rewards can be claimed.
/// Subsequent claims are according to the distribution interval set for the fractal.
///
/// # Arguments
/// * `genesis_time` - New genesis time for the fractal.
#[action]
fn set_gen_time(genesis_time: u64) {
unimplemented!()
}
/// Check if an account is a member of a fractal.
///
/// # Arguments
/// * `fractal` - The account number of the fractal.
/// * `member` - The account to check.
#[action]
fn is_member(fractal: AccountNumber, member: AccountNumber) -> bool {
unimplemented!()
}
/// Set ordered occupations
///
/// Payment for each ordered occupation will be according to the fractals payment strategy.
///
/// # Arguments
/// * `paid_occupations` - Ordered occupations to set for the fractal
#[action]
fn set_paid_occ(paid_occupations: Vec<AccountNumber>) {
unimplemented!()
}
/// Set Fractal distribution interval
///
/// Used in conjunction with genesis time to determine when fractal token distribution can be triggered.
///
/// # Arguments
/// * `distribution_interval_secs` - New fractal distribution interval in seconds.
#[action]
fn set_dist_int(distribution_interval_secs: u32) {
unimplemented!()
}
/// Exile a fractal member.
///
/// # Arguments
/// * `member` - The fractal member to be exiled.
#[action]
fn exile_member(member: AccountNumber) {
unimplemented!()
}
/// Sets the occupation used to authorize the specified fractal role.
///
/// # Arguments
/// * `role_id` - Role ID for fractal
/// * `new_occupation` - New occupation to set for role
#[action]
fn set_r_occ(role_id: u8, new_occupation: AccountNumber) {
unimplemented!()
}
/// Set distribution strategy
///
/// # Arguments
/// * `distribution_strategy` - Algorithm for weighted distribution.
#[action]
fn set_dstrat(distribution_strategy: u8) {
unimplemented!()
}
/// Get policy action used by AuthDyn service.
///
/// # Arguments
/// * `account` - Account being checked.
/// * `method` - Optional method being checked.
#[action]
fn get_policy(account: AccountNumber, method: Option<ServiceMethod>) -> DynamicAuthPolicy {
unimplemented!()
}
/// Has policy action used by AuthDyn service.
///
/// # Arguments
/// * `account` - Account being checked.
#[action]
fn has_policy(account: AccountNumber) -> bool {
unimplemented!()
}
/// Distribute token for a fractal.
#[action]
fn dist_token(fractal: AccountNumber) {
unimplemented!()
}
/// Initialise a token for a fractal.
///
/// Called only once per fractal.
/// Must be called by fractal.
#[action]
fn init_token() {
unimplemented!()
}
#[event(history)]
pub fn created_fractal(fractal_account: AccountNumber) {}
#[event(history)]
pub fn joined_fractal(fractal_account: AccountNumber, account: AccountNumber) {}
}
#[test]
fn verify_schema() {
crate::assert_schema_matches_package::<Wrapper>();
}