tx · DKFcLz3EARQ3i6HfKUqyGUy1MjP3scuUy8sfNmkLF6sz

3MuKEDU6qPggcs65swNH6JcUbS7hB6jVzrA:  -0.01000000 Waves

2023.09.19 17:21 [2762374] smart account 3MuKEDU6qPggcs65swNH6JcUbS7hB6jVzrA > SELF 0.00000000 Waves

{ "type": 13, "id": "DKFcLz3EARQ3i6HfKUqyGUy1MjP3scuUy8sfNmkLF6sz", "fee": 1000000, "feeAssetId": null, "timestamp": 1695133319779, "version": 2, "chainId": 84, "sender": "3MuKEDU6qPggcs65swNH6JcUbS7hB6jVzrA", "senderPublicKey": "GkZtgtQPEtE9JoxK1tzKc1t7uw12vz6aqKhDcBi136yV", "proofs": [ "4ezd3USS9RVLFwnEDfYomUYFW5XPZFJhrXTEA766Cevx3mykmYXMsDCrMvzKot7K9igDjSn4DVEHEvep8scni8Bi" ], "script": "base64:BgIVCAISABIDCgEBEgQKAgICEgQKAgEEEQADU0VQAgJfXwAPcmVwdXRhdGlvbkFzc2V0ASBxggycON8pyCFInplKujKGtzqQhMOf+vAbfdt6zmK1aAAMcHJvcG9zYWxUaW1lCQBoAgkAaAIJAGgCCQBoAgDoBwA8ADwAGAADARFjb3VudFByb3Bvc2Fsc0tleQACAmNwAQtwcm9wb3NhbEtleQEKcHJvcG9zYWxJZAkAuQkCCQDMCAICAXAJAMwIAgkApAMBBQpwcm9wb3NhbElkBQNuaWwFA1NFUAESdW5sb2NrVGltZXN0YW1wS2V5AQR1c2VyCQC5CQIJAMwIAgICdXQJAMwIAgkA2AQBCAUEdXNlcgVieXRlcwUDbmlsBQNTRVABEHVzZXJEZXBvc2l0ZWRLZXkBBHVzZXIJALkJAgkAzAgCAgJ1ZAkAzAgCCQDYBAEIBQR1c2VyBWJ5dGVzBQNuaWwFA1NFUAETdXNlclByb3Bvc2FsVm90ZUtleQIKcHJvcG9zYWxJZAR1c2VyCQC5CQIJAMwIAgICdXAJAMwIAgkApAMBBQpwcm9wb3NhbElkCQDMCAIJANgEAQgFBHV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QtZCy8JRzjnPJaSyFbNbZeg9SU1 Next: FR88CwjyNH75oQuG9w3eDSLezZVRtdYHCZ3mfpmEYk6e Diff:
OldNewDifferences
136136 let unlockTime = max([(proposal._4 + proposalTime), getUnlockTimestamp(i.caller)])
137137 let previusVote = getUserVote(proposalId, i.caller)
138138 let votePower = userDepositedReputationAsset(i.caller)
139-[setProposal(proposalId, proposal._1, proposal._2, proposal._3, proposal._4, ((proposal._5 - (if ((previusVote > 0))
139+[setProposal(proposalId, proposal._1, proposal._2, proposal._3, proposal._4, ((proposal._5 + (if (vote)
140+ then votePower
141+ else 0)) - (if ((previusVote > 0))
140142 then previusVote
141- else 0)) + (if (vote)
142- then votePower
143- else 0)), ((proposal._6 + (if ((0 > previusVote))
143+ else 0)), ((proposal._6 + (if (vote)
144+ then 0
145+ else votePower)) - (if ((0 > previusVote))
144146 then previusVote
145- else 0)) + (if (vote)
146- then 0
147- else votePower))), setUserVote(proposalId, i.caller, if (vote)
147+ else 0))), setUserVote(proposalId, i.caller, if (vote)
148148 then votePower
149149 else -(votePower))]
150150 }
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
1616 func unlockTimestampKey (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) = StringEntry(userProposalVoteKey(proposalId, user), toString(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
5757 func getUnlockTimestamp (user) = match getInteger(this, unlockTimestampKey(user)) {
5858 case a: Int =>
5959 a
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")
114114 else if ((getUnlockTimestamp(i.caller) > lastBlock.timestamp))
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)
139-[setProposal(proposalId, proposal._1, proposal._2, proposal._3, proposal._4, ((proposal._5 - (if ((previusVote > 0))
139+[setProposal(proposalId, proposal._1, proposal._2, proposal._3, proposal._4, ((proposal._5 + (if (vote)
140+ then votePower
141+ else 0)) - (if ((previusVote > 0))
140142 then previusVote
141- else 0)) + (if (vote)
142- then votePower
143- else 0)), ((proposal._6 + (if ((0 > previusVote))
143+ else 0)), ((proposal._6 + (if (vote)
144+ then 0
145+ else votePower)) - (if ((0 > previusVote))
144146 then previusVote
145- else 0)) + (if (vote)
146- then 0
147- else votePower))), setUserVote(proposalId, i.caller, if (vote)
147+ else 0))), setUserVote(proposalId, i.caller, if (vote)
148148 then votePower
149149 else -(votePower))]
150150 }
151151
152152
153153 @Verifier(tx)
154154 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
155155

github/deemru/w8io/026f985 
56.03 ms