DAMLe Error: Error(mismatching type: Contract and value: ValueUnit)

DAMLe Error: Error(mismatching type: Contract and value: ValueUnit)

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 分类帐 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}"

"No input" 对于 DAML 中的选择表示为没有字段的记录类型;该记录类型在您的示例中被命名为 ApproveScore

我不知道 Python API 的细节,但是对于它应该是什么样子,我会说,想象一下你的选择 做了 有一些意见,围绕这些论点的脚手架会是什么样子?然后只需删除参数,将脚手架(即空记录构造)留在原地。

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

旧版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 的参与。