0
I am trying to exercise a multi-party contract through Python ledger API. The DAML contract code as below,

**DAML Contract code which causes this issue:**
-- verification multi-party agreement block
controller Agent1 can
  ApproveScore : ContractId PendingContract 
    do create this with Agent1 = Agent2

执行合约的 Ledger API 代码如下,

执行此合约的 Python Ledger API 代码:

approve_exercise_command = ExerciseCommand(
   template_id = Identifier(
      package_id = self.package_id,name = PENDING_CONTRACT
    ),
    contract_id = event.created.contract_id,
    choice = APPROVE_CHOICE,
    choice_argument = Value(unit = Empty())
  )
  approve_score_command = Command(exercise = approve_exercise_command)

**Error details:**

    status = StatusCode.INVALID_ARGUMENT
        details = "DAMLe Error: Error(mismatching type: ApproveScore and value: ValueUnit)"
        debug_error_string = "{"created":"@1553510346.703290741","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1039,"grpc_message":"DAMLe Error: Error(mismatching type: ApproveScore and value: ValueUnit)","grpc_status":3}"
4

2 回答 2

0

DAML 中选择的“无输入”表示为没有字段的记录类型;该记录类型ApproveScore在您的示例中命名。

我不详细了解 Python API,但是对于它应该是什么样子,我想说,假设您的选择确实有一些输入,围绕这些参数的脚手架会是什么样子?然后只需删除参数,将脚手架(即空记录构造)留在原处。

于 2019-03-25T14:30:35.763 回答
0

最后,我们在 DA 团队的帮助下解决了这个问题。问题是我使用 Empty 传递空参数。使用 DA 的最新 SDK 版本,我们将必须传递如下所示的空参数。

在旧的SDK版本中选择传递空参数,

choice_argument = Value(unit = Empty())

在新的 SDK 版本中使用如下所示,

 choice_argument = Value(
        record = Record(
         record_id = Identifier(
         package_id = self.package_id,
         name= "Main.ApproveScore"
        ),
       fields = [])
    )

谢谢,Stephen Compall 加入。

于 2019-03-28T04:24:52.053 回答