tx · Fx5ACseYxVZU52MtutD5RkjvTepebGGdx4QGM9hGPtKK

3MyJoBjw9nC4uhgWULVJUaEZEL6z9As7Yfq:  -0.00900000 Waves

2022.07.12 19:40 [2136757] smart account 3MyJoBjw9nC4uhgWULVJUaEZEL6z9As7Yfq > SELF 0.00000000 Waves

{ "type": 13, "id": "Fx5ACseYxVZU52MtutD5RkjvTepebGGdx4QGM9hGPtKK", "fee": 900000, "feeAssetId": null, "timestamp": 1657644018305, "version": 2, "chainId": 84, "sender": "3MyJoBjw9nC4uhgWULVJUaEZEL6z9As7Yfq", "senderPublicKey": "6E1saVK6whrqLsuLBQRGg6smask3XK5nkfiAWyGd3pEm", "proofs": [ "5eFmUBH6ZWs4tWfKVgUDVgRs8hT85M4DGirPzC5kLrTGzsV9crjBGzAt53pGHWCG8ZdDncJzzh9ZJFBbpaDwL8oB" ], "script": "base64:AAIFAAAAAAAAABcIAhIDCgEIEgMKAQgSAwoBCBIECgIIBAAAABMAAAAADVZPVElOR19CTE9DS1MAAAAAAAAAAGQAAAAAC1ZPVEVfQ0xPU0VEAgAAAAZDTE9TRUQAAAAAC1ZPVEVfT1BFTkVEAgAAAARPUEVOAAAAAAxEWVpfQVNTRVRfSUQBAAAAIN86bNLcP4xP9VBjVIPIz45BypCk5SNOYrbRgrI4NIymAAAAAA5NSU5fRFlaX0FNT1VOVAAAAAAABfXhAAAAAAAPc3RhdHVzS2V5UHJlZml4AgAAAAdzdGF0dXNfAAAAAA1vcGVuS2V5UHJlZml4AgAAAAVvcGVuXwAAAAAOdG90YWxZZXNTdWZmaXgCAAAACl90b3RhbF95ZXMAAAAADXRvdGFsTm9TdWZmaXgCAAAACV90b3RhbF9ubwAAAAAPcmVwYXltZW50UHJlZml4AgAAAApyZXBheW1lbnRfAQAAAAxnZXRTdGF0dXNLZXkAAAABAAAAAmlkCQABLAAAAAIFAAAAD3N0YXR1c0tleVByZWZpeAUAAAACaWQBAAAACmdldE9wZW5LZXkAAAABAAAAAmlkCQABLAA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1ZvdGVzU29GYXIAAAAAAAAAAAEJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIFAAAACW5vVm90ZUtleQUAAAAKbmV3Tm9Wb3RlcwkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAAMcmVwYXltZW50S2V5BQAAAAZhbW91bnQFAAAAA25pbAUAAAADbmlsBQAAAAhuZXdFbnRyeQAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5csSM4A==", "height": 2136757, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: ghoHbqxVaDGFUWyUFrY8KcVxd2XYcCNfKrSW6Ax1uuT Next: 3NTbYMkchWtihfgiK8ogfP47R67pETNCCEi3AehbTaaq Diff:
OldNewDifferences
5252 n
5353 case _ =>
5454 -1
55+}
56+
57+
58+func isAllowed (address) = match getBoolean(this, (toString(address) + "_allowed")) {
59+ case b: Boolean =>
60+ b
61+ case _ =>
62+ false
5563 }
5664
5765
110118 else {
111119 let payment = value(i.payments[0])
112120 let caller = i.caller
113- let amount = payment.amount
114- if (!(isDefined(payment.assetId)))
115- then throw("Payment in Waves not allowed!")
121+ if (isAllowed(caller))
122+ then throw("Address not allowed to vote!")
116123 else {
117- let assetId = toBase58String(value(payment.assetId))
118- let repaymentKey = getRepaymentKey(id, caller)
119- let refundAmount = getRefundAmount(repaymentKey)
120- if ((refundAmount != -1))
121- then throw("Only one vote per id per address!")
122- else if ((assetId != toBase58String(DYZ_ASSET_ID)))
123- then throw("payment in DZY necessary!")
124- else if ((amount != MIN_DYZ_AMOUNT))
125- then throw("payment amount wrong!")
126- else {
127- let voteStatus = getVoteStatus(id)
128- if ((voteStatus == VOTE_CLOSED))
129- then throw("vote closed!")
124+ let amount = payment.amount
125+ if (!(isDefined(payment.assetId)))
126+ then throw("Payment in Waves not allowed!")
127+ else {
128+ let assetId = toBase58String(value(payment.assetId))
129+ let repaymentKey = getRepaymentKey(id, caller)
130+ let refundAmount = getRefundAmount(repaymentKey)
131+ if ((refundAmount != -1))
132+ then throw("Only one vote per id per address!")
133+ else if ((assetId != toBase58String(DYZ_ASSET_ID)))
134+ then throw("payment in DZY necessary!")
135+ else if ((amount != MIN_DYZ_AMOUNT))
136+ then throw("payment amount wrong!")
130137 else {
131- let openHeight = match getInteger(this, getOpenKey(id)) {
132- case a: Int =>
133- a
134- case _ =>
135- 0
136- }
137- if ((height > (openHeight + VOTING_BLOCKS)))
138- then throw("voting ended!")
138+ let voteStatus = getVoteStatus(id)
139+ if ((voteStatus == VOTE_CLOSED))
140+ then throw("vote closed!")
139141 else {
140- let newEntry = if ((vote == "yes"))
141- then {
142- let yesVoteKey = getTotalYesKey(id)
143- let yesVotesSoFar = match getInteger(this, yesVoteKey) {
144- case a: Int =>
145- a
146- case _ =>
147- 0
142+ let openHeight = match getInteger(this, getOpenKey(id)) {
143+ case a: Int =>
144+ a
145+ case _ =>
146+ 0
147+ }
148+ if ((height > (openHeight + VOTING_BLOCKS)))
149+ then throw("voting ended!")
150+ else {
151+ let newEntry = if ((vote == true))
152+ then {
153+ let yesVoteKey = getTotalYesKey(id)
154+ let yesVotesSoFar = match getInteger(this, yesVoteKey) {
155+ case a: Int =>
156+ a
157+ case _ =>
158+ 0
159+ }
160+ let newYesVotes = (yesVotesSoFar + 1)
161+[IntegerEntry(yesVoteKey, newYesVotes), IntegerEntry(repaymentKey, amount)]
162+ }
163+ else if ((vote == false))
164+ then {
165+ let noVoteKey = getTotalNoKey(id)
166+ let noVotesSoFar = match getInteger(this, noVoteKey) {
167+ case a: Int =>
168+ a
169+ case _ =>
170+ 0
171+ }
172+ let newNoVotes = (noVotesSoFar + 1)
173+[IntegerEntry(noVoteKey, newNoVotes), IntegerEntry(repaymentKey, amount)]
174+ }
175+ else nil
176+ newEntry
148177 }
149- let newYesVotes = (yesVotesSoFar + 1)
150-[IntegerEntry(yesVoteKey, newYesVotes), IntegerEntry(repaymentKey, amount)]
151- }
152- else if ((vote == "no"))
153- then {
154- let noVoteKey = getTotalNoKey(id)
155- let noVotesSoFar = match getInteger(this, noVoteKey) {
156- case a: Int =>
157- a
158- case _ =>
159- 0
160- }
161- let newNoVotes = (noVotesSoFar + 1)
162-[IntegerEntry(noVoteKey, newNoVotes), IntegerEntry(repaymentKey, amount)]
163- }
164- else nil
165- newEntry
166178 }
167179 }
168- }
180+ }
169181 }
170182 }
171183
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let VOTING_BLOCKS = 100
55
66 let VOTE_CLOSED = "CLOSED"
77
88 let VOTE_OPENED = "OPEN"
99
1010 let DYZ_ASSET_ID = base58'G2Pb7CMztps7XEVGCiUuJkLiS3ZCo69APQNbJs2nz21j'
1111
1212 let MIN_DYZ_AMOUNT = 100000000
1313
1414 let statusKeyPrefix = "status_"
1515
1616 let openKeyPrefix = "open_"
1717
1818 let totalYesSuffix = "_total_yes"
1919
2020 let totalNoSuffix = "_total_no"
2121
2222 let repaymentPrefix = "repayment_"
2323
2424 func getStatusKey (id) = (statusKeyPrefix + id)
2525
2626
2727 func getOpenKey (id) = (openKeyPrefix + id)
2828
2929
3030 func getTotalYesKey (id) = (id + totalYesSuffix)
3131
3232
3333 func getTotalNoKey (id) = (id + totalNoSuffix)
3434
3535
3636 func getVoteStatus (id) = getString(this, getStatusKey(id))
3737
3838
3939 func getRepaymentKey (id,address) = (((repaymentPrefix + id) + "_") + toString(address))
4040
4141
4242 func getStartHeight (id) = match getInteger(this, getOpenKey(id)) {
4343 case n: Int =>
4444 n
4545 case _ =>
4646 -1
4747 }
4848
4949
5050 func getRefundAmount (repaymentKey) = match getInteger(this, repaymentKey) {
5151 case n: Int =>
5252 n
5353 case _ =>
5454 -1
55+}
56+
57+
58+func isAllowed (address) = match getBoolean(this, (toString(address) + "_allowed")) {
59+ case b: Boolean =>
60+ b
61+ case _ =>
62+ false
5563 }
5664
5765
5866 @Callable(i)
5967 func openVote (id) = {
6068 let startHeightKey = getOpenKey(id)
6169 let alreadyVoting = getStartHeight(id)
6270 if ((alreadyVoting != -1))
6371 then throw("Vote already ongoing for id!")
6472 else {
6573 let statusKey = getStatusKey(id)
6674 [StringEntry(statusKey, VOTE_OPENED), IntegerEntry(startHeightKey, height)]
6775 }
6876 }
6977
7078
7179
7280 @Callable(i)
7381 func closeVote (id) = {
7482 let currentStartHeight = getStartHeight(id)
7583 if ((currentStartHeight == -1))
7684 then throw("No vote found for id!")
7785 else if (((currentStartHeight + VOTING_BLOCKS) > height))
7886 then throw("Vote can not be closed yet!")
7987 else {
8088 let statusKey = getStatusKey(id)
8189 [StringEntry(statusKey, VOTE_CLOSED)]
8290 }
8391 }
8492
8593
8694
8795 @Callable(i)
8896 func claim (id) = {
8997 let startHeight = getStartHeight(id)
9098 if ((startHeight == -1))
9199 then throw("No vote started for this id!")
92100 else if (((startHeight + VOTING_BLOCKS) >= height))
93101 then throw("You can only claim after vote ends!")
94102 else {
95103 let caller = i.caller
96104 let repaymentKey = getRepaymentKey(id, caller)
97105 let repayAmount = getRefundAmount(repaymentKey)
98106 let statusKey = getStatusKey(id)
99107 if ((repayAmount > 0))
100108 then [ScriptTransfer(caller, repayAmount, DYZ_ASSET_ID), StringEntry(statusKey, VOTE_CLOSED), IntegerEntry(repaymentKey, 0)]
101109 else throw("Nothing to claim!")
102110 }
103111 }
104112
105113
106114
107115 @Callable(i)
108116 func vote (id,vote) = if ((size(i.payments) != 1))
109117 then throw("One payment in DZY needs to be attached")
110118 else {
111119 let payment = value(i.payments[0])
112120 let caller = i.caller
113- let amount = payment.amount
114- if (!(isDefined(payment.assetId)))
115- then throw("Payment in Waves not allowed!")
121+ if (isAllowed(caller))
122+ then throw("Address not allowed to vote!")
116123 else {
117- let assetId = toBase58String(value(payment.assetId))
118- let repaymentKey = getRepaymentKey(id, caller)
119- let refundAmount = getRefundAmount(repaymentKey)
120- if ((refundAmount != -1))
121- then throw("Only one vote per id per address!")
122- else if ((assetId != toBase58String(DYZ_ASSET_ID)))
123- then throw("payment in DZY necessary!")
124- else if ((amount != MIN_DYZ_AMOUNT))
125- then throw("payment amount wrong!")
126- else {
127- let voteStatus = getVoteStatus(id)
128- if ((voteStatus == VOTE_CLOSED))
129- then throw("vote closed!")
124+ let amount = payment.amount
125+ if (!(isDefined(payment.assetId)))
126+ then throw("Payment in Waves not allowed!")
127+ else {
128+ let assetId = toBase58String(value(payment.assetId))
129+ let repaymentKey = getRepaymentKey(id, caller)
130+ let refundAmount = getRefundAmount(repaymentKey)
131+ if ((refundAmount != -1))
132+ then throw("Only one vote per id per address!")
133+ else if ((assetId != toBase58String(DYZ_ASSET_ID)))
134+ then throw("payment in DZY necessary!")
135+ else if ((amount != MIN_DYZ_AMOUNT))
136+ then throw("payment amount wrong!")
130137 else {
131- let openHeight = match getInteger(this, getOpenKey(id)) {
132- case a: Int =>
133- a
134- case _ =>
135- 0
136- }
137- if ((height > (openHeight + VOTING_BLOCKS)))
138- then throw("voting ended!")
138+ let voteStatus = getVoteStatus(id)
139+ if ((voteStatus == VOTE_CLOSED))
140+ then throw("vote closed!")
139141 else {
140- let newEntry = if ((vote == "yes"))
141- then {
142- let yesVoteKey = getTotalYesKey(id)
143- let yesVotesSoFar = match getInteger(this, yesVoteKey) {
144- case a: Int =>
145- a
146- case _ =>
147- 0
142+ let openHeight = match getInteger(this, getOpenKey(id)) {
143+ case a: Int =>
144+ a
145+ case _ =>
146+ 0
147+ }
148+ if ((height > (openHeight + VOTING_BLOCKS)))
149+ then throw("voting ended!")
150+ else {
151+ let newEntry = if ((vote == true))
152+ then {
153+ let yesVoteKey = getTotalYesKey(id)
154+ let yesVotesSoFar = match getInteger(this, yesVoteKey) {
155+ case a: Int =>
156+ a
157+ case _ =>
158+ 0
159+ }
160+ let newYesVotes = (yesVotesSoFar + 1)
161+[IntegerEntry(yesVoteKey, newYesVotes), IntegerEntry(repaymentKey, amount)]
162+ }
163+ else if ((vote == false))
164+ then {
165+ let noVoteKey = getTotalNoKey(id)
166+ let noVotesSoFar = match getInteger(this, noVoteKey) {
167+ case a: Int =>
168+ a
169+ case _ =>
170+ 0
171+ }
172+ let newNoVotes = (noVotesSoFar + 1)
173+[IntegerEntry(noVoteKey, newNoVotes), IntegerEntry(repaymentKey, amount)]
174+ }
175+ else nil
176+ newEntry
148177 }
149- let newYesVotes = (yesVotesSoFar + 1)
150-[IntegerEntry(yesVoteKey, newYesVotes), IntegerEntry(repaymentKey, amount)]
151- }
152- else if ((vote == "no"))
153- then {
154- let noVoteKey = getTotalNoKey(id)
155- let noVotesSoFar = match getInteger(this, noVoteKey) {
156- case a: Int =>
157- a
158- case _ =>
159- 0
160- }
161- let newNoVotes = (noVotesSoFar + 1)
162-[IntegerEntry(noVoteKey, newNoVotes), IntegerEntry(repaymentKey, amount)]
163- }
164- else nil
165- newEntry
166178 }
167179 }
168- }
180+ }
169181 }
170182 }
171183
172184
173185 @Verifier(tx)
174186 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
175187

github/deemru/w8io/169f3d6 
75.38 ms