The code copied from https://docs.daml.com/daml/intro/3_Data.html under the section titled Contract Keys throws this compilation error at the statement:
archiveCmd accountCid
Here is the full code:
module Main where
import Daml.Script
import DA.Assert (assertEq)
data Bank = Bank with
party : Party
address: Text
telephone : Text
deriving (Eq, Show)
template Account
with
accountant : Party
owner : Party
number : Text
bank : Bank
where
signatory accountant
data Cash = Cash with
currency : Text
amount : Decimal
deriving (Eq, Show)
template CashBalance
with
accountant : Party
cash : Cash
account : ContractId Account
where
signatory accountant
setup: Script()
setup = script do
accountant ← allocateParty “Bob”
owner ← allocateParty “Alice”
bank_party ← allocateParty “Bank”
let
bank = Bank with
party = bank_party
address = “High Street”
telephone = “012 3456 789”
cash = Cash with
currency = “USD”
amount = 100.0
accountCid <- submit accountant do
createCmd Account with
accountant
owner
bank
number = "ABC123"
balanceCid <- submit accountant do
createCmd CashBalance with
accountant
cash
account = accountCid
-- Now the accountant updates the telephone number for the bank on the account
Some account <- queryContractId accountant accountCid
new_account <- submit accountant do
archiveCmd accountCid
createCmd account with
bank = account.bank with
telephone = "098 7654 321"
pure ()
-- The `account` field on the balance now refers to the archived
-- contract, so this will fail.
Some balance <- queryContractId accountant balanceCid
optAccount <- queryContractId accountant balance.account
assertEq optAccount None
I made just one little change at the end where I replaced
optAccount === None
with
assertEq optAccount None
Here is the complete error message:
No instance for (Action Commands) arising from a do statement
• In a stmt of a ‘do’ block: archiveCmd accountCid
In the second argument of ‘submit’, namely
‘do archiveCmd accountCid
createCmd
(setField
@“bank”
((setField
@“telephone” (“098 7654 321”) (getField @“bank” account)))
account)
pure ()’
In a stmt of a ‘do’ block:
Will really appreciate some hints in what could I be doing wrong!