tx · 3vNLwKZ7ywkKpGbgqP6yX4tKUizLA3DeWCqEWiiqAirE 3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq: -0.01400000 Waves 2023.07.21 15:12 [2675598] smart account 3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq > SELF 0.00000000 Waves
{ "type": 13, "id": "3vNLwKZ7ywkKpGbgqP6yX4tKUizLA3DeWCqEWiiqAirE", "fee": 1400000, "feeAssetId": null, "timestamp": 1689941556370, "version": 2, "chainId": 84, "sender": "3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq", "senderPublicKey": "57SkjQUEwC1ayCqLbXLuzBqifK6B6SR6rfxtGsbAo3zW", "proofs": [ "47oBh1iJ5FmFHJxTDgaJwycfGMQ7RKv5w7M5YvN9C3Mj9LpLsegWHsAwjn4mhH7ZeffR7su3M8icNwJ8qsxugTKT" ], "script": "base64:BgIfCAISAwoBARIAEgMKAQgSAwoBARIDCgEIEgASAwoBCC0ADGNvbnRyYWN0RmlsZQIQbXB0X3N0YWtpbmcucmlkZQADU0VQAgJfXwAGc2NhbGU4AIDC1y8AEkFERFJFU1NfQllURVNfU0laRQAaAA1CTE9DS1NfSU5fREFZAAoBCHRocm93RXJyAQNtc2cJAAIBCQCsAgIJAKwCAgUMY29udHJhY3RGaWxlAgI6IAUDbXNnAAprZXlBc3NldElkCQC5CQIJAMwIAgICJXMJAMwIAgIHYXNzZXRJZAUDbmlsBQNTRVAAE2tleUVtaXNzaW9uUGVyQmxvY2sJALkJAgkAzAgCAgIlcwkAzAgCAhBlbWlzc2lvblBlckJsb2NrBQNuaWwFA1NFUAANa2V5U3RhcnRCbG9jawkAuQkCCQDMCAICAiVzCQDMCAICCnN0YXJ0QmxvY2sFA25pbAUDU0VQABBrZXlUb3RhbExwQW1vdW50CQC5CQIJAMwIAgICJXMJAMwIAgINdG90YWxMcEFtb3VudAUDbmlsBQNTRVAAE2tleVRvdGFsQXNzZXRBbW91bnQJALkJAgkAzAgCAgIlcw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2VkVHhJZAACAAQHYnlPd25lcgMJAGcCCQCQAwEJAQ1nZXRBZG1pbnNMaXN0AAUGUVVPUlVNBwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleQMFCGJ5QWRtaW5zBgUHYnlPd25lchQGpW4=", "height": 2675598, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9oVmtXc14ZJfo7dwmYj9qdGnC9i5y8C4MnhTyxbdTW7p Next: 9YYT8QXW1hJbw7ZYCQwo98GL2475ot1oVjXLYD6LrrpT Diff:
Old | New | Differences | |
---|---|---|---|
186 | 186 | let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0) | |
187 | 187 | let startDay = fraction(startBlock, 1, BLOCKS_IN_DAY) | |
188 | 188 | let elapsedDays = (heightInDays - startDay) | |
189 | - | $ | |
189 | + | $Tuple5(startDay, heightInDays, elapsedDays, startBlock, height) | |
190 | 190 | } | |
191 | 191 | ||
192 | 192 |
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 | 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 | 86 | let $t024082432 = a | |
87 | 87 | let result = $t024082432._1 | |
88 | 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 | 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 | 109 | let result = $t025792663._1 | |
110 | 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 debugDays () = { | |
186 | 186 | let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0) | |
187 | 187 | let startDay = fraction(startBlock, 1, BLOCKS_IN_DAY) | |
188 | 188 | let elapsedDays = (heightInDays - startDay) | |
189 | - | $ | |
189 | + | $Tuple5(startDay, heightInDays, elapsedDays, startBlock, height) | |
190 | 190 | } | |
191 | 191 | ||
192 | 192 | ||
193 | 193 | func getTotalAssetAmountWithProfitOrMaxAvailable () = { | |
194 | 194 | let totalAssetAmountWithProfit = (totalAssetAmount + calcTotalProfit()) | |
195 | 195 | let totalAmount = match assetIdBytes { | |
196 | 196 | case u: Unit => | |
197 | 197 | min([totalAssetAmountWithProfit, wavesBalance(this).available]) | |
198 | 198 | case b: ByteVector => | |
199 | 199 | min([totalAssetAmountWithProfit, assetBalance(this, b)]) | |
200 | 200 | case _ => | |
201 | 201 | throw("Match error") | |
202 | 202 | } | |
203 | 203 | if ((totalLpAmount == 0)) | |
204 | 204 | then 0 | |
205 | 205 | else totalAmount | |
206 | 206 | } | |
207 | 207 | ||
208 | 208 | ||
209 | 209 | func getCurrentPrice () = if ((totalLpAmount != 0)) | |
210 | 210 | then fraction(getTotalAssetAmountWithProfitOrMaxAvailable(), scale8, totalLpAmount) | |
211 | 211 | else (1 * scale8) | |
212 | 212 | ||
213 | 213 | ||
214 | 214 | func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0) | |
215 | 215 | ||
216 | 216 | ||
217 | 217 | func getUserAvailableAssetsToWithdraw (userAddress) = { | |
218 | 218 | let userLpAmount = getUserLpAmount(userAddress) | |
219 | 219 | let userAvailableAssetToWithdraw = fraction(userLpAmount, getCurrentPrice(), scale8) | |
220 | 220 | if ((getCurrentPrice() > (userAvailableAssetToWithdraw * scale8))) | |
221 | 221 | then 0 | |
222 | 222 | else userAvailableAssetToWithdraw | |
223 | 223 | } | |
224 | 224 | ||
225 | 225 | ||
226 | 226 | func getStakeActions (i,userAddress) = { | |
227 | 227 | let checks = [if ((size(i.payments) == 1)) | |
228 | 228 | then true | |
229 | 229 | else throwErr("should include 1 payment"), if ((i.payments[0].assetId == assetIdBytes)) | |
230 | 230 | then true | |
231 | 231 | else throwErr(("payment should be in " + assetIdString)), if ((i.payments[0].amount > 0)) | |
232 | 232 | then true | |
233 | 233 | else "payment amount should be greater than 0"] | |
234 | 234 | if ((checks == checks)) | |
235 | 235 | then { | |
236 | 236 | let paymentAmount = i.payments[0].amount | |
237 | 237 | let paymentLpAmount = fraction(paymentAmount, scale8, getCurrentPrice()) | |
238 | 238 | let userLpAmount = getUserLpAmount(userAddress) | |
239 | 239 | let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
240 | 240 | let newTotalLpAmount = (totalLpAmount + paymentLpAmount) | |
241 | 241 | let newTotalAssetAmount = (totalAssetAmount + paymentAmount) | |
242 | 242 | let newUserLpAmount = (userLpAmount + paymentLpAmount) | |
243 | 243 | let newUserTotalStakedAmount = (userTotalStakedAmount + paymentAmount) | |
244 | 244 | let updateStartHeightAction = if ((totalLpAmount == 0)) | |
245 | 245 | then [IntegerEntry(keyStartBlock, height)] | |
246 | 246 | else nil | |
247 | 247 | ([IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction) | |
248 | 248 | } | |
249 | 249 | else throw("Strict value is not equal to itself.") | |
250 | 250 | } | |
251 | 251 | ||
252 | 252 | ||
253 | 253 | func getWithdrawActions (i,lpAssetWithdrawAmount) = { | |
254 | 254 | let userAddress = toString(i.caller) | |
255 | 255 | let userLpAmount = getUserLpAmount(userAddress) | |
256 | 256 | let check = [if ((lpAssetWithdrawAmount > 0)) | |
257 | 257 | then true | |
258 | 258 | else throwErr("amount should be more than 0"), if ((userLpAmount >= lpAssetWithdrawAmount)) | |
259 | 259 | then true | |
260 | 260 | else throwErr((("cannot withdraw more than available (" + toString(userLpAmount)) + ")"))] | |
261 | 261 | if ((check == check)) | |
262 | 262 | then { | |
263 | 263 | let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount) | |
264 | 264 | let withdrawAssetAmount = fraction(lpAssetWithdrawAmount, getCurrentPrice(), scale8) | |
265 | 265 | let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount) | |
266 | 266 | let newTotalAssetAmount = fraction(newTotalLpAmount, getCurrentPrice(), scale8) | |
267 | 267 | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
268 | 268 | let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount) | |
269 | 269 | [IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)] | |
270 | 270 | } | |
271 | 271 | else throw("Strict value is not equal to itself.") | |
272 | 272 | } | |
273 | 273 | ||
274 | 274 | ||
275 | 275 | @Callable(i) | |
276 | 276 | func setEmissionPerBlock (emissionPerBlock) = { | |
277 | 277 | let check = [if ((i.caller == this)) | |
278 | 278 | then true | |
279 | 279 | else throwErr("permission denied")] | |
280 | 280 | if ((check == check)) | |
281 | 281 | then [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPerBlock, max([0, emissionPerBlock]))] | |
282 | 282 | else throw("Strict value is not equal to itself.") | |
283 | 283 | } | |
284 | 284 | ||
285 | 285 | ||
286 | 286 | ||
287 | 287 | @Callable(i) | |
288 | 288 | func stake () = getStakeActions(i, toString(i.caller)) | |
289 | 289 | ||
290 | 290 | ||
291 | 291 | ||
292 | 292 | @Callable(i) | |
293 | 293 | func stakeFor (userAddress) = { | |
294 | 294 | let check = [if ((size(fromBase58String(userAddress)) == ADDRESS_BYTES_SIZE)) | |
295 | 295 | then true | |
296 | 296 | else throwErr("address is not valid")] | |
297 | 297 | if ((check == check)) | |
298 | 298 | then getStakeActions(i, userAddress) | |
299 | 299 | else throw("Strict value is not equal to itself.") | |
300 | 300 | } | |
301 | 301 | ||
302 | 302 | ||
303 | 303 | ||
304 | 304 | @Callable(i) | |
305 | 305 | func withdraw (withdrawAssetAmount) = { | |
306 | 306 | let userAddress = toString(i.caller) | |
307 | 307 | let userLpAmount = getUserLpAmount(userAddress) | |
308 | 308 | let lpAmountToWithdraw = fraction(withdrawAssetAmount, scale8, getCurrentPrice()) | |
309 | 309 | let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress) | |
310 | 310 | let check = [if ((withdrawAssetAmount > 0)) | |
311 | 311 | then true | |
312 | 312 | else throwErr("withdraw amount should be more than 0"), if ((userAvailableAssetToWithdraw >= withdrawAssetAmount)) | |
313 | 313 | then true | |
314 | 314 | else throwErr((("cannot withdraw more than available (" + toString(userAvailableAssetToWithdraw)) + ")"))] | |
315 | 315 | if ((check == check)) | |
316 | 316 | then getWithdrawActions(i, lpAmountToWithdraw) | |
317 | 317 | else throw("Strict value is not equal to itself.") | |
318 | 318 | } | |
319 | 319 | ||
320 | 320 | ||
321 | 321 | ||
322 | 322 | @Callable(i) | |
323 | 323 | func getUserAssetsREADONLY (userAddress) = { | |
324 | 324 | let userLpAmount = getUserLpAmount(userAddress) | |
325 | 325 | let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress) | |
326 | 326 | let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
327 | 327 | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
328 | 328 | $Tuple2(nil, $Tuple5(userLpAmount, userAvailableAssetToWithdraw, getCurrentPrice(), userTotalStakedAmount, userTotalAssetWithdrawn)) | |
329 | 329 | } | |
330 | 330 | ||
331 | 331 | ||
332 | 332 | ||
333 | 333 | @Callable(i) | |
334 | 334 | func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple3(totalLpAmount, getTotalAssetAmountWithProfitOrMaxAvailable(), getCurrentPrice())) | |
335 | 335 | ||
336 | 336 | ||
337 | 337 | ||
338 | 338 | @Callable(i) | |
339 | 339 | func voteForTxId (txId) = { | |
340 | 340 | let callerAddressString = toBase58String(i.caller.bytes) | |
341 | 341 | let keyPrefix = keyAllowedTxIdVotePrefix(txId) | |
342 | 342 | let result = [StringEntry(keyAllowedTxId(), txId)] | |
343 | 343 | let allowedTxIdOption = getString(this, keyAllowedTxId()) | |
344 | 344 | let err = [if ((size(fromBase58String(txId)) == TXID_BYTES_LENGTH)) | |
345 | 345 | then true | |
346 | 346 | else throwErr((txId + " is not valid txId")), if (if ((allowedTxIdOption == unit)) | |
347 | 347 | then true | |
348 | 348 | else (value(allowedTxIdOption) != txId)) | |
349 | 349 | then true | |
350 | 350 | else throwErr((txId + " is already allowed"))] | |
351 | 351 | if ((err == err)) | |
352 | 352 | then voteINTERNAL(callerAddressString, keyPrefix, QUORUM, result) | |
353 | 353 | else throw("Strict value is not equal to itself.") | |
354 | 354 | } | |
355 | 355 | ||
356 | 356 | ||
357 | 357 | @Verifier(tx) | |
358 | 358 | func verify () = { | |
359 | 359 | let byAdmins = (tx.id == fromBase58String(valueOrElse(getString(this, keyAllowedTxId()), ""))) | |
360 | 360 | let byOwner = if ((size(getAdminsList()) >= QUORUM)) | |
361 | 361 | then false | |
362 | 362 | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
363 | 363 | if (byAdmins) | |
364 | 364 | then true | |
365 | 365 | else byOwner | |
366 | 366 | } | |
367 | 367 |
github/deemru/w8io/026f985 37.90 ms ◑