Skip to content

Commit

Permalink
Fixed compile and solium warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Lazovic committed Jul 9, 2018
1 parent d7e8802 commit 6a426d5
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 64 deletions.
29 changes: 16 additions & 13 deletions contracts/Colony.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {
}

function mintTokensForColonyNetwork(uint _wad) public {
require(msg.sender == colonyNetworkAddress, "colony-access-denied-only-network-allowed"); // Only the colony Network can call this function
require(this == IColonyNetwork(colonyNetworkAddress).getMetaColony(), "colony-access-denied-only-meta-colony-allowed"); // Function only valid on the Meta Colony
// Only the colony Network can call this function
require(msg.sender == colonyNetworkAddress, "colony-access-denied-only-network-allowed");
// Function only valid on the Meta Colony
require(this == IColonyNetwork(colonyNetworkAddress).getMetaColony(), "colony-access-denied-only-meta-colony-allowed");
token.mint(_wad);
token.transfer(colonyNetworkAddress, _wad);
}
Expand Down Expand Up @@ -145,16 +147,6 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {
function getDomainCount() public view returns (uint256) {
return domainCount;
}
function setFunctionReviewers(bytes4 _sig, uint8 _firstReviewer, uint8 _secondReviewer)
private
{
uint8[2] memory _reviewers = [_firstReviewer, _secondReviewer];
reviewers[_sig] = _reviewers;
}

function setRoleAssignmentFunction(bytes4 _sig) private {
roleAssignmentSigs[_sig] = true;
}

modifier verifyKey(bytes key) {
uint256 colonyAddress;
Expand All @@ -175,7 +167,7 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {

function verifyReputationProof(bytes key, bytes value, uint branchMask, bytes32[] siblings) // solium-disable-line security/no-assign-params
verifyKey(key)
public returns (bool)
public view returns (bool)
{
// Get roothash from colonynetwork
bytes32 rootHash = IColonyNetwork(colonyNetworkAddress).getReputationRootHash();
Expand All @@ -195,6 +187,17 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {
e.setResolver(newResolver);
}

function setFunctionReviewers(bytes4 _sig, uint8 _firstReviewer, uint8 _secondReviewer)
private
{
uint8[2] memory _reviewers = [_firstReviewer, _secondReviewer];
reviewers[_sig] = _reviewers;
}

function setRoleAssignmentFunction(bytes4 _sig) private {
roleAssignmentSigs[_sig] = true;
}

function initialiseDomain(uint256 _skillId) private skillExists(_skillId) {
// Create a new pot
potCount += 1;
Expand Down
8 changes: 7 additions & 1 deletion contracts/ColonyFunding.sol
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,13 @@ contract ColonyFunding is ColonyStorage, DSMath {

function getRewardPayoutInfo(uint256 _payoutId) public view returns (bytes32, uint256, uint256, address, uint256) {
RewardPayoutCycle memory rewardPayoutInfo = rewardPayoutCycles[_payoutId];
return (rewardPayoutInfo.reputationState, rewardPayoutInfo.totalTokens, rewardPayoutInfo.amount, rewardPayoutInfo.tokenAddress, rewardPayoutInfo.blockTimestamp);
return (
rewardPayoutInfo.reputationState,
rewardPayoutInfo.totalTokens,
rewardPayoutInfo.amount,
rewardPayoutInfo.tokenAddress,
rewardPayoutInfo.blockTimestamp
);
}

function updateTaskPayoutsWeCannotMakeAfterPotChange(uint256 _id, address _token, uint _prev) internal {
Expand Down
9 changes: 8 additions & 1 deletion contracts/ColonyNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ contract ColonyNetwork is ColonyNetworkStorage {
uint nParents = skills[_skillId].nParents;
// TODO: Is it cheaper to check if _amount is <0, and if not, just set nChildren to 0, because children won't be updated for such an update?
uint nChildren = skills[_skillId].nChildren;
IReputationMiningCycle(inactiveReputationMiningCycle).appendReputationUpdateLog(_user, _amount, _skillId, msg.sender, nParents, nChildren);
IReputationMiningCycle(inactiveReputationMiningCycle).appendReputationUpdateLog(
_user,
_amount,
_skillId,
msg.sender,
nParents,
nChildren
);
}
}
3 changes: 2 additions & 1 deletion contracts/ColonyNetworkStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ contract ColonyNetworkStaking is ColonyNetworkStorage, DSMath {

IColony(metaColony).mintTokensForColonyNetwork(stakers.length * reward); // This should be the total amount of new tokens we're awarding.

ReputationMiningCycle(inactiveReputationMiningCycle).rewardStakersWithReputation(stakers, metaColony, reward, rootGlobalSkillId + 2); // This gives them reputation in the next update cycle.
// This gives them reputation in the next update cycle.
ReputationMiningCycle(inactiveReputationMiningCycle).rewardStakersWithReputation(stakers, metaColony, reward, rootGlobalSkillId + 2);

for (uint256 i = 0; i < stakers.length; i++) {
// Also give them some newly minted tokens.
Expand Down
43 changes: 30 additions & 13 deletions contracts/ColonyTask.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pragma solidity ^0.4.23;
pragma experimental "v0.5.0";

import "../lib/dappsys/math.sol";
import "./IColonyNetwork.sol";
import "./ColonyStorage.sol";
import "./IColony.sol";
import "./SafeMath.sol";
Expand Down Expand Up @@ -100,7 +99,8 @@ contract ColonyTask is ColonyStorage, DSMath {

modifier taskWorkRatingsClosed(uint256 _id) {
uint taskCompletionTime = tasks[_id].deliverableTimestamp != 0 ? tasks[_id].deliverableTimestamp : tasks[_id].dueDate;
require(sub(now, taskCompletionTime) > add(RATING_COMMIT_TIMEOUT, RATING_REVEAL_TIMEOUT)); // More than 10 days from work submission have passed
// More than 10 days from work submission have passed
require(sub(now, taskCompletionTime) > add(RATING_COMMIT_TIMEOUT, RATING_REVEAL_TIMEOUT));
_;
}

Expand Down Expand Up @@ -182,11 +182,17 @@ contract ColonyTask is ColonyStorage, DSMath {
msgHash
);

require(reviewerAddresses[0] == tasks[taskId].roles[reviewers[sig][0]].user || reviewerAddresses[0] == tasks[taskId].roles[reviewers[sig][1]].user);
require(
reviewerAddresses[0] == tasks[taskId].roles[reviewers[sig][0]].user ||
reviewerAddresses[0] == tasks[taskId].roles[reviewers[sig][1]].user
);

if (nSignaturesRequired == 2) {
require(reviewerAddresses[0] != reviewerAddresses[1]);
require(reviewerAddresses[1] == tasks[taskId].roles[reviewers[sig][0]].user || reviewerAddresses[1] == tasks[taskId].roles[reviewers[sig][1]].user);
require(
reviewerAddresses[1] == tasks[taskId].roles[reviewers[sig][0]].user ||
reviewerAddresses[1] == tasks[taskId].roles[reviewers[sig][1]].user
);
}

taskChangeNonces[taskId]++;
Expand Down Expand Up @@ -248,14 +254,6 @@ contract ColonyTask is ColonyStorage, DSMath {
require(executeCall(address(this), _value, _data));
}

// The address.call() syntax is no longer recommended, see:
// https://github.com/ethereum/solidity/issues/2884
function executeCall(address to, uint256 value, bytes data) internal returns (bool success) {
assembly {
success := call(gas, to, value, add(data, 0x20), mload(data), 0, 0)
}
}

function submitTaskWorkRating(uint256 _id, uint8 _role, bytes32 _ratingSecret) public
userCanRateRole(_id, _role)
ratingSecretDoesNotExist(_id, _role)
Expand Down Expand Up @@ -423,7 +421,18 @@ contract ColonyTask is ColonyStorage, DSMath {

function getTask(uint256 _id) public view returns (bytes32, bytes32, bool, bool, uint256, uint256, uint256, uint256, uint256, uint256[]) {
Task storage t = tasks[_id];
return (t.specificationHash, t.deliverableHash, t.finalized, t.cancelled, t.dueDate, t.payoutsWeCannotMake, t.potId, t.deliverableTimestamp, t.domainId, t.skills);
return (
t.specificationHash,
t.deliverableHash,
t.finalized,
t.cancelled,
t.dueDate,
t.payoutsWeCannotMake,
t.potId,
t.deliverableTimestamp,
t.domainId,
t.skills
);
}

function getTaskRole(uint256 _id, uint8 _role) public view returns (address, bool, uint8) {
Expand Down Expand Up @@ -485,6 +494,14 @@ contract ColonyTask is ColonyStorage, DSMath {
return reviewerAddresses;
}

// The address.call() syntax is no longer recommended, see:
// https://github.com/ethereum/solidity/issues/2884
function executeCall(address to, uint256 value, bytes data) internal returns (bool success) {
assembly {
success := call(gas, to, value, add(data, 0x20), mload(data), 0, 0)
}
}

// Get the function signature and task id from the transaction bytes data
// Note: Relies on the encoded function's first parameter to be the uint256 taskId
function deconstructCall(bytes _data) internal pure returns (bytes4 sig, uint256 taskId) {
Expand Down
18 changes: 16 additions & 2 deletions contracts/IColony.sol
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,14 @@ contract IColony {
/// @param _value The transaction value, i.e. number of wei to be sent when the transaction is executed
/// Currently we only accept 0 value transactions but this is kept as a future option
/// @param _data The transaction data
function executeTaskChange(uint8[] _sigV, bytes32[] _sigR, bytes32[] _sigS, uint8[] _mode, uint256 _value, bytes _data) public;
function executeTaskChange(
uint8[] _sigV,
bytes32[] _sigR,
bytes32[] _sigS,
uint8[] _mode,
uint256 _value,
bytes _data
) public;

/// @notice Executes a task role update transaction `_data` which is approved and signed by two of addresses
/// depending of which function we are calling. Allowed functions are `setTaskManagerRole`, `setTaskEvaluatorRole` and `setTaskWorkerRole`.
Expand All @@ -230,7 +237,14 @@ contract IColony {
/// @param _value The transaction value, i.e. number of wei to be sent when the transaction is executed
/// Currently we only accept 0 value transactions but this is kept as a future option
/// @param _data The transaction data
function executeTaskRoleAssignment(uint8[] _sigV, bytes32[] _sigR, bytes32[] _sigS, uint8[] _mode, uint256 _value, bytes _data) public;
function executeTaskRoleAssignment(
uint8[] _sigV,
bytes32[] _sigR,
bytes32[] _sigS,
uint8[] _mode,
uint256 _value,
bytes _data
) public;

/// @notice Submit a hashed secret of the rating for work in task `_id` which was performed by user with task role id `_role`
/// Allowed within 5 days period starting which whichever is first from either the deliverable being submitted or the dueDate been reached
Expand Down
23 changes: 21 additions & 2 deletions contracts/IReputationMiningCycle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,19 @@ contract IReputationMiningCycle {
/// @param round The dispute round to query
/// @param index The index in the dispute round to query
/// @return The elements of the Submission struct for the submission requested. See ReputationMiningCycle.sol for the full description
function disputeRounds(uint256 round, uint256 index) public view returns (bytes32 proposedNewRootHash, uint256 nNodes, uint256 lastResponseTimestamp, uint256 challengeStepCompleted, bytes32 jrh, bytes32 intermediateReputationHash, uint256 intermediateReputationNNodes, uint256 jrhNnodes, uint256 lowerBound, uint256 upperBound, uint256 providedPreviousReputationUID);
function disputeRounds(uint256 round, uint256 index) public view returns (
bytes32 proposedNewRootHash,
uint256 nNodes,
uint256 lastResponseTimestamp,
uint256 challengeStepCompleted,
bytes32 jrh,
bytes32 intermediateReputationHash,
uint256 intermediateReputationNNodes,
uint256 jrhNnodes,
uint256 lowerBound,
uint256 upperBound,
uint256 providedPreviousReputationUID
);

/// @notice Get the hash for the corresponding entry.
/// @param submitter The address that submitted the hash
Expand Down Expand Up @@ -126,7 +138,14 @@ contract IReputationMiningCycle {
/// @param _colonyAddress The address of the colony the reputation is being affected in
/// @param _nParents The number of parent skills the skill defined by the skillId has
/// @param _nChildren The number of child skills the skill defined by the skillId has
function appendReputationUpdateLog(address _user, int _amount, uint _skillId, address _colonyAddress, uint _nParents, uint _nChildren) public;
function appendReputationUpdateLog(
address _user,
int _amount,
uint _skillId,
address _colonyAddress,
uint _nParents,
uint _nChildren
) public;

/// @notice Get the length of the ReputationUpdateLog stored on this instance of the ReputationMiningCycle contract
/// @return nUpdates
Expand Down
6 changes: 5 additions & 1 deletion contracts/PatriciaTree/PatriciaTreeProofs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ pragma experimental "ABIEncoderV2";
import {Data} from "./Data.sol";
import {Bits} from "./Bits.sol";


/// @title Functions related to checking Patricia Tree proofs
/// @notice More info at: https://github.com/chriseth/patricia-trie
contract PatriciaTreeProofs {
using Bits for uint;
using Data for Data.Edge;
using Data for Data.Label;

function getImpliedRoot(bytes key, bytes value, uint branchMask, bytes32[] siblings) public view returns (bytes32) { // solium-disable-line security/no-assign-params
function getImpliedRoot(bytes key, bytes value, uint branchMask, bytes32[] siblings) public // solium-disable-line security/no-assign-params
view
returns (bytes32)
{
Data.Label memory k = Data.Label(keccak256(key), 256);
Data.Edge memory e;
e.node = keccak256(value);
Expand Down
Loading

0 comments on commit 6a426d5

Please sign in to comment.