-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfungible-util.pact
40 lines (35 loc) · 974 Bytes
/
fungible-util.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
(module fungible-util GOVERNANCE
(defcap GOVERNANCE ()
@doc " Give the admin full access to call and upgrade the module. "
(enforce-keyset 'admin-kadena-stake)
)
(defun enforce-valid-amount
( precision:integer
amount:decimal
)
(enforce (> amount 0.0) "Positive non-zero amount")
(enforce-precision precision amount)
)
(defun enforce-valid-account (account:string)
(enforce (> (length account) 2) "minimum account length")
)
(defun enforce-precision
( precision:integer
amount:decimal
)
(enforce
(= (floor amount precision) amount)
"precision violation")
)
(defun enforce-valid-transfer
( sender:string
receiver:string
precision:integer
amount:decimal)
(enforce (!= sender receiver)
"sender cannot be the receiver of a transfer")
(enforce-valid-amount precision amount)
(enforce-valid-account sender)
(enforce-valid-account receiver)
)
)