Created
May 8, 2020 09:59
-
-
Save KardanovIR/80760ce92461845dbf0494781a8ce67f to your computer and use it in GitHub Desktop.
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
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