From 228ab306195dbc683211bd93839d32a155142642 Mon Sep 17 00:00:00 2001 From: Squiegee <97313350+squiegee@users.noreply.github.com> Date: Mon, 23 May 2022 20:58:24 -0500 Subject: [PATCH] Fungible Utilities Contract --- fungible-util.pact | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 fungible-util.pact diff --git a/fungible-util.pact b/fungible-util.pact new file mode 100644 index 0000000..3199807 --- /dev/null +++ b/fungible-util.pact @@ -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) + ) +)