Skip to content
Closed
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
12 changes: 12 additions & 0 deletions contracts/access/Roles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pragma solidity ^0.5.2;
library Roles {
struct Role {
mapping (address => bool) bearer;
uint256 count;
}

/**
Expand All @@ -17,6 +18,7 @@ library Roles {
require(!has(role, account));

role.bearer[account] = true;
role.count += 1;
}

/**
Expand All @@ -27,6 +29,7 @@ library Roles {
require(has(role, account));

role.bearer[account] = false;
role.count -= 1;
}

/**
Expand All @@ -37,4 +40,13 @@ library Roles {
require(account != address(0));
return role.bearer[account];
}

/**
* @dev check if an account has this role
* @return uint
*/

function count(Role storage role) internal view returns (uint256) {
return role.count;
}
}