-
Notifications
You must be signed in to change notification settings - Fork 17
/
non-fungible-policy-v1.pact
92 lines (76 loc) · 1.97 KB
/
non-fungible-policy-v1.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
(namespace (read-string 'ns))
(module non-fungible-policy-v1 GOVERNANCE
@doc "Concrete policy for issuing an nft with a fixed supply of 1 and precision of 0"
(defconst ADMIN-KS:string "marmalade-v2.marmalade-contract-admin")
(defconst POLICY:string (format "{}" [non-fungible-policy-v1]))
(defcap GOVERNANCE ()
(enforce-guard ADMIN-KS))
(implements kip.token-policy-v2)
(implements kip.updatable-uri-policy-v1)
(use marmalade-v2.policy-manager)
(use kip.token-policy-v2 [token-info])
(defun enforce-init:bool
( token:object{token-info}
)
(require-capability (INIT-CALL (at "id" token) (at "precision" token) (at "uri" token) POLICY))
(enforce (= 0 (at 'precision token)) "Precision must be 0")
true
)
(defun enforce-mint:bool
( token:object{token-info}
account:string
guard:guard
amount:decimal
)
(require-capability (MINT-CALL (at "id" token) account amount POLICY))
(enforce (= amount 1.0) "Mint can only be 1")
(enforce (= (at 'supply token) 0.0) "Only one mint allowed")
)
(defun enforce-burn:bool
( token:object{token-info}
account:string
amount:decimal
)
(enforce false "Burn prohibited")
)
(defun enforce-offer:bool
( token:object{token-info}
seller:string
amount:decimal
timeout:integer
sale-id:string
)
true
)
(defun enforce-buy:bool
( token:object{token-info}
seller:string
buyer:string
buyer-guard:guard
amount:decimal
sale-id:string )
true
)
(defun enforce-withdraw:bool
( token:object{token-info}
seller:string
amount:decimal
timeout:integer
sale-id:string )
true
)
(defun enforce-transfer:bool
( token:object{token-info}
sender:string
guard:guard
receiver:string
amount:decimal )
true
)
(defun enforce-update-uri:bool
( token:object{token-info}
new-uri:string )
true
)
)
(enforce-guard ADMIN-KS)