-
-
Save cocreature/c8dc3da0b869628d0f9e70aaf432bf00 to your computer and use it in GitHub Desktop.
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
{- | |
-*- mode: haskell;-*- | |
-} | |
module FetchByKey where | |
template TKey | |
with | |
p : Party | |
where | |
signatory p | |
key p : Party | |
maintainer key | |
template Helper | |
with | |
p : Party | |
where | |
signatory p | |
choice FetchKey : (ContractId TKey, TKey) | |
with | |
k : Party | |
controller p | |
do fetchByKey @TKey k | |
template T | |
with | |
p1 : Party | |
p2 : Party | |
where | |
signatory p1 | |
observer p2 | |
nonconsuming choice C : (ContractId TKey, TKey) | |
with | |
k : Party | |
controller p2 | |
do createAndExercise (Helper p1) (FetchKey k) | |
test = do | |
p1 <- getParty "p1" | |
p2 <- getParty "p2" | |
submit p1 (create (TKey p1)) | |
submit p2 (create (TKey p2)) | |
cid <- submit p1 (create (T p1 p2)) | |
-- submitter p2 is not a stakeholder | |
submitMustFail p2 (exercise cid (C p1)) | |
-- submitter p2 is a stakeholder but we only have authorization from p1 | |
submitMustFail p2 (exercise cid (C p2)) | |
pure () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment