Skip to content

Instantly share code, notes, and snippets.

@KardanovIR
Created May 8, 2020 09:59
Show Gist options
  • Save KardanovIR/80760ce92461845dbf0494781a8ce67f to your computer and use it in GitHub Desktop.
Save KardanovIR/80760ce92461845dbf0494781a8ce67f to your computer and use it in GitHub Desktop.
let NONE = "NONE"
func keyVoteByAddress(votingId: Int, address: String) = "voting_" + votingId + "_vote_" + address
@Callable(i)
func vote(id: Int) => {
let voteKey = keyVoteByAddress(id, i.caller.toBase58String())
let vote = getString(this, voteKey).valueOrElse(NONE)
# alternative option
let vote = match getString(this, voteKey){
case s: String => s
case _ => NONE
}
if (vote == NONE) then ...
else ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment