Skip to content

Commit

Permalink
Merge pull request JoinColony#265 from JoinColony/maintenance/compile…
Browse files Browse the repository at this point in the history
…-warnings

Compile warnings
  • Loading branch information
elenadimitrova authored Jul 9, 2018
2 parents b333ae5 + ac95269 commit 735cad0
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 146 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"max-len": [2, { "code": 150, "ignoreComments": true }],
"prettier/prettier": ["error", {"printWidth": 150}],
"flowtype/require-valid-file-annotation": "off",
"import/named": "off"
"import/named": "off",
"no-console": "off"
},
"parserOptions": {
"ecmaVersion": 2017
Expand Down
3 changes: 2 additions & 1 deletion .soliumrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"quotes": ["error", "double"],
"security/no-inline-assembly": 0,
"security/no-call-value": 0,
"security/no-block-members": 0
"security/no-block-members": 0,
"no-experimental": 0
}
}
65 changes: 29 additions & 36 deletions contracts/Authority.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,55 +26,48 @@ contract Authority is DSRoles {
uint8 adminRole = 1;

constructor(address colony) public {
// functions for owner role
bytes4 setTokenSig = bytes4(keccak256("setToken(address)"));
bytes4 bootstrapColonySig = bytes4(keccak256("bootstrapColony(address[],int256[])"));
bytes4 mintTokensSig = bytes4(keccak256("mintTokens(uint256)"));
bytes4 addGlobalSkillSig = bytes4(keccak256("addGlobalSkill(uint256)"));
bytes4 setOwnerRoleSig = bytes4(keccak256("setOwnerRole(address)"));
bytes4 removeAdminRoleSig = bytes4(keccak256("removeAdminRole(address)"));
bytes4 upgradeSig = bytes4(keccak256("upgrade(uint256)"));

// functions for admin + owner role
bytes4 moveFundsBetweenPotsSig = bytes4(keccak256("moveFundsBetweenPots(uint256,uint256,uint256,address)"));
bytes4 addDomainSig = bytes4(keccak256("addDomain(uint256)"));
bytes4 makeTaskSig = bytes4(keccak256("makeTask(bytes32,uint256)"));
bytes4 startNextRewardPayoutSig = bytes4(keccak256("startNextRewardPayout(address)"));
bytes4 cancelTaskSig = bytes4(keccak256("cancelTask(uint256)"));
bytes4 setAdminRoleSig = bytes4(keccak256("setAdminRole(address)"));

// Set token
setRoleCapability(ownerRole, colony, setTokenSig, true);
setOwnerRoleCapability(colony, "setToken(address)");
// Bootstrap colony
setRoleCapability(ownerRole, colony, bootstrapColonySig, true);
setOwnerRoleCapability(colony, "bootstrapColony(address[],int256[])");
// Mint tokens
setRoleCapability(ownerRole, colony, mintTokensSig, true);
setOwnerRoleCapability(colony, "mintTokens(uint256)");
// Add global skill
setRoleCapability(ownerRole, colony, addGlobalSkillSig, true);
setOwnerRoleCapability(colony, "addGlobalSkill(uint256)");
// Transfer ownership
setRoleCapability(ownerRole, colony, setOwnerRoleSig, true);
setOwnerRoleCapability(colony, "setOwnerRole(address)");
// Remove admin role
setRoleCapability(ownerRole, colony, removeAdminRoleSig, true);
setOwnerRoleCapability(colony, "removeAdminRole(address)");
// Upgrade colony
setRoleCapability(ownerRole, colony, upgradeSig, true);
setOwnerRoleCapability(colony, "upgrade(uint256)");

// Allocate funds
setRoleCapability(adminRole, colony, moveFundsBetweenPotsSig, true);
setRoleCapability(ownerRole, colony, moveFundsBetweenPotsSig, true);
setAdminRoleCapability(colony, "moveFundsBetweenPots(uint256,uint256,uint256,address)");
setOwnerRoleCapability(colony, "moveFundsBetweenPots(uint256,uint256,uint256,address)");
// Add domain
setRoleCapability(adminRole, colony, addDomainSig, true);
setRoleCapability(ownerRole, colony, addDomainSig, true);
setAdminRoleCapability(colony, "addDomain(uint256)");
setOwnerRoleCapability(colony, "addDomain(uint256)");
// Add task
setRoleCapability(adminRole, colony, makeTaskSig, true);
setRoleCapability(ownerRole, colony, makeTaskSig, true);
setAdminRoleCapability(colony, "makeTask(bytes32,uint256)");
setOwnerRoleCapability(colony, "makeTask(bytes32,uint256)");
// Start next reward payout
setRoleCapability(adminRole, colony, startNextRewardPayoutSig, true);
setRoleCapability(ownerRole, colony, startNextRewardPayoutSig, true);
setAdminRoleCapability(colony, "startNextRewardPayout(address)");
setOwnerRoleCapability(colony, "startNextRewardPayout(address)");
// Cancel task
setRoleCapability(adminRole, colony, cancelTaskSig, true);
setRoleCapability(ownerRole, colony, cancelTaskSig, true);
setAdminRoleCapability(colony, "cancelTask(uint256)");
setOwnerRoleCapability(colony, "cancelTask(uint256)");
// Set admin
setRoleCapability(adminRole, colony, setAdminRoleSig, true);
setRoleCapability(ownerRole, colony, setAdminRoleSig, true);
setAdminRoleCapability(colony, "setAdminRole(address)");
setOwnerRoleCapability(colony, "setAdminRole(address)");
}

function setOwnerRoleCapability(address colony, bytes sig) private {
bytes4 functionSig = bytes4(keccak256(sig));
setRoleCapability(ownerRole, colony, functionSig, true);
}

function setAdminRoleCapability(address colony, bytes sig) private {
bytes4 functionSig = bytes4(keccak256(sig));
setRoleCapability(adminRole, colony, functionSig, true);
}
}
33 changes: 16 additions & 17 deletions contracts/Colony.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@
pragma solidity ^0.4.23;
pragma experimental "v0.5.0";

import "./ERC20Extended.sol";
import "./IColonyNetwork.sol";
import "./IColony.sol";
import "./ColonyStorage.sol";
import "./PatriciaTree/PatriciaTreeProofs.sol";
import "./Authority.sol";
import "./EtherRouter.sol";


Expand Down Expand Up @@ -105,8 +101,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 +143,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 +163,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 +183,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
13 changes: 8 additions & 5 deletions contracts/ColonyFunding.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
pragma solidity ^0.4.23;
pragma experimental "v0.5.0";

import "../lib/dappsys/math.sol";
import "./ERC20Extended.sol";
import "./IColonyNetwork.sol";
import "./ColonyStorage.sol";
import "./ITokenLocking.sol";


contract ColonyFunding is ColonyStorage, DSMath {
contract ColonyFunding is ColonyStorage {
event RewardPayoutCycleStarted(uint256 indexed id);
event RewardPayoutCycleEnded(uint256 indexed id);
event TaskWorkerPayoutChanged(uint256 indexed id, address token, uint256 amount);
Expand Down Expand Up @@ -245,7 +242,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
12 changes: 8 additions & 4 deletions contracts/ColonyNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
pragma solidity ^0.4.23;
pragma experimental "v0.5.0";

import "../lib/dappsys/auth.sol";
import "./Authority.sol";
import "./IColony.sol";
import "./EtherRouter.sol";
import "./Token.sol";
import "./ColonyNetworkStorage.sol";
import "./IReputationMiningCycle.sol";

Expand Down Expand Up @@ -245,6 +242,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
);
}
}
21 changes: 9 additions & 12 deletions contracts/ColonyNetworkAuction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
pragma solidity ^0.4.23;
pragma experimental "v0.5.0";

import "../lib/dappsys/math.sol";
import "./ColonyNetworkStorage.sol";
import "./ERC20Extended.sol";
import "./IColony.sol";


contract ColonyNetworkAuction is ColonyNetworkStorage {
Expand Down Expand Up @@ -49,7 +46,7 @@ contract DutchAuction is DSMath {
uint public endTime;
uint public minPrice;
uint public constant TOKEN_MULTIPLIER = 10 ** 18;

// Keep track of all CLNY wei received
uint public receivedTotal;
uint public bidCount;
Expand All @@ -58,7 +55,7 @@ contract DutchAuction is DSMath {
// Final price in CLNY per 10**18 Tokens (min 1, max 1e18)
uint public finalPrice;
bool public finalized;

mapping (address => uint256) public bids;

modifier auctionNotStarted {
Expand Down Expand Up @@ -87,7 +84,7 @@ contract DutchAuction is DSMath {
modifier auctionFinalized {
require(finalized);
_;
}
}

modifier allBidsClaimed {
require(claimCount == bidCount);
Expand Down Expand Up @@ -119,7 +116,7 @@ contract DutchAuction is DSMath {
started = true;
}

function totalToEndAuction() public view
function totalToEndAuction() public view
auctionStartedAndOpen
returns (uint)
{
Expand Down Expand Up @@ -156,15 +153,15 @@ contract DutchAuction is DSMath {
amount = remainingToEndAuction;
endTime = now;
}

if (bids[msg.sender] == 0) {
bidCount += 1;
}

clnyToken.transferFrom(msg.sender, this, amount);
bids[msg.sender] = add(bids[msg.sender], amount);
receivedTotal = add(receivedTotal, amount);

emit AuctionBid(msg.sender, amount, sub(remainingToEndAuction, amount));
}

Expand All @@ -180,7 +177,7 @@ contract DutchAuction is DSMath {
emit AuctionFinalized(finalPrice);
}

function claim() public
function claim() public
auctionFinalized
returns (bool)
{
Expand All @@ -189,7 +186,7 @@ contract DutchAuction is DSMath {

uint tokens = mul(amount, TOKEN_MULTIPLIER) / finalPrice;
claimCount += 1;

// Set receiver bid to 0 before transferring the tokens
bids[msg.sender] = 0;
uint beforeClaimBalance = token.balanceOf(msg.sender);
Expand All @@ -213,4 +210,4 @@ contract DutchAuction is DSMath {
assert(token.balanceOf(this) == 0);
selfdestruct(colonyNetwork);
}
}
}
11 changes: 3 additions & 8 deletions contracts/ColonyNetworkStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@
pragma solidity ^0.4.23;
pragma experimental "v0.5.0";

import "../lib/dappsys/auth.sol";
import "./Authority.sol";
import "./IColony.sol";
import "./EtherRouter.sol";
import "./ERC20Extended.sol";
import "./ColonyNetworkStorage.sol";
import "./IColonyNetwork.sol";
import "./ReputationMiningCycle.sol";


contract ColonyNetworkStaking is ColonyNetworkStorage, DSMath {
contract ColonyNetworkStaking is ColonyNetworkStorage {
// TODO: Can we handle a dispute regarding the very first hash that should be set?

modifier onlyReputationMiningCycle () {
Expand Down Expand Up @@ -127,7 +121,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
8 changes: 3 additions & 5 deletions contracts/ColonyNetworkStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ pragma solidity ^0.4.23;
pragma experimental "v0.5.0";

import "../lib/dappsys/auth.sol";
import "../lib/dappsys/roles.sol";
import "./Authority.sol";
import "../lib/dappsys/math.sol";
import "./ERC20Extended.sol";
import "./IColony.sol";
import "./EtherRouter.sol";
import "./Token.sol";


contract ColonyNetworkStorage is DSAuth {
contract ColonyNetworkStorage is DSAuth, DSMath {
// Address of the Resolver contract used by EtherRouter for lookups and routing
address resolver;
// Number of colonies in the network
Expand Down
5 changes: 3 additions & 2 deletions contracts/ColonyStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ pragma solidity ^0.4.23;
pragma experimental "v0.5.0";

import "../lib/dappsys/auth.sol";
import "../lib/dappsys/math.sol";
import "./ERC20Extended.sol";
import "./IColonyNetwork.sol";
import "./Authority.sol";


contract ColonyStorage is DSAuth {
contract ColonyStorage is DSAuth, DSMath {
// When adding variables, do not make them public, otherwise all contracts that inherit from
// this one will have the getters. Make custom getters in the contract that seems most appropriate,
// and add it to IColony.sol
Expand All @@ -38,7 +39,7 @@ contract ColonyStorage is DSAuth {

// Mapping function signature to 2 task roles whose approval is needed to execute
mapping (bytes4 => uint8[2]) reviewers;

// Role assignment functions require special type of sign-off.
// This keeps track of which functions are related to role assignment
mapping (bytes4 => bool) roleAssignmentSigs;
Expand Down
Loading

0 comments on commit 735cad0

Please sign in to comment.