Skip to content

Instantly share code, notes, and snippets.

template VacationRequest with
vacation: Vacation
where
signatory [vacation.employee, vacation.company]
observer vacation.boss
choice AcceptRequest: ContractId Vacation
controller vacation.boss
do ...
template Vacation with
employee: Party
boss: Party
company: Party
day: Date
where
signatory [employee, company, boss]
autoApproveTrigger : Trigger ()
autoApproveTrigger = Trigger with
initialize = \_acs -> ()
updateState = \_acs _msg () -> ()
registeredTemplates = AllInDar
rule = autoApproveRule
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
daml trigger --dar=.daml/dist/vacation-trigger-0.0.1.dar --trigger-name=Trigger:autoApproveTrigger --ledger-host=localhost --ledger-port=6865 --ledger-party=Alice
template CurrentPrice
with
itemName: Text
price : Int
operator : Party
where
signatory operator
key (operator, itemName) : (Party, Text)
maintainer key._1
template CurrentPrice
with
itemName: Text
price : Int
operator : Party
reader : Party
where
signatory operator
observer reader
key (operator, itemName) : (Party, Text)
module Main where
import Daml.Script
template T2
with
alice : Party
reader : Party
where
signatory reader
template VehicleProperties
with
operator: Party -- A vehicle is associated to an operator
id: VehicleId -- Vehicle identifier
speed: Decimal
where
signatory operator
observer id.driver -- Driver should be able to see the properties
-- For a given operator, name of the vehicle should be unique
template Vehicle
with
operator: Party
id: VehicleId
lastTsLocation: TsLocation
plan: [RideActionCid] -- List of activities to perform (pickups and drop offs)
where
signatory operator
observer id.driver