指定另一份合同的签字人

问题描述

daml,我已经建立了一个 Agent 合同。这是它的向下 Agent.daml 文件。然后我有一个提案合同 (Proposal.daml),我在其中导入了 Agent 模块。我想指定 agentname 是提案合同的签字人,但编译器告诉我不存在这样的一方。

我的 Proposal 合同中没有任何一方,这就是我从另一份合同中选择一方的原因。我不知道如何解决这个问题?

这是代理合同

module Agent where


-- MAIN_TEMPLATE_BEGIN
template Agent with
  agentname: Party
  guarantors: [Party]
where

  signatory agentname
  observer guarantors

这是Proposal合同

module Proposal where

import Agent

-- MAIN_TEMPLATE_BEGIN
template Proposal with

  projectdescription: Text
  unitsrequired: Int
  marketingcost: Int
  distributioncost: Int
  additionalcost: Int

where
  signatory agentname
  observer guarantors

-- MAIN_TEMPLATE_END

     key agentname: Party   
     maintainer key

解决方法

合同的签署人需要可根据合同参数进行计算。您不能通过 ContractId 引用另一个合同并从那里获取它们。原因是其他合同可能被存档,在这种情况下,您突然有一份合同签署人无法阅读。

因此您的 Proposal 必须包含提出建议的代理:

template Proposal with
  agent : Party
  projectdescription: Text
  unitsrequired: Int
  marketingcost: Int
  distributioncost: Int
  additionalcost: Int
where
  signatory agent
  ...

顺便说一句:Party 通常不是人类可读的字符串,因此最好不要将它们用作“名称”。如果您想要一个人类可读的名称,请将 name : Text 字段添加到 Agent

现在您可能想知道:我如何强制约束每个 Proposal 都存在一个 Agent? Daml 论坛上有关于该主题的 long and informative thread

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...