格式不除Amount:Decimal

Format does not except Amount:Decimal

我正在编写一份简单的付款合同,并注意到我收到了警告:

We can only analyze calls to format formatting {string,integer,bool} (not amount)

下面是我的代码,我意识到如果我删除代码底部的 amount 参数,我将不再收到警告。有没有办法调整它?

  (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] ))))

)

Pact 属性 检查系统目前不支持格式化小数的分析。你写的例子实际上应该没问题,但如果我们看一下 simple payment example 它包括这一行:(format "{} paid {} {}" [from to amount]),其中 amountdecimal.

如果您需要像这样检查代码的属性,最简单的方法是使用 integer 而不是 decimal,因为我们可以分析整数的格式。

我们目前无法分析应该可以修复的 technical reason 的整数格式。