Skip to content

Instantly share code, notes, and snippets.

@fortmarek
Created February 28, 2020 16:06
Show Gist options
  • Save fortmarek/25e385bf1b5e820f71c90d0df7c26e32 to your computer and use it in GitHub Desktop.
Save fortmarek/25e385bf1b5e820f71c90d0df7c26e32 to your computer and use it in GitHub Desktop.
End entrypoint
@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