tx · 3fWBwoK3SgXtMTvAoWAALJ2GBNbPdvJjT7GELwHZ5WMj 3N3J9tgHhJStDpNJYDhafWkbxyw7vFwTDRM: -0.10000000 Waves 2021.03.30 17:40 [1460637] smart account 3N3J9tgHhJStDpNJYDhafWkbxyw7vFwTDRM > SELF 0.00000000 Waves
{ "type": 13, "id": "3fWBwoK3SgXtMTvAoWAALJ2GBNbPdvJjT7GELwHZ5WMj", "fee": 10000000, "feeAssetId": null, "timestamp": 1617115349263, "version": 2, "chainId": 84, "sender": "3N3J9tgHhJStDpNJYDhafWkbxyw7vFwTDRM", "senderPublicKey": "267FfEXSbZcgrWeZJQAD2qnNDAnGoN41APAmxbVJYMcd", "proofs": [ "2iRphtKZCmiNtrYzw3Xq9hXZvtzbeRzUrAfoZVFgzpsBvrFwRfFeQaomNmh6tVHfrvGbA7GzbnsUUbaxT8FpYZre" ], "script": "base64:AAIDAAAAAAAAAAwIARIDCgEIEgMKAQgAAAAHAQAAAA10cnlHZXRJbnRlZ2VyAAAAAQAAAANrZXkEAAAAA3ZhbAQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgAAAAAAAAAAAAUAAAADdmFsAQAAAAx0cnlHZXRTdHJpbmcAAAABAAAAA2tleQQAAAADdmFsBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAgAAAAAFAAAAA3ZhbAEAAAAHaXNPd25lcgAAAAEAAAAHYWRkcmVzcwkAAAAAAAACBQAAAAdhZGRyZXNzBQAAAAR0aGlzAQAAAAhnZXRHcm91cAAAAAAEAAAAA3ZhbAQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzAgAAABV3b3JraW5nX2dyb3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3R3JvdXBTaXplCQAAZAAAAAIFAAAACWdyb3VwU2l6ZQAAAAAAAAAAAQkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgIAAAAVd29ya2luZ19ncm91cF9tZW1iZXJzBQAAAAhuZXdHcm91cAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgIAAAASd29ya2luZ19ncm91cF9zaXplBQAAAAxuZXdHcm91cFNpemUJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACAgAAABV3b3JraW5nX2dyb3VwX21lbWJlcl8FAAAADW1lbWJlckFkZHJlc3MCAAAAB193ZWlnaHQAAAAAAAAAAAEFAAAAA25pbAAAAAC0Ay8t", "height": 1460637, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: f5eb6m3BGMd4U7Dz7rfjPS54L8LjwCqzwUY1nLqC7Aa Next: none Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let QUORUM = 1 | |
5 | - | ||
6 | 4 | func tryGetInteger (key) = { | |
7 | 5 | let val = match getInteger(this, key) { | |
8 | 6 | case b: Int => | |
25 | 23 | } | |
26 | 24 | ||
27 | 25 | ||
28 | - | let mainContract = addressFromStringValue("3N34V5ita42EWyEkpgc8XHbZG6LWtM8t4n7") | |
26 | + | func isOwner (address) = (address == this) | |
27 | + | ||
29 | 28 | ||
30 | 29 | func getGroup () = { | |
31 | - | let val = match getString( | |
30 | + | let val = match getString(this, "working_group_members") { | |
32 | 31 | case b: String => | |
33 | 32 | b | |
34 | 33 | case _ => | |
39 | 38 | ||
40 | 39 | ||
41 | 40 | func getMembers () = { | |
42 | - | let val = match getString( | |
41 | + | let val = match getString(this, "dao_members") { | |
43 | 42 | case b: String => | |
44 | 43 | b | |
45 | 44 | case _ => | |
49 | 48 | } | |
50 | 49 | ||
51 | 50 | ||
52 | - | func getDAOSize () = { | |
53 | - | let val = match getInteger(mainContract, "dao_size") { | |
54 | - | case b: Int => | |
55 | - | b | |
56 | - | case _ => | |
57 | - | 0 | |
58 | - | } | |
59 | - | val | |
60 | - | } | |
51 | + | func isGroupMember (a) = (tryGetInteger((("working_group_member_" + toString(a)) + "_weight")) > 0) | |
61 | 52 | ||
62 | 53 | ||
63 | - | func isGroupMember (a) = { | |
64 | - | let val = match getInteger(mainContract, (("working_group_member_" + toString(a)) + "_weight")) { | |
65 | - | case b: Int => | |
66 | - | b | |
67 | - | case _ => | |
68 | - | 0 | |
69 | - | } | |
70 | - | (val > 0) | |
71 | - | } | |
72 | - | ||
73 | - | ||
74 | - | func canMemberVote (i) = { | |
75 | - | let val = match getInteger(mainContract, (("dao_member_" + toString(i.caller)) + "_weight")) { | |
76 | - | case b: Int => | |
77 | - | b | |
78 | - | case _ => | |
79 | - | 0 | |
80 | - | } | |
81 | - | (val > 0) | |
82 | - | } | |
83 | - | ||
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 | - | ||
91 | - | func getVoteValue (s) = if ((s == "like")) | |
92 | - | then 1 | |
93 | - | else if ((s == "dislike")) | |
94 | - | then -1 | |
95 | - | else throw("you need to vote with 'like' or 'dislike' value") | |
96 | - | ||
97 | - | ||
98 | - | func initTaskVotingConditions (taskId,address) = if (!(isGroupMember(address))) | |
99 | - | then throw("grants working group access only") | |
100 | - | else if ((tryGetString((("tasks_" + taskId) + "_status")) != "")) | |
101 | - | then throw("task is not new") | |
102 | - | else true | |
103 | - | ||
104 | - | ||
105 | - | func startWorkConditions (taskId,address) = if ((tryGetString((("tasks_" + taskId) + "_status")) != "approved")) | |
106 | - | then throw("the task is not approved") | |
107 | - | else if ((toString(address) != tryGetString((("tasks_" + taskId) + "_leader")))) | |
108 | - | then throw("team leader only") | |
109 | - | else true | |
110 | - | ||
111 | - | ||
112 | - | func addRewardConditions (taskId,reward,address) = if ((tryGetString((("tasks_" + taskId) + "_status")) != "")) | |
113 | - | then throw("voting was already started, so the reward amount cannot be changed") | |
114 | - | else if ((toString(address) != tryGetString((("tasks_" + taskId) + "_leader")))) | |
115 | - | then throw("team leader only") | |
116 | - | else true | |
117 | - | ||
118 | - | ||
119 | - | func voteForTaskProposalConditions (taskId,i) = if (!(canMemberVote(i))) | |
120 | - | then throw("you can't vote") | |
121 | - | else if (isVotingDisable(taskId)) | |
122 | - | then throw("voting is closed or not started") | |
123 | - | else if (!((tryGetInteger(((("tasks_" + taskId) + "_voted_") + toString(i.caller))) == 0))) | |
124 | - | then throw("you have already voted") | |
125 | - | else true | |
126 | - | ||
127 | - | ||
128 | - | func finishTaskProposalVotingConditions (taskId,address) = if ((tryGetString((("tasks_" + taskId) + "_status")) != "voting_started")) | |
129 | - | then throw("voting is not active") | |
130 | - | else if (isQuorumAchieved(taskId)) | |
131 | - | then throw((("more than " + toString(QUORUM)) + "% members have to vote before finishing the voting")) | |
132 | - | else if (!(isGroupMember(address))) | |
133 | - | then throw("grants working group access only") | |
134 | - | else true | |
135 | - | ||
136 | - | ||
137 | - | func acceptWorkResultConditions (address) = if (!(isGroupMember(address))) | |
138 | - | then throw("grants working group access only") | |
139 | - | else true | |
54 | + | func canMemberVote (i) = (tryGetInteger((("dao_member_" + toString(i.caller)) + "_weight")) > 0) | |
140 | 55 | ||
141 | 56 | ||
142 | 57 | @Callable(i) | |
143 | - | func addTask (title,link,hash) = WriteSet([DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_title"), title), DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_link"), link), DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_hash"), hash), DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_leader"), toString(i.caller))]) | |
58 | + | func addDAOMember (memberAddress) = if (!(isOwner(i.caller))) | |
59 | + | then throw("access only to the DAO owner") | |
60 | + | else if ((tryGetInteger((("dao_member_" + memberAddress) + "_weight")) == 1)) | |
61 | + | then throw("This user already exists") | |
62 | + | else { | |
63 | + | let group = getMembers() | |
64 | + | let newGroup = ((group + ";") + memberAddress) | |
65 | + | let groupSize = tryGetInteger("dao_size") | |
66 | + | let newGroupSize = (groupSize + 1) | |
67 | + | WriteSet([DataEntry("dao_members", newGroup), DataEntry("dao_size", newGroupSize), DataEntry((("dao_member_" + memberAddress) + "_weight"), 1)]) | |
68 | + | } | |
144 | 69 | ||
145 | 70 | ||
146 | 71 | ||
147 | 72 | @Callable(i) | |
148 | - | func resetHash (taskId,hash) = WriteSet([DataEntry((("tasks_" + taskId) + "_hash"), hash)]) | |
149 | - | ||
150 | - | ||
151 | - | ||
152 | - | @Callable(i) | |
153 | - | func hideTask (taskId) = WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "hide")]) | |
154 | - | ||
155 | - | ||
156 | - | ||
157 | - | @Callable(i) | |
158 | - | func addReward (taskId,reward) = if (addRewardConditions(taskId, reward, i.caller)) | |
159 | - | then WriteSet([DataEntry((("tasks_" + taskId) + "_reward"), reward)]) | |
160 | - | else throw("checks are not passed") | |
161 | - | ||
162 | - | ||
163 | - | ||
164 | - | @Callable(i) | |
165 | - | func initTaskVoting (taskId) = if (initTaskVotingConditions(taskId, i.caller)) | |
166 | - | then WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "voting_started")]) | |
167 | - | else throw("checks are not passed") | |
168 | - | ||
169 | - | ||
170 | - | ||
171 | - | @Callable(i) | |
172 | - | func voteForTaskProposal (taskId,voteValueString) = if (voteForTaskProposalConditions(taskId, i)) | |
173 | - | then { | |
174 | - | let voteKey = ((("tasks_" + taskId) + "_voted_") + toString(i.caller)) | |
175 | - | let votingKey = (("tasks_" + taskId) + "_voting_state") | |
176 | - | let votesAmountKey = (("tasks_" + taskId) + "_voting_amount") | |
177 | - | let voteValue = getVoteValue(voteValueString) | |
178 | - | let votingState = tryGetInteger(votingKey) | |
179 | - | let votesAmountState = (tryGetInteger(votesAmountKey) + 1) | |
180 | - | WriteSet([DataEntry(votingKey, (votingState + voteValue)), DataEntry(voteKey, voteValue), DataEntry(votesAmountKey, votesAmountState)]) | |
181 | - | } | |
182 | - | else throw("checks are not passed") | |
183 | - | ||
184 | - | ||
185 | - | ||
186 | - | @Callable(i) | |
187 | - | func finishTaskProposalVoting (taskId) = if (finishTaskProposalVotingConditions(taskId, i.caller)) | |
188 | - | then { | |
189 | - | let statusKey = (("tasks_" + taskId) + "_status") | |
190 | - | let votingKey = (("tasks_" + taskId) + "_voting_state") | |
191 | - | WriteSet([DataEntry(statusKey, if ((tryGetInteger(votingKey) > 0)) | |
192 | - | then "approved" | |
193 | - | else "rejected")]) | |
194 | - | } | |
195 | - | else throw("checks are not passed") | |
196 | - | ||
197 | - | ||
198 | - | ||
199 | - | @Callable(i) | |
200 | - | func startWork (taskId) = if (startWorkConditions(taskId, i.caller)) | |
201 | - | then WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "work_started")]) | |
202 | - | else throw("checks are not passed") | |
203 | - | ||
204 | - | ||
205 | - | ||
206 | - | @Callable(i) | |
207 | - | func rejectTask (taskId) = if (isGroupMember(i.caller)) | |
208 | - | then WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "rejected")]) | |
209 | - | else throw("grants working group access only") | |
210 | - | ||
211 | - | ||
212 | - | ||
213 | - | @Callable(i) | |
214 | - | func acceptWorkResult (taskId,reportLink) = if (acceptWorkResultConditions(i.caller)) | |
215 | - | then { | |
216 | - | let rewardAmount = tryGetInteger((("tasks_" + taskId) + "_reward")) | |
217 | - | let teamAddress = getStringValue(this, (("tasks_" + taskId) + "_leader")) | |
218 | - | ScriptResult(WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "work_finished"), DataEntry((("tasks_" + taskId) + "_report"), reportLink)]), TransferSet([ScriptTransfer(addressFromStringValue(teamAddress), rewardAmount, unit)])) | |
219 | - | } | |
220 | - | else throw("grants working group access only") | |
73 | + | func addGroupMember (memberAddress) = if (!(isOwner(i.caller))) | |
74 | + | then throw("access only to the DAO owner") | |
75 | + | else if ((tryGetInteger((("working_group_member_" + memberAddress) + "_weight")) == 1)) | |
76 | + | then throw("This user already exists") | |
77 | + | else { | |
78 | + | let group = getGroup() | |
79 | + | let newGroup = ((group + ";") + memberAddress) | |
80 | + | let groupSize = tryGetInteger("working_group_size") | |
81 | + | let newGroupSize = (groupSize + 1) | |
82 | + | WriteSet([DataEntry("working_group_members", newGroup), DataEntry("working_group_size", newGroupSize), DataEntry((("working_group_member_" + memberAddress) + "_weight"), 1)]) | |
83 | + | } | |
221 | 84 | ||
222 | 85 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let QUORUM = 1 | |
5 | - | ||
6 | 4 | func tryGetInteger (key) = { | |
7 | 5 | let val = match getInteger(this, key) { | |
8 | 6 | case b: Int => | |
9 | 7 | b | |
10 | 8 | case _ => | |
11 | 9 | 0 | |
12 | 10 | } | |
13 | 11 | val | |
14 | 12 | } | |
15 | 13 | ||
16 | 14 | ||
17 | 15 | func tryGetString (key) = { | |
18 | 16 | let val = match getString(this, key) { | |
19 | 17 | case b: String => | |
20 | 18 | b | |
21 | 19 | case _ => | |
22 | 20 | "" | |
23 | 21 | } | |
24 | 22 | val | |
25 | 23 | } | |
26 | 24 | ||
27 | 25 | ||
28 | - | let mainContract = addressFromStringValue("3N34V5ita42EWyEkpgc8XHbZG6LWtM8t4n7") | |
26 | + | func isOwner (address) = (address == this) | |
27 | + | ||
29 | 28 | ||
30 | 29 | func getGroup () = { | |
31 | - | let val = match getString( | |
30 | + | let val = match getString(this, "working_group_members") { | |
32 | 31 | case b: String => | |
33 | 32 | b | |
34 | 33 | case _ => | |
35 | 34 | "" | |
36 | 35 | } | |
37 | 36 | val | |
38 | 37 | } | |
39 | 38 | ||
40 | 39 | ||
41 | 40 | func getMembers () = { | |
42 | - | let val = match getString( | |
41 | + | let val = match getString(this, "dao_members") { | |
43 | 42 | case b: String => | |
44 | 43 | b | |
45 | 44 | case _ => | |
46 | 45 | "" | |
47 | 46 | } | |
48 | 47 | val | |
49 | 48 | } | |
50 | 49 | ||
51 | 50 | ||
52 | - | func getDAOSize () = { | |
53 | - | let val = match getInteger(mainContract, "dao_size") { | |
54 | - | case b: Int => | |
55 | - | b | |
56 | - | case _ => | |
57 | - | 0 | |
58 | - | } | |
59 | - | val | |
60 | - | } | |
51 | + | func isGroupMember (a) = (tryGetInteger((("working_group_member_" + toString(a)) + "_weight")) > 0) | |
61 | 52 | ||
62 | 53 | ||
63 | - | func isGroupMember (a) = { | |
64 | - | let val = match getInteger(mainContract, (("working_group_member_" + toString(a)) + "_weight")) { | |
65 | - | case b: Int => | |
66 | - | b | |
67 | - | case _ => | |
68 | - | 0 | |
69 | - | } | |
70 | - | (val > 0) | |
71 | - | } | |
72 | - | ||
73 | - | ||
74 | - | func canMemberVote (i) = { | |
75 | - | let val = match getInteger(mainContract, (("dao_member_" + toString(i.caller)) + "_weight")) { | |
76 | - | case b: Int => | |
77 | - | b | |
78 | - | case _ => | |
79 | - | 0 | |
80 | - | } | |
81 | - | (val > 0) | |
82 | - | } | |
83 | - | ||
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 | - | ||
91 | - | func getVoteValue (s) = if ((s == "like")) | |
92 | - | then 1 | |
93 | - | else if ((s == "dislike")) | |
94 | - | then -1 | |
95 | - | else throw("you need to vote with 'like' or 'dislike' value") | |
96 | - | ||
97 | - | ||
98 | - | func initTaskVotingConditions (taskId,address) = if (!(isGroupMember(address))) | |
99 | - | then throw("grants working group access only") | |
100 | - | else if ((tryGetString((("tasks_" + taskId) + "_status")) != "")) | |
101 | - | then throw("task is not new") | |
102 | - | else true | |
103 | - | ||
104 | - | ||
105 | - | func startWorkConditions (taskId,address) = if ((tryGetString((("tasks_" + taskId) + "_status")) != "approved")) | |
106 | - | then throw("the task is not approved") | |
107 | - | else if ((toString(address) != tryGetString((("tasks_" + taskId) + "_leader")))) | |
108 | - | then throw("team leader only") | |
109 | - | else true | |
110 | - | ||
111 | - | ||
112 | - | func addRewardConditions (taskId,reward,address) = if ((tryGetString((("tasks_" + taskId) + "_status")) != "")) | |
113 | - | then throw("voting was already started, so the reward amount cannot be changed") | |
114 | - | else if ((toString(address) != tryGetString((("tasks_" + taskId) + "_leader")))) | |
115 | - | then throw("team leader only") | |
116 | - | else true | |
117 | - | ||
118 | - | ||
119 | - | func voteForTaskProposalConditions (taskId,i) = if (!(canMemberVote(i))) | |
120 | - | then throw("you can't vote") | |
121 | - | else if (isVotingDisable(taskId)) | |
122 | - | then throw("voting is closed or not started") | |
123 | - | else if (!((tryGetInteger(((("tasks_" + taskId) + "_voted_") + toString(i.caller))) == 0))) | |
124 | - | then throw("you have already voted") | |
125 | - | else true | |
126 | - | ||
127 | - | ||
128 | - | func finishTaskProposalVotingConditions (taskId,address) = if ((tryGetString((("tasks_" + taskId) + "_status")) != "voting_started")) | |
129 | - | then throw("voting is not active") | |
130 | - | else if (isQuorumAchieved(taskId)) | |
131 | - | then throw((("more than " + toString(QUORUM)) + "% members have to vote before finishing the voting")) | |
132 | - | else if (!(isGroupMember(address))) | |
133 | - | then throw("grants working group access only") | |
134 | - | else true | |
135 | - | ||
136 | - | ||
137 | - | func acceptWorkResultConditions (address) = if (!(isGroupMember(address))) | |
138 | - | then throw("grants working group access only") | |
139 | - | else true | |
54 | + | func canMemberVote (i) = (tryGetInteger((("dao_member_" + toString(i.caller)) + "_weight")) > 0) | |
140 | 55 | ||
141 | 56 | ||
142 | 57 | @Callable(i) | |
143 | - | func addTask (title,link,hash) = WriteSet([DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_title"), title), DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_link"), link), DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_hash"), hash), DataEntry((("tasks_" + toBase58String(i.transactionId)) + "_leader"), toString(i.caller))]) | |
58 | + | func addDAOMember (memberAddress) = if (!(isOwner(i.caller))) | |
59 | + | then throw("access only to the DAO owner") | |
60 | + | else if ((tryGetInteger((("dao_member_" + memberAddress) + "_weight")) == 1)) | |
61 | + | then throw("This user already exists") | |
62 | + | else { | |
63 | + | let group = getMembers() | |
64 | + | let newGroup = ((group + ";") + memberAddress) | |
65 | + | let groupSize = tryGetInteger("dao_size") | |
66 | + | let newGroupSize = (groupSize + 1) | |
67 | + | WriteSet([DataEntry("dao_members", newGroup), DataEntry("dao_size", newGroupSize), DataEntry((("dao_member_" + memberAddress) + "_weight"), 1)]) | |
68 | + | } | |
144 | 69 | ||
145 | 70 | ||
146 | 71 | ||
147 | 72 | @Callable(i) | |
148 | - | func resetHash (taskId,hash) = WriteSet([DataEntry((("tasks_" + taskId) + "_hash"), hash)]) | |
149 | - | ||
150 | - | ||
151 | - | ||
152 | - | @Callable(i) | |
153 | - | func hideTask (taskId) = WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "hide")]) | |
154 | - | ||
155 | - | ||
156 | - | ||
157 | - | @Callable(i) | |
158 | - | func addReward (taskId,reward) = if (addRewardConditions(taskId, reward, i.caller)) | |
159 | - | then WriteSet([DataEntry((("tasks_" + taskId) + "_reward"), reward)]) | |
160 | - | else throw("checks are not passed") | |
161 | - | ||
162 | - | ||
163 | - | ||
164 | - | @Callable(i) | |
165 | - | func initTaskVoting (taskId) = if (initTaskVotingConditions(taskId, i.caller)) | |
166 | - | then WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "voting_started")]) | |
167 | - | else throw("checks are not passed") | |
168 | - | ||
169 | - | ||
170 | - | ||
171 | - | @Callable(i) | |
172 | - | func voteForTaskProposal (taskId,voteValueString) = if (voteForTaskProposalConditions(taskId, i)) | |
173 | - | then { | |
174 | - | let voteKey = ((("tasks_" + taskId) + "_voted_") + toString(i.caller)) | |
175 | - | let votingKey = (("tasks_" + taskId) + "_voting_state") | |
176 | - | let votesAmountKey = (("tasks_" + taskId) + "_voting_amount") | |
177 | - | let voteValue = getVoteValue(voteValueString) | |
178 | - | let votingState = tryGetInteger(votingKey) | |
179 | - | let votesAmountState = (tryGetInteger(votesAmountKey) + 1) | |
180 | - | WriteSet([DataEntry(votingKey, (votingState + voteValue)), DataEntry(voteKey, voteValue), DataEntry(votesAmountKey, votesAmountState)]) | |
181 | - | } | |
182 | - | else throw("checks are not passed") | |
183 | - | ||
184 | - | ||
185 | - | ||
186 | - | @Callable(i) | |
187 | - | func finishTaskProposalVoting (taskId) = if (finishTaskProposalVotingConditions(taskId, i.caller)) | |
188 | - | then { | |
189 | - | let statusKey = (("tasks_" + taskId) + "_status") | |
190 | - | let votingKey = (("tasks_" + taskId) + "_voting_state") | |
191 | - | WriteSet([DataEntry(statusKey, if ((tryGetInteger(votingKey) > 0)) | |
192 | - | then "approved" | |
193 | - | else "rejected")]) | |
194 | - | } | |
195 | - | else throw("checks are not passed") | |
196 | - | ||
197 | - | ||
198 | - | ||
199 | - | @Callable(i) | |
200 | - | func startWork (taskId) = if (startWorkConditions(taskId, i.caller)) | |
201 | - | then WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "work_started")]) | |
202 | - | else throw("checks are not passed") | |
203 | - | ||
204 | - | ||
205 | - | ||
206 | - | @Callable(i) | |
207 | - | func rejectTask (taskId) = if (isGroupMember(i.caller)) | |
208 | - | then WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "rejected")]) | |
209 | - | else throw("grants working group access only") | |
210 | - | ||
211 | - | ||
212 | - | ||
213 | - | @Callable(i) | |
214 | - | func acceptWorkResult (taskId,reportLink) = if (acceptWorkResultConditions(i.caller)) | |
215 | - | then { | |
216 | - | let rewardAmount = tryGetInteger((("tasks_" + taskId) + "_reward")) | |
217 | - | let teamAddress = getStringValue(this, (("tasks_" + taskId) + "_leader")) | |
218 | - | ScriptResult(WriteSet([DataEntry((("tasks_" + taskId) + "_status"), "work_finished"), DataEntry((("tasks_" + taskId) + "_report"), reportLink)]), TransferSet([ScriptTransfer(addressFromStringValue(teamAddress), rewardAmount, unit)])) | |
219 | - | } | |
220 | - | else throw("grants working group access only") | |
73 | + | func addGroupMember (memberAddress) = if (!(isOwner(i.caller))) | |
74 | + | then throw("access only to the DAO owner") | |
75 | + | else if ((tryGetInteger((("working_group_member_" + memberAddress) + "_weight")) == 1)) | |
76 | + | then throw("This user already exists") | |
77 | + | else { | |
78 | + | let group = getGroup() | |
79 | + | let newGroup = ((group + ";") + memberAddress) | |
80 | + | let groupSize = tryGetInteger("working_group_size") | |
81 | + | let newGroupSize = (groupSize + 1) | |
82 | + | WriteSet([DataEntry("working_group_members", newGroup), DataEntry("working_group_size", newGroupSize), DataEntry((("working_group_member_" + memberAddress) + "_weight"), 1)]) | |
83 | + | } | |
221 | 84 | ||
222 | 85 |
github/deemru/w8io/169f3d6 120.94 ms ◑