Bladeren bron

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.
Vittorio Minacori 7 jaren geleden
bovenliggende
commit
ca9e317259

+ 2 - 2
contracts/access/SignatureBouncer.sol

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

+ 4 - 4
contracts/access/Whitelist.sol

@@ -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
    */
   function addAddressToWhitelist(address _operator)
-    onlyOwner
     public
+    onlyOwner
   {
     addRole(_operator, ROLE_WHITELISTED);
   }
@@ -52,8 +52,8 @@ contract Whitelist is Ownable, RBAC {
    * false if all addresses were already in the whitelist
    */
   function addAddressesToWhitelist(address[] _operators)
-    onlyOwner
     public
+    onlyOwner
   {
     for (uint256 i = 0; i < _operators.length; 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
    */
   function removeAddressFromWhitelist(address _operator)
-    onlyOwner
     public
+    onlyOwner
   {
     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
    */
   function removeAddressesFromWhitelist(address[] _operators)
-    onlyOwner
     public
+    onlyOwner
   {
     for (uint256 i = 0; i < _operators.length; i++) {
       removeAddressFromWhitelist(_operators[i]);

+ 2 - 2
contracts/access/rbac/RBAC.sol

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

+ 2 - 2
contracts/access/rbac/Roles.sol

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

+ 1 - 1
contracts/crowdsale/distribution/FinalizableCrowdsale.sol

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

+ 1 - 1
contracts/crowdsale/validation/WhitelistedCrowdsale.sol

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

+ 2 - 2
contracts/examples/RBACWithAdmin.sol

@@ -46,8 +46,8 @@ contract RBACWithAdmin is RBAC {
    * @param _roleName the name of the role
    */
   function adminAddRole(address _addr, string _roleName)
-    onlyAdmin
     public
+    onlyAdmin
   {
     addRole(_addr, _roleName);
   }
@@ -58,8 +58,8 @@ contract RBACWithAdmin is RBAC {
    * @param _roleName the name of the role
    */
   function adminRemoveRole(address _addr, string _roleName)
-    onlyAdmin
     public
+    onlyAdmin
   {
     removeRole(_addr, _roleName);
   }

+ 2 - 2
contracts/lifecycle/Destructible.sol

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

+ 2 - 2
contracts/lifecycle/Pausable.sol

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

+ 1 - 1
contracts/lifecycle/TokenDestructible.sol

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

+ 3 - 3
contracts/mocks/BouncerMock.sol

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

+ 1 - 1
contracts/mocks/DestructibleMock.sol

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

+ 1 - 2
contracts/mocks/ERC20WithMetadataMock.sol

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

+ 11 - 13
contracts/mocks/RBACCappedTokenMock.sol

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

+ 5 - 5
contracts/mocks/RBACMock.sol

@@ -27,37 +27,37 @@ contract RBACMock is RBACWithAdmin {
   }
 
   function onlyAdminsCanDoThis()
+    external
     onlyAdmin
     view
-    external
   {
   }
 
   function onlyAdvisorsCanDoThis()
+    external
     onlyRole(ROLE_ADVISOR)
     view
-    external
   {
   }
 
   function eitherAdminOrAdvisorCanDoThis()
+    external
     onlyAdminOrAdvisor
     view
-    external
   {
   }
 
   function nobodyCanDoThis()
+    external
     onlyRole("unknown")
     view
-    external
   {
   }
 
   // admins can remove advisor's role
   function removeAdvisor(address _addr)
-    onlyAdmin
     public
+    onlyAdmin
   {
     // revert if the user isn't an advisor
     //  (perhaps you want to soft-fail here instead?)

+ 1 - 1
contracts/mocks/WhitelistMock.sol

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

+ 2 - 2
contracts/ownership/Claimable.sol

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

+ 1 - 1
contracts/ownership/Contactable.sol

@@ -16,7 +16,7 @@ contract Contactable is Ownable {
     * @dev Allows the owner to set a string with their contact information.
     * @param _info The contact information to attach to the contract.
     */
-  function setContactInformation(string _info) onlyOwner public {
+  function setContactInformation(string _info) public onlyOwner {
     contactInformation = _info;
   }
 }

+ 2 - 2
contracts/ownership/DelayedClaimable.sol

@@ -19,7 +19,7 @@ contract DelayedClaimable is Claimable {
    * @param _start The earliest 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);
     end = _end;
     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
    * the specified start and end time.
    */
-  function claimOwnership() onlyPendingOwner public {
+  function claimOwnership() public onlyPendingOwner {
     require((block.number <= end) && (block.number >= start));
     emit OwnershipTransferred(owner, pendingOwner);
     owner = pendingOwner;

+ 8 - 1
contracts/ownership/HasNoTokens.sol

@@ -18,7 +18,14 @@ contract HasNoTokens is CanReclaimToken {
   * @param _value uint256 the amount of the specified token
   * @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;
     _value;
     _data;

+ 1 - 1
contracts/proposals/ERC1046/TokenMetadata.sol

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

+ 2 - 2
contracts/token/ERC20/MintableToken.sol

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

+ 2 - 2
contracts/token/ERC20/RBACMintableToken.sol

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

+ 14 - 2
contracts/token/ERC20/SafeERC20.sol

@@ -11,7 +11,13 @@ import "./ERC20.sol";
  * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
  */
 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));
   }
 
@@ -26,7 +32,13 @@ library SafeERC20 {
     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));
   }
 }

+ 1 - 1
contracts/token/ERC721/ERC721Token.sol

@@ -147,8 +147,8 @@ contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 {
     uint256 lastToken = ownedTokens[_from][lastTokenIndex];
 
     ownedTokens[_from][tokenIndex] = lastToken;
+    // This also deletes the contents at the last position of the array
     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
     // be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping

File diff suppressed because it is too large
+ 234 - 231
package-lock.json


+ 2 - 2
package.json

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

+ 1 - 1
test/ownership/HasNoEther.test.js

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

Some files were not shown because too many files changed in this diff