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