Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tasks Extension #717

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions contracts/Colony.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,26 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {
return token;
}

function emitDomainReputationPenalty(
uint256 _permissionDomainId,
uint256 _childSkillIndex,
uint256 _domainId,
address _user,
int256 _amount
) public stoppable authDomain(_permissionDomainId, _childSkillIndex, _domainId)
{
require(_amount <= 0, "colony-penalty-cannot-be-positive");
IColonyNetwork(colonyNetworkAddress).appendReputationUpdateLog(_user, _amount, domains[_domainId].skillId);
}

function emitSkillReputationPenalty(uint256 _permissionDomainId, uint256 _skillId, address _user, int256 _amount)
public stoppable validGlobalSkill(_skillId)
{
require(_amount <= 0, "colony-penalty-cannot-be-positive");
require(isAuthorized(msg.sender, _permissionDomainId, msg.sig), "ds-auth-unauthorized");
IColonyNetwork(colonyNetworkAddress).appendReputationUpdateLog(_user, _amount, _skillId);
}

function initialiseColony(address _colonyNetworkAddress, address _token) public stoppable {
require(colonyNetworkAddress == address(0x0), "colony-already-initialised-network");
require(token == address(0x0), "colony-already-initialised-token");
Expand Down Expand Up @@ -336,6 +356,10 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {
bytes4 constant SIG5 = bytes4(keccak256("setExpenditurePayoutModifier(uint256,uint256,uint256,uint256,int256)"));
bytes4 constant SIG6 = bytes4(keccak256("setExpenditureClaimDelay(uint256,uint256,uint256,uint256,uint256)"));

// Introducing arbitration penalties
bytes4 constant SIG7 = bytes4(keccak256("emitDomainReputationPenalty(uint256,uint256,uint256,address,int256)"));
bytes4 constant SIG8 = bytes4(keccak256("emitSkillReputationPenalty(uint256,uint256,address,int256)"));

// v3 to v4
function finishUpgrade() public always {
// Remove payment/task mutability from multisig
Expand All @@ -350,6 +374,10 @@ contract Colony is ColonyStorage, PatriciaTreeProofs {
colonyAuthority.setRoleCapability(uint8(ColonyRole.Arbitration), address(this), SIG4, true);
colonyAuthority.setRoleCapability(uint8(ColonyRole.Arbitration), address(this), SIG5, true);
colonyAuthority.setRoleCapability(uint8(ColonyRole.Arbitration), address(this), SIG6, true);

// Add arbitration penalty capabilities
colonyAuthority.setRoleCapability(uint8(ColonyRole.Arbitration), address(this), SIG7, true);
colonyAuthority.setRoleCapability(uint8(ColonyRole.Arbitration), address(this), SIG8, true);
}

function checkNotAdditionalProtectedVariable(uint256 _slot) public view recovery {
Expand Down
2 changes: 2 additions & 0 deletions contracts/ColonyAuthority.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ contract ColonyAuthority is CommonAuthority {
addRoleCapability(ARBITRATION_ROLE, "transferExpenditure(uint256,uint256,uint256,address)");
addRoleCapability(ARBITRATION_ROLE, "setExpenditurePayoutModifier(uint256,uint256,uint256,uint256,int256)");
addRoleCapability(ARBITRATION_ROLE, "setExpenditureClaimDelay(uint256,uint256,uint256,uint256,uint256)");
addRoleCapability(ARBITRATION_ROLE, "emitDomainReputationPenalty(uint256,uint256,uint256,address,int256)");
addRoleCapability(ARBITRATION_ROLE, "emitSkillReputationPenalty(uint256,uint256,address,int256)");
}

function addRoleCapability(uint8 role, bytes memory sig) private {
Expand Down
22 changes: 22 additions & 0 deletions contracts/IColony.sol
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,28 @@ contract IColony is ColonyDataTypes, IRecovery {
/// @return roles bytes32 representation of the roles
function getUserRoles(address who, uint256 where) public view returns (bytes32 roles);

/// @notice Emit a negative domain reputation update. Available only to Arbitration role holders.
/// @param _permissionDomainId The domainId in which I hold the Arbitration role.
/// @param _childSkillIndex The index that the `_domainId` is relative to `_permissionDomainId`,
/// (only used if `_permissionDomainId` is different to `_domainId`)
/// @param _domainId The domain where the user will lose reputation.
/// @param _user The user who will lose reputation.
/// @param _amount The (negative) amount of reputation to lose.
function emitDomainReputationPenalty(
uint256 _permissionDomainId,
uint256 _childSkillIndex,
uint256 _domainId,
address _user,
int256 _amount
) public;

/// @notice Emit a negative skill reputation update. Available only to Arbitration role holders.
/// @param _permissionDomainId The domainId in which I hold the Arbitration role.
/// @param _skillId The skill where the user will lose reputation.
/// @param _user The user who will lose reputation.
/// @param _amount The (negative) amount of reputation to lose.
function emitSkillReputationPenalty(uint256 _permissionDomainId, uint256 _skillId, address _user, int256 _amount) public;

/// @notice Called once when the colony is created to initialise certain storage slot values.
/// @dev Sets the reward inverse to the uint max 2**256 - 1.
/// @param _colonyNetworkAddress Address of the colony network
Expand Down
Loading