-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
5,402 additions
and
2,182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
pragma solidity ^0.4.18; | ||
|
||
import "./RBAC.sol"; | ||
|
||
|
||
/** | ||
* @title RBACWithAdmin | ||
* @author Matt Condon (@Shrugs) | ||
* @dev It's recommended that you define constants in the contract, | ||
* @dev like ROLE_ADMIN below, to avoid typos. | ||
*/ | ||
contract RBACWithAdmin is RBAC { | ||
/** | ||
* A constant role name for indicating admins. | ||
*/ | ||
string public constant ROLE_ADMIN = "admin"; | ||
|
||
/** | ||
* @dev modifier to scope access to admins | ||
* // reverts | ||
*/ | ||
modifier onlyAdmin() | ||
{ | ||
checkRole(msg.sender, ROLE_ADMIN); | ||
_; | ||
} | ||
|
||
/** | ||
* @dev constructor. Sets msg.sender as admin by default | ||
*/ | ||
function RBACWithAdmin() | ||
public | ||
{ | ||
addRole(msg.sender, ROLE_ADMIN); | ||
} | ||
|
||
/** | ||
* @dev add a role to an address | ||
* @param addr address | ||
* @param roleName the name of the role | ||
*/ | ||
function adminAddRole(address addr, string roleName) | ||
onlyAdmin | ||
public | ||
{ | ||
addRole(addr, roleName); | ||
} | ||
|
||
/** | ||
* @dev remove a role from an address | ||
* @param addr address | ||
* @param roleName the name of the role | ||
*/ | ||
function adminRemoveRole(address addr, string roleName) | ||
onlyAdmin | ||
public | ||
{ | ||
removeRole(addr, roleName); | ||
} | ||
} |
Oops, something went wrong.