tx · BHzWdW9Mm6inwE5GJU1YWqXMn7YhjYUxkC3g4821QugF

3MyJoBjw9nC4uhgWULVJUaEZEL6z9As7Yfq:  -0.00900000 Waves

2022.07.06 21:02 [2128162] smart account 3MyJoBjw9nC4uhgWULVJUaEZEL6z9As7Yfq > SELF 0.00000000 Waves

{ "type": 13, "id": "BHzWdW9Mm6inwE5GJU1YWqXMn7YhjYUxkC3g4821QugF", "fee": 900000, "feeAssetId": null, "timestamp": 1657130598687, "version": 2, "chainId": 84, "sender": "3MyJoBjw9nC4uhgWULVJUaEZEL6z9As7Yfq", "senderPublicKey": "6E1saVK6whrqLsuLBQRGg6smask3XK5nkfiAWyGd3pEm", "proofs": [ "3ejyKHHwRCXjA1wwoEBmSQ68cMrWRzs7ZJtBpnDsnXqNpBgZVvmcQRjLSRUgFP6uLWTigP2z1HBZsSdjrnanHz6y" ], "script": "base64:AAIFAAAAAAAAABcIAhIDCgEIEgMKAQgSAwoBCBIECgIICAAAABIAAAAADVZPVElOR19CTE9DS1MAAAAAAAAAAGQAAAAAC1ZPVEVfQ0xPU0VEAgAAAAZDTE9TRUQAAAAAC1ZPVEVfT1BFTkVEAgAAAARPUEVOAAAAAAxEWVpfQVNTRVRfSUQCAAAALEcyUGI3Q016dHBzN1hFVkdDaVV1SmtMaVMzWkNvNjlBUFFOYkpzMm56MjFqAAAAAA5NSU5fRFlaX0FNT1VOVAAAAAAABfXhAAAAAAAPc3RhdHVzS2V5UHJlZml4AgAAAAdzdGF0dXNfAAAAAA1vcGVuS2V5UHJlZml4AgAAAAVvcGVuXwAAAAAOdG90YWxZZXNTdWZmaXgCAAAACl90b3RhbF95ZXMAAAAADXRvdGFsTm9TdWZmaXgCAAAACV90b3RhbF9ubwAAAAAPcmVwYXltZW50UHJlZml4AgAAAApyZXBheW1lbnRfAQAAAAxnZXRTdGF0dXNLZXkAAAABAAAAAmlkCQABLAAAAAIFAAAAD3N0YXR1c0tleVByZWZpeAUAAAACaWQBAAAACmdldE9wZW5LZX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AAAZhbW91bnQFAAAAA25pbAMJAAAAAAAAAgUAAAAEdm90ZQIAAAACbm8EAAAACW5vVm90ZUtleQkBAAAADWdldFRvdGFsTm9LZXkAAAABBQAAAAJpZAQAAAAMbm9Wb3Rlc1NvRmFyBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAACW5vVm90ZUtleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABAAAAApuZXdOb1ZvdGVzCQAAZAAAAAIFAAAADG5vVm90ZXNTb0ZhcgAAAAAAAAAAAQkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAAJbm9Wb3RlS2V5BQAAAApuZXdOb1ZvdGVzCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAAxyZXBheW1lbnRLZXkFAAAABmFtb3VudAUAAAADbmlsBQAAAANuaWwFAAAACG5ld0VudHJ5AAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXmRdW9f", "height": 2128162, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: ENpL7fii8yGxKaY9UEzAzN9qovGmKkayscUd3kB6UJfU Next: 52weaLoGBaYGvXUijSzmGXMQtttzQ5XF1R3RtbW3Y1Km Diff:
OldNewDifferences
3030 func getTotalYesKey (id) = (id + totalYesSuffix)
3131
3232
33-func getTotalNoKey (id) = (id + totalYesSuffix)
33+func getTotalNoKey (id) = (id + totalNoSuffix)
3434
3535
3636 func getVoteStatus (id) = {
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 = "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
33-func getTotalNoKey (id) = (id + totalYesSuffix)
33+func getTotalNoKey (id) = (id + totalNoSuffix)
3434
3535
3636 func getVoteStatus (id) = {
3737 let statusKey = getStatusKey(id)
3838 let status = getString(this, statusKey)
3939 status
4040 }
4141
4242
4343 func getRepaymentKey (id,address) = (((repaymentPrefix + id) + "_") + toString(address))
4444
4545
4646 func getStartHeight (id) = {
4747 let result = match getInteger(this, getOpenKey(id)) {
4848 case n: Int =>
4949 n
5050 case _ =>
5151 -1
5252 }
5353 result
5454 }
5555
5656
5757 func getRefundAmount (id,address) = {
5858 let repaymentKey = getRepaymentKey(id, address)
5959 let result = match getInteger(this, repaymentKey) {
6060 case n: Int =>
6161 n
6262 case _ =>
6363 -1
6464 }
6565 result
6666 }
6767
6868
6969 @Callable(i)
7070 func openVote (id) = {
7171 let startHeightKey = getOpenKey(id)
7272 let statusKey = getStatusKey(id)
7373 [StringEntry(statusKey, VOTE_OPENED), IntegerEntry(startHeightKey, height)]
7474 }
7575
7676
7777
7878 @Callable(i)
7979 func closeVote (id) = {
8080 let statusKey = getStatusKey(id)
8181 [StringEntry(statusKey, VOTE_CLOSED)]
8282 }
8383
8484
8585
8686 @Callable(i)
8787 func claim (id) = {
8888 let startHeight = getStartHeight(id)
8989 if ((startHeight == -1))
9090 then throw("No vote started for this id!")
9191 else if (((startHeight + VOTING_BLOCKS) >= height))
9292 then throw("You can only claim after vote ends!")
9393 else {
9494 let caller = i.caller
9595 let repayAmount = getRefundAmount(id, caller)
9696 let statusKey = getStatusKey(id)
9797 let repaymentKey = getRepaymentKey(id, caller)
9898 if ((repayAmount > 0))
9999 then [ScriptTransfer(caller, repayAmount, toBytes(DYZ_ASSET_ID)), StringEntry(statusKey, VOTE_CLOSED), IntegerEntry(repaymentKey, 0)]
100100 else throw("Nothing to claim!")
101101 }
102102 }
103103
104104
105105
106106 @Callable(i)
107107 func vote (id,vote) = if ((size(i.payments) != 1))
108108 then throw("One payment in DZY needs to be attached")
109109 else {
110110 let payment = value(i.payments[0])
111111 let caller = i.caller
112112 let amount = payment.amount
113113 if (!(isDefined(payment.assetId)))
114114 then throw("Payment in Waves not allowed!")
115115 else {
116116 let assetId = toBase58String(value(payment.assetId))
117117 if ((assetId != DYZ_ASSET_ID))
118118 then throw("payment in DZY necessary!")
119119 else if ((amount != MIN_DYZ_AMOUNT))
120120 then throw("payment amount wrong!")
121121 else {
122122 let repaymentKey = getRepaymentKey(id, caller)
123123 let voteStatus = getVoteStatus(id)
124124 if ((voteStatus == VOTE_CLOSED))
125125 then throw("vote closed!")
126126 else {
127127 let openHeight = match getInteger(this, getOpenKey(id)) {
128128 case a: Int =>
129129 a
130130 case _ =>
131131 0
132132 }
133133 if ((height > (openHeight + VOTING_BLOCKS)))
134134 then throw("voting ended!")
135135 else {
136136 let newEntry = if ((vote == "yes"))
137137 then {
138138 let yesVoteKey = getTotalYesKey(id)
139139 let yesVotesSoFar = match getInteger(this, yesVoteKey) {
140140 case a: Int =>
141141 a
142142 case _ =>
143143 0
144144 }
145145 let newYesVotes = (yesVotesSoFar + 1)
146146 [IntegerEntry(yesVoteKey, newYesVotes), IntegerEntry(repaymentKey, amount)]
147147 }
148148 else if ((vote == "no"))
149149 then {
150150 let noVoteKey = getTotalNoKey(id)
151151 let noVotesSoFar = match getInteger(this, noVoteKey) {
152152 case a: Int =>
153153 a
154154 case _ =>
155155 0
156156 }
157157 let newNoVotes = (noVotesSoFar + 1)
158158 [IntegerEntry(noVoteKey, newNoVotes), IntegerEntry(repaymentKey, amount)]
159159 }
160160 else nil
161161 newEntry
162162 }
163163 }
164164 }
165165 }
166166 }
167167
168168
169169 @Verifier(tx)
170170 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
171171

github/deemru/w8io/169f3d6 
31.87 ms