This file contains hidden or 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
preconsuming choice IssueInvites : ContractId Doodle | |
controller organizer | |
do | |
assertMsg "this doodle has been opened for voting, cannot issue any more invites" (not open) | |
DA.Traversable.mapA | |
(\voter -> create DoodleInvite | |
with doodleName = this.name, organizer = this.organizer, voter = voter) | |
voters | |
-- archive self | |
create this with open = True |
This file contains hidden or 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
create this with voters = DA.List.delete elementToDelete voters |
This file contains hidden or 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
do | |
create this with voters = DA.List.delete voter voters |
This file contains hidden or 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
do | |
create this with voters = voter::voters |
This file contains hidden or 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
choice AddVoter : ContractId Doodle | |
with | |
voter: Party | |
controller organizer | |
do | |
assertMsg "this doodle has been opened for voting, cannot add voters" (not open) | |
create this with voters = voter::voters | |
choice RemoveVoter : ContractId Doodle | |
with |
This file contains hidden or 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
where | |
signatory organizer | |
observer voters | |
ensure (unique voters) && (unique options) |
This file contains hidden or 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
where | |
... | |
key (organizer, name): (Party, Text) | |
maintainer (fst key) |
This file contains hidden or 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
template Doodle | |
with | |
name: Text | |
organizer: Party | |
voters: [Party] | |
options: [Text] | |
votes: TextMap VotingSlot | |
open: Bool | |
where | |
signatory organizer |
This file contains hidden or 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
data VotingSlot = VotingSlot | |
with | |
count : Int | |
voted : [Party] | |
deriving (Eq, Show) |
This file contains hidden or 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
test = scenario do | |
user1 <- getParty "User One" | |
user2 <- getParty "User Two" | |
user3 <- getParty "User Three" | |
userContract1 <- user1 `submit` do | |
create User with username = user1, following = [] | |
userContract2 <- user2 `submit` do | |
create User with username = user2, following = [] |