-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename WhitelisterRole to WhitelistAdminRole. (#1589)
* Rename WhitelisterRole to WhitelistAdminRole. * Update WhitelistAdmin changelog entry.
- Loading branch information
Showing
9 changed files
with
88 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,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); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
const { shouldBehaveLikePublicRole } = require('../../access/roles/PublicRole.behavior'); | ||
const WhitelistAdminRoleMock = artifacts.require('WhitelistAdminRoleMock'); | ||
|
||
contract('WhitelistAdminRole', function ([_, whitelistAdmin, otherWhitelistAdmin, ...otherAccounts]) { | ||
beforeEach(async function () { | ||
this.contract = await WhitelistAdminRoleMock.new({ from: whitelistAdmin }); | ||
await this.contract.addWhitelistAdmin(otherWhitelistAdmin, { from: whitelistAdmin }); | ||
}); | ||
|
||
shouldBehaveLikePublicRole(whitelistAdmin, otherWhitelistAdmin, otherAccounts, 'whitelistAdmin'); | ||
}); |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
const { shouldBehaveLikePublicRole } = require('../../access/roles/PublicRole.behavior'); | ||
const WhitelistedRoleMock = artifacts.require('WhitelistedRoleMock'); | ||
|
||
contract('WhitelistedRole', function ([_, whitelisted, otherWhitelisted, whitelister, ...otherAccounts]) { | ||
contract('WhitelistedRole', function ([_, whitelisted, otherWhitelisted, whitelistAdmin, ...otherAccounts]) { | ||
beforeEach(async function () { | ||
this.contract = await WhitelistedRoleMock.new({ from: whitelister }); | ||
await this.contract.addWhitelisted(whitelisted, { from: whitelister }); | ||
await this.contract.addWhitelisted(otherWhitelisted, { from: whitelister }); | ||
this.contract = await WhitelistedRoleMock.new({ from: whitelistAdmin }); | ||
await this.contract.addWhitelisted(whitelisted, { from: whitelistAdmin }); | ||
await this.contract.addWhitelisted(otherWhitelisted, { from: whitelistAdmin }); | ||
}); | ||
|
||
shouldBehaveLikePublicRole(whitelisted, otherWhitelisted, otherAccounts, 'whitelisted', whitelister); | ||
shouldBehaveLikePublicRole(whitelisted, otherWhitelisted, otherAccounts, 'whitelisted', whitelistAdmin); | ||
}); |
This file was deleted.
Oops, something went wrong.