@@ -116,33 +116,33 @@ contract Tasks is DSMath {
116
116
}
117
117
118
118
modifier self () {
119
- require (address (this ) == msg .sender , "colony- task-not-self " );
119
+ require (address (this ) == msg .sender , "task-not-self " );
120
120
_;
121
121
}
122
122
123
+ ColonyDataTypes.ColonyRole constant ADMIN = ColonyDataTypes.ColonyRole.Administration;
123
124
modifier isAdmin (address _user , uint256 _permissionDomainId , uint256 _childSkillIndex , uint256 _domainId ) {
124
- ColonyDataTypes.ColonyRole admin = ColonyDataTypes.ColonyRole.Administration;
125
- require (colony.hasInheritedUserRole (_user, _permissionDomainId, admin, _childSkillIndex, _domainId), "colony-task-not-admin " );
125
+ require (colony.hasInheritedUserRole (_user, _permissionDomainId, ADMIN, _childSkillIndex, _domainId), "task-not-admin " );
126
126
_;
127
127
}
128
128
129
129
modifier taskExists (uint256 _id ) {
130
- require (_id > 0 && _id <= taskCount , "colony- task-does-not-exist " );
130
+ require (doesTaskExist ( _id) , "task-does-not-exist " );
131
131
_;
132
132
}
133
133
134
134
modifier taskComplete (uint256 _id ) {
135
- require (tasks[ _id].completionTimestamp > 0 , "colony- task-not-complete " );
135
+ require (isTaskComplete ( _id) , "task-not-complete " );
136
136
_;
137
137
}
138
138
139
139
modifier taskNotComplete (uint256 _id ) {
140
- require (tasks[ _id].completionTimestamp == 0 , "colony- task-complete " );
140
+ require (! isTaskComplete ( _id) , "task-complete " );
141
141
_;
142
142
}
143
143
144
144
modifier confirmTaskRoleIdentity (uint256 _id , address _user , TaskRole _role ) {
145
- require (msg . sender == getTaskRoleUser (_id, _role), "colony- task-role-identity-mismatch " );
145
+ require (getTaskRoleUser (_id, _role) == msg . sender , "task-role-identity-mismatch " );
146
146
_;
147
147
}
148
148
@@ -156,17 +156,17 @@ contract Tasks is DSMath {
156
156
)
157
157
public
158
158
{
159
- require (_value == 0 , "colony- task-change-non-zero-value " );
160
- require (_sigR.length == _sigS.length && _sigR.length == _sigV.length , "colony- task-change-signatures -count-do-not -match " );
159
+ require (_value == 0 , "task-change-non-zero-value " );
160
+ require (_sigR.length == _sigS.length && _sigR.length == _sigV.length , "task-change-sig -count-no -match " );
161
161
162
162
bytes4 sig;
163
163
uint256 taskId;
164
164
(sig, taskId) = deconstructCall (_data);
165
- require (taskId > 0 && taskId <= taskCount, "colony- task-does-not-exist " );
166
- require (! roleAssignmentSigs[sig], "colony- task-change-is-role-assignment " );
165
+ require (taskId > 0 && taskId <= taskCount, "task-does-not-exist " );
166
+ require (! roleAssignmentSigs[sig], "task-change-is-role-assign " );
167
167
168
168
ColonyDataTypes.ExpenditureStatus status = colony.getExpenditure (tasks[taskId].expenditureId).status;
169
- require (status != ColonyDataTypes.ExpenditureStatus.Finalized, "colony- task-finalized " );
169
+ require (status != ColonyDataTypes.ExpenditureStatus.Finalized, "task-finalized " );
170
170
171
171
uint8 nSignaturesRequired;
172
172
address taskRole1User = getTaskRoleUser (taskId, TaskRole (reviewers[sig][0 ]));
@@ -180,26 +180,26 @@ contract Tasks is DSMath {
180
180
} else {
181
181
nSignaturesRequired = 2 ;
182
182
}
183
- require (_sigR.length == nSignaturesRequired, "colony- task-change-does-not-meet-signatures-required " );
183
+ require (_sigR.length == nSignaturesRequired, "task-change-wrong-num-sigs " );
184
184
185
185
bytes32 msgHash = keccak256 (abi.encodePacked (address (this ), address (this ), _value, _data, tasks[taskId].changeNonce));
186
186
address [] memory reviewerAddresses = getReviewerAddresses (_sigV, _sigR, _sigS, _mode, msgHash);
187
187
188
188
require (
189
189
reviewerAddresses[0 ] == taskRole1User || reviewerAddresses[0 ] == taskRole2User,
190
- "colony- task-signatures-do-not -match-reviewer-1 "
190
+ "task-sigs-no -match-reviewer-1 "
191
191
);
192
192
193
193
if (nSignaturesRequired == 2 ) {
194
- require (reviewerAddresses[0 ] != reviewerAddresses[1 ], "colony- task-duplicate-reviewers " );
194
+ require (reviewerAddresses[0 ] != reviewerAddresses[1 ], "task-duplicate-reviewers " );
195
195
require (
196
196
reviewerAddresses[1 ] == taskRole1User || reviewerAddresses[1 ] == taskRole2User,
197
- "colony- task-signatures-do-not -match-reviewer-2 "
197
+ "task-sigs-no -match-reviewer-2 "
198
198
);
199
199
}
200
200
201
201
tasks[taskId].changeNonce += 1 ;
202
- require (executeCall (address (this ), _value, _data), "colony- task-change-execution-failed " );
202
+ require (executeCall (address (this ), _value, _data), "task-change-execution-failed " );
203
203
}
204
204
205
205
function executeTaskRoleAssignment (
@@ -212,18 +212,18 @@ contract Tasks is DSMath {
212
212
)
213
213
public
214
214
{
215
- require (_value == 0 , "colony- task-role-assignment -non-zero-value " );
216
- require (_sigR.length == _sigS.length && _sigR.length == _sigV.length , "colony- task-role-assignment-signatures -count-do-not -match " );
215
+ require (_value == 0 , "task-role-assign -non-zero-value " );
216
+ require (_sigR.length == _sigS.length && _sigR.length == _sigV.length , "task-role-assign-sig -count-no -match " );
217
217
218
218
bytes4 sig;
219
219
uint256 taskId;
220
220
address userAddress;
221
221
(sig, taskId, userAddress) = deconstructRoleChangeCall (_data);
222
- require (taskId > 0 && taskId <= taskCount, "colony- task-does-not-exist " );
223
- require (roleAssignmentSigs[sig], "colony- task-change-is-not-role-assignment " );
222
+ require (taskId > 0 && taskId <= taskCount, "task-does-not-exist " );
223
+ require (roleAssignmentSigs[sig], "task-change-is-not-role-assign " );
224
224
225
225
ColonyDataTypes.ExpenditureStatus status = colony.getExpenditure (tasks[taskId].expenditureId).status;
226
- require (status != ColonyDataTypes.ExpenditureStatus.Finalized, "colony- task-finalized " );
226
+ require (status != ColonyDataTypes.ExpenditureStatus.Finalized, "task-finalized " );
227
227
228
228
uint8 nSignaturesRequired;
229
229
address manager = getTaskRoleUser (taskId, TaskRole.Manager);
@@ -233,36 +233,36 @@ contract Tasks is DSMath {
233
233
} else {
234
234
nSignaturesRequired = 2 ;
235
235
}
236
- require (_sigR.length == nSignaturesRequired, "colony- task-role-assignment-does-not-meet-required-signatures " );
236
+ require (_sigR.length == nSignaturesRequired, "task-role-assign-wrong-num-sigs " );
237
237
238
238
bytes32 msgHash = keccak256 (abi.encodePacked (address (this ), address (this ), _value, _data, tasks[taskId].changeNonce));
239
239
address [] memory reviewerAddresses = getReviewerAddresses (_sigV, _sigR, _sigS, _mode, msgHash);
240
240
241
241
if (nSignaturesRequired == 1 ) {
242
242
// Since we want to set a manager as an evaluator, require just manager's signature
243
- require (reviewerAddresses[0 ] == manager, "colony- task-role-assignment-not-signed-by- manager " );
243
+ require (reviewerAddresses[0 ] == manager, "task-role-assign-no- manager-sig " );
244
244
} else {
245
245
// One of signers must be a manager
246
246
require (
247
247
reviewerAddresses[0 ] == manager ||
248
248
reviewerAddresses[1 ] == manager,
249
- "colony- task-role-assignment-not-signed-by- manager "
249
+ "task-role-assign-no- manager-sig "
250
250
);
251
251
252
252
// One of the signers must be an address we want to set here
253
253
require (
254
254
userAddress == reviewerAddresses[0 ] || userAddress == reviewerAddresses[1 ],
255
- "colony- task-role-assignment-not-signed-by- new-user-for-role "
255
+ "task-role-assign-no- new-user-sig "
256
256
);
257
257
// Require that signatures are not from the same address
258
258
// This will never throw, because we require that manager is one of the signers,
259
259
// and if manager is both signers, then `userAddress` must also be a manager, and if
260
260
// `userAddress` is a manager, then we require 1 signature (will be kept for possible future changes)
261
- require (reviewerAddresses[0 ] != reviewerAddresses[1 ], "colony- task-role-assignment -duplicate-signatures " );
261
+ require (reviewerAddresses[0 ] != reviewerAddresses[1 ], "task-role-assign -duplicate-sigs " );
262
262
}
263
263
264
264
tasks[taskId].changeNonce += 1 ;
265
- require (executeCall (address (this ), _value, _data), "colony- task-role-assignment-execution -failed " );
265
+ require (executeCall (address (this ), _value, _data), "task-role-assign-exec -failed " );
266
266
}
267
267
268
268
// Permissions pertain to the Administration role here
@@ -302,15 +302,15 @@ contract Tasks is DSMath {
302
302
taskComplete (_id)
303
303
{
304
304
if (_role == TaskRole.Manager) { // Manager rated by worker
305
- require (msg .sender == getTaskRoleUser (_id, TaskRole.Worker), "colony -user-cannot-rate-task -manager " );
305
+ require (msg .sender == getTaskRoleUser (_id, TaskRole.Worker), "task -user-cannot-rate-manager " );
306
306
} else if (_role == TaskRole.Worker) { // Worker rated by evaluator
307
- require (msg .sender == getTaskRoleUser (_id, TaskRole.Evaluator), "colony -user-cannot-rate-task -worker " );
307
+ require (msg .sender == getTaskRoleUser (_id, TaskRole.Evaluator), "task -user-cannot-rate-worker " );
308
308
} else {
309
- revert ("colony -unsupported-role-to-rate " );
309
+ revert ("task -unsupported-role-to-rate " );
310
310
}
311
311
312
- require (sub (now , tasks[_id].completionTimestamp) <= RATING_COMMIT_TIMEOUT, "colony- task-rating- secret-submit-period -closed " );
313
- require (ratingSecrets[_id].secret[uint8 (_role)] == "" , "colony- task-rating -secret-already-exists " );
312
+ require (sub (now , tasks[_id].completionTimestamp) <= RATING_COMMIT_TIMEOUT, "task-secret-submissions -closed " );
313
+ require (ratingSecrets[_id].secret[uint8 (_role)] == "" , "task-secret-already-exists " );
314
314
315
315
ratingSecrets[_id].count += 1 ;
316
316
ratingSecrets[_id].timestamp = now ;
@@ -326,18 +326,18 @@ contract Tasks is DSMath {
326
326
// Otherwise start the reveal period after the commit period has expired
327
327
// In both cases, keep reveal period open for 5 days
328
328
if (ratingSecrets[_id].count == 2 ) {
329
- require (sub (now , ratingSecrets[_id].timestamp) <= RATING_REVEAL_TIMEOUT, "colony- task-rating- secret-reveal-period -closed " );
329
+ require (sub (now , ratingSecrets[_id].timestamp) <= RATING_REVEAL_TIMEOUT, "task-secret-reveal-closed " );
330
330
} else {
331
331
uint taskCompletionTime = tasks[_id].completionTimestamp;
332
- require (sub (now , taskCompletionTime) > RATING_COMMIT_TIMEOUT, "colony- task-rating- secret-reveal-period -not-open " );
333
- require (sub (now , taskCompletionTime) <= add (RATING_COMMIT_TIMEOUT, RATING_REVEAL_TIMEOUT), "colony- task-rating- secret-reveal-period -closed " );
332
+ require (sub (now , taskCompletionTime) > RATING_COMMIT_TIMEOUT, "task-secret-reveal-not-open " );
333
+ require (sub (now , taskCompletionTime) <= add (RATING_COMMIT_TIMEOUT, RATING_REVEAL_TIMEOUT), "task-secret-reveal-closed " );
334
334
}
335
335
336
336
bytes32 secret = generateSecret (_salt, _rating);
337
- require (secret == ratingSecrets[_id].secret[uint8 (_role)], "colony- task-rating -secret-mismatch " );
337
+ require (secret == ratingSecrets[_id].secret[uint8 (_role)], "task-secret-mismatch " );
338
338
339
339
TaskRatings rating = TaskRatings (_rating);
340
- require (rating != TaskRatings.None, "colony- task-rating-missing " );
340
+ require (rating != TaskRatings.None, "task-rating-missing " );
341
341
taskRoles[_id][uint8 (_role)].rating = rating;
342
342
343
343
emit TaskWorkRatingRevealed (_id, _role, _rating);
@@ -366,15 +366,15 @@ contract Tasks is DSMath {
366
366
367
367
function setTaskEvaluatorRole (uint256 _id , address payable _user ) public self {
368
368
// Can only assign role if no one is currently assigned to it
369
- require (getTaskRoleUser (_id, TaskRole.Evaluator) == address (0x0 ), "colony- task-evaluator-role-already -assigned " );
369
+ require (getTaskRoleUser (_id, TaskRole.Evaluator) == address (0x0 ), "task-evaluator-role-assigned " );
370
370
setTaskRoleUser (_id, TaskRole.Evaluator, _user);
371
371
}
372
372
373
373
function setTaskWorkerRole (uint256 _id , address payable _user ) public self {
374
374
// Can only assign role if no one is currently assigned to it
375
- require (getTaskRoleUser (_id, TaskRole.Worker) == address (0x0 ), "colony- task-worker-role-already -assigned " );
375
+ require (getTaskRoleUser (_id, TaskRole.Worker) == address (0x0 ), "task-worker-role-assigned " );
376
376
uint256 [] memory skills = colony.getExpenditureSlot (tasks[_id].expenditureId, uint256 (TaskRole.Worker)).skills;
377
- require (skills[0 ] > 0 , "colony- task-skill-not-set " ); // ignore-swc-110
377
+ require (skills. length > 0 && skills [0 ] > 0 , "task-skill-not-set " ); // ignore-swc-110
378
378
setTaskRoleUser (_id, TaskRole.Worker, _user);
379
379
}
380
380
@@ -413,8 +413,8 @@ contract Tasks is DSMath {
413
413
address evaluator = getTaskRoleUser (_id, TaskRole.Evaluator);
414
414
address worker = getTaskRoleUser (_id, TaskRole.Worker);
415
415
416
- require (evaluator == manager || evaluator == address (0x0 ), "colony-funding -evaluator-already-set " );
417
- require (worker == manager || worker == address (0x0 ), "colony-funding -worker-already-set " );
416
+ require (evaluator == manager || evaluator == address (0x0 ), "task -evaluator-already-set " );
417
+ require (worker == manager || worker == address (0x0 ), "task -worker-already-set " );
418
418
419
419
this .setTaskManagerPayout (_id, _token, _managerAmount);
420
420
this .setTaskEvaluatorPayout (_id, _token, _evaluatorAmount);
@@ -471,7 +471,7 @@ contract Tasks is DSMath {
471
471
taskNotComplete (_id)
472
472
confirmTaskRoleIdentity (_id, msg .sender , TaskRole.Manager)
473
473
{
474
- require (now >= tasks[_id].dueDate, "colony- task-due-date-in-future " );
474
+ require (now >= tasks[_id].dueDate, "task-due-date-in-future " );
475
475
tasks[_id].completionTimestamp = now ;
476
476
477
477
emit TaskCompleted (_id);
@@ -643,7 +643,7 @@ contract Tasks is DSMath {
643
643
}
644
644
645
645
function assignWorkRatings (uint256 _id ) internal {
646
- require (taskWorkRatingsAssigned (_id) || taskWorkRatingsClosed (_id), "colony- task-ratings-not-closed " );
646
+ require (taskWorkRatingsAssigned (_id) || taskWorkRatingsClosed (_id), "task-ratings-not-closed " );
647
647
648
648
// In the event of a user not committing/revealing within the rating window,
649
649
// their rating of their counterpart is assumed to be the maximum
@@ -668,7 +668,7 @@ contract Tasks is DSMath {
668
668
}
669
669
670
670
function setTaskRoleUser (uint256 _id , TaskRole _role , address payable _user )
671
- private
671
+ internal
672
672
taskExists (_id)
673
673
taskNotComplete (_id)
674
674
{
@@ -679,4 +679,12 @@ contract Tasks is DSMath {
679
679
680
680
colony.setExpenditureRecipient (tasks[_id].expenditureId, uint256 (_role), _user);
681
681
}
682
+
683
+ function doesTaskExist (uint256 _id ) internal view returns (bool ) {
684
+ return _id > 0 && _id <= taskCount;
685
+ }
686
+
687
+ function isTaskComplete (uint256 _id ) internal view returns (bool ) {
688
+ return tasks[_id].completionTimestamp > 0 ;
689
+ }
682
690
}
0 commit comments