tx · L5dEc1bUtmwWiQh1Ho2vr4FeSaASoWXhERhWsKD5y4T 3Mzep1R5kHeC1ecKFkWjuhU3Gw4LAdCib9N: -0.01000000 Waves 2023.11.08 16:28 [2834437] smart account 3Mzep1R5kHeC1ecKFkWjuhU3Gw4LAdCib9N > SELF 0.00000000 Waves
{ "type": 13, "id": "L5dEc1bUtmwWiQh1Ho2vr4FeSaASoWXhERhWsKD5y4T", "fee": 1000000, "feeAssetId": null, "timestamp": 1699450133412, "version": 2, "chainId": 84, "sender": "3Mzep1R5kHeC1ecKFkWjuhU3Gw4LAdCib9N", "senderPublicKey": "41THq9VrFxHEvVGJyz2oMpJQErnSkkqJXpBypSDxa5Mv", "proofs": [ "86MGT8hRE7axQTSShW55623i354QYzdB1P3AYz2HjoiCpK2sSaqxsEzDX8wRTBoGzGTFjh12GVaMDeGnkZuWFEH" ], "script": "base64:BgJSCAISBAoCCAgSBAoCCAESBAoCCAQSBAoCCAISAwoBCBIDCgEBEgMKAQESBQoDAgECEgUKAwIYGBIECgICARIICgYICAgBAgESBAoCCBgSAwoBCDIACXNlcGFyYXRvcgICX18AB2NoYWluSWQJAMkBAgkAygECCAUEdGhpcwVieXRlcwABAAEACGNoYWluSWRUAQFUAAhjaGFpbklkVwEBVwELbXVzdEFkZHJlc3MCAWkHYWRkcmVzcwMJAAACCAUBaQZjYWxsZXIFB2FkZHJlc3MGCQACAQIRcGVybWlzc2lvbiBkZW5pZWQBCG11c3RUaGlzAQFpCQELbXVzdEFkZHJlc3MCBQFpBQR0aGlzAANTRVACAl9fAAVXQVZFUwIFV0FWRVMAEGNvbnRyYWN0RmlsZW5hbWUCEnd4ZGFvX2ZhY3RvcnkucmlkZQEHd3JhcEVycgEBcwkArAICCQCsAgIFEGNvbnRyYWN0RmlsZW5hbWUCAjogBQFzAQh0aHJvd0VycgEBcwkAAgEJAQd3cmFwRXJyAQUBcwEPc3RyaW5nVG9Bc3NldElkAQFzAwkAAAIFAXMFBVdBVkVTBQR1bml0CQD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WRPcHRpb24FBHVuaXQGCQECIT0CCQEFdmFsdWUBBRFhbGxvd2VkVHhJZE9wdGlvbgUEdHhJZAYJAQh0aHJvd0VycgEJAKwCAgUEdHhJZAITIGlzIGFscmVhZHkgYWxsb3dlZAUDbmlsAwkAAAIFA2VycgUDZXJyCQEMdm90ZUlOVEVSTkFMBAUTY2FsbGVyQWRkcmVzc1N0cmluZwUJa2V5UHJlZml4BQZRVU9SVU0FBnJlc3VsdAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAECmJ5UHJvcG9zYWwEByRtYXRjaDAFGXZvdGluZ1Jlc3VsdEFkZHJlc3NPcHRpb24DCQABAgUHJG1hdGNoMAIHQWRkcmVzcwQPcHJvcG9zYWxBZGRyZXNzBQckbWF0Y2gwCQELdmFsdWVPckVsc2UCCQCbCAIFD3Byb3Bvc2FsQWRkcmVzcwkBGWtleVByb3Bvc2FsQWxsb3dCcm9hZGNhc3QCBQR0aGlzCAUCdHgCaWQHBwQIYnlBZG1pbnMJAAACCAUCdHgCaWQJANkEAQkBC3ZhbHVlT3JFbHNlAgkAnQgCBQR0aGlzCQEOa2V5QWxsb3dlZFR4SWQAAgAEB2J5T3duZXIDCQBnAgkAkAMBCQENZ2V0QWRtaW5zTGlzdAAFBlFVT1JVTQcJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXkDAwUKYnlQcm9wb3NhbAYFCGJ5QWRtaW5zBgUHYnlPd25lcn7eq+k=", "height": 2834437, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GxbVASMqHKqKyJLwGcQCNNTAH9sukSbtqETeFGxQY5nE Next: 2AnQUPScjXu7B8u5ETtoD7VLeAFPRozVwoThe5HBHnr6 Diff:
Old | New | Differences | |
---|---|---|---|
21 | 21 | ||
22 | 22 | let WAVES = "WAVES" | |
23 | 23 | ||
24 | - | let contractFilename = "wxdao_ | |
24 | + | let contractFilename = "wxdao_factory.ride" | |
25 | 25 | ||
26 | 26 | func wrapErr (s) = ((contractFilename + ": ") + s) | |
27 | 27 | ||
29 | 29 | func throwErr (s) = throw(wrapErr(s)) | |
30 | 30 | ||
31 | 31 | ||
32 | - | func keyConfigAddress () = "%s__powerConfigAddress" | |
32 | + | func stringToAssetId (s) = if ((s == WAVES)) | |
33 | + | then unit | |
34 | + | else fromBase58String(s) | |
33 | 35 | ||
34 | 36 | ||
35 | - | func powerConfigAddress (factoryAddress) = valueOrErrorMessage(match getString(this, keyConfigAddress()) { | |
37 | + | let ADMIN_LIST_SIZE = 5 | |
38 | + | ||
39 | + | let QUORUM = 3 | |
40 | + | ||
41 | + | let TXID_BYTES_LENGTH = 32 | |
42 | + | ||
43 | + | func keyAllowedTxIdVotePrefix (txId) = makeString(["%s%s%s", "allowTxId", txId], SEP) | |
44 | + | ||
45 | + | ||
46 | + | func keyFullAdminVote (prefix,adminAddress) = makeString([prefix, adminAddress], SEP) | |
47 | + | ||
48 | + | ||
49 | + | func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP) | |
50 | + | ||
51 | + | ||
52 | + | func keyAllowedTxId () = makeString(["%s", "txId"], SEP) | |
53 | + | ||
54 | + | ||
55 | + | func getAdminVote (prefix,admin) = { | |
56 | + | let voteKey = keyFullAdminVote(prefix, admin) | |
57 | + | valueOrElse(getInteger(voteKey), 0) | |
58 | + | } | |
59 | + | ||
60 | + | ||
61 | + | func getAdminsList () = match getString(this, keyAdminAddressList()) { | |
62 | + | case s: String => | |
63 | + | split(s, SEP) | |
64 | + | case _ => | |
65 | + | nil | |
66 | + | } | |
67 | + | ||
68 | + | ||
69 | + | func isInAdminList (address) = containsElement(getAdminsList(), address) | |
70 | + | ||
71 | + | ||
72 | + | func genVotesKeysHelper (a,adminAddress) = { | |
73 | + | let $t014801504 = a | |
74 | + | let result = $t014801504._1 | |
75 | + | let prefix = $t014801504._2 | |
76 | + | $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix) | |
77 | + | } | |
78 | + | ||
79 | + | ||
80 | + | func genVotesKeys (keyPrefix) = { | |
81 | + | let adminList = keyAdminAddressList() | |
82 | + | let $t016511735 = { | |
83 | + | let $l = getAdminsList() | |
84 | + | let $s = size($l) | |
85 | + | let $acc0 = $Tuple2(nil, keyPrefix) | |
86 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
87 | + | then $a | |
88 | + | else genVotesKeysHelper($a, $l[$i]) | |
89 | + | ||
90 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
91 | + | then $a | |
92 | + | else throw("List size exceeds 5") | |
93 | + | ||
94 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
95 | + | } | |
96 | + | let result = $t016511735._1 | |
97 | + | let prefix = $t016511735._2 | |
98 | + | result | |
99 | + | } | |
100 | + | ||
101 | + | ||
102 | + | func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0)) | |
103 | + | ||
104 | + | ||
105 | + | func countVotes (prefix) = { | |
106 | + | let votes = genVotesKeys(prefix) | |
107 | + | let $l = votes | |
108 | + | let $s = size($l) | |
109 | + | let $acc0 = 0 | |
110 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
111 | + | then $a | |
112 | + | else countVotesHelper($a, $l[$i]) | |
113 | + | ||
114 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
115 | + | then $a | |
116 | + | else throw("List size exceeds 5") | |
117 | + | ||
118 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
119 | + | } | |
120 | + | ||
121 | + | ||
122 | + | func clearVotesHelper (result,key) = (result :+ DeleteEntry(key)) | |
123 | + | ||
124 | + | ||
125 | + | func getClearVoteEntries (prefix) = { | |
126 | + | let votes = genVotesKeys(prefix) | |
127 | + | let $l = votes | |
128 | + | let $s = size($l) | |
129 | + | let $acc0 = nil | |
130 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
131 | + | then $a | |
132 | + | else clearVotesHelper($a, $l[$i]) | |
133 | + | ||
134 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
135 | + | then $a | |
136 | + | else throw("List size exceeds 5") | |
137 | + | ||
138 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
139 | + | } | |
140 | + | ||
141 | + | ||
142 | + | func voteINTERNAL (callerAddressString,keyPrefix,minVotes,voteResult) = { | |
143 | + | let voteKey = keyFullAdminVote(keyPrefix, callerAddressString) | |
144 | + | let adminCurrentVote = getAdminVote(keyPrefix, callerAddressString) | |
145 | + | let err = if (!(isInAdminList(callerAddressString))) | |
146 | + | then throwErr((("Address: " + callerAddressString) + " not in Admin list")) | |
147 | + | else if ((adminCurrentVote == 1)) | |
148 | + | then throwErr((voteKey + " you already voted")) | |
149 | + | else unit | |
150 | + | if ((err == err)) | |
151 | + | then { | |
152 | + | let votes = countVotes(keyPrefix) | |
153 | + | if (((votes + 1) >= minVotes)) | |
154 | + | then { | |
155 | + | let clearVoteEntries = getClearVoteEntries(keyPrefix) | |
156 | + | (clearVoteEntries ++ voteResult) | |
157 | + | } | |
158 | + | else [IntegerEntry(voteKey, 1)] | |
159 | + | } | |
160 | + | else throw("Strict value is not equal to itself.") | |
161 | + | } | |
162 | + | ||
163 | + | ||
164 | + | func keyCalculatorAddress () = "%s__calculatorAddress" | |
165 | + | ||
166 | + | ||
167 | + | func keyLpAssetId () = "%s__lpAssetId" | |
168 | + | ||
169 | + | ||
170 | + | func currentPeriod () = makeString(["%s", "currentPeriod"], SEP) | |
171 | + | ||
172 | + | ||
173 | + | func startHeightByPeriod (period) = makeString(["%s%d", "startHeight", toString(period)], SEP) | |
174 | + | ||
175 | + | ||
176 | + | func periodLength () = makeString(["%s", "periodLength"], SEP) | |
177 | + | ||
178 | + | ||
179 | + | func treasuryValueByPeriod (period) = makeString(["%s%d", "treasuryValue", toString(period)], SEP) | |
180 | + | ||
181 | + | ||
182 | + | func treasuryValue () = makeString(["%s", "treasuryValue"], SEP) | |
183 | + | ||
184 | + | ||
185 | + | let calculatorAddressOption = match getString(this, keyCalculatorAddress()) { | |
36 | 186 | case s: String => | |
37 | 187 | addressFromString(s) | |
38 | 188 | case _: Unit => | |
39 | 189 | unit | |
40 | 190 | case _ => | |
41 | 191 | throw("Match error") | |
42 | - | } | |
192 | + | } | |
43 | 193 | ||
194 | + | let calculatorAddressOrFail = valueOrErrorMessage(calculatorAddressOption, wrapErr("invalid calculator address")) | |
44 | 195 | ||
45 | - | func keyPowerAssetId () = "powerAssetId" | |
46 | - | ||
47 | - | ||
48 | - | func powerAssetId (factoryAddress) = fromBase58String(valueOrErrorMessage(getString(powerConfigAddress(factoryAddress), keyPowerAssetId()), wrapErr("invalid power asset id"))) | |
196 | + | func keyConfigAddress () = "%s__powerConfigAddress" | |
49 | 197 | ||
50 | 198 | ||
51 | 199 | func keyPowerContractAddress () = "%s__powerContractAddress" | |
52 | 200 | ||
53 | 201 | ||
54 | - | func powerContractAddress (factoryAddress) = valueOrErrorMessage(match getString(factoryAddress, keyPowerContractAddress()) { | |
202 | + | func keyVotingResultAddress () = "contract_voting_result" | |
203 | + | ||
204 | + | ||
205 | + | func keyProposalAllowBroadcast (address,txId) = ((("proposal_allow_broadcast_" + toString(address)) + "_") + toBase58String(txId)) | |
206 | + | ||
207 | + | ||
208 | + | let configAddressOption = match getString(this, keyConfigAddress()) { | |
55 | 209 | case s: String => | |
56 | 210 | addressFromString(s) | |
57 | 211 | case _: Unit => | |
58 | 212 | unit | |
59 | 213 | case _ => | |
60 | 214 | throw("Match error") | |
61 | - | }, wrapErr("invalid power contract address")) | |
215 | + | } | |
216 | + | ||
217 | + | let votingResultAddressOption = match configAddressOption { | |
218 | + | case a: Address => | |
219 | + | match getString(a, keyVotingResultAddress()) { | |
220 | + | case s: String => | |
221 | + | addressFromString(s) | |
222 | + | case _: Unit => | |
223 | + | unit | |
224 | + | case _ => | |
225 | + | throw("Match error") | |
226 | + | } | |
227 | + | case _: Unit => | |
228 | + | unit | |
229 | + | case _ => | |
230 | + | throw("Match error") | |
231 | + | } | |
232 | + | ||
233 | + | let votingResultAddressOrFail = valueOrErrorMessage(votingResultAddressOption, wrapErr("invalid voting result address")) | |
234 | + | ||
235 | + | let lpAssetIdOption = match getString(this, keyLpAssetId()) { | |
236 | + | case s: String => | |
237 | + | fromBase58String(s) | |
238 | + | case _: Unit => | |
239 | + | unit | |
240 | + | case _ => | |
241 | + | throw("Match error") | |
242 | + | } | |
243 | + | ||
244 | + | let lpAssetIdOrFail = valueOrErrorMessage(lpAssetIdOption, wrapErr("invalid lpAssetId")) | |
245 | + | ||
246 | + | func onlyAddress (i,address) = if ((i.caller == address)) | |
247 | + | then true | |
248 | + | else throwErr("permission denied") | |
62 | 249 | ||
63 | 250 | ||
64 | - | func | |
251 | + | func onlyThis (i) = onlyAddress(i, this) | |
65 | 252 | ||
66 | 253 | ||
67 | - | func | |
254 | + | func onlyCalculator (i) = onlyAddress(i, calculatorAddressOrFail) | |
68 | 255 | ||
69 | 256 | ||
70 | 257 | @Callable(i) | |
71 | - | func withdraw (args) = { | |
72 | - | let recipient = addressFromStringValue(args[0]) | |
73 | - | let amount = parseIntValue(args[1]) | |
74 | - | let result = invoke(i.caller, "transferWaves", [recipient.bytes, amount], nil) | |
258 | + | func stringEntry (key,val) = if (onlyCalculator(i)) | |
259 | + | then $Tuple2([StringEntry(key, val)], key) | |
260 | + | else $Tuple2(nil, unit) | |
261 | + | ||
262 | + | ||
263 | + | ||
264 | + | @Callable(i) | |
265 | + | func integerEntry (key,val) = if (onlyCalculator(i)) | |
266 | + | then $Tuple2([IntegerEntry(key, val)], key) | |
267 | + | else $Tuple2(nil, unit) | |
268 | + | ||
269 | + | ||
270 | + | ||
271 | + | @Callable(i) | |
272 | + | func booleanEntry (key,val) = if (onlyCalculator(i)) | |
273 | + | then $Tuple2([BooleanEntry(key, val)], key) | |
274 | + | else $Tuple2(nil, unit) | |
275 | + | ||
276 | + | ||
277 | + | ||
278 | + | @Callable(i) | |
279 | + | func binaryEntry (key,val) = if (onlyCalculator(i)) | |
280 | + | then $Tuple2([BinaryEntry(key, val)], key) | |
281 | + | else $Tuple2(nil, unit) | |
282 | + | ||
283 | + | ||
284 | + | ||
285 | + | @Callable(i) | |
286 | + | func deleteEntry (key) = if (onlyCalculator(i)) | |
287 | + | then $Tuple2([DeleteEntry(key)], key) | |
288 | + | else $Tuple2(nil, unit) | |
289 | + | ||
290 | + | ||
291 | + | ||
292 | + | @Callable(i) | |
293 | + | func reissue (amount) = if (onlyCalculator(i)) | |
294 | + | then $Tuple2([Reissue(lpAssetIdOrFail, amount, true)], amount) | |
295 | + | else $Tuple2(nil, unit) | |
296 | + | ||
297 | + | ||
298 | + | ||
299 | + | @Callable(i) | |
300 | + | func burn (amount) = if (onlyCalculator(i)) | |
301 | + | then $Tuple2([Burn(lpAssetIdOrFail, amount)], amount) | |
302 | + | else $Tuple2(nil, unit) | |
303 | + | ||
304 | + | ||
305 | + | ||
306 | + | @Callable(i) | |
307 | + | func transferAsset (recipientBytes,amount,assetId) = if (onlyCalculator(i)) | |
308 | + | then $Tuple2([ScriptTransfer(Address(recipientBytes), amount, assetId)], amount) | |
309 | + | else $Tuple2(nil, unit) | |
310 | + | ||
311 | + | ||
312 | + | ||
313 | + | @Callable(i) | |
314 | + | func transferAssets (recipientBytes,assetsList,amountsList) = if (onlyCalculator(i)) | |
315 | + | then { | |
316 | + | func addNewTransfer (acc,nextAssetId) = { | |
317 | + | let $t063846408 = acc | |
318 | + | let transfers = $t063846408._1 | |
319 | + | let j = $t063846408._2 | |
320 | + | let newTransfer = ScriptTransfer(Address(recipientBytes), parseIntValue(amountsList[j]), stringToAssetId(assetsList[j])) | |
321 | + | let updatedTransfers = (transfers :+ newTransfer) | |
322 | + | $Tuple2(updatedTransfers, (j + 1)) | |
323 | + | } | |
324 | + | ||
325 | + | let $t066686749 = { | |
326 | + | let $l = assetsList | |
327 | + | let $s = size($l) | |
328 | + | let $acc0 = $Tuple2(nil, 0) | |
329 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
330 | + | then $a | |
331 | + | else addNewTransfer($a, $l[$i]) | |
332 | + | ||
333 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
334 | + | then $a | |
335 | + | else throw("List size exceeds 10") | |
336 | + | ||
337 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
338 | + | } | |
339 | + | let assetsTransfers = $t066686749._1 | |
340 | + | let _lastIndex = $t066686749._2 | |
341 | + | $Tuple2(assetsTransfers, unit) | |
342 | + | } | |
343 | + | else $Tuple2(nil, unit) | |
344 | + | ||
345 | + | ||
346 | + | ||
347 | + | @Callable(i) | |
348 | + | func transferWaves (recipientBytes,amount) = if (onlyCalculator(i)) | |
349 | + | then $Tuple2([ScriptTransfer(Address(recipientBytes), amount, unit)], amount) | |
350 | + | else $Tuple2(nil, unit) | |
351 | + | ||
352 | + | ||
353 | + | ||
354 | + | @Callable(i) | |
355 | + | func commitAfterStartWithLockRoundFor (contract,child,address,additionalLockRounds,paymentAssetId,paymentAmount) = $Tuple2(nil, invoke(addressFromStringValue(contract), "commitAfterStartWithLockRoundFor", [child, address, additionalLockRounds], [AttachedPayment(paymentAssetId, paymentAmount)])) | |
356 | + | ||
357 | + | ||
358 | + | ||
359 | + | @Callable(i) | |
360 | + | func call (function,args) = { | |
361 | + | let result = reentrantInvoke(calculatorAddressOrFail, function, [i.callerPublicKey, args], i.payments) | |
75 | 362 | $Tuple2(nil, result) | |
76 | 363 | } | |
77 | 364 | ||
78 | 365 | ||
79 | 366 | ||
80 | 367 | @Callable(i) | |
81 | - | func setIntParam (args) = { | |
82 | - | let key = args[0] | |
83 | - | let val = parseIntValue(args[1]) | |
84 | - | let result = invoke(i.caller, "integerEntry", [key, val], nil) | |
85 | - | $Tuple2(nil, result) | |
86 | - | } | |
87 | - | ||
88 | - | ||
89 | - | ||
90 | - | @Callable(i) | |
91 | - | func swap (callerPublicKey,args) = $Tuple2(nil, unit) | |
92 | - | ||
93 | - | ||
94 | - | ||
95 | - | @Callable(i) | |
96 | - | func claim (callerPublicKey,args) = { | |
97 | - | let factoryAddress = i.caller | |
98 | - | let userAddress = addressFromPublicKey(callerPublicKey) | |
99 | - | let available = valueOrElse(getInteger(factoryAddress, keyAvailable(userAddress)), 0) | |
100 | - | let claimed = valueOrElse(getBoolean(factoryAddress, keyClaimed(userAddress)), false) | |
101 | - | let checks = [if ((available > 0)) | |
368 | + | func voteForTxId (txId) = { | |
369 | + | let callerAddressString = toBase58String(i.caller.bytes) | |
370 | + | let keyPrefix = keyAllowedTxIdVotePrefix(txId) | |
371 | + | let result = [StringEntry(keyAllowedTxId(), txId)] | |
372 | + | let allowedTxIdOption = getString(this, keyAllowedTxId()) | |
373 | + | let err = [if ((size(fromBase58String(txId)) == TXID_BYTES_LENGTH)) | |
102 | 374 | then true | |
103 | - | else throwErr(" | |
375 | + | else throwErr((txId + " is not valid txId")), if (if ((allowedTxIdOption == unit)) | |
104 | 376 | then true | |
105 | - | else throwErr("already claimed")] | |
106 | - | if ((checks == checks)) | |
107 | - | then { | |
108 | - | let additionalLockRounds = 0 | |
109 | - | let factoryActions = [invoke(factoryAddress, "booleanEntry", [keyClaimed(userAddress), true], nil), invoke(factoryAddress, "commitAfterStartWithLockRoundFor", [powerContractAddress(factoryAddress), toString(factoryAddress), toString(userAddress), additionalLockRounds, powerAssetId(factoryAddress), available], i.payments)] | |
110 | - | $Tuple2(nil, factoryActions) | |
111 | - | } | |
377 | + | else (value(allowedTxIdOption) != txId)) | |
378 | + | then true | |
379 | + | else throwErr((txId + " is already allowed"))] | |
380 | + | if ((err == err)) | |
381 | + | then voteINTERNAL(callerAddressString, keyPrefix, QUORUM, result) | |
112 | 382 | else throw("Strict value is not equal to itself.") | |
113 | 383 | } | |
114 | 384 | ||
115 | 385 | ||
116 | - | ||
117 | - | @Callable(i) | |
118 | - | func price (callerPublicKey,args) = $Tuple2(nil, 0) | |
119 | - | ||
120 | - | ||
121 | 386 | @Verifier(tx) | |
122 | - | func verify () = (chainId == chainIdT) | |
387 | + | func verify () = { | |
388 | + | let byProposal = match votingResultAddressOption { | |
389 | + | case proposalAddress: Address => | |
390 | + | valueOrElse(getBoolean(proposalAddress, keyProposalAllowBroadcast(this, tx.id)), false) | |
391 | + | case _ => | |
392 | + | false | |
393 | + | } | |
394 | + | let byAdmins = (tx.id == fromBase58String(valueOrElse(getString(this, keyAllowedTxId()), ""))) | |
395 | + | let byOwner = if ((size(getAdminsList()) >= QUORUM)) | |
396 | + | then false | |
397 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
398 | + | if (if (byProposal) | |
399 | + | then true | |
400 | + | else byAdmins) | |
401 | + | then true | |
402 | + | else byOwner | |
403 | + | } | |
123 | 404 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "__" | |
5 | 5 | ||
6 | 6 | let chainId = take(drop(this.bytes, 1), 1) | |
7 | 7 | ||
8 | 8 | let chainIdT = base58'2T' | |
9 | 9 | ||
10 | 10 | let chainIdW = base58'2W' | |
11 | 11 | ||
12 | 12 | func mustAddress (i,address) = if ((i.caller == address)) | |
13 | 13 | then true | |
14 | 14 | else throw("permission denied") | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func mustThis (i) = mustAddress(i, this) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | let SEP = "__" | |
21 | 21 | ||
22 | 22 | let WAVES = "WAVES" | |
23 | 23 | ||
24 | - | let contractFilename = "wxdao_ | |
24 | + | let contractFilename = "wxdao_factory.ride" | |
25 | 25 | ||
26 | 26 | func wrapErr (s) = ((contractFilename + ": ") + s) | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func throwErr (s) = throw(wrapErr(s)) | |
30 | 30 | ||
31 | 31 | ||
32 | - | func keyConfigAddress () = "%s__powerConfigAddress" | |
32 | + | func stringToAssetId (s) = if ((s == WAVES)) | |
33 | + | then unit | |
34 | + | else fromBase58String(s) | |
33 | 35 | ||
34 | 36 | ||
35 | - | func powerConfigAddress (factoryAddress) = valueOrErrorMessage(match getString(this, keyConfigAddress()) { | |
37 | + | let ADMIN_LIST_SIZE = 5 | |
38 | + | ||
39 | + | let QUORUM = 3 | |
40 | + | ||
41 | + | let TXID_BYTES_LENGTH = 32 | |
42 | + | ||
43 | + | func keyAllowedTxIdVotePrefix (txId) = makeString(["%s%s%s", "allowTxId", txId], SEP) | |
44 | + | ||
45 | + | ||
46 | + | func keyFullAdminVote (prefix,adminAddress) = makeString([prefix, adminAddress], SEP) | |
47 | + | ||
48 | + | ||
49 | + | func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP) | |
50 | + | ||
51 | + | ||
52 | + | func keyAllowedTxId () = makeString(["%s", "txId"], SEP) | |
53 | + | ||
54 | + | ||
55 | + | func getAdminVote (prefix,admin) = { | |
56 | + | let voteKey = keyFullAdminVote(prefix, admin) | |
57 | + | valueOrElse(getInteger(voteKey), 0) | |
58 | + | } | |
59 | + | ||
60 | + | ||
61 | + | func getAdminsList () = match getString(this, keyAdminAddressList()) { | |
62 | + | case s: String => | |
63 | + | split(s, SEP) | |
64 | + | case _ => | |
65 | + | nil | |
66 | + | } | |
67 | + | ||
68 | + | ||
69 | + | func isInAdminList (address) = containsElement(getAdminsList(), address) | |
70 | + | ||
71 | + | ||
72 | + | func genVotesKeysHelper (a,adminAddress) = { | |
73 | + | let $t014801504 = a | |
74 | + | let result = $t014801504._1 | |
75 | + | let prefix = $t014801504._2 | |
76 | + | $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix) | |
77 | + | } | |
78 | + | ||
79 | + | ||
80 | + | func genVotesKeys (keyPrefix) = { | |
81 | + | let adminList = keyAdminAddressList() | |
82 | + | let $t016511735 = { | |
83 | + | let $l = getAdminsList() | |
84 | + | let $s = size($l) | |
85 | + | let $acc0 = $Tuple2(nil, keyPrefix) | |
86 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
87 | + | then $a | |
88 | + | else genVotesKeysHelper($a, $l[$i]) | |
89 | + | ||
90 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
91 | + | then $a | |
92 | + | else throw("List size exceeds 5") | |
93 | + | ||
94 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
95 | + | } | |
96 | + | let result = $t016511735._1 | |
97 | + | let prefix = $t016511735._2 | |
98 | + | result | |
99 | + | } | |
100 | + | ||
101 | + | ||
102 | + | func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0)) | |
103 | + | ||
104 | + | ||
105 | + | func countVotes (prefix) = { | |
106 | + | let votes = genVotesKeys(prefix) | |
107 | + | let $l = votes | |
108 | + | let $s = size($l) | |
109 | + | let $acc0 = 0 | |
110 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
111 | + | then $a | |
112 | + | else countVotesHelper($a, $l[$i]) | |
113 | + | ||
114 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
115 | + | then $a | |
116 | + | else throw("List size exceeds 5") | |
117 | + | ||
118 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
119 | + | } | |
120 | + | ||
121 | + | ||
122 | + | func clearVotesHelper (result,key) = (result :+ DeleteEntry(key)) | |
123 | + | ||
124 | + | ||
125 | + | func getClearVoteEntries (prefix) = { | |
126 | + | let votes = genVotesKeys(prefix) | |
127 | + | let $l = votes | |
128 | + | let $s = size($l) | |
129 | + | let $acc0 = nil | |
130 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
131 | + | then $a | |
132 | + | else clearVotesHelper($a, $l[$i]) | |
133 | + | ||
134 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
135 | + | then $a | |
136 | + | else throw("List size exceeds 5") | |
137 | + | ||
138 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
139 | + | } | |
140 | + | ||
141 | + | ||
142 | + | func voteINTERNAL (callerAddressString,keyPrefix,minVotes,voteResult) = { | |
143 | + | let voteKey = keyFullAdminVote(keyPrefix, callerAddressString) | |
144 | + | let adminCurrentVote = getAdminVote(keyPrefix, callerAddressString) | |
145 | + | let err = if (!(isInAdminList(callerAddressString))) | |
146 | + | then throwErr((("Address: " + callerAddressString) + " not in Admin list")) | |
147 | + | else if ((adminCurrentVote == 1)) | |
148 | + | then throwErr((voteKey + " you already voted")) | |
149 | + | else unit | |
150 | + | if ((err == err)) | |
151 | + | then { | |
152 | + | let votes = countVotes(keyPrefix) | |
153 | + | if (((votes + 1) >= minVotes)) | |
154 | + | then { | |
155 | + | let clearVoteEntries = getClearVoteEntries(keyPrefix) | |
156 | + | (clearVoteEntries ++ voteResult) | |
157 | + | } | |
158 | + | else [IntegerEntry(voteKey, 1)] | |
159 | + | } | |
160 | + | else throw("Strict value is not equal to itself.") | |
161 | + | } | |
162 | + | ||
163 | + | ||
164 | + | func keyCalculatorAddress () = "%s__calculatorAddress" | |
165 | + | ||
166 | + | ||
167 | + | func keyLpAssetId () = "%s__lpAssetId" | |
168 | + | ||
169 | + | ||
170 | + | func currentPeriod () = makeString(["%s", "currentPeriod"], SEP) | |
171 | + | ||
172 | + | ||
173 | + | func startHeightByPeriod (period) = makeString(["%s%d", "startHeight", toString(period)], SEP) | |
174 | + | ||
175 | + | ||
176 | + | func periodLength () = makeString(["%s", "periodLength"], SEP) | |
177 | + | ||
178 | + | ||
179 | + | func treasuryValueByPeriod (period) = makeString(["%s%d", "treasuryValue", toString(period)], SEP) | |
180 | + | ||
181 | + | ||
182 | + | func treasuryValue () = makeString(["%s", "treasuryValue"], SEP) | |
183 | + | ||
184 | + | ||
185 | + | let calculatorAddressOption = match getString(this, keyCalculatorAddress()) { | |
36 | 186 | case s: String => | |
37 | 187 | addressFromString(s) | |
38 | 188 | case _: Unit => | |
39 | 189 | unit | |
40 | 190 | case _ => | |
41 | 191 | throw("Match error") | |
42 | - | } | |
192 | + | } | |
43 | 193 | ||
194 | + | let calculatorAddressOrFail = valueOrErrorMessage(calculatorAddressOption, wrapErr("invalid calculator address")) | |
44 | 195 | ||
45 | - | func keyPowerAssetId () = "powerAssetId" | |
46 | - | ||
47 | - | ||
48 | - | func powerAssetId (factoryAddress) = fromBase58String(valueOrErrorMessage(getString(powerConfigAddress(factoryAddress), keyPowerAssetId()), wrapErr("invalid power asset id"))) | |
196 | + | func keyConfigAddress () = "%s__powerConfigAddress" | |
49 | 197 | ||
50 | 198 | ||
51 | 199 | func keyPowerContractAddress () = "%s__powerContractAddress" | |
52 | 200 | ||
53 | 201 | ||
54 | - | func powerContractAddress (factoryAddress) = valueOrErrorMessage(match getString(factoryAddress, keyPowerContractAddress()) { | |
202 | + | func keyVotingResultAddress () = "contract_voting_result" | |
203 | + | ||
204 | + | ||
205 | + | func keyProposalAllowBroadcast (address,txId) = ((("proposal_allow_broadcast_" + toString(address)) + "_") + toBase58String(txId)) | |
206 | + | ||
207 | + | ||
208 | + | let configAddressOption = match getString(this, keyConfigAddress()) { | |
55 | 209 | case s: String => | |
56 | 210 | addressFromString(s) | |
57 | 211 | case _: Unit => | |
58 | 212 | unit | |
59 | 213 | case _ => | |
60 | 214 | throw("Match error") | |
61 | - | }, wrapErr("invalid power contract address")) | |
215 | + | } | |
216 | + | ||
217 | + | let votingResultAddressOption = match configAddressOption { | |
218 | + | case a: Address => | |
219 | + | match getString(a, keyVotingResultAddress()) { | |
220 | + | case s: String => | |
221 | + | addressFromString(s) | |
222 | + | case _: Unit => | |
223 | + | unit | |
224 | + | case _ => | |
225 | + | throw("Match error") | |
226 | + | } | |
227 | + | case _: Unit => | |
228 | + | unit | |
229 | + | case _ => | |
230 | + | throw("Match error") | |
231 | + | } | |
232 | + | ||
233 | + | let votingResultAddressOrFail = valueOrErrorMessage(votingResultAddressOption, wrapErr("invalid voting result address")) | |
234 | + | ||
235 | + | let lpAssetIdOption = match getString(this, keyLpAssetId()) { | |
236 | + | case s: String => | |
237 | + | fromBase58String(s) | |
238 | + | case _: Unit => | |
239 | + | unit | |
240 | + | case _ => | |
241 | + | throw("Match error") | |
242 | + | } | |
243 | + | ||
244 | + | let lpAssetIdOrFail = valueOrErrorMessage(lpAssetIdOption, wrapErr("invalid lpAssetId")) | |
245 | + | ||
246 | + | func onlyAddress (i,address) = if ((i.caller == address)) | |
247 | + | then true | |
248 | + | else throwErr("permission denied") | |
62 | 249 | ||
63 | 250 | ||
64 | - | func | |
251 | + | func onlyThis (i) = onlyAddress(i, this) | |
65 | 252 | ||
66 | 253 | ||
67 | - | func | |
254 | + | func onlyCalculator (i) = onlyAddress(i, calculatorAddressOrFail) | |
68 | 255 | ||
69 | 256 | ||
70 | 257 | @Callable(i) | |
71 | - | func withdraw (args) = { | |
72 | - | let recipient = addressFromStringValue(args[0]) | |
73 | - | let amount = parseIntValue(args[1]) | |
74 | - | let result = invoke(i.caller, "transferWaves", [recipient.bytes, amount], nil) | |
258 | + | func stringEntry (key,val) = if (onlyCalculator(i)) | |
259 | + | then $Tuple2([StringEntry(key, val)], key) | |
260 | + | else $Tuple2(nil, unit) | |
261 | + | ||
262 | + | ||
263 | + | ||
264 | + | @Callable(i) | |
265 | + | func integerEntry (key,val) = if (onlyCalculator(i)) | |
266 | + | then $Tuple2([IntegerEntry(key, val)], key) | |
267 | + | else $Tuple2(nil, unit) | |
268 | + | ||
269 | + | ||
270 | + | ||
271 | + | @Callable(i) | |
272 | + | func booleanEntry (key,val) = if (onlyCalculator(i)) | |
273 | + | then $Tuple2([BooleanEntry(key, val)], key) | |
274 | + | else $Tuple2(nil, unit) | |
275 | + | ||
276 | + | ||
277 | + | ||
278 | + | @Callable(i) | |
279 | + | func binaryEntry (key,val) = if (onlyCalculator(i)) | |
280 | + | then $Tuple2([BinaryEntry(key, val)], key) | |
281 | + | else $Tuple2(nil, unit) | |
282 | + | ||
283 | + | ||
284 | + | ||
285 | + | @Callable(i) | |
286 | + | func deleteEntry (key) = if (onlyCalculator(i)) | |
287 | + | then $Tuple2([DeleteEntry(key)], key) | |
288 | + | else $Tuple2(nil, unit) | |
289 | + | ||
290 | + | ||
291 | + | ||
292 | + | @Callable(i) | |
293 | + | func reissue (amount) = if (onlyCalculator(i)) | |
294 | + | then $Tuple2([Reissue(lpAssetIdOrFail, amount, true)], amount) | |
295 | + | else $Tuple2(nil, unit) | |
296 | + | ||
297 | + | ||
298 | + | ||
299 | + | @Callable(i) | |
300 | + | func burn (amount) = if (onlyCalculator(i)) | |
301 | + | then $Tuple2([Burn(lpAssetIdOrFail, amount)], amount) | |
302 | + | else $Tuple2(nil, unit) | |
303 | + | ||
304 | + | ||
305 | + | ||
306 | + | @Callable(i) | |
307 | + | func transferAsset (recipientBytes,amount,assetId) = if (onlyCalculator(i)) | |
308 | + | then $Tuple2([ScriptTransfer(Address(recipientBytes), amount, assetId)], amount) | |
309 | + | else $Tuple2(nil, unit) | |
310 | + | ||
311 | + | ||
312 | + | ||
313 | + | @Callable(i) | |
314 | + | func transferAssets (recipientBytes,assetsList,amountsList) = if (onlyCalculator(i)) | |
315 | + | then { | |
316 | + | func addNewTransfer (acc,nextAssetId) = { | |
317 | + | let $t063846408 = acc | |
318 | + | let transfers = $t063846408._1 | |
319 | + | let j = $t063846408._2 | |
320 | + | let newTransfer = ScriptTransfer(Address(recipientBytes), parseIntValue(amountsList[j]), stringToAssetId(assetsList[j])) | |
321 | + | let updatedTransfers = (transfers :+ newTransfer) | |
322 | + | $Tuple2(updatedTransfers, (j + 1)) | |
323 | + | } | |
324 | + | ||
325 | + | let $t066686749 = { | |
326 | + | let $l = assetsList | |
327 | + | let $s = size($l) | |
328 | + | let $acc0 = $Tuple2(nil, 0) | |
329 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
330 | + | then $a | |
331 | + | else addNewTransfer($a, $l[$i]) | |
332 | + | ||
333 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
334 | + | then $a | |
335 | + | else throw("List size exceeds 10") | |
336 | + | ||
337 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
338 | + | } | |
339 | + | let assetsTransfers = $t066686749._1 | |
340 | + | let _lastIndex = $t066686749._2 | |
341 | + | $Tuple2(assetsTransfers, unit) | |
342 | + | } | |
343 | + | else $Tuple2(nil, unit) | |
344 | + | ||
345 | + | ||
346 | + | ||
347 | + | @Callable(i) | |
348 | + | func transferWaves (recipientBytes,amount) = if (onlyCalculator(i)) | |
349 | + | then $Tuple2([ScriptTransfer(Address(recipientBytes), amount, unit)], amount) | |
350 | + | else $Tuple2(nil, unit) | |
351 | + | ||
352 | + | ||
353 | + | ||
354 | + | @Callable(i) | |
355 | + | func commitAfterStartWithLockRoundFor (contract,child,address,additionalLockRounds,paymentAssetId,paymentAmount) = $Tuple2(nil, invoke(addressFromStringValue(contract), "commitAfterStartWithLockRoundFor", [child, address, additionalLockRounds], [AttachedPayment(paymentAssetId, paymentAmount)])) | |
356 | + | ||
357 | + | ||
358 | + | ||
359 | + | @Callable(i) | |
360 | + | func call (function,args) = { | |
361 | + | let result = reentrantInvoke(calculatorAddressOrFail, function, [i.callerPublicKey, args], i.payments) | |
75 | 362 | $Tuple2(nil, result) | |
76 | 363 | } | |
77 | 364 | ||
78 | 365 | ||
79 | 366 | ||
80 | 367 | @Callable(i) | |
81 | - | func setIntParam (args) = { | |
82 | - | let key = args[0] | |
83 | - | let val = parseIntValue(args[1]) | |
84 | - | let result = invoke(i.caller, "integerEntry", [key, val], nil) | |
85 | - | $Tuple2(nil, result) | |
86 | - | } | |
87 | - | ||
88 | - | ||
89 | - | ||
90 | - | @Callable(i) | |
91 | - | func swap (callerPublicKey,args) = $Tuple2(nil, unit) | |
92 | - | ||
93 | - | ||
94 | - | ||
95 | - | @Callable(i) | |
96 | - | func claim (callerPublicKey,args) = { | |
97 | - | let factoryAddress = i.caller | |
98 | - | let userAddress = addressFromPublicKey(callerPublicKey) | |
99 | - | let available = valueOrElse(getInteger(factoryAddress, keyAvailable(userAddress)), 0) | |
100 | - | let claimed = valueOrElse(getBoolean(factoryAddress, keyClaimed(userAddress)), false) | |
101 | - | let checks = [if ((available > 0)) | |
368 | + | func voteForTxId (txId) = { | |
369 | + | let callerAddressString = toBase58String(i.caller.bytes) | |
370 | + | let keyPrefix = keyAllowedTxIdVotePrefix(txId) | |
371 | + | let result = [StringEntry(keyAllowedTxId(), txId)] | |
372 | + | let allowedTxIdOption = getString(this, keyAllowedTxId()) | |
373 | + | let err = [if ((size(fromBase58String(txId)) == TXID_BYTES_LENGTH)) | |
102 | 374 | then true | |
103 | - | else throwErr(" | |
375 | + | else throwErr((txId + " is not valid txId")), if (if ((allowedTxIdOption == unit)) | |
104 | 376 | then true | |
105 | - | else throwErr("already claimed")] | |
106 | - | if ((checks == checks)) | |
107 | - | then { | |
108 | - | let additionalLockRounds = 0 | |
109 | - | let factoryActions = [invoke(factoryAddress, "booleanEntry", [keyClaimed(userAddress), true], nil), invoke(factoryAddress, "commitAfterStartWithLockRoundFor", [powerContractAddress(factoryAddress), toString(factoryAddress), toString(userAddress), additionalLockRounds, powerAssetId(factoryAddress), available], i.payments)] | |
110 | - | $Tuple2(nil, factoryActions) | |
111 | - | } | |
377 | + | else (value(allowedTxIdOption) != txId)) | |
378 | + | then true | |
379 | + | else throwErr((txId + " is already allowed"))] | |
380 | + | if ((err == err)) | |
381 | + | then voteINTERNAL(callerAddressString, keyPrefix, QUORUM, result) | |
112 | 382 | else throw("Strict value is not equal to itself.") | |
113 | 383 | } | |
114 | 384 | ||
115 | 385 | ||
116 | - | ||
117 | - | @Callable(i) | |
118 | - | func price (callerPublicKey,args) = $Tuple2(nil, 0) | |
119 | - | ||
120 | - | ||
121 | 386 | @Verifier(tx) | |
122 | - | func verify () = (chainId == chainIdT) | |
387 | + | func verify () = { | |
388 | + | let byProposal = match votingResultAddressOption { | |
389 | + | case proposalAddress: Address => | |
390 | + | valueOrElse(getBoolean(proposalAddress, keyProposalAllowBroadcast(this, tx.id)), false) | |
391 | + | case _ => | |
392 | + | false | |
393 | + | } | |
394 | + | let byAdmins = (tx.id == fromBase58String(valueOrElse(getString(this, keyAllowedTxId()), ""))) | |
395 | + | let byOwner = if ((size(getAdminsList()) >= QUORUM)) | |
396 | + | then false | |
397 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
398 | + | if (if (byProposal) | |
399 | + | then true | |
400 | + | else byAdmins) | |
401 | + | then true | |
402 | + | else byOwner | |
403 | + | } | |
123 | 404 |
github/deemru/w8io/026f985 44.39 ms ◑