This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template Vacation with | |
employee: Party | |
boss: Party | |
company: Party | |
day: Date | |
where | |
signatory [employee, company, boss] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template VacationRequest with | |
vacation: Vacation | |
where | |
signatory [vacation.employee, vacation.company] | |
observer vacation.boss | |
choice AcceptRequest: ContractId Vacation | |
controller vacation.boss | |
do ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autoApproveTrigger : Trigger () | |
autoApproveTrigger = Trigger with | |
initialize = \_acs -> () | |
updateState = \_acs _msg () -> () | |
registeredTemplates = AllInDar | |
rule = autoApproveRule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
daml trigger --dar=.daml/dist/vacation-trigger-0.0.1.dar --trigger-name=Trigger:autoApproveTrigger --ledger-host=localhost --ledger-port=6865 --ledger-party=Alice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template CurrentPrice | |
with | |
itemName: Text | |
price : Int | |
operator : Party | |
where | |
signatory operator | |
key (operator, itemName) : (Party, Text) | |
maintainer key._1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template CurrentPrice | |
with | |
itemName: Text | |
price : Int | |
operator : Party | |
reader : Party | |
where | |
signatory operator | |
observer reader | |
key (operator, itemName) : (Party, Text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Daml.Script | |
template T2 | |
with | |
alice : Party | |
reader : Party | |
where | |
signatory reader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
OlderNewer