在DAML中,当选择可能导致创建不同的新合同时返回的内容

时间:2019-06-11 00:48:48

标签: daml

在DAML中,如果我有一个称为“提交”的选择,则它可能导致新合同的认可请求或拒绝请求。我应该如何管理选择中的返回值?

template Request
  with 
    content : Text
    anyone : Party
  where 
    signatory anyone

--what to return ? ApprovedRequest or RejectedRequest
    controller anyone can 
      Submit : ContractId ApprovedRequest
        do
          -- passed all the checks and approved
          create ApprovedRequest with request = Request 


1 个答案:

答案 0 :(得分:1)

也许Maybe (ContractId ApprovedRequest)将在这里工作?或者,也许Either (ContractId RejectedRequest, ContractId ApprovedRequest)