This repository has been archived by the owner on Oct 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessFlows.sqnc
69 lines (62 loc) · 1.76 KB
/
processFlows.sqnc
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
/*
* ------------------
* Token Declarations
* ------------------
*
* Note that `token`s define formats that should be persisted in transitions.
* Fields can be of type Role, File, Literal, a specific literal, a token type
* or a union of any of these
*/
token InitiatedCert {
hydrogen_owner: Role,
energy_owner: Role,
regulator: Role,
hydrogen_quantity_wh: Literal,
commitment: Literal,
}
token IssuedCert {
hydrogen_owner: Role,
energy_owner: Role,
regulator: Role,
embodied_co2: Literal,
}
token RevokedCert {
hydrogen_owner: Role,
energy_owner: Role,
regulator: Role,
reason: File,
}
/*
* ---------------------
* Function Declarations
* ---------------------
*
* Note that `fn`s define process flow restrictions and consist of a set of
* inputs, a set of outputs and a set of additional conditions.
* public `fn` will be published as a process flow (`fn`s can also be private)
*/
pub fn initiate_cert || => |output: InitiatedCert| where {
output.hydrogen_owner == sender,
output.energy_owner != sender,
output.regulator != sender,
}
pub fn issue_cert |input: InitiatedCert| => |output: IssuedCert| where {
output == input,
input.hydrogen_owner == output.hydrogen_owner,
input.energy_owner == output.energy_owner,
input.regulator == output.regulator,
input.energy_owner != output.regulator,
output.hydrogen_owner != sender,
output.regulator != sender,
output.energy_owner == sender,
}
pub fn revoke_cert |input: IssuedCert| => |output: RevokedCert| where {
output == input,
input.hydrogen_owner == output.hydrogen_owner,
input.energy_owner == output.energy_owner,
input.regulator == output.regulator,
output.energy_owner != sender,
output.hydrogen_owner != sender,
output.regulator == sender,
output.reason: File
}