tx · 9Q3kyVY7tKSLQqq1vdDiKv5wu4SVnHMRZgZmcCWeo7EM

3N8ECQLYDdCmJt4izWqSTdqAKXgZHwsvn2E:  -0.00400000 Waves

2022.08.17 13:33 [2188356] smart account 3N8ECQLYDdCmJt4izWqSTdqAKXgZHwsvn2E > SELF 0.00000000 Waves

{ "type": 13, "id": "9Q3kyVY7tKSLQqq1vdDiKv5wu4SVnHMRZgZmcCWeo7EM", "fee": 400000, "feeAssetId": null, "timestamp": 1660732429495, "version": 2, "chainId": 84, "sender": "3N8ECQLYDdCmJt4izWqSTdqAKXgZHwsvn2E", "senderPublicKey": "3gYxd65tRPLfRX8rW8gMXdVbJGruywnY2S5ZCBqQ9uuy", "proofs": [ "4Q5SvCehsXJvbBM1TVoDwsEeJme9Ew2U3qyLu8jNiYajr6eVs2bnvWTfpisUeNX8Z9XHCPhEk5fjbRoAa8C63Ec2" ], "script": "base64:AAIFAAAAAAAAAAcIAhIDCgEIAAAACQAAAAAJaGVpZ2h0RW5kCQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQaAAAAAgUAAAAEdGhpcwIAAAAKaGVpZ2h0X2VuZAIAAAAkaGVpZ2h0X2VuZCBpcyBub3Qgc3BlY2lmaWVkIGluIHN0YXRlAAAAAAxhc3NldHNTdHJpbmcJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABB0AAAACBQAAAAR0aGlzAgAAABBhdmFpbGFibGVfYXNzZXRzAgAAACVBc3NldHMgbGlzdCBpcyBub3Qgc3BlY2lmaWVkIGluIHN0YXRlAQAAAAlhc0FueUxpc3QAAAABAAAAA3ZhbAQAAAAHJG1hdGNoMAUAAAADdmFsAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAlMaXN0W0FueV0EAAAACnZhbEFueUx5c3QFAAAAByRtYXRjaDAFAAAACnZhbEFueUx5c3QJAAACAAAAAQIAAAAbZmFpbCB0byBjYXN0IGludG8gTGlzdFtBbnldAQAAAAVhc0lud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AAAAAAAAAAUAAAAAuP8gQw==", "height": 2188356, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 8GosqhFdEg4ZAnSeG73K3HqhYwtHkgm8ZPxxZWD2TKwL Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 5 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let heightEnd = valueOrErrorMessage(getInteger(this, "height_end"), "height_end is not specified in state")
5+
6+let assetsString = valueOrErrorMessage(getString(this, "available_assets"), "Assets list is not specified in state")
7+
8+func asAnyList (val) = match val {
9+ case valAnyLyst: List[Any] =>
10+ valAnyLyst
11+ case _ =>
12+ throw("fail to cast into List[Any]")
13+}
14+
15+
16+func asInt (val) = match val {
17+ case valInt: Int =>
18+ valInt
19+ case _ =>
20+ throw("fail to cast into Int")
21+}
22+
23+
24+let nsbtStakingContract = Address(base58'3MuGfNhF98CNBCfthhoJEo6SYUv7zTgkK4J')
25+
26+let availableVotes = split(assetsString, ",")
27+
28+func keyUserBalance (userAddr) = makeString(["balance", toString(userAddr)], "_")
29+
30+
31+func keyUserVote (userAddr,vote) = makeString(["vote", userAddr, vote], "_")
32+
33+
34+func keyUserLastVote (userAddr) = makeString(["last_vote", userAddr], "_")
35+
36+
37+@Callable(contextObj)
38+func castVote (newUserSelectedOptions) = {
39+ let userAddress = toString(contextObj.caller)
40+ if ((containsElement(availableVotes, newUserSelectedOptions) == false))
41+ then throw("Incorrect vote!")
42+ else if ((height >= heightEnd))
43+ then throw("vote finished")
44+ else {
45+ let nsbtData = asAnyList(invoke(nsbtStakingContract, "nsbtStakingSYSREADONLY", [userAddress, 0], nil))
46+ let newUserVotingPower = asInt(nsbtData[0])
47+ let selectedOptions = split(newUserSelectedOptions, ":")
48+ func calcVotes (data,idx) = {
49+ let newUserChoice = selectedOptions[idx]
50+ let newTotalByChoiceKEY = makeString(["vote", newUserChoice], "_")
51+ let newTotalByChoiceAmount = valueOrElse(getInteger(this, newTotalByChoiceKEY), 0)
52+ let newUserVotingPowerKEY = keyUserVote(userAddress, newUserChoice)
53+ let prevUserChoiceKEY = keyUserLastVote(userAddress)
54+ let prevUserChoice = valueOrElse(getString(this, prevUserChoiceKEY), newUserChoice)
55+ let prevUserVotingPowerKEY = keyUserVote(userAddress, prevUserChoice)
56+ let prevUserVotingPower = valueOrElse(getInteger(this, prevUserVotingPowerKEY), 0)
57+ let prevTotalByChoiceKEY = makeString(["vote", prevUserChoice], "_")
58+ let prevTotalByChoiceAmount = valueOrElse(getInteger(this, prevTotalByChoiceKEY), 0)
59+ let refreshTotals = if ((prevUserChoice != newUserChoice))
60+ then [IntegerEntry(prevUserVotingPowerKEY, 0), IntegerEntry(prevTotalByChoiceKEY, (prevTotalByChoiceAmount - prevUserVotingPower)), IntegerEntry(newTotalByChoiceKEY, (newTotalByChoiceAmount + newUserVotingPower))]
61+ else [IntegerEntry(newTotalByChoiceKEY, ((newTotalByChoiceAmount + newUserVotingPower) - prevUserVotingPower))]
62+ ((data ++ refreshTotals) ++ [IntegerEntry(newUserVotingPowerKEY, newUserVotingPower), StringEntry(prevUserChoiceKEY, newUserChoice)])
63+ }
64+
65+ let idxes = [0, 1, 2, 3, 4]
66+ let $l = idxes
67+ let $s = size($l)
68+ let $acc0 = nil
69+ func $f0_1 ($a,$i) = if (($i >= $s))
70+ then $a
71+ else calcVotes($a, $l[$i])
72+
73+ func $f0_2 ($a,$i) = if (($i >= $s))
74+ then $a
75+ else throw("List size exceeds 5")
76+
77+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
78+ }
79+ }
80+
81+

github/deemru/w8io/169f3d6 
23.66 ms