tx · J3tJi6bV1jGFPYQ4Z4eqyjZ4ZoQvHHE8P5BJQ9dQf2bS 3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq: -0.01400000 Waves 2023.07.21 15:03 [2675588] smart account 3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq > SELF 0.00000000 Waves
{ "type": 13, "id": "J3tJi6bV1jGFPYQ4Z4eqyjZ4ZoQvHHE8P5BJQ9dQf2bS", "fee": 1400000, "feeAssetId": null, "timestamp": 1689941018885, "version": 2, "chainId": 84, "sender": "3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq", "senderPublicKey": "57SkjQUEwC1ayCqLbXLuzBqifK6B6SR6rfxtGsbAo3zW", "proofs": [ "5AHEpwWtYkvh7ZaRfztzvJZXGzvJcHaufs54j37RweJY5uSeR2MH5CSbTyi7hwRo6T2xScoCDBnhPDyL2Biq8vuN" ], "script": "base64:BgIfCAISAwoBARIAEgMKAQgSAwoBARIDCgEIEgASAwoBCCwADGNvbnRyYWN0RmlsZQIQbXB0X3N0YWtpbmcucmlkZQADU0VQAgJfXwAGc2NhbGU4AIDC1y8AEkFERFJFU1NfQllURVNfU0laRQAaAA1CTE9DS1NfSU5fREFZAAoBCHRocm93RXJyAQNtc2cJAAIBCQCsAgIJAKwCAgUMY29udHJhY3RGaWxlAgI6IAUDbXNnAAprZXlBc3NldElkCQC5CQIJAMwIAgICJXMJAMwIAgIHYXNzZXRJZAUDbmlsBQNTRVAAE2tleUVtaXNzaW9uUGVyQmxvY2sJALkJAgkAzAgCAgIlcwkAzAgCAhBlbWlzc2lvblBlckJsb2NrBQNuaWwFA1NFUAANa2V5U3RhcnRCbG9jawkAuQkCCQDMCAICAiVzCQDMCAICCnN0YXJ0QmxvY2sFA25pbAUDU0VQABBrZXlUb3RhbExwQW1vdW50CQC5CQIJAMwIAgICJXMJAMwIAgINdG90YWxMcEFtb3VudAUDbmlsBQNTRVAAE2tleVRvdGFsQXNzZXRBbW91bnQJALkJAgkAzAg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H8MSURBEh Next: 9oVmtXc14ZJfo7dwmYj9qdGnC9i5y8C4MnhTyxbdTW7p Diff:
Old | New | Differences | |
---|---|---|---|
9 | 9 | ||
10 | 10 | let ADDRESS_BYTES_SIZE = 26 | |
11 | 11 | ||
12 | - | let BLOCKS_IN_DAY = | |
12 | + | let BLOCKS_IN_DAY = 10 | |
13 | 13 | ||
14 | 14 | func throwErr (msg) = throw(((contractFile + ": ") + msg)) | |
15 | 15 | ||
83 | 83 | ||
84 | 84 | ||
85 | 85 | func genVotesKeysHelper (a,adminAddress) = { | |
86 | - | let $ | |
87 | - | let result = $ | |
88 | - | let prefix = $ | |
86 | + | let $t024082432 = a | |
87 | + | let result = $t024082432._1 | |
88 | + | let prefix = $t024082432._2 | |
89 | 89 | $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix) | |
90 | 90 | } | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func genVotesKeys (keyPrefix) = { | |
94 | 94 | let adminList = keyAdminAddressList() | |
95 | - | let $ | |
95 | + | let $t025792663 = { | |
96 | 96 | let $l = getAdminsList() | |
97 | 97 | let $s = size($l) | |
98 | 98 | let $acc0 = $Tuple2(nil, keyPrefix) | |
106 | 106 | ||
107 | 107 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
108 | 108 | } | |
109 | - | let result = $ | |
110 | - | let prefix = $ | |
109 | + | let result = $t025792663._1 | |
110 | + | let prefix = $t025792663._2 | |
111 | 111 | result | |
112 | 112 | } | |
113 | 113 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let contractFile = "mpt_staking.ride" | |
5 | 5 | ||
6 | 6 | let SEP = "__" | |
7 | 7 | ||
8 | 8 | let scale8 = 100000000 | |
9 | 9 | ||
10 | 10 | let ADDRESS_BYTES_SIZE = 26 | |
11 | 11 | ||
12 | - | let BLOCKS_IN_DAY = | |
12 | + | let BLOCKS_IN_DAY = 10 | |
13 | 13 | ||
14 | 14 | func throwErr (msg) = throw(((contractFile + ": ") + msg)) | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | let keyAssetId = makeString(["%s", "assetId"], SEP) | |
18 | 18 | ||
19 | 19 | let keyEmissionPerBlock = makeString(["%s", "emissionPerBlock"], SEP) | |
20 | 20 | ||
21 | 21 | let keyStartBlock = makeString(["%s", "startBlock"], SEP) | |
22 | 22 | ||
23 | 23 | let keyTotalLpAmount = makeString(["%s", "totalLpAmount"], SEP) | |
24 | 24 | ||
25 | 25 | let keyTotalAssetAmount = makeString(["%s", "totalAssetAmount"], SEP) | |
26 | 26 | ||
27 | 27 | func keyUserLpAmount (userAddress) = makeString(["%s%s", "userLpAmount", userAddress], SEP) | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func keyUserTotalAssetWithdrawn (userAddress) = makeString(["%s%s", "totalAssetWithdrawn", userAddress], SEP) | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func keyUserTotalAssetStaked (userAddress) = makeString(["%s%s", "totalAssetStaked", userAddress], SEP) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | let totalLpAmount = valueOrElse(getInteger(this, keyTotalLpAmount), 0) | |
37 | 37 | ||
38 | 38 | let totalAssetAmount = valueOrElse(getInteger(this, keyTotalAssetAmount), 0) | |
39 | 39 | ||
40 | 40 | let assetIdString = valueOrElse(getString(this, keyAssetId), "WAVES") | |
41 | 41 | ||
42 | 42 | let assetIdBytes = if ((assetIdString == "WAVES")) | |
43 | 43 | then unit | |
44 | 44 | else fromBase58String(assetIdString) | |
45 | 45 | ||
46 | 46 | let emissionPerDay = (valueOrElse(getInteger(this, keyEmissionPerBlock), 0) * BLOCKS_IN_DAY) | |
47 | 47 | ||
48 | 48 | let heightInDays = fraction(height, 1, BLOCKS_IN_DAY) | |
49 | 49 | ||
50 | 50 | let ADMIN_LIST_SIZE = 5 | |
51 | 51 | ||
52 | 52 | let QUORUM = 3 | |
53 | 53 | ||
54 | 54 | let TXID_BYTES_LENGTH = 32 | |
55 | 55 | ||
56 | 56 | func keyAllowedTxIdVotePrefix (txId) = makeString(["%s%s%s", "allowTxId", txId], SEP) | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | func keyFullAdminVote (prefix,adminAddress) = makeString([prefix, adminAddress], SEP) | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP) | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func keyAllowedTxId () = makeString(["%s", "txId"], SEP) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func getAdminVote (prefix,admin) = { | |
69 | 69 | let voteKey = keyFullAdminVote(prefix, admin) | |
70 | 70 | valueOrElse(getInteger(voteKey), 0) | |
71 | 71 | } | |
72 | 72 | ||
73 | 73 | ||
74 | 74 | func getAdminsList () = match getString(this, keyAdminAddressList()) { | |
75 | 75 | case s: String => | |
76 | 76 | split(s, SEP) | |
77 | 77 | case _ => | |
78 | 78 | nil | |
79 | 79 | } | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func isInAdminList (address) = containsElement(getAdminsList(), address) | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func genVotesKeysHelper (a,adminAddress) = { | |
86 | - | let $ | |
87 | - | let result = $ | |
88 | - | let prefix = $ | |
86 | + | let $t024082432 = a | |
87 | + | let result = $t024082432._1 | |
88 | + | let prefix = $t024082432._2 | |
89 | 89 | $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix) | |
90 | 90 | } | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func genVotesKeys (keyPrefix) = { | |
94 | 94 | let adminList = keyAdminAddressList() | |
95 | - | let $ | |
95 | + | let $t025792663 = { | |
96 | 96 | let $l = getAdminsList() | |
97 | 97 | let $s = size($l) | |
98 | 98 | let $acc0 = $Tuple2(nil, keyPrefix) | |
99 | 99 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
100 | 100 | then $a | |
101 | 101 | else genVotesKeysHelper($a, $l[$i]) | |
102 | 102 | ||
103 | 103 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
104 | 104 | then $a | |
105 | 105 | else throw("List size exceeds 5") | |
106 | 106 | ||
107 | 107 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
108 | 108 | } | |
109 | - | let result = $ | |
110 | - | let prefix = $ | |
109 | + | let result = $t025792663._1 | |
110 | + | let prefix = $t025792663._2 | |
111 | 111 | result | |
112 | 112 | } | |
113 | 113 | ||
114 | 114 | ||
115 | 115 | func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0)) | |
116 | 116 | ||
117 | 117 | ||
118 | 118 | func countVotes (prefix) = { | |
119 | 119 | let votes = genVotesKeys(prefix) | |
120 | 120 | let $l = votes | |
121 | 121 | let $s = size($l) | |
122 | 122 | let $acc0 = 0 | |
123 | 123 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
124 | 124 | then $a | |
125 | 125 | else countVotesHelper($a, $l[$i]) | |
126 | 126 | ||
127 | 127 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
128 | 128 | then $a | |
129 | 129 | else throw("List size exceeds 5") | |
130 | 130 | ||
131 | 131 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
132 | 132 | } | |
133 | 133 | ||
134 | 134 | ||
135 | 135 | func clearVotesHelper (result,key) = (result :+ DeleteEntry(key)) | |
136 | 136 | ||
137 | 137 | ||
138 | 138 | func getClearVoteEntries (prefix) = { | |
139 | 139 | let votes = genVotesKeys(prefix) | |
140 | 140 | let $l = votes | |
141 | 141 | let $s = size($l) | |
142 | 142 | let $acc0 = nil | |
143 | 143 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
144 | 144 | then $a | |
145 | 145 | else clearVotesHelper($a, $l[$i]) | |
146 | 146 | ||
147 | 147 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
148 | 148 | then $a | |
149 | 149 | else throw("List size exceeds 5") | |
150 | 150 | ||
151 | 151 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
152 | 152 | } | |
153 | 153 | ||
154 | 154 | ||
155 | 155 | func voteINTERNAL (callerAddressString,keyPrefix,minVotes,voteResult) = { | |
156 | 156 | let voteKey = keyFullAdminVote(keyPrefix, callerAddressString) | |
157 | 157 | let adminCurrentVote = getAdminVote(keyPrefix, callerAddressString) | |
158 | 158 | let err = if (!(isInAdminList(callerAddressString))) | |
159 | 159 | then throwErr((("Address: " + callerAddressString) + " not in Admin list")) | |
160 | 160 | else if ((adminCurrentVote == 1)) | |
161 | 161 | then throwErr((voteKey + " you already voted")) | |
162 | 162 | else unit | |
163 | 163 | if ((err == err)) | |
164 | 164 | then { | |
165 | 165 | let votes = countVotes(keyPrefix) | |
166 | 166 | if (((votes + 1) >= minVotes)) | |
167 | 167 | then { | |
168 | 168 | let clearVoteEntries = getClearVoteEntries(keyPrefix) | |
169 | 169 | (clearVoteEntries ++ voteResult) | |
170 | 170 | } | |
171 | 171 | else [IntegerEntry(voteKey, 1)] | |
172 | 172 | } | |
173 | 173 | else throw("Strict value is not equal to itself.") | |
174 | 174 | } | |
175 | 175 | ||
176 | 176 | ||
177 | 177 | func calcTotalProfit () = { | |
178 | 178 | let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0) | |
179 | 179 | let startDay = fraction(startBlock, 1, BLOCKS_IN_DAY) | |
180 | 180 | let elapsedDays = (heightInDays - startDay) | |
181 | 181 | max([0, (emissionPerDay * elapsedDays)]) | |
182 | 182 | } | |
183 | 183 | ||
184 | 184 | ||
185 | 185 | func getTotalAssetAmountWithProfitOrMaxAvailable () = { | |
186 | 186 | let totalAssetAmountWithProfit = (totalAssetAmount + calcTotalProfit()) | |
187 | 187 | let totalAmount = match assetIdBytes { | |
188 | 188 | case u: Unit => | |
189 | 189 | min([totalAssetAmountWithProfit, wavesBalance(this).available]) | |
190 | 190 | case b: ByteVector => | |
191 | 191 | min([totalAssetAmountWithProfit, assetBalance(this, b)]) | |
192 | 192 | case _ => | |
193 | 193 | throw("Match error") | |
194 | 194 | } | |
195 | 195 | if ((totalLpAmount == 0)) | |
196 | 196 | then 0 | |
197 | 197 | else totalAmount | |
198 | 198 | } | |
199 | 199 | ||
200 | 200 | ||
201 | 201 | func getCurrentPrice () = if ((totalLpAmount != 0)) | |
202 | 202 | then fraction(getTotalAssetAmountWithProfitOrMaxAvailable(), scale8, totalLpAmount) | |
203 | 203 | else (1 * scale8) | |
204 | 204 | ||
205 | 205 | ||
206 | 206 | func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0) | |
207 | 207 | ||
208 | 208 | ||
209 | 209 | func getUserAvailableAssetsToWithdraw (userAddress) = { | |
210 | 210 | let userLpAmount = getUserLpAmount(userAddress) | |
211 | 211 | let userAvailableAssetToWithdraw = fraction(userLpAmount, getCurrentPrice(), scale8) | |
212 | 212 | if ((getCurrentPrice() > (userAvailableAssetToWithdraw * scale8))) | |
213 | 213 | then 0 | |
214 | 214 | else userAvailableAssetToWithdraw | |
215 | 215 | } | |
216 | 216 | ||
217 | 217 | ||
218 | 218 | func getStakeActions (i,userAddress) = { | |
219 | 219 | let checks = [if ((size(i.payments) == 1)) | |
220 | 220 | then true | |
221 | 221 | else throwErr("should include 1 payment"), if ((i.payments[0].assetId == assetIdBytes)) | |
222 | 222 | then true | |
223 | 223 | else throwErr(("payment should be in " + assetIdString)), if ((i.payments[0].amount > 0)) | |
224 | 224 | then true | |
225 | 225 | else "payment amount should be greater than 0"] | |
226 | 226 | if ((checks == checks)) | |
227 | 227 | then { | |
228 | 228 | let paymentAmount = i.payments[0].amount | |
229 | 229 | let paymentLpAmount = fraction(paymentAmount, scale8, getCurrentPrice()) | |
230 | 230 | let userLpAmount = getUserLpAmount(userAddress) | |
231 | 231 | let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
232 | 232 | let newTotalLpAmount = (totalLpAmount + paymentLpAmount) | |
233 | 233 | let newTotalAssetAmount = (totalAssetAmount + paymentAmount) | |
234 | 234 | let newUserLpAmount = (userLpAmount + paymentLpAmount) | |
235 | 235 | let newUserTotalStakedAmount = (userTotalStakedAmount + paymentAmount) | |
236 | 236 | let updateStartHeightAction = if ((totalLpAmount == 0)) | |
237 | 237 | then [IntegerEntry(keyStartBlock, height)] | |
238 | 238 | else nil | |
239 | 239 | ([IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction) | |
240 | 240 | } | |
241 | 241 | else throw("Strict value is not equal to itself.") | |
242 | 242 | } | |
243 | 243 | ||
244 | 244 | ||
245 | 245 | func getWithdrawActions (i,lpAssetWithdrawAmount) = { | |
246 | 246 | let userAddress = toString(i.caller) | |
247 | 247 | let userLpAmount = getUserLpAmount(userAddress) | |
248 | 248 | let check = [if ((lpAssetWithdrawAmount > 0)) | |
249 | 249 | then true | |
250 | 250 | else throwErr("amount should be more than 0"), if ((userLpAmount >= lpAssetWithdrawAmount)) | |
251 | 251 | then true | |
252 | 252 | else throwErr((("cannot withdraw more than available (" + toString(userLpAmount)) + ")"))] | |
253 | 253 | if ((check == check)) | |
254 | 254 | then { | |
255 | 255 | let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount) | |
256 | 256 | let withdrawAssetAmount = fraction(lpAssetWithdrawAmount, getCurrentPrice(), scale8) | |
257 | 257 | let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount) | |
258 | 258 | let newTotalAssetAmount = fraction(newTotalLpAmount, getCurrentPrice(), scale8) | |
259 | 259 | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
260 | 260 | let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount) | |
261 | 261 | [IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)] | |
262 | 262 | } | |
263 | 263 | else throw("Strict value is not equal to itself.") | |
264 | 264 | } | |
265 | 265 | ||
266 | 266 | ||
267 | 267 | @Callable(i) | |
268 | 268 | func setEmissionPerBlock (emissionPerBlock) = { | |
269 | 269 | let check = [if ((i.caller == this)) | |
270 | 270 | then true | |
271 | 271 | else throwErr("permission denied")] | |
272 | 272 | if ((check == check)) | |
273 | 273 | then [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPerBlock, max([0, emissionPerBlock]))] | |
274 | 274 | else throw("Strict value is not equal to itself.") | |
275 | 275 | } | |
276 | 276 | ||
277 | 277 | ||
278 | 278 | ||
279 | 279 | @Callable(i) | |
280 | 280 | func stake () = getStakeActions(i, toString(i.caller)) | |
281 | 281 | ||
282 | 282 | ||
283 | 283 | ||
284 | 284 | @Callable(i) | |
285 | 285 | func stakeFor (userAddress) = { | |
286 | 286 | let check = [if ((size(fromBase58String(userAddress)) == ADDRESS_BYTES_SIZE)) | |
287 | 287 | then true | |
288 | 288 | else throwErr("address is not valid")] | |
289 | 289 | if ((check == check)) | |
290 | 290 | then getStakeActions(i, userAddress) | |
291 | 291 | else throw("Strict value is not equal to itself.") | |
292 | 292 | } | |
293 | 293 | ||
294 | 294 | ||
295 | 295 | ||
296 | 296 | @Callable(i) | |
297 | 297 | func withdraw (withdrawAssetAmount) = { | |
298 | 298 | let userAddress = toString(i.caller) | |
299 | 299 | let userLpAmount = getUserLpAmount(userAddress) | |
300 | 300 | let lpAmountToWithdraw = fraction(withdrawAssetAmount, scale8, getCurrentPrice()) | |
301 | 301 | let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress) | |
302 | 302 | let check = [if ((withdrawAssetAmount > 0)) | |
303 | 303 | then true | |
304 | 304 | else throwErr("withdraw amount should be more than 0"), if ((userAvailableAssetToWithdraw >= withdrawAssetAmount)) | |
305 | 305 | then true | |
306 | 306 | else throwErr((("cannot withdraw more than available (" + toString(userAvailableAssetToWithdraw)) + ")"))] | |
307 | 307 | if ((check == check)) | |
308 | 308 | then getWithdrawActions(i, lpAmountToWithdraw) | |
309 | 309 | else throw("Strict value is not equal to itself.") | |
310 | 310 | } | |
311 | 311 | ||
312 | 312 | ||
313 | 313 | ||
314 | 314 | @Callable(i) | |
315 | 315 | func getUserAssetsREADONLY (userAddress) = { | |
316 | 316 | let userLpAmount = getUserLpAmount(userAddress) | |
317 | 317 | let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress) | |
318 | 318 | let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
319 | 319 | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
320 | 320 | $Tuple2(nil, $Tuple5(userLpAmount, userAvailableAssetToWithdraw, getCurrentPrice(), userTotalStakedAmount, userTotalAssetWithdrawn)) | |
321 | 321 | } | |
322 | 322 | ||
323 | 323 | ||
324 | 324 | ||
325 | 325 | @Callable(i) | |
326 | 326 | func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple3(totalLpAmount, getTotalAssetAmountWithProfitOrMaxAvailable(), getCurrentPrice())) | |
327 | 327 | ||
328 | 328 | ||
329 | 329 | ||
330 | 330 | @Callable(i) | |
331 | 331 | func voteForTxId (txId) = { | |
332 | 332 | let callerAddressString = toBase58String(i.caller.bytes) | |
333 | 333 | let keyPrefix = keyAllowedTxIdVotePrefix(txId) | |
334 | 334 | let result = [StringEntry(keyAllowedTxId(), txId)] | |
335 | 335 | let allowedTxIdOption = getString(this, keyAllowedTxId()) | |
336 | 336 | let err = [if ((size(fromBase58String(txId)) == TXID_BYTES_LENGTH)) | |
337 | 337 | then true | |
338 | 338 | else throwErr((txId + " is not valid txId")), if (if ((allowedTxIdOption == unit)) | |
339 | 339 | then true | |
340 | 340 | else (value(allowedTxIdOption) != txId)) | |
341 | 341 | then true | |
342 | 342 | else throwErr((txId + " is already allowed"))] | |
343 | 343 | if ((err == err)) | |
344 | 344 | then voteINTERNAL(callerAddressString, keyPrefix, QUORUM, result) | |
345 | 345 | else throw("Strict value is not equal to itself.") | |
346 | 346 | } | |
347 | 347 | ||
348 | 348 | ||
349 | 349 | @Verifier(tx) | |
350 | 350 | func verify () = { | |
351 | 351 | let byAdmins = (tx.id == fromBase58String(valueOrElse(getString(this, keyAllowedTxId()), ""))) | |
352 | 352 | let byOwner = if ((size(getAdminsList()) >= QUORUM)) | |
353 | 353 | then false | |
354 | 354 | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
355 | 355 | if (byAdmins) | |
356 | 356 | then true | |
357 | 357 | else byOwner | |
358 | 358 | } | |
359 | 359 |
github/deemru/w8io/169f3d6 42.72 ms ◑