tx · EXzUheFWnL8SopRFx29XiqEfy5YWeJ73AR8HJ6GjAqMV

3MsmgWBZKrHwbVbSQiqmStRiFyg5hkfxxa2:  -0.00300000 Waves

2022.08.17 11:20 [2188222] smart account 3MsmgWBZKrHwbVbSQiqmStRiFyg5hkfxxa2 > SELF 0.00000000 Waves

{ "type": 13, "id": "EXzUheFWnL8SopRFx29XiqEfy5YWeJ73AR8HJ6GjAqMV", "fee": 300000, "feeAssetId": null, "timestamp": 1660724359821, "version": 2, "chainId": 84, "sender": "3MsmgWBZKrHwbVbSQiqmStRiFyg5hkfxxa2", "senderPublicKey": "9TejtrnvgE7MvzMR4DcLbf3dqUzovyt4BKEmCsqha2z", "proofs": [ "3BmDBNZxwLACGx7NKWHXgQac4s8uZmtH8wBPjkJDff8hHXRttFowKafZxGafC4D8KL8J9WyrHGCovMDmsfMGkJsm" ], "script": "base64:AAIFAAAAAAAAAAcIAhIDCgEIAAAACQAAAAAJaGVpZ2h0RW5kCQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQaAAAAAgUAAAAEdGhpcwIAAAAKaGVpZ2h0X2VuZAIAAAAkaGVpZ2h0X2VuZCBpcyBub3Qgc3BlY2lmaWVkIGluIHN0YXRlAAAAAAxhc3NldHNTdHJpbmcJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABB0AAAACBQAAAAR0aGlzAgAAABBhdmFpbGFibGVfYXNzZXRzAgAAACVBc3NldHMgbGlzdCBpcyBub3Qgc3BlY2lmaWVkIGluIHN0YXRlAQAAAAlhc0FueUxpc3QAAAABAAAAA3ZhbAQAAAAHJG1hdGNoMAUAAAADdmFsAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAlMaXN0W0FueV0EAAAACnZhbEFueUx5c3QFAAAAByRtYXRjaDAFAAAACnZhbEFueUx5c3QJAAACAAAAAQIAAAAbZmFpbCB0byBjYXN0IGludG8gTGlzdFtBbnldAQAAAAVhc0ludAAAAAEAAAADdmFsBA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XJLRVkFAAAAEm5ld1VzZXJWb3RpbmdQb3dlcgkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACBQAAABFwcmV2VXNlckNob2ljZUtFWQUAAAANbmV3VXNlckNob2ljZQUAAAADbmlsAAAAAGbnIx0=", "height": 2188222, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8DhSBHjrM1Ce9718nfVUbWj3hWfGMS51SQ5VoBUpZVHT Next: 313i8e9KiMVPaArpQ9HjvgdzfDhzDqFi9zEKs52w8pJh Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let heightEnd = valueOrErrorMessage(getInteger(this, "height_end"), "height_end is not specified in state")
55
66 let assetsString = valueOrErrorMessage(getString(this, "available_assets"), "Assets list is not specified in state")
77
88 func asAnyList (val) = match val {
99 case valAnyLyst: List[Any] =>
1010 valAnyLyst
1111 case _ =>
1212 throw("fail to cast into List[Any]")
1313 }
1414
1515
1616 func asInt (val) = match val {
1717 case valInt: Int =>
1818 valInt
1919 case _ =>
2020 throw("fail to cast into Int")
2121 }
2222
2323
2424 let nsbtStakingContract = Address(base58'3MuGfNhF98CNBCfthhoJEo6SYUv7zTgkK4J')
2525
2626 let availableVotes = split(assetsString, ",")
2727
2828 func keyUserBalance (userAddr) = makeString(["balance", toString(userAddr)], "_")
2929
3030
3131 func keyUserVote (userAddr,vote) = makeString(["vote", userAddr, vote], "_")
3232
3333
3434 func keyUserLastVote (userAddr) = makeString(["last_vote", userAddr], "_")
3535
3636
3737 @Callable(contextObj)
3838 func castVote (newUserChoice) = {
3939 let userAddress = toString(contextObj.caller)
4040 if ((containsElement(availableVotes, newUserChoice) == false))
4141 then throw("Incorrect vote!")
4242 else if ((height >= heightEnd))
4343 then throw("vote finished")
4444 else {
4545 let nsbtData = asAnyList(invoke(nsbtStakingContract, "nsbtStakingSYSREADONLY", [userAddress, 0], nil))
4646 let newUserVotingPower = asInt(nsbtData[0])
4747 let newTotalByChoiceKEY = makeString(["vote", newUserChoice], "_")
4848 let newTotalByChoiceAmount = valueOrElse(getInteger(this, newTotalByChoiceKEY), 0)
4949 let newUserVotingPowerKEY = keyUserVote(userAddress, newUserChoice)
5050 let prevUserChoiceKEY = keyUserLastVote(userAddress)
5151 let prevUserChoice = valueOrElse(getString(this, prevUserChoiceKEY), newUserChoice)
5252 let prevUserVotingPowerKEY = keyUserVote(userAddress, prevUserChoice)
5353 let prevUserVotingPower = valueOrElse(getInteger(this, prevUserVotingPowerKEY), 0)
5454 let prevTotalByChoiceKEY = makeString(["vote", prevUserChoice], "_")
5555 let prevTotalByChoiceAmount = valueOrElse(getInteger(this, prevTotalByChoiceKEY), 0)
5656 let refreshTotals = if ((prevUserChoice != newUserChoice))
5757 then [IntegerEntry(prevUserVotingPowerKEY, 0), IntegerEntry(prevTotalByChoiceKEY, (prevTotalByChoiceAmount - prevUserVotingPower)), IntegerEntry(newTotalByChoiceKEY, (newTotalByChoiceAmount + newUserVotingPower))]
5858 else [IntegerEntry(newTotalByChoiceKEY, ((newTotalByChoiceAmount + newUserVotingPower) - prevUserVotingPower))]
5959 (refreshTotals ++ [IntegerEntry(newUserVotingPowerKEY, newUserVotingPower), StringEntry(prevUserChoiceKEY, newUserChoice)])
6060 }
6161 }
6262
6363

github/deemru/w8io/169f3d6 
58.12 ms