Created
February 28, 2020 16:05
-
-
Save fortmarek/e0d02cec8acdf9b8d70d1ba24ce98a86 to your computer and use it in GitHub Desktop.
Vote entrypoint
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
@sp.entry_point | |
def vote(self, params): | |
#1 | |
sp.verify(self.data.hasEnded == False) | |
#2 | |
sp.verify(self.data.voters.contains(sp.sender)) | |
#3 | |
sp.for vote in params.votes.items(): | |
sp.verify(self.data.voters[sp.sender] >= vote.value) | |
self.data.ballot[vote.key].numberOfVotes += vote.value | |
self.data.voters[sp.sender] -= vote.value | |
self.data.totalNumberOfVotes += vote.value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment