Update Truffle and Solium (#1105)

* fixed visibility warnings

* solved visibility and line length warning

* change a test assertion that fails due to chai dependence update

* linter, constructor style and solved visibility warnings

* Changed Windows line endings to Unix.
pull/1138/head
Vittorio Minacori 7 years ago committed by Nicolás Venturo
parent 9638ecd87a
commit ca9e317259
  1. 4
      contracts/access/SignatureBouncer.sol
  2. 8
      contracts/access/Whitelist.sol
  3. 4
      contracts/access/rbac/RBAC.sol
  4. 4
      contracts/access/rbac/Roles.sol
  5. 2
      contracts/crowdsale/distribution/FinalizableCrowdsale.sol
  6. 2
      contracts/crowdsale/validation/WhitelistedCrowdsale.sol
  7. 4
      contracts/examples/RBACWithAdmin.sol
  8. 4
      contracts/lifecycle/Destructible.sol
  9. 4
      contracts/lifecycle/Pausable.sol
  10. 2
      contracts/lifecycle/TokenDestructible.sol
  11. 6
      contracts/mocks/BouncerMock.sol
  12. 2
      contracts/mocks/DestructibleMock.sol
  13. 3
      contracts/mocks/ERC20WithMetadataMock.sol
  14. 24
      contracts/mocks/RBACCappedTokenMock.sol
  15. 10
      contracts/mocks/RBACMock.sol
  16. 2
      contracts/mocks/WhitelistMock.sol
  17. 4
      contracts/ownership/Claimable.sol
  18. 2
      contracts/ownership/Contactable.sol
  19. 4
      contracts/ownership/DelayedClaimable.sol
  20. 9
      contracts/ownership/HasNoTokens.sol
  21. 2
      contracts/proposals/ERC1046/TokenMetadata.sol
  22. 4
      contracts/token/ERC20/MintableToken.sol
  23. 4
      contracts/token/ERC20/RBACMintableToken.sol
  24. 16
      contracts/token/ERC20/SafeERC20.sol
  25. 2
      contracts/token/ERC721/ERC721Token.sol
  26. 4352
      package-lock.json
  27. 4
      package.json
  28. 2
      test/ownership/HasNoEther.test.js

@ -68,8 +68,8 @@ contract SignatureBouncer is Ownable, RBAC {
* @dev allows the owner to add additional bouncer addresses * @dev allows the owner to add additional bouncer addresses
*/ */
function addBouncer(address _bouncer) function addBouncer(address _bouncer)
onlyOwner
public public
onlyOwner
{ {
require(_bouncer != address(0)); require(_bouncer != address(0));
addRole(_bouncer, ROLE_BOUNCER); addRole(_bouncer, ROLE_BOUNCER);
@ -79,8 +79,8 @@ contract SignatureBouncer is Ownable, RBAC {
* @dev allows the owner to remove bouncer addresses * @dev allows the owner to remove bouncer addresses
*/ */
function removeBouncer(address _bouncer) function removeBouncer(address _bouncer)
onlyOwner
public public
onlyOwner
{ {
require(_bouncer != address(0)); require(_bouncer != address(0));
removeRole(_bouncer, ROLE_BOUNCER); removeRole(_bouncer, ROLE_BOUNCER);

@ -28,8 +28,8 @@ contract Whitelist is Ownable, RBAC {
* @return true if the address was added to the whitelist, false if the address was already in the whitelist * @return true if the address was added to the whitelist, false if the address was already in the whitelist
*/ */
function addAddressToWhitelist(address _operator) function addAddressToWhitelist(address _operator)
onlyOwner
public public
onlyOwner
{ {
addRole(_operator, ROLE_WHITELISTED); addRole(_operator, ROLE_WHITELISTED);
} }
@ -52,8 +52,8 @@ contract Whitelist is Ownable, RBAC {
* false if all addresses were already in the whitelist * false if all addresses were already in the whitelist
*/ */
function addAddressesToWhitelist(address[] _operators) function addAddressesToWhitelist(address[] _operators)
onlyOwner
public public
onlyOwner
{ {
for (uint256 i = 0; i < _operators.length; i++) { for (uint256 i = 0; i < _operators.length; i++) {
addAddressToWhitelist(_operators[i]); addAddressToWhitelist(_operators[i]);
@ -67,8 +67,8 @@ contract Whitelist is Ownable, RBAC {
* false if the address wasn't in the whitelist in the first place * false if the address wasn't in the whitelist in the first place
*/ */
function removeAddressFromWhitelist(address _operator) function removeAddressFromWhitelist(address _operator)
onlyOwner
public public
onlyOwner
{ {
removeRole(_operator, ROLE_WHITELISTED); removeRole(_operator, ROLE_WHITELISTED);
} }
@ -80,8 +80,8 @@ contract Whitelist is Ownable, RBAC {
* false if all addresses weren't in the whitelist in the first place * false if all addresses weren't in the whitelist in the first place
*/ */
function removeAddressesFromWhitelist(address[] _operators) function removeAddressesFromWhitelist(address[] _operators)
onlyOwner
public public
onlyOwner
{ {
for (uint256 i = 0; i < _operators.length; i++) { for (uint256 i = 0; i < _operators.length; i++) {
removeAddressFromWhitelist(_operators[i]); removeAddressFromWhitelist(_operators[i]);

@ -27,8 +27,8 @@ contract RBAC {
* // reverts * // reverts
*/ */
function checkRole(address _operator, string _role) function checkRole(address _operator, string _role)
view
public public
view
{ {
roles[_role].check(_operator); roles[_role].check(_operator);
} }
@ -40,8 +40,8 @@ contract RBAC {
* @return bool * @return bool
*/ */
function hasRole(address _operator, string _role) function hasRole(address _operator, string _role)
view
public public
view
returns (bool) returns (bool)
{ {
return roles[_role].has(_operator); return roles[_role].has(_operator);

@ -35,8 +35,8 @@ library Roles {
* // reverts * // reverts
*/ */
function check(Role storage _role, address _addr) function check(Role storage _role, address _addr)
view
internal internal
view
{ {
require(has(_role, _addr)); require(has(_role, _addr));
} }
@ -46,8 +46,8 @@ library Roles {
* @return bool * @return bool
*/ */
function has(Role storage _role, address _addr) function has(Role storage _role, address _addr)
view
internal internal
view
returns (bool) returns (bool)
{ {
return _role.bearer[_addr]; return _role.bearer[_addr];

@ -21,7 +21,7 @@ contract FinalizableCrowdsale is TimedCrowdsale, Ownable {
* @dev Must be called after crowdsale ends, to do some extra finalization * @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function. * work. Calls the contract's finalization function.
*/ */
function finalize() onlyOwner public { function finalize() public onlyOwner {
require(!isFinalized); require(!isFinalized);
require(hasClosed()); require(hasClosed());

@ -18,8 +18,8 @@ contract WhitelistedCrowdsale is Whitelist, Crowdsale {
address _beneficiary, address _beneficiary,
uint256 _weiAmount uint256 _weiAmount
) )
onlyIfWhitelisted(_beneficiary)
internal internal
onlyIfWhitelisted(_beneficiary)
{ {
super._preValidatePurchase(_beneficiary, _weiAmount); super._preValidatePurchase(_beneficiary, _weiAmount);
} }

@ -46,8 +46,8 @@ contract RBACWithAdmin is RBAC {
* @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
public public
onlyAdmin
{ {
addRole(_addr, _roleName); addRole(_addr, _roleName);
} }
@ -58,8 +58,8 @@ contract RBACWithAdmin is RBAC {
* @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
public public
onlyAdmin
{ {
removeRole(_addr, _roleName); removeRole(_addr, _roleName);
} }

@ -12,11 +12,11 @@ contract Destructible is Ownable {
/** /**
* @dev Transfers the current balance to the owner and terminates the contract. * @dev Transfers the current balance to the owner and terminates the contract.
*/ */
function destroy() onlyOwner public { function destroy() public onlyOwner {
selfdestruct(owner); selfdestruct(owner);
} }
function destroyAndSend(address _recipient) onlyOwner public { function destroyAndSend(address _recipient) public onlyOwner {
selfdestruct(_recipient); selfdestruct(_recipient);
} }
} }

@ -34,7 +34,7 @@ contract Pausable is Ownable {
/** /**
* @dev called by the owner to pause, triggers stopped state * @dev called by the owner to pause, triggers stopped state
*/ */
function pause() onlyOwner whenNotPaused public { function pause() public onlyOwner whenNotPaused {
paused = true; paused = true;
emit Pause(); emit Pause();
} }
@ -42,7 +42,7 @@ contract Pausable is Ownable {
/** /**
* @dev called by the owner to unpause, returns to normal state * @dev called by the owner to unpause, returns to normal state
*/ */
function unpause() onlyOwner whenPaused public { function unpause() public onlyOwner whenPaused {
paused = false; paused = false;
emit Unpause(); emit Unpause();
} }

@ -21,7 +21,7 @@ contract TokenDestructible is Ownable {
* @notice The called token contracts could try to re-enter this contract. Only * @notice The called token contracts could try to re-enter this contract. Only
supply token contracts you trust. supply token contracts you trust.
*/ */
function destroy(address[] _tokens) onlyOwner public { function destroy(address[] _tokens) public onlyOwner {
// Transfer tokens to owner // Transfer tokens to owner
for (uint256 i = 0; i < _tokens.length; i++) { for (uint256 i = 0; i < _tokens.length; i++) {

@ -13,8 +13,8 @@ contract SignatureBouncerMock is SignatureBouncer {
} }
function onlyWithValidSignature(bytes _sig) function onlyWithValidSignature(bytes _sig)
onlyValidSignature(_sig)
public public
onlyValidSignature(_sig)
view view
{ {
@ -29,8 +29,8 @@ contract SignatureBouncerMock is SignatureBouncer {
} }
function onlyWithValidSignatureAndMethod(bytes _sig) function onlyWithValidSignatureAndMethod(bytes _sig)
onlyValidSignatureAndMethod(_sig)
public public
onlyValidSignatureAndMethod(_sig)
view view
{ {
@ -50,8 +50,8 @@ contract SignatureBouncerMock is SignatureBouncer {
} }
function onlyWithValidSignatureAndData(uint, bytes _sig) function onlyWithValidSignatureAndData(uint, bytes _sig)
onlyValidSignatureAndData(_sig)
public public
onlyValidSignatureAndData(_sig)
view view
{ {

@ -4,5 +4,5 @@ import "../lifecycle/Destructible.sol";
contract DestructibleMock is Destructible { contract DestructibleMock is Destructible {
function() payable public {} function() public payable {}
} }

@ -5,9 +5,8 @@ import "../proposals/ERC1046/TokenMetadata.sol";
contract ERC20WithMetadataMock is StandardToken, ERC20WithMetadata { contract ERC20WithMetadataMock is StandardToken, ERC20WithMetadata {
function ERC20WithMetadataMock(string _tokenURI) constructor(string _tokenURI) public
ERC20WithMetadata(_tokenURI) ERC20WithMetadata(_tokenURI)
public
{ {
} }
} }

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

@ -27,37 +27,37 @@ contract RBACMock is RBACWithAdmin {
} }
function onlyAdminsCanDoThis() function onlyAdminsCanDoThis()
external
onlyAdmin onlyAdmin
view view
external
{ {
} }
function onlyAdvisorsCanDoThis() function onlyAdvisorsCanDoThis()
external
onlyRole(ROLE_ADVISOR) onlyRole(ROLE_ADVISOR)
view view
external
{ {
} }
function eitherAdminOrAdvisorCanDoThis() function eitherAdminOrAdvisorCanDoThis()
external
onlyAdminOrAdvisor onlyAdminOrAdvisor
view view
external
{ {
} }
function nobodyCanDoThis() function nobodyCanDoThis()
external
onlyRole("unknown") onlyRole("unknown")
view view
external
{ {
} }
// admins can remove advisor's role // admins can remove advisor's role
function removeAdvisor(address _addr) function removeAdvisor(address _addr)
onlyAdmin
public public
onlyAdmin
{ {
// 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?)

@ -6,9 +6,9 @@ import "../access/Whitelist.sol";
contract WhitelistMock is Whitelist { contract WhitelistMock is Whitelist {
function onlyWhitelistedCanDoThis() function onlyWhitelistedCanDoThis()
external
onlyIfWhitelisted(msg.sender) onlyIfWhitelisted(msg.sender)
view view
external
{ {
} }
} }

@ -24,14 +24,14 @@ contract Claimable is Ownable {
* @dev Allows the current owner to set the pendingOwner address. * @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to. * @param newOwner The address to transfer ownership to.
*/ */
function transferOwnership(address newOwner) onlyOwner public { function transferOwnership(address newOwner) public onlyOwner {
pendingOwner = newOwner; pendingOwner = newOwner;
} }
/** /**
* @dev Allows the pendingOwner address to finalize the transfer. * @dev Allows the pendingOwner address to finalize the transfer.
*/ */
function claimOwnership() onlyPendingOwner public { function claimOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner, pendingOwner); emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner; owner = pendingOwner;
pendingOwner = address(0); pendingOwner = address(0);

@ -16,7 +16,7 @@ contract Contactable is Ownable {
* @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) public onlyOwner {
contactInformation = _info; contactInformation = _info;
} }
} }

@ -19,7 +19,7 @@ contract DelayedClaimable is Claimable {
* @param _start The earliest time ownership can be claimed. * @param _start The earliest time ownership can be claimed.
* @param _end The latest time ownership can be claimed. * @param _end The latest time ownership can be claimed.
*/ */
function setLimits(uint256 _start, uint256 _end) onlyOwner public { function setLimits(uint256 _start, uint256 _end) public onlyOwner {
require(_start <= _end); require(_start <= _end);
end = _end; end = _end;
start = _start; start = _start;
@ -29,7 +29,7 @@ contract DelayedClaimable is Claimable {
* @dev Allows the pendingOwner address to finalize the transfer, as long as it is called within * @dev Allows the pendingOwner address to finalize the transfer, as long as it is called within
* the specified start and end time. * the specified start and end time.
*/ */
function claimOwnership() onlyPendingOwner public { function claimOwnership() public onlyPendingOwner {
require((block.number <= end) && (block.number >= start)); require((block.number <= end) && (block.number >= start));
emit OwnershipTransferred(owner, pendingOwner); emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner; owner = pendingOwner;

@ -18,7 +18,14 @@ contract HasNoTokens is CanReclaimToken {
* @param _value uint256 the amount of the specified token * @param _value uint256 the amount of the specified token
* @param _data Bytes The data passed from the caller. * @param _data Bytes The data passed from the caller.
*/ */
function tokenFallback(address _from, uint256 _value, bytes _data) external pure { function tokenFallback(
address _from,
uint256 _value,
bytes _data
)
external
pure
{
_from; _from;
_value; _value;
_data; _data;

@ -17,7 +17,7 @@ contract ERC20TokenMetadata is ERC20 {
contract ERC20WithMetadata is ERC20TokenMetadata { contract ERC20WithMetadata is ERC20TokenMetadata {
string private tokenURI_ = ""; string private tokenURI_ = "";
function ERC20WithMetadata(string _tokenURI) constructor(string _tokenURI)
public public
{ {
tokenURI_ = _tokenURI; tokenURI_ = _tokenURI;

@ -36,9 +36,9 @@ contract MintableToken is StandardToken, Ownable {
address _to, address _to,
uint256 _amount uint256 _amount
) )
public
hasMintPermission hasMintPermission
canMint canMint
public
returns (bool) returns (bool)
{ {
totalSupply_ = totalSupply_.add(_amount); totalSupply_ = totalSupply_.add(_amount);
@ -52,7 +52,7 @@ contract MintableToken is StandardToken, Ownable {
* @dev Function to stop minting new tokens. * @dev Function to stop minting new tokens.
* @return True if the operation was successful. * @return True if the operation was successful.
*/ */
function finishMinting() onlyOwner canMint public returns (bool) { function finishMinting() public onlyOwner canMint returns (bool) {
mintingFinished = true; mintingFinished = true;
emit MintFinished(); emit MintFinished();
return true; return true;

@ -27,7 +27,7 @@ contract RBACMintableToken is MintableToken, RBAC {
* @dev add a minter role to an address * @dev add a minter role to an address
* @param _minter address * @param _minter address
*/ */
function addMinter(address _minter) onlyOwner public { function addMinter(address _minter) public onlyOwner {
addRole(_minter, ROLE_MINTER); addRole(_minter, ROLE_MINTER);
} }
@ -35,7 +35,7 @@ contract RBACMintableToken is MintableToken, RBAC {
* @dev remove a minter role from an address * @dev remove a minter role from an address
* @param _minter address * @param _minter address
*/ */
function removeMinter(address _minter) onlyOwner public { function removeMinter(address _minter) public onlyOwner {
removeRole(_minter, ROLE_MINTER); removeRole(_minter, ROLE_MINTER);
} }
} }

@ -11,7 +11,13 @@ import "./ERC20.sol";
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc. * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/ */
library SafeERC20 { library SafeERC20 {
function safeTransfer(ERC20Basic _token, address _to, uint256 _value) internal { function safeTransfer(
ERC20Basic _token,
address _to,
uint256 _value
)
internal
{
require(_token.transfer(_to, _value)); require(_token.transfer(_to, _value));
} }
@ -26,7 +32,13 @@ library SafeERC20 {
require(_token.transferFrom(_from, _to, _value)); require(_token.transferFrom(_from, _to, _value));
} }
function safeApprove(ERC20 _token, address _spender, uint256 _value) internal { function safeApprove(
ERC20 _token,
address _spender,
uint256 _value
)
internal
{
require(_token.approve(_spender, _value)); require(_token.approve(_spender, _value));
} }
} }

@ -147,8 +147,8 @@ contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 {
uint256 lastToken = ownedTokens[_from][lastTokenIndex]; uint256 lastToken = ownedTokens[_from][lastTokenIndex];
ownedTokens[_from][tokenIndex] = lastToken; ownedTokens[_from][tokenIndex] = lastToken;
// This also deletes the contents at the last position of the array
ownedTokens[_from].length--; ownedTokens[_from].length--;
// ^ This also deletes the contents at the last position of the array
// Note that this will handle single-element arrays. In that case, both tokenIndex and lastTokenIndex are going to // Note that this will handle single-element arrays. In that case, both tokenIndex and lastTokenIndex are going to
// be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping // be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping

4352
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -51,8 +51,8 @@
"ethjs-abi": "^0.2.1", "ethjs-abi": "^0.2.1",
"ganache-cli": "6.1.0", "ganache-cli": "6.1.0",
"solidity-coverage": "^0.5.4", "solidity-coverage": "^0.5.4",
"solium": "^1.1.7", "solium": "^1.1.8",
"truffle": "^4.1.11", "truffle": "^4.1.13",
"truffle-hdwallet-provider": "0.0.5", "truffle-hdwallet-provider": "0.0.5",
"web3-utils": "^1.0.0-beta.34" "web3-utils": "^1.0.0-beta.34"
} }

@ -45,7 +45,7 @@ contract('HasNoEther', function (accounts) {
const ownerFinalBalance = await ethGetBalance(accounts[0]); const ownerFinalBalance = await ethGetBalance(accounts[0]);
const finalBalance = await ethGetBalance(hasNoEther.address); const finalBalance = await ethGetBalance(hasNoEther.address);
assert.equal(finalBalance, 0); assert.equal(finalBalance, 0);
assert.isAbove(ownerFinalBalance, ownerStartBalance); assert.isTrue(ownerFinalBalance.greaterThan(ownerStartBalance));
}); });
it('should allow only owner to reclaim ether', async function () { it('should allow only owner to reclaim ether', async function () {

Loading…
Cancel
Save