Skip to content

Commit

Permalink
Merge c2f2099 into 1d2d18f
Browse files Browse the repository at this point in the history
  • Loading branch information
shrugs committed Apr 3, 2018
2 parents 1d2d18f + c2f2099 commit dbde96d
Show file tree
Hide file tree
Showing 7 changed files with 5,402 additions and 2,182 deletions.
4 changes: 2 additions & 2 deletions contracts/crowdsale/distribution/RefundableCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
RefundVault public vault;

/**
* @dev Constructor, creates RefundVault.
* @dev Constructor, creates RefundVault.
* @param _goal Funding goal
*/
function RefundableCrowdsale(uint256 _goal) public {
Expand All @@ -42,7 +42,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
}

/**
* @dev Checks whether funding goal was reached.
* @dev Checks whether funding goal was reached.
* @return Whether funding goal was reached
*/
function goalReached() public view returns (bool) {
Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/RBACMock.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pragma solidity ^0.4.8;

import "../ownership/rbac/RBAC.sol";
import "../ownership/rbac/RBACWithAdmin.sol";


contract RBACMock is RBAC {
contract RBACMock is RBACWithAdmin {

string constant ROLE_ADVISOR = "advisor";

Expand Down
52 changes: 2 additions & 50 deletions contracts/ownership/rbac/RBAC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import "./Roles.sol";
* @title RBAC (Role-Based Access Control)
* @author Matt Condon (@Shrugs)
* @dev Stores and provides setters and getters for roles and addresses.
* Supports unlimited numbers of roles and addresses.
* See //contracts/mocks/RBACMock.sol for an example of usage.
* @dev Supports unlimited numbers of roles and addresses.
* @dev See //contracts/mocks/RBACMock.sol for an example of usage.
* This RBAC method uses strings to key roles. It may be beneficial
* for you to write your own implementation of this interface using Enums or similar.
* It's also recommended that you define constants in the contract, like ROLE_ADMIN below,
Expand All @@ -22,20 +22,6 @@ contract RBAC {
event RoleAdded(address addr, string roleName);
event RoleRemoved(address addr, string roleName);

/**
* A constant role name for indicating admins.
*/
string public constant ROLE_ADMIN = "admin";

/**
* @dev constructor. Sets msg.sender as admin by default
*/
function RBAC()
public
{
addRole(msg.sender, ROLE_ADMIN);
}

/**
* @dev reverts if addr does not have role
* @param addr address
Expand Down Expand Up @@ -63,30 +49,6 @@ contract RBAC {
return roles[roleName].has(addr);
}

/**
* @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);
}

/**
* @dev add a role to an address
* @param addr address
Expand Down Expand Up @@ -122,16 +84,6 @@ contract RBAC {
_;
}

/**
* @dev modifier to scope access to admins
* // reverts
*/
modifier onlyAdmin()
{
checkRole(msg.sender, ROLE_ADMIN);
_;
}

/**
* @dev modifier to scope access to a set of roles (uses msg.sender as addr)
* @param roleNames the names of the roles to scope access to
Expand Down
60 changes: 60 additions & 0 deletions contracts/ownership/rbac/RBACWithAdmin.sol
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);
}
}

0 comments on commit dbde96d

Please sign in to comment.