Skip to content

Commit

Permalink
Return a isGlobalSkill boolean flag in ColonyNetwork.getSkill
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinLiLu authored and elenadimitrova committed Jul 17, 2018
1 parent 7bd945f commit 191d06e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
5 changes: 3 additions & 2 deletions contracts/ColonyNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ contract ColonyNetwork is ColonyNetworkStorage {
return colonyVersionResolver[_version];
}

function getSkill(uint256 _skillId) public view returns (uint256, uint256) {
return (skills[_skillId].nParents, skills[_skillId].nChildren);
function getSkill(uint256 _skillId) public view returns (uint256, uint256, bool) {
Skill storage skill = skills[_skillId];
return (skill.nParents, skill.nChildren, skill.globalSkill);
}

function isGlobalSkill(uint256 _skillId) public view returns (bool) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/ColonyNetworkStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ contract ColonyNetworkStorage is DSAuth, DSMath {
// `true` for a global skill reused across colonies or `false` for a skill mapped to a single colony's domain
bool globalSkill;
}
// Contains all global and local skills in the network, mapping skillId to Skill. Where skillId is 1-based unique identofier
// Contains all global and local skills in the network, mapping skillId to Skill. Where skillId is 1-based unique identifier
mapping (uint256 => Skill) skills;
// Number of skills in the network, including both global and local skills
uint256 skillCount;
Expand Down
3 changes: 2 additions & 1 deletion contracts/IColonyNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ contract IColonyNetwork {
/// @param _skillId Id of the skill
/// @return nParents uint256 `skill.nParents` i.e. the number of parent skills of skill with id `_skillId`
/// @return nChildren uint256 `skill.nChildren` i.e. the number of child skills of skill with id `_skillId`
function getSkill(uint256 _skillId) public view returns (uint256 nParents, uint256 nChildren);
/// @return isGlobalSkill true if specified skill is a global skill, otherwise false
function getSkill(uint256 _skillId) public view returns (uint256 nParents, uint256 nChildren, bool isGlobalSkill);

/// @notice Checks if skill with id `_skillId` is a global skill
/// @param _skillId Id of the skill
Expand Down
2 changes: 1 addition & 1 deletion contracts/ReputationMiningCycle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ contract ReputationMiningCycle is PatriciaTreeProofs, DSMath {
// We update skills in the order children, then parents, then the skill listed in the log itself.
// If the amount in the log is positive, then no children are being updated.
uint nParents;
(nParents, ) = IColonyNetwork(colonyNetworkAddress).getSkill(logEntry.skillId);
(nParents, , ) = IColonyNetwork(colonyNetworkAddress).getSkill(logEntry.skillId);
uint nChildUpdates;
if (logEntry.amount >= 0) { // solium-disable-line no-empty-blocks, whitespace
// Then we have no child updates to consider
Expand Down
12 changes: 12 additions & 0 deletions test/meta-colony.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,16 @@ contract("Meta Colony", accounts => {
await checkErrorRevert(colony.setTaskSkill(1, 3));
});
});

describe("when getting a skill", () => {
it("should return a true flag if the skill is global", async () => {
const globalSkill = await colonyNetwork.getSkill.call(1);
assert.isTrue(globalSkill[2]);
});

it("should return a false flag if the skill is local", async () => {
const localSkill = await colonyNetwork.getSkill.call(2);
assert.isFalse(localSkill[2]);
});
});
});

0 comments on commit 191d06e

Please sign in to comment.