Created
February 28, 2020 16:06
-
-
Save fortmarek/25e385bf1b5e820f71c90d0df7c26e32 to your computer and use it in GitHub Desktop.
End 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 end(self, params): | |
#1 | |
sp.verify(sp.sender == self.data.manager) | |
sp.verify(self.data.hasEnded == False) | |
sp.for candidate in self.data.ballot.keys(): | |
#2 | |
sp.if self.data.ballot[candidate].numberOfVotes != 0: | |
sp.send(candidate, sp.split_tokens(sp.balance, sp.as_nat(self.data.ballot[candidate].numberOfVotes), sp.as_nat(self.data.totalNumberOfVotes))) | |
self.data.hasEnded = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment