mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 09:17:43 +03:00
Add createAndExercise to the standard library (#3182)
This commit is contained in:
parent
07b75e0008
commit
b568827563
@ -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 {}
|
||||
|
20
compiler/damlc/tests/daml-test-files/CreateAndExercise.daml
Normal file
20
compiler/damlc/tests/daml-test-files/CreateAndExercise.daml
Normal 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
|
@ -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``
|
||||
|
Loading…
Reference in New Issue
Block a user