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}"
答案 0 :(得分:0)
DAML中用于选择的“无输入”表示为没有字段的记录类型;在您的示例中,该记录类型被命名为ApproveScore
。
我不了解Python API的详细信息,但我想说的是,假设您的选择 did 有一些输入,围绕这些参数的脚手架会是什么样子喜欢?然后只需删除自变量,即可将支架(即空记录构造)保留在原处。
答案 1 :(得分:0)
最后,我们在DA团队的帮助下找出了问题所在。问题是我使用Empty传递了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的加入。