Commit b2e2d9ab by Matt Condon

fix: solium errors - indentation only

parent 4d263b7f
...@@ -5,65 +5,65 @@ import "../ownership/rbac/RBAC.sol"; ...@@ -5,65 +5,65 @@ import "../ownership/rbac/RBAC.sol";
contract RBACMock is RBAC { contract RBACMock is RBAC {
string constant ROLE_ADVISOR = "advisor"; string constant ROLE_ADVISOR = "advisor";
modifier onlyAdminOrAdvisor() modifier onlyAdminOrAdvisor()
{ {
require( require(
hasRole(msg.sender, ROLE_ADMIN) || hasRole(msg.sender, ROLE_ADMIN) ||
hasRole(msg.sender, ROLE_ADVISOR) hasRole(msg.sender, ROLE_ADVISOR)
); );
_; _;
} }
function RBACMock(address[] _advisors) function RBACMock(address[] _advisors)
public public
{ {
addRole(msg.sender, ROLE_ADVISOR); addRole(msg.sender, ROLE_ADVISOR);
for (uint256 i = 0; i < _advisors.length; i++) { for (uint256 i = 0; i < _advisors.length; i++) {
addRole(_advisors[i], ROLE_ADVISOR); addRole(_advisors[i], ROLE_ADVISOR);
}
} }
}
function onlyAdminsCanDoThis() function onlyAdminsCanDoThis()
onlyAdmin onlyAdmin
view view
external external
{ {
} }
function onlyAdvisorsCanDoThis() function onlyAdvisorsCanDoThis()
onlyRole(ROLE_ADVISOR) onlyRole(ROLE_ADVISOR)
view view
external external
{ {
} }
function eitherAdminOrAdvisorCanDoThis() function eitherAdminOrAdvisorCanDoThis()
onlyAdminOrAdvisor onlyAdminOrAdvisor
view view
external external
{ {
} }
function nobodyCanDoThis() function nobodyCanDoThis()
onlyRole("unknown") onlyRole("unknown")
view view
external external
{ {
} }
// admins can remove advisor's role // admins can remove advisor's role
function removeAdvisor(address _addr) function removeAdvisor(address _addr)
onlyAdmin onlyAdmin
public public
{ {
// revert if the user isn't an advisor // revert if the user isn't an advisor
// (perhaps you want to soft-fail here instead?) // (perhaps you want to soft-fail here instead?)
checkRole(_addr, ROLE_ADVISOR); checkRole(_addr, ROLE_ADVISOR);
// remove the advisor's role // remove the advisor's role
removeRole(_addr, ROLE_ADVISOR); removeRole(_addr, ROLE_ADVISOR);
} }
} }
...@@ -9,13 +9,13 @@ import "./Ownable.sol"; ...@@ -9,13 +9,13 @@ import "./Ownable.sol";
*/ */
contract Contactable is Ownable{ contract Contactable is Ownable{
string public contactInformation; string public contactInformation;
/** /**
* @dev Allows the owner to set a string with their contact information. * @dev Allows the owner to set a string with their contact information.
* @param info The contact information to attach to the contract. * @param info The contact information to attach to the contract.
*/ */
function setContactInformation(string info) onlyOwner public { function setContactInformation(string info) onlyOwner public {
contactInformation = info; contactInformation = info;
} }
} }
...@@ -15,143 +15,143 @@ import "./Roles.sol"; ...@@ -15,143 +15,143 @@ import "./Roles.sol";
* to avoid typos. * to avoid typos.
*/ */
contract RBAC { contract RBAC {
using Roles for Roles.Role; using Roles for Roles.Role;
mapping (string => Roles.Role) private roles; mapping (string => Roles.Role) private roles;
event RoleAdded(address addr, string roleName); event RoleAdded(address addr, string roleName);
event RoleRemoved(address addr, string roleName); event RoleRemoved(address addr, string roleName);
/** /**
* A constant role name for indicating admins. * A constant role name for indicating admins.
*/ */
string public constant ROLE_ADMIN = "admin"; string public constant ROLE_ADMIN = "admin";
/** /**
* @dev constructor. Sets msg.sender as admin by default * @dev constructor. Sets msg.sender as admin by default
*/ */
function RBAC() function RBAC()
public public
{ {
addRole(msg.sender, ROLE_ADMIN); addRole(msg.sender, ROLE_ADMIN);
} }
/** /**
* @dev add a role to an address * @dev add a role to an address
* @param addr address * @param addr address
* @param roleName the name of the role * @param roleName the name of the role
*/ */
function addRole(address addr, string roleName) function addRole(address addr, string roleName)
internal internal
{ {
roles[roleName].add(addr); roles[roleName].add(addr);
RoleAdded(addr, roleName); RoleAdded(addr, roleName);
} }
/** /**
* @dev remove a role from an address * @dev remove a role from an address
* @param addr address * @param addr address
* @param roleName the name of the role * @param roleName the name of the role
*/ */
function removeRole(address addr, string roleName) function removeRole(address addr, string roleName)
internal internal
{ {
roles[roleName].remove(addr); roles[roleName].remove(addr);
RoleRemoved(addr, roleName); RoleRemoved(addr, roleName);
} }
/** /**
* @dev reverts if addr does not have role * @dev reverts if addr does not have role
* @param addr address * @param addr address
* @param roleName the name of the role * @param roleName the name of the role
* // reverts * // reverts
*/ */
function checkRole(address addr, string roleName) function checkRole(address addr, string roleName)
view view
public public
{ {
roles[roleName].check(addr); roles[roleName].check(addr);
} }
/** /**
* @dev determine if addr has role * @dev determine if addr has role
* @param addr address * @param addr address
* @param roleName the name of the role * @param roleName the name of the role
* @return bool * @return bool
*/ */
function hasRole(address addr, string roleName) function hasRole(address addr, string roleName)
view view
public public
returns (bool) returns (bool)
{ {
return roles[roleName].has(addr); return roles[roleName].has(addr);
} }
/** /**
* @dev add a role to an address * @dev add a role to an address
* @param addr address * @param addr address
* @param roleName the name of the role * @param roleName the name of the role
*/ */
function adminAddRole(address addr, string roleName) function adminAddRole(address addr, string roleName)
onlyAdmin onlyAdmin
public public
{ {
addRole(addr, roleName); addRole(addr, roleName);
} }
/** /**
* @dev remove a role from an address * @dev remove a role from an address
* @param addr address * @param addr address
* @param roleName the name of the role * @param roleName the name of the role
*/ */
function adminRemoveRole(address addr, string roleName) function adminRemoveRole(address addr, string roleName)
onlyAdmin onlyAdmin
public public
{ {
removeRole(addr, roleName); removeRole(addr, roleName);
} }
/** /**
* @dev modifier to scope access to a single role (uses msg.sender as addr) * @dev modifier to scope access to a single role (uses msg.sender as addr)
* @param roleName the name of the role * @param roleName the name of the role
* // reverts * // reverts
*/ */
modifier onlyRole(string roleName) modifier onlyRole(string roleName)
{ {
checkRole(msg.sender, roleName); checkRole(msg.sender, roleName);
_; _;
} }
/** /**
* @dev modifier to scope access to admins * @dev modifier to scope access to admins
* // reverts * // reverts
*/ */
modifier onlyAdmin() modifier onlyAdmin()
{ {
checkRole(msg.sender, ROLE_ADMIN); checkRole(msg.sender, ROLE_ADMIN);
_; _;
} }
/** /**
* @dev modifier to scope access to a set of roles (uses msg.sender as addr) * @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 * @param roleNames the names of the roles to scope access to
* // reverts * // reverts
* *
* @TODO - when solidity supports dynamic arrays as arguments to modifiers, provide this * @TODO - when solidity supports dynamic arrays as arguments to modifiers, provide this
* see: https://github.com/ethereum/solidity/issues/2467 * see: https://github.com/ethereum/solidity/issues/2467
*/ */
// modifier onlyRoles(string[] roleNames) { // modifier onlyRoles(string[] roleNames) {
// bool hasAnyRole = false; // bool hasAnyRole = false;
// for (uint8 i = 0; i < roleNames.length; i++) { // for (uint8 i = 0; i < roleNames.length; i++) {
// if (hasRole(msg.sender, roleNames[i])) { // if (hasRole(msg.sender, roleNames[i])) {
// hasAnyRole = true; // hasAnyRole = true;
// break; // break;
// } // }
// } // }
// require(hasAnyRole); // require(hasAnyRole);
// _; // _;
// } // }
} }
...@@ -8,48 +8,48 @@ pragma solidity ^0.4.18; ...@@ -8,48 +8,48 @@ pragma solidity ^0.4.18;
* See RBAC.sol for example usage. * See RBAC.sol for example usage.
*/ */
library Roles { library Roles {
struct Role { struct Role {
mapping (address => bool) bearer; mapping (address => bool) bearer;
} }
/** /**
* @dev give an address access to this role * @dev give an address access to this role
*/ */
function add(Role storage role, address addr) function add(Role storage role, address addr)
internal internal
{ {
role.bearer[addr] = true; role.bearer[addr] = true;
} }
/** /**
* @dev remove an address' access to this role * @dev remove an address' access to this role
*/ */
function remove(Role storage role, address addr) function remove(Role storage role, address addr)
internal internal
{ {
role.bearer[addr] = false; role.bearer[addr] = false;
} }
/** /**
* @dev check if an address has this role * @dev check if an address has this role
* // reverts * // reverts
*/ */
function check(Role storage role, address addr) function check(Role storage role, address addr)
view view
internal internal
{ {
require(has(role, addr)); require(has(role, addr));
} }
/** /**
* @dev check if an address has this role * @dev check if an address has this role
* @return bool * @return bool
*/ */
function has(Role storage role, address addr) function has(Role storage role, address addr)
view view
internal internal
returns (bool) returns (bool)
{ {
return role.bearer[addr]; return role.bearer[addr];
} }
} }
...@@ -8,20 +8,20 @@ import "./BasicToken.sol"; ...@@ -8,20 +8,20 @@ import "./BasicToken.sol";
*/ */
contract BurnableToken is BasicToken { contract BurnableToken is BasicToken {
event Burn(address indexed burner, uint256 value); event Burn(address indexed burner, uint256 value);
/** /**
* @dev Burns a specific amount of tokens. * @dev Burns a specific amount of tokens.
* @param _value The amount of token to be burned. * @param _value The amount of token to be burned.
*/ */
function burn(uint256 _value) public { function burn(uint256 _value) public {
require(_value <= balances[msg.sender]); require(_value <= balances[msg.sender]);
// no need to require value <= totalSupply, since that would imply the // no need to require value <= totalSupply, since that would imply the
// sender's balance is greater than the totalSupply, which *should* be an assertion failure // sender's balance is greater than the totalSupply, which *should* be an assertion failure
address burner = msg.sender; address burner = msg.sender;
balances[burner] = balances[burner].sub(_value); balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value); totalSupply = totalSupply.sub(_value);
Burn(burner, _value); Burn(burner, _value);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment