Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A DAML model showcasing flexible controllers
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
daml 1.2
module FlexibleControllers where
template FeatureAssignment with
employee : Party
sponsor : Party
description : Text
signatory [employee, sponsor]
template FeatureSuggestion with
employee : Party
founders : [Party]
description : Text
signatory employee
observer founders
choice AcceptFeature: ContractId FeatureAssignment with
sponsor : Party
controller sponsor
assert $ elem sponsor founders
create FeatureAssignment with employee, description, sponsor
test = scenario do
drWho <- getParty "Dr Who"
founders@[eric, shaul, yuval] <- mapA getParty ["Eric", "Shaul", "Yuval"]
suggestion <- submit drWho do
create FeatureSuggestion with
employee = drWho
description = "Implement a bill splitting app in DAML"
-- Despite being the CEO, Yuval can't exercise on Shaul's behalf
-- due to a missing authorization.
submitMustFail yuval do
exercise suggestion AcceptFeature with sponsor = shaul
-- Dr. Who can't make themselves the sponsor of their own suggestion
-- because they are not a founder.
submitMustFail drWho do
exercise suggestion AcceptFeature with sponsor = drWho
submit eric do
exercise suggestion AcceptFeature with sponsor = eric
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment