M below, traditionally I would have
o as an observer on
M so that either
s could exercise
AddSecret. But in one case I left it out.
template M with s : Party o : Party secrets : [Text] where signatory s choice AddSecret : ContractId M with actor : Party secret : Text controller actor do create this with secrets = secret :: filter (/= secret) secrets test : Script () test = do let secret = "S's secret only" [s,o] <- forA ["s", "o"] allocateParty mId <- s `submit` do createCmd M with secrets = , .. -- o is not an observer, so can't be a controller via flexible controllers o `submitMustFail` do exerciseCmd mId AddSecret with actor = o, .. mId2 <- s `submit` do exerciseCmd mId AddSecret with actor = s, .. pure ()
But what happens if
o is a witness to the creation of
M (via a request for example).
template Mr with s : Party o : Party where signatory s controller o can CreateM : ContractId M do create M with secrets = , .. test2: Script () test2 = do let secret = "O can add a secret" [s,o] <- forA ["s", "o"] allocateParty mr <- s `submit` do createCmd Mr with .. mId <- o `submit` do exerciseCmd mr CreateM -- should o be able to submit this? mId2 <- o `submit` do exerciseCmd mId AddSecret with actor = o, .. pure ()