tx · BffsLs7DkYdUZ3A3uKoQviWy4Y56ub2fKHQb2uK2qcSu 3MtV1AQ8fEPk76tjKgvrufuMe5aA3q4TviQ: -0.10000000 Waves 2020.12.22 18:36 [1320103] smart account 3MtV1AQ8fEPk76tjKgvrufuMe5aA3q4TviQ > SELF 0.00000000 Waves
{ "type": 13, "id": "BffsLs7DkYdUZ3A3uKoQviWy4Y56ub2fKHQb2uK2qcSu", "fee": 10000000, "feeAssetId": null, "timestamp": 1608651375645, "version": 2, "chainId": 84, "sender": "3MtV1AQ8fEPk76tjKgvrufuMe5aA3q4TviQ", "senderPublicKey": "3Fjao2FW1JXSPd5EkP7C3uerW18HYacYsaMYALFMGA6N", "proofs": [ "4G81fBCJuUDnPdj7TrizqzLjg5cLZ16vSXTjwSKq24yW4CxjSdM28MHx771iX5AujJmhyNSS3vSFXiufLyKLYjBM" ], "script": "base64:AAIDAAAAAAAAAC4IARIECgIICBIECgIIARIDCgEIEgQKAggIEgMKAQgSAwoBCBIDCgEIEgQKAggIAAAADAAAAAAGUVVPUlVNAAAAAAAAAAABAQAAAA10cnlHZXRJbnRlZ2VyAAAAAQAAAANrZXkEAAAAA3ZhbAQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgAAAAAAAAAAAAUAAAADdmFsAQAAAAx0cnlHZXRTdHJpbmcAAAABAAAAA2tleQQAAAADdmFsBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAgAAAAAFAAAAA3ZhbAAAAAAMbWFpbkNvbnRyYWN0CQEAAAAcQGV4dHJVc2VyKGFkZHJlc3NGcm9tU3RyaW5nKQAAAAECAAAAIzNNd1J6aTJCbXFaWlhXckNHQ3dj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dXMCAAAADXdvcmtfZmluaXNoZWQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAZ0YXNrc18FAAAABnRhc2tJZAIAAAAHX3JlcG9ydAUAAAAKcmVwb3J0TGluawUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQUAAAALdGVhbUFkZHJlc3MFAAAADHJld2FyZEFtb3VudAUAAAAEdW5pdAUAAAADbmlsAAAAAHFCy7g=", "height": 1320103, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: G3DxqjJyMHncb1yePgDw9pZgMWQubQoCKaiF7DvrxEAV Next: 9cCddCFYEzWZ5wiBUEihBjk4Zh3hbBM4MfpjZdT4EuGX Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let mainContract = addressFromStringValue("3MwRzi2BmqZZXWrCGCwcRQLsnic2Aod6zhS") | |
5 | - | ||
6 | 4 | let QUORUM = 1 | |
7 | 5 | ||
8 | 6 | func tryGetInteger (key) = { | |
27 | 25 | } | |
28 | 26 | ||
29 | 27 | ||
30 | - | func isOwner (address) = (address == this) | |
31 | - | ||
28 | + | let mainContract = addressFromStringValue("3MwRzi2BmqZZXWrCGCwcRQLsnic2Aod6zhS") | |
32 | 29 | ||
33 | 30 | func getGroup () = { | |
34 | 31 | let val = match getString(mainContract, "working_group_members") { | |
92 | 89 | else throw("you need to vote with 'like' or 'dislike' value") | |
93 | 90 | ||
94 | 91 | ||
92 | + | func isVotingLive (taskId) = (getStringValue(this, (("tasks_" + taskId) + "_status")) == "voting_started") | |
93 | + | ||
94 | + | ||
95 | + | func isQuorumAchieved (taskId) = (QUORUM > ((tryGetInteger((("tasks_" + taskId) + "_voting_amount")) * 100) / getDAOSize())) | |
96 | + | ||
97 | + | ||
95 | 98 | @Callable(i) | |
96 | - | func addTask (title,link) = if (!(isGroupMember(i.caller))) | |
97 | - | then throw("grants working group access only") | |
98 | - | else WriteSet([DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_title"), title), DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_link"), link)]) | |
99 | + | func addTask (title,link) = WriteSet([DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_title"), title), DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_link"), link), DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_leader"), toString(i.caller))]) | |
99 | 100 | ||
100 | 101 | ||
101 | 102 | ||
102 | 103 | @Callable(i) | |
103 | - | func addReward (taskId) = if (!(isGroupMember(i.caller))) | |
104 | - | then throw("grants working group access only") | |
105 | - | else { | |
106 | - | let reward = extract(i.payment).amount | |
107 | - | WriteSet([DataEntry((("tasks_" + taskId) + "_reward"), reward), DataEntry((("tasks_" + taskId) + "_status"), "proposed")]) | |
108 | - | } | |
104 | + | func addReward (taskId,reward) = if ((tryGetString((("tasks_" + taskId) + "_status")) != "")) | |
105 | + | then throw("voting was already started, so the reward amount cannot be changed") | |
106 | + | else if ((toString(i.caller) != tryGetString((("tasks_" + taskId) + "_leader")))) | |
107 | + | then throw("team leader only") | |
108 | + | else WriteSet([DataEntry((("tasks_" + taskId) + "_reward"), reward)]) | |
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | 112 | @Callable(i) | |
113 | - | func voteForTaskProposal (taskId,voteValue) = if (!(canMemberVote(i))) | |
114 | - | then throw("you can't vote") | |
115 | - | else if ((getStringValue(this, (("tasks_" + taskId) + "_status")) != "proposed")) | |
116 | - | then throw("voting is closed or not started") | |
117 | - | else if (if ((voteValue != "like")) | |
118 | - | then (voteValue != "dislike") | |
119 | - | else false) | |
120 | - | then throw("you need to vote like or dislike") | |
121 | - | else { | |
122 | - | let valueVoteInt = getVoteValue(voteValue) | |
123 | - | let voteKey = ((("tasks_" + taskId) + "_voted_") + toString(i.caller)) | |
124 | - | let previousVote = tryGetInteger(voteKey) | |
125 | - | if (!((previousVote == 0))) | |
126 | - | then throw("you have already voted") | |
127 | - | else { | |
128 | - | let votingKey = (("tasks_" + taskId) + "_voting_state") | |
129 | - | let votingState = tryGetInteger(votingKey) | |
130 | - | let votesAmountKey = (("tasks_" + taskId) + "_voting_amount") | |
131 | - | let votesAmountState = (tryGetInteger(votingKey) + 1) | |
132 | - | let newVotingState = (votingState + valueVoteInt) | |
133 | - | ScriptResult(WriteSet([DataEntry(votingKey, newVotingState), DataEntry(voteKey, valueVoteInt), DataEntry(votesAmountKey, votesAmountState)]), TransferSet([ScriptTransfer(i.caller, 500000, unit)])) | |
134 | - | } | |
135 | - | } | |
113 | + | func initTaskVoting (taskId) = if (!(isGroupMember(i.caller))) | |
114 | + | then throw("grants working group access only") | |
115 | + | else WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "voting_started")]) | |
136 | 116 | ||
137 | 117 | ||
138 | 118 | ||
139 | 119 | @Callable(i) | |
140 | - | func finishTaskProposalVoting (taskId) = if ((QUORUM > ((tryGetInteger((("tasks_" + taskId) + "_voting_amount")) * 100) / getDAOSize()))) | |
120 | + | func voteForTaskProposal (taskId,voteValueString) = if (!(canMemberVote(i))) | |
121 | + | then throw("you can't vote") | |
122 | + | else if (isVotingLive(taskId)) | |
123 | + | then throw("voting is closed or not started") | |
124 | + | else { | |
125 | + | let voteValue = getVoteValue(voteValueString) | |
126 | + | let voteKey = ((("tasks_" + taskId) + "_voted_") + toString(i.caller)) | |
127 | + | let previousVote = tryGetInteger(voteKey) | |
128 | + | if (!((previousVote == 0))) | |
129 | + | then throw("you have already voted") | |
130 | + | else { | |
131 | + | let votingKey = (("tasks_" + taskId) + "_voting_state") | |
132 | + | let votingState = tryGetInteger(votingKey) | |
133 | + | let votesAmountKey = (("tasks_" + taskId) + "_voting_amount") | |
134 | + | let votesAmountState = (tryGetInteger(votingKey) + 1) | |
135 | + | let newVotingState = (votingState + voteValue) | |
136 | + | WriteSet([DataEntry(votingKey, newVotingState), DataEntry(voteKey, voteValue), DataEntry(votesAmountKey, votesAmountState)]) | |
137 | + | } | |
138 | + | } | |
139 | + | ||
140 | + | ||
141 | + | ||
142 | + | @Callable(i) | |
143 | + | func finishTaskProposalVoting (taskId) = if (isQuorumAchieved(taskId)) | |
141 | 144 | then throw((("more than " + toString(QUORUM)) + "% members have to vote before finishing the voting")) | |
142 | 145 | else if (!(isGroupMember(i.caller))) | |
143 | 146 | then throw("grants working group access only") | |
146 | 149 | let votingState = tryGetInteger(votingKey) | |
147 | 150 | if ((votingState > 0)) | |
148 | 151 | then { | |
149 | - | let votingResult = " | |
152 | + | let votingResult = "approved" | |
150 | 153 | WriteSet([DataEntry((("tasks_" + taskId) + "_status"), votingResult)]) | |
151 | 154 | } | |
152 | 155 | else { | |
158 | 161 | ||
159 | 162 | ||
160 | 163 | @Callable(i) | |
161 | - | func applyForTask (taskId,teamName,link) = { | |
162 | - | let status = tryGetString((("tasks_" + taskId) + "_status")) | |
163 | - | if ((status != "ready_to_apply")) | |
164 | - | then throw("This grant has not yet been approved") | |
165 | - | else { | |
166 | - | let listKey = (("tasks_" + taskId) + "_applicants") | |
167 | - | let currentApplicantsList = tryGetString(listKey) | |
168 | - | let applicantKey = drop(toString(i.caller), 10) | |
169 | - | let newApplicantsList = ((currentApplicantsList + ";") + toString(i.caller)) | |
170 | - | WriteSet([DataEntry((((("tasks_" + taskId) + "_app_") + applicantKey) + "_name"), teamName), DataEntry((((("tasks_" + taskId) + "_app_") + applicantKey) + "_link"), link), DataEntry((((("tasks_" + taskId) + "_app_") + applicantKey) + "_leader"), toString(i.caller)), DataEntry((((("tasks_" + taskId) + "_app_") + applicantKey) + "_id"), applicantKey), DataEntry(listKey, newApplicantsList)]) | |
171 | - | } | |
164 | + | func startWork (taskId) = { | |
165 | + | let teamIdentifier = getStringValue(this, (("tasks_" + taskId) + "_performer")) | |
166 | + | if ((toString(i.caller) != getStringValue(this, (("tasks_" + taskId) + "_leader")))) | |
167 | + | then throw("team leader only") | |
168 | + | else WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "work_started")]) | |
172 | 169 | } | |
173 | 170 | ||
174 | 171 | ||
175 | 172 | ||
176 | 173 | @Callable(i) | |
177 | - | func | |
178 | - | then throw(" | |
174 | + | func rejectTask (taskId) = if (!(isGroupMember(i.caller))) | |
175 | + | then throw("grants working group access only") | |
179 | 176 | else { | |
180 | - | let voteHash = (drop(toString(i.caller), 10) + drop(teamIdentifier, 10)) | |
181 | - | let voteKey = ((("tasks_" + taskId) + "_vote_") + voteHash) | |
182 | - | let vote = tryGetInteger(voteKey) | |
183 | - | if ((vote != 0)) | |
184 | - | then throw("you have already voted on this team") | |
185 | - | else { | |
186 | - | let valueVoteInt = getVoteValue(voteValue) | |
187 | - | let teamVotesAmountKey = (((("tasks_" + taskId) + "_app_") + teamIdentifier) + "_votes") | |
188 | - | let teamScoreKey = (((("tasks_" + taskId) + "_app_") + teamIdentifier) + "_score") | |
189 | - | let teamVotesAmount = (1 + tryGetInteger(teamVotesAmountKey)) | |
190 | - | let newTeamScore = (valueVoteInt + tryGetInteger(teamScoreKey)) | |
191 | - | WriteSet([DataEntry(voteKey, valueVoteInt), DataEntry(teamScoreKey, newTeamScore)]) | |
192 | - | } | |
177 | + | let teamIdentifier = getStringValue(this, (("tasks_" + taskId) + "_performer")) | |
178 | + | WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "rejected")]) | |
193 | 179 | } | |
194 | - | ||
195 | - | ||
196 | - | ||
197 | - | @Callable(i) | |
198 | - | func finishApplicantsVoting (taskId) = { | |
199 | - | func isApplicantVotedEnough (aid,aid2) = { | |
200 | - | let listKey = (("tasks_" + taskId) + "_applicants") | |
201 | - | let applicantsList = split(getStringValue(this, listKey), ";") | |
202 | - | let teamIdentifier = applicantsList[aid] | |
203 | - | let teamVotesAmountKey = (((("tasks_" + taskId) + "_app_") + teamIdentifier) + "_votes") | |
204 | - | let teamVotesAmount = tryGetInteger(teamVotesAmountKey) | |
205 | - | if ((teamVotesAmount > 0)) | |
206 | - | then 1 | |
207 | - | else throw(("not enough votes to make decision on " + teamIdentifier)) | |
208 | - | } | |
209 | - | ||
210 | - | func hasMoreVotes (aid,aid2) = { | |
211 | - | let listKey = (("tasks_" + taskId) + "_applicants") | |
212 | - | let applicantsList = split(getStringValue(this, listKey), ";") | |
213 | - | let teamIdentifier = applicantsList[aid] | |
214 | - | let teamVotesAmountKey = (((("tasks_" + taskId) + "_app_") + teamIdentifier) + "_votes") | |
215 | - | let teamVotesAmount = tryGetInteger(teamVotesAmountKey) | |
216 | - | let team2Identifier = applicantsList[aid2] | |
217 | - | let team2VotesAmountKey = (((("tasks_" + taskId) + "_app_") + team2Identifier) + "_votes") | |
218 | - | let team2VotesAmount = tryGetInteger(team2VotesAmountKey) | |
219 | - | if ((teamVotesAmount > team2VotesAmount)) | |
220 | - | then aid | |
221 | - | else aid2 | |
222 | - | } | |
223 | - | ||
224 | - | if (!(isGroupMember(i.caller))) | |
225 | - | then throw("grants working group access only") | |
226 | - | else { | |
227 | - | let listKeys = tryGetString((("tasks_" + taskId) + "_applicants")) | |
228 | - | let applicantsList = split(listKeys, ";") | |
229 | - | if ((size(applicantsList) == 0)) | |
230 | - | then throw("No one has yet responded to the grant") | |
231 | - | else { | |
232 | - | let chosenTeamId = { | |
233 | - | let $list98869917 = [0, 1] | |
234 | - | let $size98869917 = size($list98869917) | |
235 | - | let $acc098869917 = 0 | |
236 | - | if (($size98869917 == 0)) | |
237 | - | then $acc098869917 | |
238 | - | else { | |
239 | - | let $acc198869917 = hasMoreVotes($acc098869917, $list98869917[0]) | |
240 | - | if (($size98869917 == 1)) | |
241 | - | then $acc198869917 | |
242 | - | else { | |
243 | - | let $acc298869917 = hasMoreVotes($acc198869917, $list98869917[1]) | |
244 | - | if (($size98869917 == 2)) | |
245 | - | then $acc298869917 | |
246 | - | else { | |
247 | - | let $acc398869917 = hasMoreVotes($acc298869917, $list98869917[2]) | |
248 | - | throw("List size exceed 2") | |
249 | - | } | |
250 | - | } | |
251 | - | } | |
252 | - | } | |
253 | - | let teamIdentifier = applicantsList[chosenTeamId] | |
254 | - | WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "team_chosen"), DataEntry((("tasks_" + taskId) + "_performer"), teamIdentifier), DataEntry((((("tasks_" + taskId) + "_app_") + teamIdentifier) + "_process"), "can_begin")]) | |
255 | - | } | |
256 | - | } | |
257 | - | } | |
258 | - | ||
259 | - | ||
260 | - | ||
261 | - | @Callable(i) | |
262 | - | func startWork (taskId) = { | |
263 | - | let teamIdentifier = getStringValue(this, (("tasks_" + taskId) + "_performer")) | |
264 | - | if ((toString(i.caller) != getStringValue(this, (((("tasks_" + taskId) + "_app_") + teamIdentifier) + "_leader")))) | |
265 | - | then throw("team leader only") | |
266 | - | else WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "work_started"), DataEntry((((("tasks_" + taskId) + "_app_") + teamIdentifier) + "_process"), "work_started")]) | |
267 | - | } | |
268 | 180 | ||
269 | 181 | ||
270 | 182 | ||
274 | 186 | else { | |
275 | 187 | let rewardAmount = tryGetInteger((("tasks_" + taskId) + "_reward")) | |
276 | 188 | let teamIdentifier = getStringValue(this, (("tasks_" + taskId) + "_performer")) | |
277 | - | let teamAddress = getStringValue(this, (( | |
278 | - | ScriptResult(WriteSet([DataEntry((("tasks_" + taskId) + "_status | |
189 | + | let teamAddress = getStringValue(this, (("tasks_" + taskId) + "_leader")) | |
190 | + | ScriptResult(WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "work_finished"), DataEntry((("tasks_" + taskId) + "_report"), reportLink)]), TransferSet([ScriptTransfer(addressFromStringValue(teamAddress), rewardAmount, unit)])) | |
279 | 191 | } | |
280 | - | ||
281 | - | ||
282 | - | ||
283 | - | @Callable(i) | |
284 | - | func rejectTask (taskId) = if (!(isGroupMember(i.caller))) | |
285 | - | then throw("grants working group access only") | |
286 | - | else WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "rejected")]) | |
287 | 192 | ||
288 | 193 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let mainContract = addressFromStringValue("3MwRzi2BmqZZXWrCGCwcRQLsnic2Aod6zhS") | |
5 | - | ||
6 | 4 | let QUORUM = 1 | |
7 | 5 | ||
8 | 6 | func tryGetInteger (key) = { | |
9 | 7 | let val = match getInteger(this, key) { | |
10 | 8 | case b: Int => | |
11 | 9 | b | |
12 | 10 | case _ => | |
13 | 11 | 0 | |
14 | 12 | } | |
15 | 13 | val | |
16 | 14 | } | |
17 | 15 | ||
18 | 16 | ||
19 | 17 | func tryGetString (key) = { | |
20 | 18 | let val = match getString(this, key) { | |
21 | 19 | case b: String => | |
22 | 20 | b | |
23 | 21 | case _ => | |
24 | 22 | "" | |
25 | 23 | } | |
26 | 24 | val | |
27 | 25 | } | |
28 | 26 | ||
29 | 27 | ||
30 | - | func isOwner (address) = (address == this) | |
31 | - | ||
28 | + | let mainContract = addressFromStringValue("3MwRzi2BmqZZXWrCGCwcRQLsnic2Aod6zhS") | |
32 | 29 | ||
33 | 30 | func getGroup () = { | |
34 | 31 | let val = match getString(mainContract, "working_group_members") { | |
35 | 32 | case b: String => | |
36 | 33 | b | |
37 | 34 | case _ => | |
38 | 35 | "" | |
39 | 36 | } | |
40 | 37 | val | |
41 | 38 | } | |
42 | 39 | ||
43 | 40 | ||
44 | 41 | func getMembers () = { | |
45 | 42 | let val = match getString(mainContract, "dao_members") { | |
46 | 43 | case b: String => | |
47 | 44 | b | |
48 | 45 | case _ => | |
49 | 46 | "" | |
50 | 47 | } | |
51 | 48 | val | |
52 | 49 | } | |
53 | 50 | ||
54 | 51 | ||
55 | 52 | func getDAOSize () = { | |
56 | 53 | let val = match getInteger(mainContract, "dao_size") { | |
57 | 54 | case b: Int => | |
58 | 55 | b | |
59 | 56 | case _ => | |
60 | 57 | 0 | |
61 | 58 | } | |
62 | 59 | val | |
63 | 60 | } | |
64 | 61 | ||
65 | 62 | ||
66 | 63 | func isGroupMember (a) = { | |
67 | 64 | let val = match getInteger(mainContract, (("working_group_member_" + toString(a)) + "_weight")) { | |
68 | 65 | case b: Int => | |
69 | 66 | b | |
70 | 67 | case _ => | |
71 | 68 | 0 | |
72 | 69 | } | |
73 | 70 | (val > 0) | |
74 | 71 | } | |
75 | 72 | ||
76 | 73 | ||
77 | 74 | func canMemberVote (i) = { | |
78 | 75 | let val = match getInteger(mainContract, (("dao_member_" + toString(i.caller)) + "_weight")) { | |
79 | 76 | case b: Int => | |
80 | 77 | b | |
81 | 78 | case _ => | |
82 | 79 | 0 | |
83 | 80 | } | |
84 | 81 | (val > 0) | |
85 | 82 | } | |
86 | 83 | ||
87 | 84 | ||
88 | 85 | func getVoteValue (s) = if ((s == "like")) | |
89 | 86 | then 1 | |
90 | 87 | else if ((s == "dislike")) | |
91 | 88 | then -1 | |
92 | 89 | else throw("you need to vote with 'like' or 'dislike' value") | |
93 | 90 | ||
94 | 91 | ||
92 | + | func isVotingLive (taskId) = (getStringValue(this, (("tasks_" + taskId) + "_status")) == "voting_started") | |
93 | + | ||
94 | + | ||
95 | + | func isQuorumAchieved (taskId) = (QUORUM > ((tryGetInteger((("tasks_" + taskId) + "_voting_amount")) * 100) / getDAOSize())) | |
96 | + | ||
97 | + | ||
95 | 98 | @Callable(i) | |
96 | - | func addTask (title,link) = if (!(isGroupMember(i.caller))) | |
97 | - | then throw("grants working group access only") | |
98 | - | else WriteSet([DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_title"), title), DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_link"), link)]) | |
99 | + | func addTask (title,link) = WriteSet([DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_title"), title), DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_link"), link), DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_leader"), toString(i.caller))]) | |
99 | 100 | ||
100 | 101 | ||
101 | 102 | ||
102 | 103 | @Callable(i) | |
103 | - | func addReward (taskId) = if (!(isGroupMember(i.caller))) | |
104 | - | then throw("grants working group access only") | |
105 | - | else { | |
106 | - | let reward = extract(i.payment).amount | |
107 | - | WriteSet([DataEntry((("tasks_" + taskId) + "_reward"), reward), DataEntry((("tasks_" + taskId) + "_status"), "proposed")]) | |
108 | - | } | |
104 | + | func addReward (taskId,reward) = if ((tryGetString((("tasks_" + taskId) + "_status")) != "")) | |
105 | + | then throw("voting was already started, so the reward amount cannot be changed") | |
106 | + | else if ((toString(i.caller) != tryGetString((("tasks_" + taskId) + "_leader")))) | |
107 | + | then throw("team leader only") | |
108 | + | else WriteSet([DataEntry((("tasks_" + taskId) + "_reward"), reward)]) | |
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | 112 | @Callable(i) | |
113 | - | func voteForTaskProposal (taskId,voteValue) = if (!(canMemberVote(i))) | |
114 | - | then throw("you can't vote") | |
115 | - | else if ((getStringValue(this, (("tasks_" + taskId) + "_status")) != "proposed")) | |
116 | - | then throw("voting is closed or not started") | |
117 | - | else if (if ((voteValue != "like")) | |
118 | - | then (voteValue != "dislike") | |
119 | - | else false) | |
120 | - | then throw("you need to vote like or dislike") | |
121 | - | else { | |
122 | - | let valueVoteInt = getVoteValue(voteValue) | |
123 | - | let voteKey = ((("tasks_" + taskId) + "_voted_") + toString(i.caller)) | |
124 | - | let previousVote = tryGetInteger(voteKey) | |
125 | - | if (!((previousVote == 0))) | |
126 | - | then throw("you have already voted") | |
127 | - | else { | |
128 | - | let votingKey = (("tasks_" + taskId) + "_voting_state") | |
129 | - | let votingState = tryGetInteger(votingKey) | |
130 | - | let votesAmountKey = (("tasks_" + taskId) + "_voting_amount") | |
131 | - | let votesAmountState = (tryGetInteger(votingKey) + 1) | |
132 | - | let newVotingState = (votingState + valueVoteInt) | |
133 | - | ScriptResult(WriteSet([DataEntry(votingKey, newVotingState), DataEntry(voteKey, valueVoteInt), DataEntry(votesAmountKey, votesAmountState)]), TransferSet([ScriptTransfer(i.caller, 500000, unit)])) | |
134 | - | } | |
135 | - | } | |
113 | + | func initTaskVoting (taskId) = if (!(isGroupMember(i.caller))) | |
114 | + | then throw("grants working group access only") | |
115 | + | else WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "voting_started")]) | |
136 | 116 | ||
137 | 117 | ||
138 | 118 | ||
139 | 119 | @Callable(i) | |
140 | - | func finishTaskProposalVoting (taskId) = if ((QUORUM > ((tryGetInteger((("tasks_" + taskId) + "_voting_amount")) * 100) / getDAOSize()))) | |
120 | + | func voteForTaskProposal (taskId,voteValueString) = if (!(canMemberVote(i))) | |
121 | + | then throw("you can't vote") | |
122 | + | else if (isVotingLive(taskId)) | |
123 | + | then throw("voting is closed or not started") | |
124 | + | else { | |
125 | + | let voteValue = getVoteValue(voteValueString) | |
126 | + | let voteKey = ((("tasks_" + taskId) + "_voted_") + toString(i.caller)) | |
127 | + | let previousVote = tryGetInteger(voteKey) | |
128 | + | if (!((previousVote == 0))) | |
129 | + | then throw("you have already voted") | |
130 | + | else { | |
131 | + | let votingKey = (("tasks_" + taskId) + "_voting_state") | |
132 | + | let votingState = tryGetInteger(votingKey) | |
133 | + | let votesAmountKey = (("tasks_" + taskId) + "_voting_amount") | |
134 | + | let votesAmountState = (tryGetInteger(votingKey) + 1) | |
135 | + | let newVotingState = (votingState + voteValue) | |
136 | + | WriteSet([DataEntry(votingKey, newVotingState), DataEntry(voteKey, voteValue), DataEntry(votesAmountKey, votesAmountState)]) | |
137 | + | } | |
138 | + | } | |
139 | + | ||
140 | + | ||
141 | + | ||
142 | + | @Callable(i) | |
143 | + | func finishTaskProposalVoting (taskId) = if (isQuorumAchieved(taskId)) | |
141 | 144 | then throw((("more than " + toString(QUORUM)) + "% members have to vote before finishing the voting")) | |
142 | 145 | else if (!(isGroupMember(i.caller))) | |
143 | 146 | then throw("grants working group access only") | |
144 | 147 | else { | |
145 | 148 | let votingKey = (("tasks_" + taskId) + "_voting_state") | |
146 | 149 | let votingState = tryGetInteger(votingKey) | |
147 | 150 | if ((votingState > 0)) | |
148 | 151 | then { | |
149 | - | let votingResult = " | |
152 | + | let votingResult = "approved" | |
150 | 153 | WriteSet([DataEntry((("tasks_" + taskId) + "_status"), votingResult)]) | |
151 | 154 | } | |
152 | 155 | else { | |
153 | 156 | let votingResult = "rejected" | |
154 | 157 | WriteSet([DataEntry((("tasks_" + taskId) + "_status"), votingResult)]) | |
155 | 158 | } | |
156 | 159 | } | |
157 | 160 | ||
158 | 161 | ||
159 | 162 | ||
160 | 163 | @Callable(i) | |
161 | - | func applyForTask (taskId,teamName,link) = { | |
162 | - | let status = tryGetString((("tasks_" + taskId) + "_status")) | |
163 | - | if ((status != "ready_to_apply")) | |
164 | - | then throw("This grant has not yet been approved") | |
165 | - | else { | |
166 | - | let listKey = (("tasks_" + taskId) + "_applicants") | |
167 | - | let currentApplicantsList = tryGetString(listKey) | |
168 | - | let applicantKey = drop(toString(i.caller), 10) | |
169 | - | let newApplicantsList = ((currentApplicantsList + ";") + toString(i.caller)) | |
170 | - | WriteSet([DataEntry((((("tasks_" + taskId) + "_app_") + applicantKey) + "_name"), teamName), DataEntry((((("tasks_" + taskId) + "_app_") + applicantKey) + "_link"), link), DataEntry((((("tasks_" + taskId) + "_app_") + applicantKey) + "_leader"), toString(i.caller)), DataEntry((((("tasks_" + taskId) + "_app_") + applicantKey) + "_id"), applicantKey), DataEntry(listKey, newApplicantsList)]) | |
171 | - | } | |
164 | + | func startWork (taskId) = { | |
165 | + | let teamIdentifier = getStringValue(this, (("tasks_" + taskId) + "_performer")) | |
166 | + | if ((toString(i.caller) != getStringValue(this, (("tasks_" + taskId) + "_leader")))) | |
167 | + | then throw("team leader only") | |
168 | + | else WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "work_started")]) | |
172 | 169 | } | |
173 | 170 | ||
174 | 171 | ||
175 | 172 | ||
176 | 173 | @Callable(i) | |
177 | - | func | |
178 | - | then throw(" | |
174 | + | func rejectTask (taskId) = if (!(isGroupMember(i.caller))) | |
175 | + | then throw("grants working group access only") | |
179 | 176 | else { | |
180 | - | let voteHash = (drop(toString(i.caller), 10) + drop(teamIdentifier, 10)) | |
181 | - | let voteKey = ((("tasks_" + taskId) + "_vote_") + voteHash) | |
182 | - | let vote = tryGetInteger(voteKey) | |
183 | - | if ((vote != 0)) | |
184 | - | then throw("you have already voted on this team") | |
185 | - | else { | |
186 | - | let valueVoteInt = getVoteValue(voteValue) | |
187 | - | let teamVotesAmountKey = (((("tasks_" + taskId) + "_app_") + teamIdentifier) + "_votes") | |
188 | - | let teamScoreKey = (((("tasks_" + taskId) + "_app_") + teamIdentifier) + "_score") | |
189 | - | let teamVotesAmount = (1 + tryGetInteger(teamVotesAmountKey)) | |
190 | - | let newTeamScore = (valueVoteInt + tryGetInteger(teamScoreKey)) | |
191 | - | WriteSet([DataEntry(voteKey, valueVoteInt), DataEntry(teamScoreKey, newTeamScore)]) | |
192 | - | } | |
177 | + | let teamIdentifier = getStringValue(this, (("tasks_" + taskId) + "_performer")) | |
178 | + | WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "rejected")]) | |
193 | 179 | } | |
194 | - | ||
195 | - | ||
196 | - | ||
197 | - | @Callable(i) | |
198 | - | func finishApplicantsVoting (taskId) = { | |
199 | - | func isApplicantVotedEnough (aid,aid2) = { | |
200 | - | let listKey = (("tasks_" + taskId) + "_applicants") | |
201 | - | let applicantsList = split(getStringValue(this, listKey), ";") | |
202 | - | let teamIdentifier = applicantsList[aid] | |
203 | - | let teamVotesAmountKey = (((("tasks_" + taskId) + "_app_") + teamIdentifier) + "_votes") | |
204 | - | let teamVotesAmount = tryGetInteger(teamVotesAmountKey) | |
205 | - | if ((teamVotesAmount > 0)) | |
206 | - | then 1 | |
207 | - | else throw(("not enough votes to make decision on " + teamIdentifier)) | |
208 | - | } | |
209 | - | ||
210 | - | func hasMoreVotes (aid,aid2) = { | |
211 | - | let listKey = (("tasks_" + taskId) + "_applicants") | |
212 | - | let applicantsList = split(getStringValue(this, listKey), ";") | |
213 | - | let teamIdentifier = applicantsList[aid] | |
214 | - | let teamVotesAmountKey = (((("tasks_" + taskId) + "_app_") + teamIdentifier) + "_votes") | |
215 | - | let teamVotesAmount = tryGetInteger(teamVotesAmountKey) | |
216 | - | let team2Identifier = applicantsList[aid2] | |
217 | - | let team2VotesAmountKey = (((("tasks_" + taskId) + "_app_") + team2Identifier) + "_votes") | |
218 | - | let team2VotesAmount = tryGetInteger(team2VotesAmountKey) | |
219 | - | if ((teamVotesAmount > team2VotesAmount)) | |
220 | - | then aid | |
221 | - | else aid2 | |
222 | - | } | |
223 | - | ||
224 | - | if (!(isGroupMember(i.caller))) | |
225 | - | then throw("grants working group access only") | |
226 | - | else { | |
227 | - | let listKeys = tryGetString((("tasks_" + taskId) + "_applicants")) | |
228 | - | let applicantsList = split(listKeys, ";") | |
229 | - | if ((size(applicantsList) == 0)) | |
230 | - | then throw("No one has yet responded to the grant") | |
231 | - | else { | |
232 | - | let chosenTeamId = { | |
233 | - | let $list98869917 = [0, 1] | |
234 | - | let $size98869917 = size($list98869917) | |
235 | - | let $acc098869917 = 0 | |
236 | - | if (($size98869917 == 0)) | |
237 | - | then $acc098869917 | |
238 | - | else { | |
239 | - | let $acc198869917 = hasMoreVotes($acc098869917, $list98869917[0]) | |
240 | - | if (($size98869917 == 1)) | |
241 | - | then $acc198869917 | |
242 | - | else { | |
243 | - | let $acc298869917 = hasMoreVotes($acc198869917, $list98869917[1]) | |
244 | - | if (($size98869917 == 2)) | |
245 | - | then $acc298869917 | |
246 | - | else { | |
247 | - | let $acc398869917 = hasMoreVotes($acc298869917, $list98869917[2]) | |
248 | - | throw("List size exceed 2") | |
249 | - | } | |
250 | - | } | |
251 | - | } | |
252 | - | } | |
253 | - | let teamIdentifier = applicantsList[chosenTeamId] | |
254 | - | WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "team_chosen"), DataEntry((("tasks_" + taskId) + "_performer"), teamIdentifier), DataEntry((((("tasks_" + taskId) + "_app_") + teamIdentifier) + "_process"), "can_begin")]) | |
255 | - | } | |
256 | - | } | |
257 | - | } | |
258 | - | ||
259 | - | ||
260 | - | ||
261 | - | @Callable(i) | |
262 | - | func startWork (taskId) = { | |
263 | - | let teamIdentifier = getStringValue(this, (("tasks_" + taskId) + "_performer")) | |
264 | - | if ((toString(i.caller) != getStringValue(this, (((("tasks_" + taskId) + "_app_") + teamIdentifier) + "_leader")))) | |
265 | - | then throw("team leader only") | |
266 | - | else WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "work_started"), DataEntry((((("tasks_" + taskId) + "_app_") + teamIdentifier) + "_process"), "work_started")]) | |
267 | - | } | |
268 | 180 | ||
269 | 181 | ||
270 | 182 | ||
271 | 183 | @Callable(i) | |
272 | 184 | func acceptWorkResult (taskId,reportLink) = if (!(isGroupMember(i.caller))) | |
273 | 185 | then throw("grants working group access only") | |
274 | 186 | else { | |
275 | 187 | let rewardAmount = tryGetInteger((("tasks_" + taskId) + "_reward")) | |
276 | 188 | let teamIdentifier = getStringValue(this, (("tasks_" + taskId) + "_performer")) | |
277 | - | let teamAddress = getStringValue(this, (( | |
278 | - | ScriptResult(WriteSet([DataEntry((("tasks_" + taskId) + "_status | |
189 | + | let teamAddress = getStringValue(this, (("tasks_" + taskId) + "_leader")) | |
190 | + | ScriptResult(WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "work_finished"), DataEntry((("tasks_" + taskId) + "_report"), reportLink)]), TransferSet([ScriptTransfer(addressFromStringValue(teamAddress), rewardAmount, unit)])) | |
279 | 191 | } | |
280 | - | ||
281 | - | ||
282 | - | ||
283 | - | @Callable(i) | |
284 | - | func rejectTask (taskId) = if (!(isGroupMember(i.caller))) | |
285 | - | then throw("grants working group access only") | |
286 | - | else WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "rejected")]) | |
287 | 192 | ||
288 | 193 |
github/deemru/w8io/3ef1775 55.14 ms ◑