Files
openzeppelin-contracts/contracts/mocks/RBACMock.sol
Leo Arias f4eb51a7e9 Improve encapsulation on SignatureBouncer, Whitelist and RBAC example (#1265)
* Improve encapsulation on Whitelist

* remove only

* update whitelisted crowdsale test

* Improve encapsulation on SignatureBouncer

* fix missing test

* Improve encapsulation on RBAC example

* Improve encapsulation on RBAC example

* Remove extra visibility

* Improve encapsulation on ERC20 Mintable

* Improve encapsulation on Superuser

* fix lint

* add missing constant
2018-09-03 19:06:43 -03:00

70 lines
1.1 KiB
Solidity

pragma solidity ^0.4.24;
import "../examples/RBACWithAdmin.sol";
contract RBACMock is RBACWithAdmin {
string internal constant ROLE_ADVISOR = "advisor";
modifier onlyAdminOrAdvisor()
{
require(
isAdmin(msg.sender) ||
hasRole(msg.sender, ROLE_ADVISOR)
);
_;
}
constructor(address[] _advisors)
public
{
_addRole(msg.sender, ROLE_ADVISOR);
for (uint256 i = 0; i < _advisors.length; i++) {
_addRole(_advisors[i], ROLE_ADVISOR);
}
}
function onlyAdminsCanDoThis()
external
onlyAdmin
view
{
}
function onlyAdvisorsCanDoThis()
external
onlyRole(ROLE_ADVISOR)
view
{
}
function eitherAdminOrAdvisorCanDoThis()
external
onlyAdminOrAdvisor
view
{
}
function nobodyCanDoThis()
external
onlyRole("unknown")
view
{
}
// admins can remove advisor's role
function removeAdvisor(address _account)
public
onlyAdmin
{
// revert if the user isn't an advisor
// (perhaps you want to soft-fail here instead?)
checkRole(_account, ROLE_ADVISOR);
// remove the advisor's role
_removeRole(_account, ROLE_ADVISOR);
}
}