Skip to content

Commit

Permalink
Fungible Utilities Contract
Browse files Browse the repository at this point in the history
  • Loading branch information
squiegee authored May 24, 2022
1 parent e16dc9b commit 228ab30
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions fungible-util.pact
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)
)
)

0 comments on commit 228ab30

Please sign in to comment.