指定另一份合同的签字人

Specifying a signatory from another contract

在 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