tx · H1B3rFHswuUrUTWSpekShTTnBZCZKHdFR8FBG2r9Kcya 3MrmLk5vPSPy1nKpvsbWWaTipvbZqkm6QMS: -0.00500000 Waves 2022.07.22 15:44 [2150986] smart account 3MrmLk5vPSPy1nKpvsbWWaTipvbZqkm6QMS > SELF 0.00000000 Waves
{ "type": 13, "id": "H1B3rFHswuUrUTWSpekShTTnBZCZKHdFR8FBG2r9Kcya", "fee": 500000, "feeAssetId": null, "timestamp": 1658493833434, "version": 2, "chainId": 84, "sender": "3MrmLk5vPSPy1nKpvsbWWaTipvbZqkm6QMS", "senderPublicKey": "3o8tkYNujFWhAg8vHr9M9TEWpFcDMfM7TRsk933exjy7", "proofs": [ "2th5rzdRTZm9MdAV14jy67FLq719R5Tt9cpB1Su1iDAuSQkpELjYMHwy24EmTU15pg1xr1oHKeN7SWTLuvoPB8KG" ], "script": "base64:AAIFAAAAAAAAABcIAhIDCgEIEgMKAQgSAwoBCBIECgIIBAAAABQAAAAADERZWl9BU1NFVF9JRAEAAAAg3zps0tw/jE/1UGNUg8jPjkHKkKTlI05ittGCsjg0jKYAAAAADk1JTl9EWVpfQU1PVU5UAAAAAAAF9eEAAAAAAA1WT1RJTkdfQkxPQ0tTAAAAAAAAAABkAAAAAAtWT1RFX0NMT1NFRAIAAAAGQ0xPU0VEAAAAAAtWT1RFX09QRU5FRAIAAAAET1BFTgAAAAAPc3RhdHVzS2V5UHJlZml4AgAAAAdzdGF0dXNfAAAAAA1vcGVuS2V5UHJlZml4AgAAAAVvcGVuXwAAAAAOdG90YWxZZXNTdWZmaXgCAAAACl90b3RhbF95ZXMAAAAADXRvdGFsTm9TdWZmaXgCAAAACV90b3RhbF9ubwAAAAAPcmVwYXltZW50UHJlZml4AgAAAApyZXBheW1lbnRfAAAAABBhbGxvd2VkS2V5U3VmZml4AgAAAAhfYWxsb3dlZAEAAAAMZ2V0U3RhdHVzS2V5AAAAAQAAAAJpZAkAASwAAAACBQAAAA9zdGF0dXNLZXlQcmVmaXgFA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AAAAAAAAAABAAAAApuZXdOb1ZvdGVzCQAAZAAAAAIFAAAADG5vVm90ZXNTb0ZhcgAAAAAAAAAAAQkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAAJbm9Wb3RlS2V5BQAAAApuZXdOb1ZvdGVzCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAAxyZXBheW1lbnRLZXkFAAAABmFtb3VudAUAAAADbmlsBQAAAANuaWwFAAAACG5ld0VudHJ5AAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXmfL4NT", "height": 2150986, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let DYZ_ASSET_ID = base58'G2Pb7CMztps7XEVGCiUuJkLiS3ZCo69APQNbJs2nz21j' | |
5 | + | ||
6 | + | let MIN_DYZ_AMOUNT = 100000000 | |
7 | + | ||
8 | + | let VOTING_BLOCKS = 100 | |
9 | + | ||
10 | + | let VOTE_CLOSED = "CLOSED" | |
11 | + | ||
12 | + | let VOTE_OPENED = "OPEN" | |
13 | + | ||
14 | + | let statusKeyPrefix = "status_" | |
15 | + | ||
16 | + | let openKeyPrefix = "open_" | |
17 | + | ||
18 | + | let totalYesSuffix = "_total_yes" | |
19 | + | ||
20 | + | let totalNoSuffix = "_total_no" | |
21 | + | ||
22 | + | let repaymentPrefix = "repayment_" | |
23 | + | ||
24 | + | let allowedKeySuffix = "_allowed" | |
25 | + | ||
26 | + | func getStatusKey (id) = (statusKeyPrefix + id) | |
27 | + | ||
28 | + | ||
29 | + | func getOpenKey (id) = (openKeyPrefix + id) | |
30 | + | ||
31 | + | ||
32 | + | func getTotalYesKey (id) = (id + totalYesSuffix) | |
33 | + | ||
34 | + | ||
35 | + | func getTotalNoKey (id) = (id + totalNoSuffix) | |
36 | + | ||
37 | + | ||
38 | + | func getVoteStatus (id) = getString(this, getStatusKey(id)) | |
39 | + | ||
40 | + | ||
41 | + | func getRepaymentKey (id,address) = (((repaymentPrefix + id) + "_") + toString(address)) | |
42 | + | ||
43 | + | ||
44 | + | func getStartHeight (id) = match getInteger(this, getOpenKey(id)) { | |
45 | + | case n: Int => | |
46 | + | n | |
47 | + | case _ => | |
48 | + | -1 | |
49 | + | } | |
50 | + | ||
51 | + | ||
52 | + | func getRefundAmount (repaymentKey) = match getInteger(this, repaymentKey) { | |
53 | + | case n: Int => | |
54 | + | n | |
55 | + | case _ => | |
56 | + | -1 | |
57 | + | } | |
58 | + | ||
59 | + | ||
60 | + | func isAllowed (address) = match getBoolean(this, (toString(address) + allowedKeySuffix)) { | |
61 | + | case b: Boolean => | |
62 | + | b | |
63 | + | case _ => | |
64 | + | false | |
65 | + | } | |
66 | + | ||
67 | + | ||
68 | + | @Callable(i) | |
69 | + | func openVote (id) = { | |
70 | + | let startHeightKey = getOpenKey(id) | |
71 | + | let alreadyVoting = getStartHeight(id) | |
72 | + | if ((alreadyVoting != -1)) | |
73 | + | then throw("Vote already ongoing for id!") | |
74 | + | else { | |
75 | + | let statusKey = getStatusKey(id) | |
76 | + | [StringEntry(statusKey, VOTE_OPENED), IntegerEntry(startHeightKey, height)] | |
77 | + | } | |
78 | + | } | |
79 | + | ||
80 | + | ||
81 | + | ||
82 | + | @Callable(i) | |
83 | + | func closeVote (id) = { | |
84 | + | let currentStartHeight = getStartHeight(id) | |
85 | + | if ((currentStartHeight == -1)) | |
86 | + | then throw("No vote found for id!") | |
87 | + | else if (((currentStartHeight + VOTING_BLOCKS) > height)) | |
88 | + | then throw("Vote can not be closed yet!") | |
89 | + | else { | |
90 | + | let statusKey = getStatusKey(id) | |
91 | + | [StringEntry(statusKey, VOTE_CLOSED)] | |
92 | + | } | |
93 | + | } | |
94 | + | ||
95 | + | ||
96 | + | ||
97 | + | @Callable(i) | |
98 | + | func claim (id) = { | |
99 | + | let startHeight = getStartHeight(id) | |
100 | + | if ((startHeight == -1)) | |
101 | + | then throw("No vote started for this id!") | |
102 | + | else if (((startHeight + VOTING_BLOCKS) >= height)) | |
103 | + | then throw("You can only claim after vote ends!") | |
104 | + | else { | |
105 | + | let caller = i.caller | |
106 | + | let repaymentKey = getRepaymentKey(id, caller) | |
107 | + | let repayAmount = getRefundAmount(repaymentKey) | |
108 | + | let statusKey = getStatusKey(id) | |
109 | + | if ((repayAmount > 0)) | |
110 | + | then [ScriptTransfer(caller, repayAmount, DYZ_ASSET_ID), StringEntry(statusKey, VOTE_CLOSED), IntegerEntry(repaymentKey, 0)] | |
111 | + | else throw("Nothing to claim!") | |
112 | + | } | |
113 | + | } | |
114 | + | ||
115 | + | ||
116 | + | ||
117 | + | @Callable(i) | |
118 | + | func vote (id,vote) = if ((size(i.payments) != 1)) | |
119 | + | then throw("One payment in DZY needs to be attached") | |
120 | + | else { | |
121 | + | let payment = value(i.payments[0]) | |
122 | + | let caller = i.caller | |
123 | + | if (!(isAllowed(caller))) | |
124 | + | then throw("Address not allowed to vote!") | |
125 | + | else { | |
126 | + | let amount = payment.amount | |
127 | + | if (!(isDefined(payment.assetId))) | |
128 | + | then throw("Payment in Waves not allowed!") | |
129 | + | else { | |
130 | + | let assetId = toBase58String(value(payment.assetId)) | |
131 | + | let repaymentKey = getRepaymentKey(id, caller) | |
132 | + | let refundAmount = getRefundAmount(repaymentKey) | |
133 | + | if ((refundAmount != -1)) | |
134 | + | then throw("Only one vote per id per address!") | |
135 | + | else if ((assetId != toBase58String(DYZ_ASSET_ID))) | |
136 | + | then throw("payment in DZY necessary!") | |
137 | + | else if ((amount != MIN_DYZ_AMOUNT)) | |
138 | + | then throw("payment amount wrong!") | |
139 | + | else { | |
140 | + | let voteStatus = getVoteStatus(id) | |
141 | + | if ((voteStatus == VOTE_CLOSED)) | |
142 | + | then throw("vote closed!") | |
143 | + | else { | |
144 | + | let openHeight = match getInteger(this, getOpenKey(id)) { | |
145 | + | case a: Int => | |
146 | + | a | |
147 | + | case _ => | |
148 | + | 0 | |
149 | + | } | |
150 | + | if ((height > (openHeight + VOTING_BLOCKS))) | |
151 | + | then throw("voting ended!") | |
152 | + | else { | |
153 | + | let newEntry = if ((vote == true)) | |
154 | + | then { | |
155 | + | let yesVoteKey = getTotalYesKey(id) | |
156 | + | let yesVotesSoFar = match getInteger(this, yesVoteKey) { | |
157 | + | case a: Int => | |
158 | + | a | |
159 | + | case _ => | |
160 | + | 0 | |
161 | + | } | |
162 | + | let newYesVotes = (yesVotesSoFar + 1) | |
163 | + | [IntegerEntry(yesVoteKey, newYesVotes), IntegerEntry(repaymentKey, amount)] | |
164 | + | } | |
165 | + | else if ((vote == false)) | |
166 | + | then { | |
167 | + | let noVoteKey = getTotalNoKey(id) | |
168 | + | let noVotesSoFar = match getInteger(this, noVoteKey) { | |
169 | + | case a: Int => | |
170 | + | a | |
171 | + | case _ => | |
172 | + | 0 | |
173 | + | } | |
174 | + | let newNoVotes = (noVotesSoFar + 1) | |
175 | + | [IntegerEntry(noVoteKey, newNoVotes), IntegerEntry(repaymentKey, amount)] | |
176 | + | } | |
177 | + | else nil | |
178 | + | newEntry | |
179 | + | } | |
180 | + | } | |
181 | + | } | |
182 | + | } | |
183 | + | } | |
184 | + | } | |
185 | + | ||
186 | + | ||
187 | + | @Verifier(tx) | |
188 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
189 | + |
github/deemru/w8io/026f985 32.46 ms ◑