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
| 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
| 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
| 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
| 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
| 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
| 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
| public static <T, R> List<R> mapA(Function<T,R> function, List<T> list) { | |
| return list.stream().map(t -> function.apply(t)).collect(Collectors.toList()); | |
| } |
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 DoodleInvite | |
| with | |
| doodleName: Text | |
| organizer: Party | |
| voter: Party | |
| where | |
| signatory organizer | |
| observer voter | |
| key (organizer, voter, doodleName) : (Party, Party, Text) | |
| maintainer key._1 |
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
| nonconsuming choice Vote : ContractId Doodle | |
| with | |
| option: Text | |
| controller voter | |
| do | |
| doodleContractId <- lookupByKey @Doodle (organizer, doodleName) | |
| doodleContract <- fetch (fromSome doodleContractId) | |
| assertMsg "this party does not own the doodle " (organizer == doodleContract.organizer) | |
| exercise (fromSome doodleContractId) CastVote with voter = this.voter, option = option, inviteId = self |