Add createAndExercise to the standard library (#3182)

This commit is contained in:
Moritz Kiefer 2019-10-15 15:03:25 +02:00 committed by GitHub
parent 07b75e0008
commit b568827563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View File

@ -110,6 +110,12 @@ exerciseByKey k c = do
(cid, _) <- fetchByKey @t k
exercise cid c
-- | Create a contract and exercise the choice on the newly created contract.
createAndExercise : forall t k c r. Choice t c r => t -> c -> Update r
createAndExercise t c = do
cid <- create t
exercise cid c
data NonConsuming t = NonConsuming {}
data PreConsuming t = PreConsuming {}
data PostConsuming t = PostConsuming {}

View File

@ -0,0 +1,20 @@
-- Copyright (c) 2019, Digital Asset (Switzerland) GmbH and/or its affiliates.
-- All rights reserved.
daml 1.2 module CreateAndExercise where
import DA.Assert
template T1
with
p : Party
where
signatory p
choice C1 : Int
controller p
do pure 42
main = scenario do
alice <- getParty "Alice"
r <- alice `submit` createAndExercise (T1 alice) C1
r === 42

View File

@ -34,3 +34,4 @@ HEAD — ongoing
- `com.digitalasset.daml-lf-archive` becomes `com.digitalasset:daml-lf-dev-archive-java-proto`
- `com.digitalasset.daml-lf-archive-scala` becomes `com.digitalasset.daml-lf-archive-reader`
-[Sandbox] Filter contracts or contracts keys in the database query for parties that cannot see them.
+ [DAML Standard Library] Add ``createAndExercise``