tx · 6q8kjtgE3kPQrYV1aU1EDta44aXe8e9k3vLrRkrq97bo

3MuKEDU6qPggcs65swNH6JcUbS7hB6jVzrA:  -0.01000000 Waves

2023.09.20 18:20 [2763885] smart account 3MuKEDU6qPggcs65swNH6JcUbS7hB6jVzrA > SELF 0.00000000 Waves

{ "type": 13, "id": "6q8kjtgE3kPQrYV1aU1EDta44aXe8e9k3vLrRkrq97bo", "fee": 1000000, "feeAssetId": null, "timestamp": 1695223278801, "version": 2, "chainId": 84, "sender": "3MuKEDU6qPggcs65swNH6JcUbS7hB6jVzrA", "senderPublicKey": "GkZtgtQPEtE9JoxK1tzKc1t7uw12vz6aqKhDcBi136yV", "proofs": [ "wNFB4wqJx7dpc3yhBc8vf1eLrjFS19pdN948pP5fPW2QThFzHSNUrauP6H87WbQXdAi7ZjDXfAXZrrj4zkfXYeX" ], "script": "base64:BgIVCAISABIDCgEBEgQKAgICEgQKAgEEEQADU0VQAgJfXwAPcmVwdXRhdGlvbkFzc2V0ASBxggycON8pyCFInplKujKGtzqQhMOf+vAbfdt6zmK1aAAMcHJvcG9zYWxUaW1lCQBoAgkAaAIJAGgCCQBoAgDoBwA8ADwAGAADARFjb3VudFByb3Bvc2Fsc0tleQACAmNwAQtwcm9wb3NhbEtleQEKcHJvcG9zYWxJZAkAuQkCCQDMCAICAXAJAMwIAgkApAMBBQpwcm9wb3NhbElkBQNuaWwFA1NFUAEYZ3JlYXRlc3RWb3RlVGltZXN0YW1wS2V5AQR1c2VyCQC5CQIJAMwIAgICdXQJAMwIAgkA2AQBCAUEdXNlcgVieXRlcwUDbmlsBQNTRVABEHVzZXJEZXBvc2l0ZWRLZXkBBHVzZXIJALkJAgkAzAgCAgJ1ZAkAzAgCCQDYBAEIBQR1c2VyBWJ5dGVzBQNuaWwFA1NFUAETdXNlclByb3Bvc2FsVm90ZUtleQIKcHJvcG9zYWxJZAR1c2VyCQC5CQIJAMwIAgICdXAJAMwIAgkApAMBBQpwcm9wb3NhbElkCQDMCAIJ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b3dlcgUDbmlsAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleTCMSYY=", "height": 2763885, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4pjT18sgChf2DJkc191M5De7FN2JCyC39avJ3EJUUyPg Next: GLkqH8ReVo1iGXiQzm3fGHzWyuCeMSDzARnsiZgVGKpb Diff:
OldNewDifferences
1313 func proposalKey (proposalId) = makeString(["p", toString(proposalId)], SEP)
1414
1515
16-func unlockTimestampKey (user) = makeString(["ut", toBase58String(user.bytes)], SEP)
16+func greatestVoteTimestampKey (user) = makeString(["ut", toBase58String(user.bytes)], SEP)
1717
1818
1919 func userDepositedKey (user) = makeString(["ud", toBase58String(user.bytes)], SEP)
5454 else throw("only 1 payment")
5555
5656
57-func getUnlockTimestamp (user) = match getInteger(this, unlockTimestampKey(user)) {
57+func getUnlockTimestamp (user) = match getInteger(this, greatestVoteTimestampKey(user)) {
5858 case a: Int =>
59- a
59+ (a + proposalTime)
6060 case _ =>
6161 0
6262 }
111111 let newAmount = (currentAmount - amount)
112112 if ((0 > amount))
113113 then throw("Can't withdraw negative amount")
114- else if ((getUnlockTimestamp(i.caller) > lastBlock.timestamp))
114+ else if ((lastBlock.timestamp > getUnlockTimestamp(i.caller)))
115115 then throw("Locked")
116116 else if ((0 > newAmount))
117117 then throw("Not enough balance")
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 let reputationAsset = base58'8e65zYSAcGfmQnVX462UEMWf6PmHgtckyGcrEMXKZZaF'
77
88 let proposalTime = ((((1000 * 60) * 60) * 24) * 3)
99
1010 func countProposalsKey () = "cp"
1111
1212
1313 func proposalKey (proposalId) = makeString(["p", toString(proposalId)], SEP)
1414
1515
16-func unlockTimestampKey (user) = makeString(["ut", toBase58String(user.bytes)], SEP)
16+func greatestVoteTimestampKey (user) = makeString(["ut", toBase58String(user.bytes)], SEP)
1717
1818
1919 func userDepositedKey (user) = makeString(["ud", toBase58String(user.bytes)], SEP)
2020
2121
2222 func userProposalVoteKey (proposalId,user) = makeString(["up", toString(proposalId), toBase58String(user.bytes)], SEP)
2323
2424
2525 func setUserVote (proposalId,user,votePower) = IntegerEntry(userProposalVoteKey(proposalId, user), votePower)
2626
2727
2828 func getUserVote (proposalId,user) = match getInteger(userProposalVoteKey(proposalId, user)) {
2929 case i: Int =>
3030 i
3131 case _ =>
3232 0
3333 }
3434
3535
3636 func setProposal (id,creator,title,text,timestampCreation,countVotesFor,CountVotesAgainst) = StringEntry(proposalKey(id), makeString_11C([toBase16String(creator.bytes), title, text, toString(timestampCreation), toString(countVotesFor), toString(CountVotesAgainst)], SEP))
3737
3838
3939 func getProposal (id) = {
4040 let savedString = split( match getString(this, proposalKey(id)) {
4141 case s: String =>
4242 s
4343 case _ =>
4444 throw("proposal not found")
4545 }, SEP)
4646 $Tuple6(Address(fromBase16String(savedString[0])), savedString[1], savedString[2], parseIntValue(savedString[3]), parseIntValue(savedString[4]), parseIntValue(savedString[5]))
4747 }
4848
4949
5050 func isPayReputationAsset (i) = if ((size(i.payments) == 1))
5151 then if ((i.payments[0].assetId == reputationAsset))
5252 then true
5353 else throw("only reputation assets")
5454 else throw("only 1 payment")
5555
5656
57-func getUnlockTimestamp (user) = match getInteger(this, unlockTimestampKey(user)) {
57+func getUnlockTimestamp (user) = match getInteger(this, greatestVoteTimestampKey(user)) {
5858 case a: Int =>
59- a
59+ (a + proposalTime)
6060 case _ =>
6161 0
6262 }
6363
6464
6565 func countProposals () = match getInteger(this, countProposalsKey()) {
6666 case a: Int =>
6767 a
6868 case _ =>
6969 0
7070 }
7171
7272
7373 func userDepositedReputationAsset (user) = match getInteger(this, userDepositedKey(user)) {
7474 case a: Int =>
7575 a
7676 case _ =>
7777 0
7878 }
7979
8080
8181 func isProposalAlive (id) = if (if ((countProposals() > id))
8282 then ((getProposal(id)._4 + proposalTime) > lastBlock.timestamp)
8383 else false)
8484 then true
8585 else throw("proposal not alive")
8686
8787
8888 @Callable(i)
8989 func deposit () = {
9090 let checks = [isPayReputationAsset(i)]
9191 if ((checks == checks))
9292 then {
9393 let currentAmount = userDepositedReputationAsset(i.caller)
9494 let newAmount = (currentAmount + i.payments[0].amount)
9595 [IntegerEntry(userDepositedKey(i.caller), newAmount)]
9696 }
9797 else throw("onlyReputationAsset")
9898 }
9999
100100
101101
102102 @Callable(i)
103103 func withdraw (amount) = {
104104 let currentKey = toBase58String(i.caller.bytes)
105105 let currentAmount = match getInteger(this, currentKey) {
106106 case a: Int =>
107107 a
108108 case _ =>
109109 0
110110 }
111111 let newAmount = (currentAmount - amount)
112112 if ((0 > amount))
113113 then throw("Can't withdraw negative amount")
114- else if ((getUnlockTimestamp(i.caller) > lastBlock.timestamp))
114+ else if ((lastBlock.timestamp > getUnlockTimestamp(i.caller)))
115115 then throw("Locked")
116116 else if ((0 > newAmount))
117117 then throw("Not enough balance")
118118 else [IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, amount, reputationAsset)]
119119 }
120120
121121
122122
123123 @Callable(i)
124124 func createProposal (title,text) = {
125125 let count = countProposals()
126126 [setProposal(count, i.caller, toBase16String(title), toBase16String(text), lastBlock.timestamp, 0, 0), IntegerEntry(countProposalsKey(), (count + 1))]
127127 }
128128
129129
130130
131131 @Callable(i)
132132 func vote (proposalId,vote) = if (!(isProposalAlive(proposalId)))
133133 then throw("proposalNotAlive")
134134 else {
135135 let proposal = getProposal(proposalId)
136136 let unlockTime = max([(proposal._4 + proposalTime), getUnlockTimestamp(i.caller)])
137137 let previusVote = getUserVote(proposalId, i.caller)
138138 let votePower = userDepositedReputationAsset(i.caller)
139139 let minusFor = if ((previusVote > 0))
140140 then previusVote
141141 else 0
142142 let minusAgainst = if ((0 > previusVote))
143143 then -(previusVote)
144144 else 0
145145 let plusFor = if ((vote == true))
146146 then votePower
147147 else 0
148148 let plusAgainst = if ((vote == false))
149149 then votePower
150150 else 0
151151 [setProposal(proposalId, proposal._1, proposal._2, proposal._3, proposal._4, ((proposal._5 - minusFor) + plusFor), ((proposal._6 - minusAgainst) + plusAgainst)), setUserVote(proposalId, i.caller, if (vote)
152152 then votePower
153153 else -(votePower))]
154154 }
155155
156156
157157 @Verifier(tx)
158158 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
159159

github/deemru/w8io/fabc49c 
31.57 ms