I was writing over a simple payment contract and noticed that I was receiving the warning:
We can only analyze calls to
format
formatting {string,integer,bool} (not amount)
Below is my code, I realized if I remove the amount parameter on the bottom of my code I no longer receive the warning.. is there a way to adjust it?
(defun pay (from:string to:string amount:decimal)
(with-read payments-table from { "balance":= from-bal, "keyset":= keyset }
(enforce-keyset keyset)
(with-read payments-table to { "balance":= to-bal }
(enforce (> amount 0.0) "Negative Transaction Amount")
(enforce (>= from-bal amount) "Insufficient Funds")
(update payments-table from
{ "balance": (- from-bal amount) })
(update payments-table to
{ "balance": (+ to-bal amount) })
(format "{} paid {}" [from to] ))))
)
The Pact property checking system doesn't currently support analysis of formatting decimals. Your example as written should actually be okay, but if we look at the simple payment example it includes this line: (format "{} paid {} {}" [from to amount])
, where amount
is a decimal
.
If you need to check properties of code like this, the easiest way would be to use integer
instead of decimal
, since we can analyze the formatting of integers.
We can't currently analyze formatting of integers for a technical reason that should be fixable.