Rename WhitelisterRole to WhitelistAdminRole. (#1589)
* Rename WhitelisterRole to WhitelistAdminRole. * Update WhitelistAdmin changelog entry.
This commit is contained in:
47
contracts/access/roles/WhitelistAdminRole.sol
Normal file
47
contracts/access/roles/WhitelistAdminRole.sol
Normal file
@ -0,0 +1,47 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
import "../Roles.sol";
|
||||
|
||||
/**
|
||||
* @title WhitelistAdminRole
|
||||
* @dev WhitelistAdmins are responsible for assigning and removing Whitelisted accounts.
|
||||
*/
|
||||
contract WhitelistAdminRole {
|
||||
using Roles for Roles.Role;
|
||||
|
||||
event WhitelistAdminAdded(address indexed account);
|
||||
event WhitelistAdminRemoved(address indexed account);
|
||||
|
||||
Roles.Role private _whitelistAdmins;
|
||||
|
||||
constructor () internal {
|
||||
_addWhitelistAdmin(msg.sender);
|
||||
}
|
||||
|
||||
modifier onlyWhitelistAdmin() {
|
||||
require(isWhitelistAdmin(msg.sender));
|
||||
_;
|
||||
}
|
||||
|
||||
function isWhitelistAdmin(address account) public view returns (bool) {
|
||||
return _whitelistAdmins.has(account);
|
||||
}
|
||||
|
||||
function addWhitelistAdmin(address account) public onlyWhitelistAdmin {
|
||||
_addWhitelistAdmin(account);
|
||||
}
|
||||
|
||||
function renounceWhitelistAdmin() public {
|
||||
_removeWhitelistAdmin(msg.sender);
|
||||
}
|
||||
|
||||
function _addWhitelistAdmin(address account) internal {
|
||||
_whitelistAdmins.add(account);
|
||||
emit WhitelistAdminAdded(account);
|
||||
}
|
||||
|
||||
function _removeWhitelistAdmin(address account) internal {
|
||||
_whitelistAdmins.remove(account);
|
||||
emit WhitelistAdminRemoved(account);
|
||||
}
|
||||
}
|
||||
@ -1,15 +1,15 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
import "../Roles.sol";
|
||||
import "./WhitelisterRole.sol";
|
||||
import "./WhitelistAdminRole.sol";
|
||||
|
||||
/**
|
||||
* @title WhitelistedRole
|
||||
* @dev Whitelisted accounts have been approved by a Whitelister to perform certain actions (e.g. participate in a
|
||||
* crowdsale). This role is special in that the only accounts that can add it are Whitelisters (who can also remove it),
|
||||
* and not Whitelisteds themselves.
|
||||
* @dev Whitelisted accounts have been approved by a WhitelistAdmin to perform certain actions (e.g. participate in a
|
||||
* crowdsale). This role is special in that the only accounts that can add it are WhitelistAdmins (who can also remove
|
||||
* it), and not Whitelisteds themselves.
|
||||
*/
|
||||
contract WhitelistedRole is WhitelisterRole {
|
||||
contract WhitelistedRole is WhitelistAdminRole {
|
||||
using Roles for Roles.Role;
|
||||
|
||||
event WhitelistedAdded(address indexed account);
|
||||
@ -26,11 +26,11 @@ contract WhitelistedRole is WhitelisterRole {
|
||||
return _whitelisteds.has(account);
|
||||
}
|
||||
|
||||
function addWhitelisted(address account) public onlyWhitelister {
|
||||
function addWhitelisted(address account) public onlyWhitelistAdmin {
|
||||
_addWhitelisted(account);
|
||||
}
|
||||
|
||||
function removeWhitelisted(address account) public onlyWhitelister {
|
||||
function removeWhitelisted(address account) public onlyWhitelistAdmin {
|
||||
_removeWhitelisted(account);
|
||||
}
|
||||
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
import "../Roles.sol";
|
||||
|
||||
/**
|
||||
* @title WhitelisterRole
|
||||
* @dev Whitelisters are responsible for assigning and removing Whitelisted accounts.
|
||||
*/
|
||||
contract WhitelisterRole {
|
||||
using Roles for Roles.Role;
|
||||
|
||||
event WhitelisterAdded(address indexed account);
|
||||
event WhitelisterRemoved(address indexed account);
|
||||
|
||||
Roles.Role private _whitelisters;
|
||||
|
||||
constructor () internal {
|
||||
_addWhitelister(msg.sender);
|
||||
}
|
||||
|
||||
modifier onlyWhitelister() {
|
||||
require(isWhitelister(msg.sender));
|
||||
_;
|
||||
}
|
||||
|
||||
function isWhitelister(address account) public view returns (bool) {
|
||||
return _whitelisters.has(account);
|
||||
}
|
||||
|
||||
function addWhitelister(address account) public onlyWhitelister {
|
||||
_addWhitelister(account);
|
||||
}
|
||||
|
||||
function renounceWhitelister() public {
|
||||
_removeWhitelister(msg.sender);
|
||||
}
|
||||
|
||||
function _addWhitelister(address account) internal {
|
||||
_whitelisters.add(account);
|
||||
emit WhitelisterAdded(account);
|
||||
}
|
||||
|
||||
function _removeWhitelister(address account) internal {
|
||||
_whitelisters.remove(account);
|
||||
emit WhitelisterRemoved(account);
|
||||
}
|
||||
}
|
||||
17
contracts/mocks/WhitelistAdminRoleMock.sol
Normal file
17
contracts/mocks/WhitelistAdminRoleMock.sol
Normal file
@ -0,0 +1,17 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
import "../access/roles/WhitelistAdminRole.sol";
|
||||
|
||||
contract WhitelistAdminRoleMock is WhitelistAdminRole {
|
||||
function removeWhitelistAdmin(address account) public {
|
||||
_removeWhitelistAdmin(account);
|
||||
}
|
||||
|
||||
function onlyWhitelistAdminMock() public view onlyWhitelistAdmin {
|
||||
}
|
||||
|
||||
// Causes a compilation error if super._removeWhitelistAdmin is not internal
|
||||
function _removeWhitelistAdmin(address account) internal {
|
||||
super._removeWhitelistAdmin(account);
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
pragma solidity ^0.5.0;
|
||||
|
||||
import "../access/roles/WhitelisterRole.sol";
|
||||
|
||||
contract WhitelisterRoleMock is WhitelisterRole {
|
||||
function removeWhitelister(address account) public {
|
||||
_removeWhitelister(account);
|
||||
}
|
||||
|
||||
function onlyWhitelisterMock() public view onlyWhitelister {
|
||||
}
|
||||
|
||||
// Causes a compilation error if super._removeWhitelister is not internal
|
||||
function _removeWhitelister(address account) internal {
|
||||
super._removeWhitelister(account);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user