-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkip-token-manifest.pact
73 lines (62 loc) · 1.27 KB
/
kip-token-manifest.pact
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
(module token-manifest GOVERNANCE
(defcap GOVERNANCE ()
(enforce-guard (keyset-ref-guard 'marmalade-admin )))
(defschema mf-uri
scheme:string
data:string
)
(defschema mf-datum
uri:object{mf-uri}
hash:string
datum:object
)
(defschema manifest
uri:object{mf-uri}
hash:string
data:[object{mf-datum}]
)
(defun hash-contents:string
( uri:object{mf-uri}
hashes:[string]
)
(hash {'uri: uri, 'data: hashes})
)
(defun create-manifest:object{manifest}
( uri:object{mf-uri}
data:[object{mf-datum}]
)
{ 'uri: uri
, 'hash: (hash-contents uri (map (at 'hash ) data))
, 'data: data
}
)
(defun create-datum:object{mf-datum}
( uri:object{mf-uri}
datum:object
)
{ 'uri: uri
, 'hash: (hash-contents uri [(hash datum)])
, 'datum: datum
}
)
(defun verify-manifest:bool
( manifest:object{manifest}
)
(bind manifest
{ "uri":= uri
, "data":= data
}
(= (create-manifest uri data) manifest)
)
)
(defun enforce-verify-manifest:bool
( manifest:object{manifest}
)
(enforce
(verify-manifest manifest)
"Manifest is not valid")
)
(defun uri (scheme:string data:string)
{'scheme: scheme, 'data: data }
)
)