RBAC and Ownable migration towards Roles (#1291)

* Role tests (#1228)

* Moved RBAC tests to access.

* Added Roles.addMany and tests.

* Fixed linter error.

* Now using uint256 indexes.

* Removed RBAC tokens (#1229)

* Deleted RBACCappedTokenMock.

* Removed RBACMintableToken.

* Removed RBACMintableToken from the MintedCrowdsale tests.

* Roles can now be transfered. (#1235)

* Roles can now be transfered.

* Now explicitly checking support for the null address.

* Now rejecting transfer to a role-haver.

* Added renounce, roles can no longer be transfered to 0.

* Fixed linter errors.

* Fixed a Roles test.

* True Ownership (#1247)

* Added barebones Secondary.

* Added transferPrimary

* Escrow is now Secondary instead of Ownable.

* Now reverting on transfers to 0.

* The Secondary's primary is now private.

* MintableToken using Roles (#1236)

* Minor test style improvements (#1219)

* Changed .eq to .equal

* Changed equal(bool) to .to.be.bool

* Changed be.bool to equal(bool), disallowed unused expressions.

* Add ERC165Query library (#1086)

* Add ERC165Query library

* Address PR Comments

* Add tests and mocks from #1024 and refactor code slightly

* Fix javascript and solidity linting errors

* Split supportsInterface into three methods as discussed in #1086

* Change InterfaceId_ERC165 comment to match style in the rest of the repo

* Fix max-len lint issue on ERC165Checker.sol

* Conditionally ignore the asserts during solidity-coverage test

* Switch to abi.encodeWithSelector and add test for account addresses

* Switch to supportsInterfaces API as suggested by @frangio

* Adding ERC165InterfacesSupported.sol

* Fix style issues

* Add test for supportsInterfaces returning false

* Add ERC165Checker.sol newline

* feat: fix coverage implementation

* fix: solidity linting error

* fix: revert to using boolean tests instead of require statements

* fix: make supportsERC165Interface private again

* rename SupportsInterfaceWithLookupMock to avoid name clashing

* Added mint and burn tests for zero amounts. (#1230)

* Changed .eq to .equal. (#1231)

* ERC721 pausable token (#1154)

* ERC721 pausable token

* Reuse of ERC721 Basic behavior for Pausable, split view checks in paused state & style fixes

* [~] paused token behavior

* Add some detail to releasing steps (#1190)

* add note about pulling upstream changes to release branch

* add comment about upstream changes in merging section

* Increase test coverage (#1237)

* Fixed a SplitPayment test

* Deleted unnecessary function.

* Improved PostDeliveryCrowdsale tests.

* Improved RefundableCrowdsale tests.

* Improved MintedCrowdsale tests.

* Improved IncreasingPriceCrowdsale tests.

* Fixed a CappedCrowdsale test.

* Improved TimedCrowdsale tests.

* Improved descriptions of added tests.

*  ci: trigger docs update on tag  (#1186)

* MintableToken now uses Roles.

* Fixed FinalizableCrowdsale test.

* Roles can now be transfered.

* Fixed tests related to MintableToken.

* Removed Roles.check.

* Renamed transferMintPermission.

* Moved MinterRole

* Fixed RBAC.

* Adressed review comments.

* Addressed review comments

* Fixed linter errors.

* Added Events tests of Pausable contract (#1207)

* Fixed roles tests.

* Rename events to past-tense (#1181)

* fix: refactor sign.js and related tests (#1243)

* fix: refactor sign.js and related tests

* fix: remove unused dep

* fix: update package.json correctly

* Added "_" sufix to internal variables (#1171)

* Added PublicRole test.

* Fixed crowdsale tests.

* Rename ERC interfaces to I prefix (#1252)

* rename ERC20 to IERC20

* move ERC20.sol to IERC20.sol

* rename StandardToken to ERC20

* rename StandardTokenMock to ERC20Mock

* move StandardToken.sol to ERC20.sol, likewise test and mock files

* rename MintableToken to ERC20Mintable

* move MintableToken.sol to ERC20Mintable.sol, likewise test and mock files

* rename BurnableToken to ERC20Burnable

* move BurnableToken.sol to ERC20Burnable.sol, likewise for related files

* rename CappedToken to ERC20Capped

* move CappedToken.sol to ERC20Capped.sol, likewise for related files

* rename PausableToken to ERC20Pausable

* move PausableToken.sol to ERC20Pausable.sol, likewise for related files

* rename DetailedERC20 to ERC20Detailed

* move DetailedERC20.sol to ERC20Detailed.sol, likewise for related files

* rename ERC721 to IERC721, and likewise for other related interfaces

* move ERC721.sol to IERC721.sol, likewise for other 721 interfaces

* rename ERC721Token to ERC721

* move ERC721Token.sol to ERC721.sol, likewise for related files

* rename ERC721BasicToken to ERC721Basic

* move ERC721BasicToken.sol to ERC721Basic.sol, likewise for related files

* rename ERC721PausableToken to ERC721Pausable

* move ERC721PausableToken.sol to ERC721Pausable.sol

* rename ERC165 to IERC165

* move ERC165.sol to IERC165.sol

* amend comment that ERC20 is based on FirstBlood

* fix comments mentioning IERC721Receiver

* added explicit visibility (#1261)

* Remove underscores from event parameters. (#1258)

* Remove underscores from event parameters.

Fixes #1175

* Add comment about ERC

* Move contracts to subdirectories (#1253)

* Move contracts to subdirectories

Fixes #1177.

This Change also removes the LimitBalance contract.

* fix import

* move MerkleProof to cryptography

* Fix import

* Remove HasNoEther, HasNoTokens, HasNoContracts, and NoOwner (#1254)

* remove HasNoEther, HasNoTokens, HasNoContracts, and NoOwner

* remove unused ERC223TokenMock

* remove Contactable

* remove TokenDestructible

* remove DeprecatedERC721

* inline Destructible#destroy in Bounty

* remove Destructible

* Functions in interfaces changed to "external" (#1263)

* Add a leading underscore to internal and private functions. (#1257)

* Add a leading underscore to internal and private functions.

Fixes #1176

* Remove super

* update the ERC721 changes

* add missing underscore after merge

* Fix mock

* Improve encapsulation on SignatureBouncer, Whitelist and RBAC example (#1265)

* Improve encapsulation on Whitelist

* remove only

* update whitelisted crowdsale test

* Improve encapsulation on SignatureBouncer

* fix missing test

* Improve encapsulation on RBAC example

* Improve encapsulation on RBAC example

* Remove extra visibility

* Improve encapsulation on ERC20 Mintable

* Improve encapsulation on Superuser

* fix lint

* add missing constant

* Addressed review comments.

* Fixed build error.

* Improved Roles API. (#1280)

* Improved Roles API.

* fix linter error

* Added PauserRole. (#1283)

* Remove Claimable, DelayedClaimable, Heritable (#1274)

* remove Claimable, DelayedClaimable, Heritable

* remove SimpleSavingsWallet example which used Heritable

(cherry picked from commit 0dc711732a)

* Role behavior tests (#1285)

* Added role tests.

* Added PauserRole tests to contracts that have that role.

* Added MinterRole tests to contracts that have that role.

* Fixed linter errors.

* Migrate Ownable to Roles (#1287)

* Added CapperRole.

* RefundEscrow is now Secondary.

* FinalizableCrowdsale is no longer Ownable.

* Removed Whitelist and WhitelistedCrowdsale, redesign needed.

* Fixed linter errors, disabled lbrace due to it being buggy.

* Remove RBAC, SignatureBouncer refactor (#1289)

* Added CapperRole.

* RefundEscrow is now Secondary.

* FinalizableCrowdsale is no longer Ownable.

* Removed Whitelist and WhitelistedCrowdsale, redesign needed.

* Fixed linter errors, disabled lbrace due to it being buggy.

* Moved SignatureBouncer tests.

* Deleted RBAC and Superuser.

* Deleted rbac directory.

* Updated readme.

* SignatureBouncer now uses SignerRole, renamed bouncer to signer.

* feat: implement ERC721Mintable and ERC721Burnable (#1276)

* feat: implement ERC721Mintable and ERC721Burnable

* fix: linting errors

* fix: remove unused mintable mock for ERC721BasicMock

* fix: add finishMinting tests

* fix: catch MintFinished typo

* inline ERC721Full behavior

* undo pretty formatting

* fix lint errors

* rename canMint to onlyBeforeMintingFinished for consistency with ERC20Mintable

* Fix the merge with the privatization branch

* remove duplicate CapperRole test
This commit is contained in:
Nicolás Venturo
2018-09-07 07:16:51 -03:00
committed by GitHub
parent bf95602404
commit f12817e446
88 changed files with 1504 additions and 1673 deletions

View File

@ -0,0 +1,18 @@
pragma solidity ^0.4.24;
import "../access/roles/CapperRole.sol";
contract CapperRoleMock is CapperRole {
function removeCapper(address _account) public {
_removeCapper(_account);
}
function onlyCapperMock() public view onlyCapper {
}
// Causes a compilation error if super._removeCapper is not internal
function _removeCapper(address _account) internal {
super._removeCapper(_account);
}
}

View File

@ -0,0 +1,8 @@
pragma solidity ^0.4.24;
import "../token/ERC20/ERC20Mintable.sol";
import "./MinterRoleMock.sol";
contract ERC20MintableMock is ERC20Mintable, MinterRoleMock {
}

View File

@ -1,10 +1,11 @@
pragma solidity ^0.4.24;
import "../token/ERC20/ERC20Pausable.sol";
import "./PauserRoleMock.sol";
// mock class using ERC20Pausable
contract ERC20PausableMock is ERC20Pausable {
contract ERC20PausableMock is ERC20Pausable, PauserRoleMock {
constructor(address _initialAccount, uint _initialBalance) public {
_mint(_initialAccount, _initialBalance);

View File

@ -9,10 +9,10 @@ import "../token/ERC721/ERC721Basic.sol";
*/
contract ERC721BasicMock is ERC721Basic {
function mint(address _to, uint256 _tokenId) public {
super._mint(_to, _tokenId);
_mint(_to, _tokenId);
}
function burn(uint256 _tokenId) public {
super._burn(ownerOf(_tokenId), _tokenId);
_burn(ownerOf(_tokenId), _tokenId);
}
}

View File

@ -0,0 +1,18 @@
pragma solidity ^0.4.24;
import "../token/ERC721/ERC721.sol";
import "../token/ERC721/ERC721Mintable.sol";
import "../token/ERC721/ERC721Burnable.sol";
/**
* @title ERC721MintableBurnableImpl
*/
contract ERC721MintableBurnableImpl is ERC721, ERC721Mintable, ERC721Burnable {
constructor()
ERC721Mintable()
ERC721("Test", "TEST")
public
{
}
}

View File

@ -1,6 +1,8 @@
pragma solidity ^0.4.24;
import "../token/ERC721/ERC721.sol";
import "../token/ERC721/ERC721Mintable.sol";
import "../token/ERC721/ERC721Burnable.sol";
/**
@ -8,18 +10,11 @@ import "../token/ERC721/ERC721.sol";
* This mock just provides a public mint and burn functions for testing purposes,
* and a public setter for metadata URI
*/
contract ERC721Mock is ERC721 {
constructor(string name, string symbol) public
ERC721(name, symbol)
{ }
function mint(address _to, uint256 _tokenId) public {
_mint(_to, _tokenId);
}
function burn(uint256 _tokenId) public {
_burn(ownerOf(_tokenId), _tokenId);
}
contract ERC721Mock is ERC721, ERC721Mintable, ERC721Burnable {
constructor(string _name, string _symbol) public
ERC721Mintable()
ERC721(_name, _symbol)
{}
function exists(uint256 _tokenId) public view returns (bool) {
return _exists(_tokenId);

View File

@ -1,13 +1,14 @@
pragma solidity ^0.4.24;
import "../token/ERC721/ERC721Pausable.sol";
import "./PauserRoleMock.sol";
/**
* @title ERC721PausableMock
* This mock just provides a public mint, burn and exists functions for testing purposes
*/
contract ERC721PausableMock is ERC721Pausable {
contract ERC721PausableMock is ERC721Pausable, PauserRoleMock {
function mint(address _to, uint256 _tokenId) public {
super._mint(_to, _tokenId);
}

View File

@ -1,6 +1,6 @@
pragma solidity ^0.4.24;
import "../token/ERC20/ERC20Mintable.sol";
import "../token/ERC20/IERC20.sol";
import "../crowdsale/distribution/FinalizableCrowdsale.sol";
@ -11,7 +11,7 @@ contract FinalizableCrowdsaleImpl is FinalizableCrowdsale {
uint256 _closingTime,
uint256 _rate,
address _wallet,
ERC20Mintable _token
IERC20 _token
)
public
Crowdsale(_rate, _wallet, _token)

View File

@ -2,11 +2,13 @@ pragma solidity ^0.4.24;
import "../token/ERC20/IERC20.sol";
import "../crowdsale/validation/IndividuallyCappedCrowdsale.sol";
import "./CapperRoleMock.sol";
contract IndividuallyCappedCrowdsaleImpl is IndividuallyCappedCrowdsale {
contract IndividuallyCappedCrowdsaleImpl
is IndividuallyCappedCrowdsale, CapperRoleMock {
constructor (
constructor(
uint256 _rate,
address _wallet,
IERC20 _token
@ -15,5 +17,4 @@ contract IndividuallyCappedCrowdsaleImpl is IndividuallyCappedCrowdsale {
Crowdsale(_rate, _wallet, _token)
{
}
}

View File

@ -0,0 +1,18 @@
pragma solidity ^0.4.24;
import "../access/roles/MinterRole.sol";
contract MinterRoleMock is MinterRole {
function removeMinter(address _account) public {
_removeMinter(_account);
}
function onlyMinterMock() public view onlyMinter {
}
// Causes a compilation error if super._removeMinter is not internal
function _removeMinter(address _account) internal {
super._removeMinter(_account);
}
}

View File

@ -2,10 +2,11 @@ pragma solidity ^0.4.24;
import "../lifecycle/Pausable.sol";
import "./PauserRoleMock.sol";
// mock class using Pausable
contract PausableMock is Pausable {
contract PausableMock is Pausable, PauserRoleMock {
bool public drasticMeasureTaken;
uint256 public count;

View File

@ -0,0 +1,18 @@
pragma solidity ^0.4.24;
import "../access/roles/PauserRole.sol";
contract PauserRoleMock is PauserRole {
function removePauser(address _account) public {
_removePauser(_account);
}
function onlyPauserMock() public view onlyPauser {
}
// Causes a compilation error if super._removePauser is not internal
function _removePauser(address _account) internal {
super._removePauser(_account);
}
}

View File

@ -1,12 +0,0 @@
pragma solidity ^0.4.24;
import "../token/ERC20/RBACMintableToken.sol";
import "../token/ERC20/ERC20Capped.sol";
contract RBACCappedTokenMock is ERC20Capped, RBACMintableToken {
constructor(uint256 _cap)
ERC20Capped(_cap)
public
{}
}

View File

@ -1,69 +0,0 @@
pragma solidity ^0.4.24;
import "../examples/RBACWithAdmin.sol";
contract RBACMock is RBACWithAdmin {
string internal constant ROLE_ADVISOR = "advisor";
modifier onlyAdminOrAdvisor()
{
require(
isAdmin(msg.sender) ||
hasRole(msg.sender, ROLE_ADVISOR)
);
_;
}
constructor(address[] _advisors)
public
{
_addRole(msg.sender, ROLE_ADVISOR);
for (uint256 i = 0; i < _advisors.length; i++) {
_addRole(_advisors[i], ROLE_ADVISOR);
}
}
function onlyAdminsCanDoThis()
external
onlyAdmin
view
{
}
function onlyAdvisorsCanDoThis()
external
onlyRole(ROLE_ADVISOR)
view
{
}
function eitherAdminOrAdvisorCanDoThis()
external
onlyAdminOrAdvisor
view
{
}
function nobodyCanDoThis()
external
onlyRole("unknown")
view
{
}
// admins can remove advisor's role
function removeAdvisor(address _account)
public
onlyAdmin
{
// revert if the user isn't an advisor
// (perhaps you want to soft-fail here instead?)
checkRole(_account, ROLE_ADVISOR);
// remove the advisor's role
_removeRole(_account, ROLE_ADVISOR);
}
}

View File

@ -0,0 +1,22 @@
pragma solidity ^0.4.24;
import "../access/Roles.sol";
contract RolesMock {
using Roles for Roles.Role;
Roles.Role private dummyRole;
function add(address _account) public {
dummyRole.add(_account);
}
function remove(address _account) public {
dummyRole.remove(_account);
}
function has(address _account) public view returns (bool) {
return dummyRole.has(_account);
}
}

View File

@ -0,0 +1,9 @@
pragma solidity ^0.4.24;
import "../ownership/Secondary.sol";
contract SecondaryMock is Secondary {
function onlyPrimaryMock() public view onlyPrimary {
}
}

View File

@ -1,9 +1,10 @@
pragma solidity ^0.4.24;
import "../drafts/SignatureBouncer.sol";
import "./SignerRoleMock.sol";
contract SignatureBouncerMock is SignatureBouncer {
contract SignatureBouncerMock is SignatureBouncer, SignerRoleMock {
function checkValidSignature(address _address, bytes _signature)
public
view

View File

@ -0,0 +1,18 @@
pragma solidity ^0.4.24;
import "../access/roles/SignerRole.sol";
contract SignerRoleMock is SignerRole {
function removeSigner(address _account) public {
_removeSigner(_account);
}
function onlySignerMock() public view onlySigner {
}
// Causes a compilation error if super._removeSigner is not internal
function _removeSigner(address _account) internal {
super._removeSigner(_account);
}
}

View File

@ -1,14 +0,0 @@
pragma solidity ^0.4.24;
import "../access/Whitelist.sol";
contract WhitelistMock is Whitelist {
function onlyWhitelistedCanDoThis()
external
onlyIfWhitelisted(msg.sender)
view
{
}
}

View File

@ -1,19 +0,0 @@
pragma solidity ^0.4.24;
import "../token/ERC20/IERC20.sol";
import "../crowdsale/validation/WhitelistedCrowdsale.sol";
import "../crowdsale/Crowdsale.sol";
contract WhitelistedCrowdsaleImpl is Crowdsale, WhitelistedCrowdsale {
constructor (
uint256 _rate,
address _wallet,
IERC20 _token
)
Crowdsale(_rate, _wallet, _token)
public
{
}
}