tx · GGvfrA6NRCJKLMB7uEkTFa8V2dtpZehd8H2sd5c9s6vi 3MtKnDmJju2Y4dp9A2ACPr11jDZiW6gmKKK: -0.01000000 Waves 2022.01.16 16:13 [1881545] smart account 3MtKnDmJju2Y4dp9A2ACPr11jDZiW6gmKKK > SELF 0.00000000 Waves
{ "type": 13, "id": "GGvfrA6NRCJKLMB7uEkTFa8V2dtpZehd8H2sd5c9s6vi", "fee": 1000000, "feeAssetId": null, "timestamp": 1642338861550, "version": 2, "chainId": 84, "sender": "3MtKnDmJju2Y4dp9A2ACPr11jDZiW6gmKKK", "senderPublicKey": "3itc77jAZTQAcaPCyYEe4KD7h18CvqZZ2JRynZHsuJ61", "proofs": [ "5zjRhphVi7ZjU1M49MCmSmFwfdrqquvGamUC5WmgtxLqqJNNxefku6kEwiqutqkEfzbpnt3nTtC7CfW45PJmSvhw" ], "script": "base64:AAIFAAAAAAAAACkIAhIFCgMICAgSABIAEgMKAQgSBAoCCAESBAoCCAgSBAoCCAESAwoBCAAAAA0AAAAADGFkbWluQWRkcmVzcwkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABB0AAAACBQAAAAR0aGlzAgAAAAVhZG1pbgIAAAAAAAAAAAt0b3RhbFN1cHBseQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABBoAAAACBQAAAAR0aGlzAgAAAAt0b3RhbFN1cHBseQAAAAAAAAAAAAAAAAAOdm90aW5nRHVyYXRpb24JAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABBoAAAACBQAAAAR0aGlzAgAAAA52b3RpbmdEdXJhdGlvbgIAAAAfTm8ga2V5IHZvdGluZ0R1cmF0aW9uIHdhcyBmb3VuZAAAAAAIY3Rva2VuSWQJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABB0AAAACBQAAAAR0aGlzAgAAAAd0b2tlbklkAgAAABlObyBrZXkgZFRva2VuSWQgd2FzIGZvdW5kAQAAAAdpc0FkbWluAAAAAQAA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kcmVzcyBkb2VzIG5vdCBtYXRjaCB3aXRoIGFkbWluIGFkZHJlc3MhAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXnwSIt0", "height": 1881545, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GRyM6FrBGLeEMmpwogHbvzV8fWBt6ZjJb5bnDZdTrHz8 Next: 57eUJuyYivTEXwEu1R6trhtJxxMRAAYmTHLicSwgoNts Diff:
Old | New | Differences | |
---|---|---|---|
4 | 4 | let adminAddress = valueOrElse(getString(this, "admin"), "") | |
5 | 5 | ||
6 | 6 | let totalSupply = valueOrElse(getInteger(this, "totalSupply"), 0) | |
7 | + | ||
8 | + | let votingDuration = valueOrErrorMessage(getInteger(this, "votingDuration"), "No key votingDuration was found") | |
7 | 9 | ||
8 | 10 | let ctokenId = valueOrErrorMessage(getString(this, "tokenId"), "No key dTokenId was found") | |
9 | 11 | ||
18 | 20 | func writeString (key,stringValue) = StringEntry(key, stringValue) | |
19 | 21 | ||
20 | 22 | ||
23 | + | func countFrequency (helperList,votingList) = { | |
24 | + | func foldFrequency (accum,next) = { | |
25 | + | func countItems (acc,item) = if ((next == item)) | |
26 | + | then (acc + 1) | |
27 | + | else acc | |
28 | + | ||
29 | + | (accum :+ { | |
30 | + | let $l = votingList | |
31 | + | let $s = size($l) | |
32 | + | let $acc0 = 0 | |
33 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
34 | + | then $a | |
35 | + | else countItems($a, $l[$i]) | |
36 | + | ||
37 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
38 | + | then $a | |
39 | + | else throw("List size exceeds 5") | |
40 | + | ||
41 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
42 | + | }) | |
43 | + | } | |
44 | + | ||
45 | + | let $l = helperList | |
46 | + | let $s = size($l) | |
47 | + | let $acc0 = nil | |
48 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
49 | + | then $a | |
50 | + | else foldFrequency($a, $l[$i]) | |
51 | + | ||
52 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
53 | + | then $a | |
54 | + | else throw("List size exceeds 5") | |
55 | + | ||
56 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
57 | + | } | |
58 | + | ||
59 | + | ||
60 | + | func initVotingHelperList (voteArray) = { | |
61 | + | func foldHelperList (accum,next) = if ((containsElement(accum, next) == false)) | |
62 | + | then (accum :+ next) | |
63 | + | else accum | |
64 | + | ||
65 | + | let $l = voteArray | |
66 | + | let $s = size($l) | |
67 | + | let $acc0 = nil | |
68 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
69 | + | then $a | |
70 | + | else foldHelperList($a, $l[$i]) | |
71 | + | ||
72 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
73 | + | then $a | |
74 | + | else throw("List size exceeds 5") | |
75 | + | ||
76 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
77 | + | } | |
78 | + | ||
79 | + | ||
80 | + | func isGreaterThen (potential,itemList) = { | |
81 | + | let intPotential = parseIntValue(potential) | |
82 | + | let listLength = (size(itemList) - 1) | |
83 | + | let currentGreatest = itemList[listLength] | |
84 | + | if ((intPotential > currentGreatest)) | |
85 | + | then true | |
86 | + | else false | |
87 | + | } | |
88 | + | ||
89 | + | ||
90 | + | func findHighestVote (helperList,frequencies) = { | |
91 | + | func foldFrequencies (highestItemList,nextItem) = if ((size(highestItemList) == 0)) | |
92 | + | then (highestItemList :+ parseIntValue(nextItem)) | |
93 | + | else if (isGreaterThen(nextItem, highestItemList)) | |
94 | + | then (highestItemList :+ parseIntValue(nextItem)) | |
95 | + | else highestItemList | |
96 | + | ||
97 | + | let highestVotes = { | |
98 | + | let $l = frequencies | |
99 | + | let $s = size($l) | |
100 | + | let $acc0 = nil | |
101 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
102 | + | then $a | |
103 | + | else foldFrequencies($a, $l[$i]) | |
104 | + | ||
105 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
106 | + | then $a | |
107 | + | else throw("List size exceeds 5") | |
108 | + | ||
109 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
110 | + | } | |
111 | + | let lastIdx = (size(highestVotes) - 1) | |
112 | + | let highestVote = highestVotes[lastIdx] | |
113 | + | let helperIdx = indexOf(frequencies, toString(highestVote)) | |
114 | + | match helperIdx { | |
115 | + | case t: Int => | |
116 | + | helperList[t] | |
117 | + | case _ => | |
118 | + | throw("Type does not match!") | |
119 | + | } | |
120 | + | } | |
121 | + | ||
122 | + | ||
123 | + | func alterBoard (field,gameId,team) = { | |
124 | + | let currentBoard = getStringValue((gameId + "_board")) | |
125 | + | let boardList = split(currentBoard, ",") | |
126 | + | let teamTag = if ((team == "teamBlue")) | |
127 | + | then "B" | |
128 | + | else "Y" | |
129 | + | func foldBoard (accum,nextValue) = { | |
130 | + | let $t045024525 = accum | |
131 | + | let result = $t045024525._1 | |
132 | + | let j = $t045024525._2 | |
133 | + | if ((j == parseIntValue(field))) | |
134 | + | then $Tuple2((result :+ teamTag), (j + 1)) | |
135 | + | else $Tuple2((result :+ nextValue), (j + 1)) | |
136 | + | } | |
137 | + | ||
138 | + | let newBoardList = { | |
139 | + | let $l = boardList | |
140 | + | let $s = size($l) | |
141 | + | let $acc0 = $Tuple2(nil, 0) | |
142 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
143 | + | then $a | |
144 | + | else foldBoard($a, $l[$i]) | |
145 | + | ||
146 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
147 | + | then $a | |
148 | + | else throw("List size exceeds 42") | |
149 | + | ||
150 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42) | |
151 | + | } | |
152 | + | match newBoardList { | |
153 | + | case t: (List[String], Int) => | |
154 | + | makeString(t._1, ",") | |
155 | + | case _ => | |
156 | + | throw("Type does not match!") | |
157 | + | } | |
158 | + | } | |
159 | + | ||
160 | + | ||
161 | + | func updateVotingResults (gameId,round,activeTeam,currentVotingEntryList) = { | |
162 | + | func foldVotings (accum,nextValue) = (accum :+ split(nextValue, "_")[1]) | |
163 | + | ||
164 | + | let votes = { | |
165 | + | let $l = currentVotingEntryList | |
166 | + | let $s = size($l) | |
167 | + | let $acc0 = nil | |
168 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
169 | + | then $a | |
170 | + | else foldVotings($a, $l[$i]) | |
171 | + | ||
172 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
173 | + | then $a | |
174 | + | else throw("List size exceeds 5") | |
175 | + | ||
176 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
177 | + | } | |
178 | + | let helperList = initVotingHelperList(votes) | |
179 | + | let frequencies = countFrequency(helperList, votes) | |
180 | + | let votedField = findHighestVote(helperList, frequencies) | |
181 | + | alterBoard(votedField, gameId, activeTeam) | |
182 | + | } | |
183 | + | ||
184 | + | ||
21 | 185 | @Callable(i) | |
22 | 186 | func setup (adminAddress,tokenName,tokenDescription) = if (!(isDefined(getString(this, "admin")))) | |
23 | 187 | then { | |
24 | 188 | let asset = Issue(tokenName, tokenDescription, 0, 8, true) | |
25 | 189 | let tokenId = calculateAssetId(asset) | |
26 | - | [asset, writeString("admin", adminAddress), writeInteger("totalSupply", 0), writeString("tokenName", tokenName), writeString("tokenId", toBase58String(tokenId)), writeInteger("tokenDecimals", 8)] | |
190 | + | [asset, writeString("admin", adminAddress), writeInteger("votingDuration", 2), writeInteger("totalSupply", 0), writeString("tokenName", tokenName), writeString("tokenId", toBase58String(tokenId)), writeInteger("tokenDecimals", 8)] | |
27 | 191 | } | |
28 | 192 | else throw("Pool already setup!") | |
29 | 193 | ||
35 | 199 | let amount = i.payments[0].amount | |
36 | 200 | if ((amount >= 1)) | |
37 | 201 | then { | |
38 | - | let cTokenAmount = fraction(amount, | |
202 | + | let cTokenAmount = fraction(amount, 42, 1) | |
39 | 203 | let currentTotalSupply = (totalSupply + cTokenAmount) | |
40 | 204 | [writeInteger("totalSupply", currentTotalSupply), Reissue(fromBase58String(ctokenId), cTokenAmount, true), ScriptTransfer(i.caller, cTokenAmount, fromBase58String(ctokenId))] | |
41 | 205 | } | |
42 | 206 | else throw("Payment is to small!") | |
43 | 207 | } | |
44 | 208 | else throw("No payment attached!") | |
209 | + | ||
210 | + | ||
211 | + | ||
212 | + | @Callable(i) | |
213 | + | func createGame () = { | |
214 | + | let board = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" | |
215 | + | let gameId = toBase58String(i.transactionId) | |
216 | + | [writeString((gameId + "_board"), board), writeString((gameId + "_status"), "waiting for players"), writeString((gameId + "_teamBlue"), toString(i.caller)), writeString((gameId + "_teamYellow"), "")] | |
217 | + | } | |
218 | + | ||
219 | + | ||
220 | + | ||
221 | + | @Callable(i) | |
222 | + | func joinGame (gameId) = { | |
223 | + | let teamBlue = getStringValue((gameId + "_teamBlue")) | |
224 | + | let teamYellow = getStringValue((gameId + "_teamYellow")) | |
225 | + | let teamBlueList = split(teamBlue, ",") | |
226 | + | let teamYellowList = split(teamYellow, ",") | |
227 | + | if ((5 > size(teamBlueList))) | |
228 | + | then [writeString((gameId + "_teamBlue"), ((teamBlue + ",") + toBase58String(i.caller.bytes)))] | |
229 | + | else if ((size(teamYellowList) == 4)) | |
230 | + | then [writeString((gameId + "_status"), "round_1,turn_teamBlue"), writeString((gameId + "_voting_1"), ""), writeInteger((gameId + "_storedHeight"), (height + votingDuration)), writeString((gameId + "_teamYellow"), ((teamYellow + ",") + toBase58String(i.caller.bytes)))] | |
231 | + | else if ((4 > size(teamYellowList))) | |
232 | + | then [writeString((gameId + "_teamYellow"), ((teamYellow + ",") + toBase58String(i.caller.bytes)))] | |
233 | + | else throw("Teams are full, cannot join.") | |
234 | + | } | |
235 | + | ||
236 | + | ||
237 | + | ||
238 | + | @Callable(i) | |
239 | + | func vote (gameId,voting) = { | |
240 | + | let status = valueOrErrorMessage(getStringValue((gameId + "_status")), "No status entry found under gameId!") | |
241 | + | let round = parseIntValue(drop(split(status, ",")[0], 6)) | |
242 | + | let activeTeam = drop(split(status, ",")[1], 5) | |
243 | + | let storedHeight = valueOrErrorMessage(getInteger((gameId + "_storedHeight")), (("No status entry found under " + gameId) + "_storedHeight!")) | |
244 | + | let votingEntry = valueOrErrorMessage(getStringValue(((gameId + "_voting_") + toString(round))), "No votes found for this game id!") | |
245 | + | let votingEntryList = split(votingEntry, ",") | |
246 | + | let members = if ((activeTeam == "teamBlue")) | |
247 | + | then { | |
248 | + | let teamB = getStringValue((gameId + "_teamBlue")) | |
249 | + | let teamBList = split(teamB, ",") | |
250 | + | teamBList | |
251 | + | } | |
252 | + | else { | |
253 | + | let teamY = getStringValue((gameId + "_teamYellow")) | |
254 | + | let teamYList = split(teamY, ",") | |
255 | + | teamYList | |
256 | + | } | |
257 | + | let unactiveTeam = if ((activeTeam == "teamBlue")) | |
258 | + | then "teamYellow" | |
259 | + | else "teamBlue" | |
260 | + | let membersUnactive = if ((unactiveTeam == "teamBlue")) | |
261 | + | then { | |
262 | + | let teamB = getStringValue((gameId + "_teamBlue")) | |
263 | + | let teamBList = split(teamB, ",") | |
264 | + | teamBList | |
265 | + | } | |
266 | + | else { | |
267 | + | let teamY = getStringValue((gameId + "_teamYellow")) | |
268 | + | let teamYList = split(teamY, ",") | |
269 | + | teamYList | |
270 | + | } | |
271 | + | let callerAddress = toBase58String(i.caller.bytes) | |
272 | + | if ((storedHeight >= height)) | |
273 | + | then if (containsElement(members, callerAddress)) | |
274 | + | then { | |
275 | + | func foldVoters (accum,nextValue) = (accum :+ split(nextValue, "_")[0]) | |
276 | + | ||
277 | + | let voters = { | |
278 | + | let $l = votingEntryList | |
279 | + | let $s = size($l) | |
280 | + | let $acc0 = nil | |
281 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
282 | + | then $a | |
283 | + | else foldVoters($a, $l[$i]) | |
284 | + | ||
285 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
286 | + | then $a | |
287 | + | else throw("List size exceeds 5") | |
288 | + | ||
289 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
290 | + | } | |
291 | + | if ((containsElement(voters, callerAddress) == false)) | |
292 | + | then { | |
293 | + | let newVote = ((callerAddress + "_") + toString(voting)) | |
294 | + | let currentVotingEntryList = (votingEntryList :+ newVote) | |
295 | + | let currentVotingEntry = makeString(currentVotingEntryList, ",") | |
296 | + | let alteredBoard = updateVotingResults(gameId, round, activeTeam, currentVotingEntryList) | |
297 | + | if ((5 > size(currentVotingEntryList))) | |
298 | + | then [writeString(((gameId + "_voting_") + toString(round)), currentVotingEntry)] | |
299 | + | else [writeString(((gameId + "_voting_") + toString(round)), currentVotingEntry), writeString((gameId + "_board"), alteredBoard), writeInteger((gameId + "_storedHeight"), (height + votingDuration)), writeString((gameId + "_status"), ((("round_" + toString((round + 1))) + ",turn_") + unactiveTeam)), writeString(((gameId + "_voting_") + toString((round + 1))), "")] | |
300 | + | } | |
301 | + | else throw("Caller already voted!") | |
302 | + | } | |
303 | + | else throw((("Caller is not in " + activeTeam) + "!")) | |
304 | + | else if (containsElement(membersUnactive, callerAddress)) | |
305 | + | then { | |
306 | + | let alteredBoard = updateVotingResults(gameId, round, activeTeam, votingEntryList) | |
307 | + | let newVote = ((callerAddress + "_") + toString(voting)) | |
308 | + | [writeString((gameId + "_board"), alteredBoard), writeInteger((gameId + "_storedHeight"), (height + votingDuration)), writeString((gameId + "_status"), ((("round_" + toString((round + 1))) + ",turn_") + unactiveTeam)), writeString(((gameId + "_voting_") + toString((round + 1))), newVote)] | |
309 | + | } | |
310 | + | else throw((("Caller is not in " + unactiveTeam) + "!")) | |
311 | + | } | |
45 | 312 | ||
46 | 313 | ||
47 | 314 | ||
65 | 332 | else throw("Address does not match with admin address!") | |
66 | 333 | ||
67 | 334 | ||
335 | + | @Verifier(tx) | |
336 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
337 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let adminAddress = valueOrElse(getString(this, "admin"), "") | |
5 | 5 | ||
6 | 6 | let totalSupply = valueOrElse(getInteger(this, "totalSupply"), 0) | |
7 | + | ||
8 | + | let votingDuration = valueOrErrorMessage(getInteger(this, "votingDuration"), "No key votingDuration was found") | |
7 | 9 | ||
8 | 10 | let ctokenId = valueOrErrorMessage(getString(this, "tokenId"), "No key dTokenId was found") | |
9 | 11 | ||
10 | 12 | func isAdmin (callerAddress) = if ((callerAddress == fromBase58String(adminAddress))) | |
11 | 13 | then true | |
12 | 14 | else false | |
13 | 15 | ||
14 | 16 | ||
15 | 17 | func writeInteger (key,integerValue) = IntegerEntry(key, integerValue) | |
16 | 18 | ||
17 | 19 | ||
18 | 20 | func writeString (key,stringValue) = StringEntry(key, stringValue) | |
19 | 21 | ||
20 | 22 | ||
23 | + | func countFrequency (helperList,votingList) = { | |
24 | + | func foldFrequency (accum,next) = { | |
25 | + | func countItems (acc,item) = if ((next == item)) | |
26 | + | then (acc + 1) | |
27 | + | else acc | |
28 | + | ||
29 | + | (accum :+ { | |
30 | + | let $l = votingList | |
31 | + | let $s = size($l) | |
32 | + | let $acc0 = 0 | |
33 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
34 | + | then $a | |
35 | + | else countItems($a, $l[$i]) | |
36 | + | ||
37 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
38 | + | then $a | |
39 | + | else throw("List size exceeds 5") | |
40 | + | ||
41 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
42 | + | }) | |
43 | + | } | |
44 | + | ||
45 | + | let $l = helperList | |
46 | + | let $s = size($l) | |
47 | + | let $acc0 = nil | |
48 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
49 | + | then $a | |
50 | + | else foldFrequency($a, $l[$i]) | |
51 | + | ||
52 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
53 | + | then $a | |
54 | + | else throw("List size exceeds 5") | |
55 | + | ||
56 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
57 | + | } | |
58 | + | ||
59 | + | ||
60 | + | func initVotingHelperList (voteArray) = { | |
61 | + | func foldHelperList (accum,next) = if ((containsElement(accum, next) == false)) | |
62 | + | then (accum :+ next) | |
63 | + | else accum | |
64 | + | ||
65 | + | let $l = voteArray | |
66 | + | let $s = size($l) | |
67 | + | let $acc0 = nil | |
68 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
69 | + | then $a | |
70 | + | else foldHelperList($a, $l[$i]) | |
71 | + | ||
72 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
73 | + | then $a | |
74 | + | else throw("List size exceeds 5") | |
75 | + | ||
76 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
77 | + | } | |
78 | + | ||
79 | + | ||
80 | + | func isGreaterThen (potential,itemList) = { | |
81 | + | let intPotential = parseIntValue(potential) | |
82 | + | let listLength = (size(itemList) - 1) | |
83 | + | let currentGreatest = itemList[listLength] | |
84 | + | if ((intPotential > currentGreatest)) | |
85 | + | then true | |
86 | + | else false | |
87 | + | } | |
88 | + | ||
89 | + | ||
90 | + | func findHighestVote (helperList,frequencies) = { | |
91 | + | func foldFrequencies (highestItemList,nextItem) = if ((size(highestItemList) == 0)) | |
92 | + | then (highestItemList :+ parseIntValue(nextItem)) | |
93 | + | else if (isGreaterThen(nextItem, highestItemList)) | |
94 | + | then (highestItemList :+ parseIntValue(nextItem)) | |
95 | + | else highestItemList | |
96 | + | ||
97 | + | let highestVotes = { | |
98 | + | let $l = frequencies | |
99 | + | let $s = size($l) | |
100 | + | let $acc0 = nil | |
101 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
102 | + | then $a | |
103 | + | else foldFrequencies($a, $l[$i]) | |
104 | + | ||
105 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
106 | + | then $a | |
107 | + | else throw("List size exceeds 5") | |
108 | + | ||
109 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
110 | + | } | |
111 | + | let lastIdx = (size(highestVotes) - 1) | |
112 | + | let highestVote = highestVotes[lastIdx] | |
113 | + | let helperIdx = indexOf(frequencies, toString(highestVote)) | |
114 | + | match helperIdx { | |
115 | + | case t: Int => | |
116 | + | helperList[t] | |
117 | + | case _ => | |
118 | + | throw("Type does not match!") | |
119 | + | } | |
120 | + | } | |
121 | + | ||
122 | + | ||
123 | + | func alterBoard (field,gameId,team) = { | |
124 | + | let currentBoard = getStringValue((gameId + "_board")) | |
125 | + | let boardList = split(currentBoard, ",") | |
126 | + | let teamTag = if ((team == "teamBlue")) | |
127 | + | then "B" | |
128 | + | else "Y" | |
129 | + | func foldBoard (accum,nextValue) = { | |
130 | + | let $t045024525 = accum | |
131 | + | let result = $t045024525._1 | |
132 | + | let j = $t045024525._2 | |
133 | + | if ((j == parseIntValue(field))) | |
134 | + | then $Tuple2((result :+ teamTag), (j + 1)) | |
135 | + | else $Tuple2((result :+ nextValue), (j + 1)) | |
136 | + | } | |
137 | + | ||
138 | + | let newBoardList = { | |
139 | + | let $l = boardList | |
140 | + | let $s = size($l) | |
141 | + | let $acc0 = $Tuple2(nil, 0) | |
142 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
143 | + | then $a | |
144 | + | else foldBoard($a, $l[$i]) | |
145 | + | ||
146 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
147 | + | then $a | |
148 | + | else throw("List size exceeds 42") | |
149 | + | ||
150 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42) | |
151 | + | } | |
152 | + | match newBoardList { | |
153 | + | case t: (List[String], Int) => | |
154 | + | makeString(t._1, ",") | |
155 | + | case _ => | |
156 | + | throw("Type does not match!") | |
157 | + | } | |
158 | + | } | |
159 | + | ||
160 | + | ||
161 | + | func updateVotingResults (gameId,round,activeTeam,currentVotingEntryList) = { | |
162 | + | func foldVotings (accum,nextValue) = (accum :+ split(nextValue, "_")[1]) | |
163 | + | ||
164 | + | let votes = { | |
165 | + | let $l = currentVotingEntryList | |
166 | + | let $s = size($l) | |
167 | + | let $acc0 = nil | |
168 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
169 | + | then $a | |
170 | + | else foldVotings($a, $l[$i]) | |
171 | + | ||
172 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
173 | + | then $a | |
174 | + | else throw("List size exceeds 5") | |
175 | + | ||
176 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
177 | + | } | |
178 | + | let helperList = initVotingHelperList(votes) | |
179 | + | let frequencies = countFrequency(helperList, votes) | |
180 | + | let votedField = findHighestVote(helperList, frequencies) | |
181 | + | alterBoard(votedField, gameId, activeTeam) | |
182 | + | } | |
183 | + | ||
184 | + | ||
21 | 185 | @Callable(i) | |
22 | 186 | func setup (adminAddress,tokenName,tokenDescription) = if (!(isDefined(getString(this, "admin")))) | |
23 | 187 | then { | |
24 | 188 | let asset = Issue(tokenName, tokenDescription, 0, 8, true) | |
25 | 189 | let tokenId = calculateAssetId(asset) | |
26 | - | [asset, writeString("admin", adminAddress), writeInteger("totalSupply", 0), writeString("tokenName", tokenName), writeString("tokenId", toBase58String(tokenId)), writeInteger("tokenDecimals", 8)] | |
190 | + | [asset, writeString("admin", adminAddress), writeInteger("votingDuration", 2), writeInteger("totalSupply", 0), writeString("tokenName", tokenName), writeString("tokenId", toBase58String(tokenId)), writeInteger("tokenDecimals", 8)] | |
27 | 191 | } | |
28 | 192 | else throw("Pool already setup!") | |
29 | 193 | ||
30 | 194 | ||
31 | 195 | ||
32 | 196 | @Callable(i) | |
33 | 197 | func buyRound () = if ((size(i.payments) > 0)) | |
34 | 198 | then { | |
35 | 199 | let amount = i.payments[0].amount | |
36 | 200 | if ((amount >= 1)) | |
37 | 201 | then { | |
38 | - | let cTokenAmount = fraction(amount, | |
202 | + | let cTokenAmount = fraction(amount, 42, 1) | |
39 | 203 | let currentTotalSupply = (totalSupply + cTokenAmount) | |
40 | 204 | [writeInteger("totalSupply", currentTotalSupply), Reissue(fromBase58String(ctokenId), cTokenAmount, true), ScriptTransfer(i.caller, cTokenAmount, fromBase58String(ctokenId))] | |
41 | 205 | } | |
42 | 206 | else throw("Payment is to small!") | |
43 | 207 | } | |
44 | 208 | else throw("No payment attached!") | |
209 | + | ||
210 | + | ||
211 | + | ||
212 | + | @Callable(i) | |
213 | + | func createGame () = { | |
214 | + | let board = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" | |
215 | + | let gameId = toBase58String(i.transactionId) | |
216 | + | [writeString((gameId + "_board"), board), writeString((gameId + "_status"), "waiting for players"), writeString((gameId + "_teamBlue"), toString(i.caller)), writeString((gameId + "_teamYellow"), "")] | |
217 | + | } | |
218 | + | ||
219 | + | ||
220 | + | ||
221 | + | @Callable(i) | |
222 | + | func joinGame (gameId) = { | |
223 | + | let teamBlue = getStringValue((gameId + "_teamBlue")) | |
224 | + | let teamYellow = getStringValue((gameId + "_teamYellow")) | |
225 | + | let teamBlueList = split(teamBlue, ",") | |
226 | + | let teamYellowList = split(teamYellow, ",") | |
227 | + | if ((5 > size(teamBlueList))) | |
228 | + | then [writeString((gameId + "_teamBlue"), ((teamBlue + ",") + toBase58String(i.caller.bytes)))] | |
229 | + | else if ((size(teamYellowList) == 4)) | |
230 | + | then [writeString((gameId + "_status"), "round_1,turn_teamBlue"), writeString((gameId + "_voting_1"), ""), writeInteger((gameId + "_storedHeight"), (height + votingDuration)), writeString((gameId + "_teamYellow"), ((teamYellow + ",") + toBase58String(i.caller.bytes)))] | |
231 | + | else if ((4 > size(teamYellowList))) | |
232 | + | then [writeString((gameId + "_teamYellow"), ((teamYellow + ",") + toBase58String(i.caller.bytes)))] | |
233 | + | else throw("Teams are full, cannot join.") | |
234 | + | } | |
235 | + | ||
236 | + | ||
237 | + | ||
238 | + | @Callable(i) | |
239 | + | func vote (gameId,voting) = { | |
240 | + | let status = valueOrErrorMessage(getStringValue((gameId + "_status")), "No status entry found under gameId!") | |
241 | + | let round = parseIntValue(drop(split(status, ",")[0], 6)) | |
242 | + | let activeTeam = drop(split(status, ",")[1], 5) | |
243 | + | let storedHeight = valueOrErrorMessage(getInteger((gameId + "_storedHeight")), (("No status entry found under " + gameId) + "_storedHeight!")) | |
244 | + | let votingEntry = valueOrErrorMessage(getStringValue(((gameId + "_voting_") + toString(round))), "No votes found for this game id!") | |
245 | + | let votingEntryList = split(votingEntry, ",") | |
246 | + | let members = if ((activeTeam == "teamBlue")) | |
247 | + | then { | |
248 | + | let teamB = getStringValue((gameId + "_teamBlue")) | |
249 | + | let teamBList = split(teamB, ",") | |
250 | + | teamBList | |
251 | + | } | |
252 | + | else { | |
253 | + | let teamY = getStringValue((gameId + "_teamYellow")) | |
254 | + | let teamYList = split(teamY, ",") | |
255 | + | teamYList | |
256 | + | } | |
257 | + | let unactiveTeam = if ((activeTeam == "teamBlue")) | |
258 | + | then "teamYellow" | |
259 | + | else "teamBlue" | |
260 | + | let membersUnactive = if ((unactiveTeam == "teamBlue")) | |
261 | + | then { | |
262 | + | let teamB = getStringValue((gameId + "_teamBlue")) | |
263 | + | let teamBList = split(teamB, ",") | |
264 | + | teamBList | |
265 | + | } | |
266 | + | else { | |
267 | + | let teamY = getStringValue((gameId + "_teamYellow")) | |
268 | + | let teamYList = split(teamY, ",") | |
269 | + | teamYList | |
270 | + | } | |
271 | + | let callerAddress = toBase58String(i.caller.bytes) | |
272 | + | if ((storedHeight >= height)) | |
273 | + | then if (containsElement(members, callerAddress)) | |
274 | + | then { | |
275 | + | func foldVoters (accum,nextValue) = (accum :+ split(nextValue, "_")[0]) | |
276 | + | ||
277 | + | let voters = { | |
278 | + | let $l = votingEntryList | |
279 | + | let $s = size($l) | |
280 | + | let $acc0 = nil | |
281 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
282 | + | then $a | |
283 | + | else foldVoters($a, $l[$i]) | |
284 | + | ||
285 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
286 | + | then $a | |
287 | + | else throw("List size exceeds 5") | |
288 | + | ||
289 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
290 | + | } | |
291 | + | if ((containsElement(voters, callerAddress) == false)) | |
292 | + | then { | |
293 | + | let newVote = ((callerAddress + "_") + toString(voting)) | |
294 | + | let currentVotingEntryList = (votingEntryList :+ newVote) | |
295 | + | let currentVotingEntry = makeString(currentVotingEntryList, ",") | |
296 | + | let alteredBoard = updateVotingResults(gameId, round, activeTeam, currentVotingEntryList) | |
297 | + | if ((5 > size(currentVotingEntryList))) | |
298 | + | then [writeString(((gameId + "_voting_") + toString(round)), currentVotingEntry)] | |
299 | + | else [writeString(((gameId + "_voting_") + toString(round)), currentVotingEntry), writeString((gameId + "_board"), alteredBoard), writeInteger((gameId + "_storedHeight"), (height + votingDuration)), writeString((gameId + "_status"), ((("round_" + toString((round + 1))) + ",turn_") + unactiveTeam)), writeString(((gameId + "_voting_") + toString((round + 1))), "")] | |
300 | + | } | |
301 | + | else throw("Caller already voted!") | |
302 | + | } | |
303 | + | else throw((("Caller is not in " + activeTeam) + "!")) | |
304 | + | else if (containsElement(membersUnactive, callerAddress)) | |
305 | + | then { | |
306 | + | let alteredBoard = updateVotingResults(gameId, round, activeTeam, votingEntryList) | |
307 | + | let newVote = ((callerAddress + "_") + toString(voting)) | |
308 | + | [writeString((gameId + "_board"), alteredBoard), writeInteger((gameId + "_storedHeight"), (height + votingDuration)), writeString((gameId + "_status"), ((("round_" + toString((round + 1))) + ",turn_") + unactiveTeam)), writeString(((gameId + "_voting_") + toString((round + 1))), newVote)] | |
309 | + | } | |
310 | + | else throw((("Caller is not in " + unactiveTeam) + "!")) | |
311 | + | } | |
45 | 312 | ||
46 | 313 | ||
47 | 314 | ||
48 | 315 | @Callable(i) | |
49 | 316 | func updateStringEntry (key,stringValue) = if (isAdmin(i.caller.bytes)) | |
50 | 317 | then [writeString(key, stringValue)] | |
51 | 318 | else throw("Address does not match with admin address!") | |
52 | 319 | ||
53 | 320 | ||
54 | 321 | ||
55 | 322 | @Callable(i) | |
56 | 323 | func updateIntegerEntry (key,integerValue) = if (isAdmin(i.caller.bytes)) | |
57 | 324 | then [writeInteger(key, integerValue)] | |
58 | 325 | else throw("Address does not match with admin address!") | |
59 | 326 | ||
60 | 327 | ||
61 | 328 | ||
62 | 329 | @Callable(i) | |
63 | 330 | func deleteStorageEntry (key) = if (isAdmin(i.caller.bytes)) | |
64 | 331 | then [DeleteEntry(key)] | |
65 | 332 | else throw("Address does not match with admin address!") | |
66 | 333 | ||
67 | 334 | ||
335 | + | @Verifier(tx) | |
336 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
337 | + |
github/deemru/w8io/169f3d6 51.80 ms ◑