Skip to content

Instantly share code, notes, and snippets.

View DigitalMarketplace.hs
module Main where
import Daml.Script
template T2
with
alice : Party
reader : Party
where
signatory reader
View CurrentPrice.hs
template CurrentPrice
with
itemName: Text
price : Int
operator : Party
reader : Party
where
signatory operator
observer reader
key (operator, itemName) : (Party, Text)
View CurrentPrice.hs
template CurrentPrice
with
itemName: Text
price : Int
operator : Party
where
signatory operator
key (operator, itemName) : (Party, Text)
maintainer key._1
View runTriggers.txt
daml trigger --dar=.daml/dist/vacation-trigger-0.0.1.dar --trigger-name=Trigger:autoApproveTrigger --ledger-host=localhost --ledger-port=6865 --ledger-party=Alice
View autoApproveRule.daml
autoApproveRule : Party -> ACS -> Map CommandId [Command] -> () -> TriggerA ()
autoApproveRule boss acs _commandsInFlight () = do
let requests : [(ContractId VacationRequest, VacationRequest)] = getContracts @VacationRequest acs
let requestsForMe = filter (\(_, request) -> request.vacation.boss == boss) requests
forA_ requestsForMe $ \(contractId, _) -> do
dedupExercise contractId AcceptRequest
View autoApprove.daml
autoApproveTrigger : Trigger ()
autoApproveTrigger = Trigger with
initialize = \_acs -> ()
updateState = \_acs _msg () -> ()
registeredTemplates = AllInDar
rule = autoApproveRule
View VacationRequest.daml
template VacationRequest with
vacation: Vacation
where
signatory [vacation.employee, vacation.company]
observer vacation.boss
choice AcceptRequest: ContractId Vacation
controller vacation.boss
do ...
View Vacation.daml
template Vacation with
employee: Party
boss: Party
company: Party
day: Date
where
signatory [employee, company, boss]