Hello! I’m receiving an error when I attempt to run daml start
in the interactive Terminal for the exercise (page 5) of the Automation with Daml Triggers tutorial.
Here’s the error:
$ daml start
Compiling market to a DAR.
File: daml/Market.daml
Hidden: no
Range: 109:30-109:33
Source: typecheck
Severity: DsError
Message: daml/Market.daml:109:30: error:Not in scope: type constructor or class ‘ACS’
ERROR: Creation of DAR file failed.
daml-helper: Received ExitFailure 1 when running
Shell command: /root/.daml/bin/daml build
I’ve tried messing with the indentation but that triggers another error. What am I missing?
Here’s the code that I copied into the browser IDE:
module Market where
import DA.Date
import Daml.Trigger
import DA.Next.Map
import DA.Foldable(forA_)
template User
with
party : Party
where
signatory party
key party : Party
maintainer key
nonconsuming choice NewSellOffer : ()
with
observers : [Party]
title : Text
description : Text
price : Int
controller party
do
now <- getTime
create $ SellOffer {seller = party, date = toDateUTC now, ..}
pure ()
nonconsuming choice TakeSellOffer : ()
with
offer : ContractId SellOffer
controller party
do
exercise offer DoTrade with tradePartner = party
pure ()
nonconsuming choice ConfirmPayment : ()
with
invoice : ContractId Invoice
controller party
do
Invoice{..} <- fetch invoice
assert $ owner == party
create $ PaymentConfirmation
with
invoice = invoice
party = party
obligor = obligor
pure ()
template SellOffer
with
observers : [Party]
title : Text
description : Text
price : Int
seller : Party
date : Date
where
signatory seller
observer observers
nonconsuming choice DoTrade : ()
with
tradePartner : Party
controller tradePartner
do
assert $ tradePartner `elem` observers
archive self
create $ Invoice {owner = seller, obligor = tradePartner, amount = price, description = title}
pure ()
template Invoice
with
owner : Party
obligor : Party
amount : Int
description : Text
where
signatory obligor
observer owner
template PaymentConfirmation
with
invoice : ContractId Invoice
party : Party
obligor : Party
where
signatory party
observer obligor
nonconsuming choice ArchiveInvoice : ()
controller obligor
do
archive invoice
archive self
deleteInvoiceTrigger : Trigger ()
deleteInvoiceTrigger = Trigger
{ initialize = const ()
, updateState = \_acs _message () -> ()
, rule = deleteInvoiceRule
, registeredTemplates = RegisteredTemplates
[ registeredTemplate @Invoice
, registeredTemplate @PaymentConfirmation
]
, heartbeat = None
}
deleteInvoiceRule : Party -> ACS -> Time -> Map CommandId [Command] -> () -> TriggerA ()
deleteInvoiceRule party acs _t commandsInFlight () = do
let invoices = getContracts @Invoice acs
let confirmations = getContracts @PaymentConfirmation acs
let ready = do
(confirmationCid, PaymentConfirmation{invoice, obligor}) <- confirmations
(invoiceCid, Invoice{}) <- invoices
guard $ invoiceCid == invoice
guard $ party == obligor
pure confirmationCid
forA_ ready $ \confirmationCid -> dedupExercise confirmationCid ArchiveInvoice