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