From 746673a94f7e43835fcb5cb7b1af8ff1eea4e276 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Mon, 14 May 2018 11:42:32 -0600 Subject: [PATCH] style: use the max-len solidity rule (#944) --- .soliumrc.json | 2 +- contracts/AddressUtils.sol | 3 +- contracts/DayLimit.sol | 5 +- contracts/MerkleProof.sol | 10 +++- contracts/access/SignatureBouncer.sol | 1 + contracts/crowdsale/Crowdsale.sol | 46 ++++++++++++++++--- .../distribution/PostDeliveryCrowdsale.sol | 7 ++- .../crowdsale/emission/AllowanceCrowdsale.sol | 7 ++- .../crowdsale/emission/MintedCrowdsale.sol | 7 ++- .../price/IncreasingPriceCrowdsale.sol | 4 +- .../crowdsale/validation/CappedCrowdsale.sol | 7 ++- .../IndividuallyCappedCrowdsale.sol | 26 +++++++++-- .../crowdsale/validation/TimedCrowdsale.sol | 8 +++- .../validation/WhitelistedCrowdsale.sol | 8 +++- contracts/examples/SampleCrowdsale.sol | 8 +++- contracts/mocks/DetailedERC20Mock.sol | 9 +++- contracts/mocks/ERC721ReceiverMock.sol | 7 ++- contracts/mocks/MerkleProofWrapper.sol | 10 +++- contracts/mocks/MessageHelper.sol | 19 +++++++- contracts/ownership/Heritable.sol | 15 ++++-- contracts/ownership/Ownable.sol | 5 +- contracts/payment/SplitPayment.sol | 6 ++- contracts/token/ERC20/CappedToken.sol | 10 +++- contracts/token/ERC20/ERC20.sol | 14 ++++-- contracts/token/ERC20/MintableToken.sol | 10 +++- contracts/token/ERC20/PausableToken.sol | 46 +++++++++++++++++-- .../token/ERC20/StandardBurnableToken.sol | 1 + contracts/token/ERC20/StandardToken.sol | 37 +++++++++++++-- contracts/token/ERC20/TokenTimelock.sol | 8 +++- contracts/token/ERC721/ERC721.sol | 9 +++- contracts/token/ERC721/ERC721Basic.sol | 28 ++++++++--- contracts/token/ERC721/ERC721BasicToken.sol | 39 ++++++++++++++-- contracts/token/ERC721/ERC721Receiver.sol | 8 +++- contracts/token/ERC721/ERC721Token.sol | 9 +++- contracts/token/ERC827/ERC827.sol | 20 +++++++- contracts/token/ERC827/ERC827Token.sol | 40 ++++++++++++++-- 36 files changed, 430 insertions(+), 69 deletions(-) diff --git a/.soliumrc.json b/.soliumrc.json index b295c68ce..ea6b7968f 100644 --- a/.soliumrc.json +++ b/.soliumrc.json @@ -5,7 +5,7 @@ "quotes": ["error", "double"], "no-empty-blocks": "off", "indentation": ["error", 2], - "arg-overflow": ["warning", 3], + "max-len": ["warning", 79], "no-constant": ["error"], "security/enforce-explicit-visibility": ["error"], "security/no-block-members": ["warning"], diff --git a/contracts/AddressUtils.sol b/contracts/AddressUtils.sol index 57e9e9f53..97ee3ac0b 100644 --- a/contracts/AddressUtils.sol +++ b/contracts/AddressUtils.sol @@ -21,7 +21,8 @@ library AddressUtils { // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. - assembly { size := extcodesize(addr) } // solium-disable-line security/no-inline-assembly + // solium-disable-next-line security/no-inline-assembly + assembly { size := extcodesize(addr) } return size > 0; } diff --git a/contracts/DayLimit.sol b/contracts/DayLimit.sol index a73e7ece7..1aa4082ef 100644 --- a/contracts/DayLimit.sol +++ b/contracts/DayLimit.sol @@ -49,7 +49,10 @@ contract DayLimit { } // check to see if there's enough left - if so, subtract and return true. // overflow protection // dailyLimit check - if (spentToday + _value >= spentToday && spentToday + _value <= dailyLimit) { + if ( + spentToday + _value >= spentToday && + spentToday + _value <= dailyLimit + ) { spentToday += _value; return true; } diff --git a/contracts/MerkleProof.sol b/contracts/MerkleProof.sol index 1ea6ceef1..1aaba5cb3 100644 --- a/contracts/MerkleProof.sol +++ b/contracts/MerkleProof.sol @@ -14,7 +14,15 @@ library MerkleProof { * @param _root Merkle root * @param _leaf Leaf of Merkle tree */ - function verifyProof(bytes32[] _proof, bytes32 _root, bytes32 _leaf) internal pure returns (bool) { + function verifyProof( + bytes32[] _proof, + bytes32 _root, + bytes32 _leaf + ) + internal + pure + returns (bool) + { bytes32 computedHash = _leaf; for (uint256 i = 0; i < _proof.length; i++) { diff --git a/contracts/access/SignatureBouncer.sol b/contracts/access/SignatureBouncer.sol index ae0cc032e..b037b1ded 100644 --- a/contracts/access/SignatureBouncer.sol +++ b/contracts/access/SignatureBouncer.sol @@ -4,6 +4,7 @@ import "../ownership/Ownable.sol"; import "../ownership/rbac/RBAC.sol"; import "../ECRecovery.sol"; + /** * @title SignatureBouncer * @author PhABC and Shrugs diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index b3ab7a2d6..d4578ec4e 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -38,7 +38,12 @@ contract Crowdsale { * @param value weis paid for purchase * @param amount amount of tokens purchased */ - event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); + event TokenPurchase( + address indexed purchaser, + address indexed beneficiary, + uint256 value, + uint256 amount + ); /** * @param _rate Number of token units a buyer gets per wei @@ -104,7 +109,12 @@ contract Crowdsale { * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase */ - function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { + function _preValidatePurchase( + address _beneficiary, + uint256 _weiAmount + ) + internal + { require(_beneficiary != address(0)); require(_weiAmount != 0); } @@ -114,7 +124,12 @@ contract Crowdsale { * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase */ - function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { + function _postValidatePurchase( + address _beneficiary, + uint256 _weiAmount + ) + internal + { // optional override } @@ -123,7 +138,12 @@ contract Crowdsale { * @param _beneficiary Address performing the token purchase * @param _tokenAmount Number of tokens to be emitted */ - function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { + function _deliverTokens( + address _beneficiary, + uint256 _tokenAmount + ) + internal + { token.transfer(_beneficiary, _tokenAmount); } @@ -132,7 +152,12 @@ contract Crowdsale { * @param _beneficiary Address receiving the tokens * @param _tokenAmount Number of tokens to be purchased */ - function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal { + function _processPurchase( + address _beneficiary, + uint256 _tokenAmount + ) + internal + { _deliverTokens(_beneficiary, _tokenAmount); } @@ -141,7 +166,12 @@ contract Crowdsale { * @param _beneficiary Address receiving the tokens * @param _weiAmount Value in wei involved in the purchase */ - function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal { + function _updatePurchasingState( + address _beneficiary, + uint256 _weiAmount + ) + internal + { // optional override } @@ -150,7 +180,9 @@ contract Crowdsale { * @param _weiAmount Value in wei to be converted into tokens * @return Number of tokens that can be purchased with the specified _weiAmount */ - function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { + function _getTokenAmount(uint256 _weiAmount) + internal view returns (uint256) + { return _weiAmount.mul(rate); } diff --git a/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol b/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol index 4f3c92d67..6acb4f4f1 100644 --- a/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol +++ b/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol @@ -30,7 +30,12 @@ contract PostDeliveryCrowdsale is TimedCrowdsale { * @param _beneficiary Token purchaser * @param _tokenAmount Amount of tokens purchased */ - function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal { + function _processPurchase( + address _beneficiary, + uint256 _tokenAmount + ) + internal + { balances[_beneficiary] = balances[_beneficiary].add(_tokenAmount); } diff --git a/contracts/crowdsale/emission/AllowanceCrowdsale.sol b/contracts/crowdsale/emission/AllowanceCrowdsale.sol index 8679a5a6d..a79716b32 100644 --- a/contracts/crowdsale/emission/AllowanceCrowdsale.sol +++ b/contracts/crowdsale/emission/AllowanceCrowdsale.sol @@ -36,7 +36,12 @@ contract AllowanceCrowdsale is Crowdsale { * @param _beneficiary Token purchaser * @param _tokenAmount Amount of tokens purchased */ - function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { + function _deliverTokens( + address _beneficiary, + uint256 _tokenAmount + ) + internal + { token.transferFrom(tokenWallet, _beneficiary, _tokenAmount); } } diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index 247fe9717..02ae3d16a 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -16,7 +16,12 @@ contract MintedCrowdsale is Crowdsale { * @param _beneficiary Token purchaser * @param _tokenAmount Number of tokens to be minted */ - function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { + function _deliverTokens( + address _beneficiary, + uint256 _tokenAmount + ) + internal + { require(MintableToken(token).mint(_beneficiary, _tokenAmount)); } } diff --git a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol index 4a09caf3e..592749a0a 100644 --- a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol +++ b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol @@ -46,7 +46,9 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale { * @param _weiAmount The value in wei to be converted into tokens * @return The number of tokens _weiAmount wei will buy at present time */ - function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { + function _getTokenAmount(uint256 _weiAmount) + internal view returns (uint256) + { uint256 currentRate = getCurrentRate(); return currentRate.mul(_weiAmount); } diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index d0d0e43ba..87c032825 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -35,7 +35,12 @@ contract CappedCrowdsale is Crowdsale { * @param _beneficiary Token purchaser * @param _weiAmount Amount of wei contributed */ - function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { + function _preValidatePurchase( + address _beneficiary, + uint256 _weiAmount + ) + internal + { super._preValidatePurchase(_beneficiary, _weiAmount); require(weiRaised.add(_weiAmount) <= cap); } diff --git a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol index 29d539ccd..b60466c16 100644 --- a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol +++ b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol @@ -29,7 +29,13 @@ contract IndividuallyCappedCrowdsale is Crowdsale, Ownable { * @param _beneficiaries List of addresses to be capped * @param _cap Wei limit for individual contribution */ - function setGroupCap(address[] _beneficiaries, uint256 _cap) external onlyOwner { + function setGroupCap( + address[] _beneficiaries, + uint256 _cap + ) + external + onlyOwner + { for (uint256 i = 0; i < _beneficiaries.length; i++) { caps[_beneficiaries[i]] = _cap; } @@ -49,7 +55,9 @@ contract IndividuallyCappedCrowdsale is Crowdsale, Ownable { * @param _beneficiary Address of contributor * @return User contribution so far */ - function getUserContribution(address _beneficiary) public view returns (uint256) { + function getUserContribution(address _beneficiary) + public view returns (uint256) + { return contributions[_beneficiary]; } @@ -58,7 +66,12 @@ contract IndividuallyCappedCrowdsale is Crowdsale, Ownable { * @param _beneficiary Token purchaser * @param _weiAmount Amount of wei contributed */ - function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { + function _preValidatePurchase( + address _beneficiary, + uint256 _weiAmount + ) + internal + { super._preValidatePurchase(_beneficiary, _weiAmount); require(contributions[_beneficiary].add(_weiAmount) <= caps[_beneficiary]); } @@ -68,7 +81,12 @@ contract IndividuallyCappedCrowdsale is Crowdsale, Ownable { * @param _beneficiary Token purchaser * @param _weiAmount Amount of wei contributed */ - function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal { + function _updatePurchasingState( + address _beneficiary, + uint256 _weiAmount + ) + internal + { super._updatePurchasingState(_beneficiary, _weiAmount); contributions[_beneficiary] = contributions[_beneficiary].add(_weiAmount); } diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol index 5cff816f6..28d6beeca 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -51,7 +51,13 @@ contract TimedCrowdsale is Crowdsale { * @param _beneficiary Token purchaser * @param _weiAmount Amount of wei contributed */ - function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal onlyWhileOpen { + function _preValidatePurchase( + address _beneficiary, + uint256 _weiAmount + ) + internal + onlyWhileOpen + { super._preValidatePurchase(_beneficiary, _weiAmount); } diff --git a/contracts/crowdsale/validation/WhitelistedCrowdsale.sol b/contracts/crowdsale/validation/WhitelistedCrowdsale.sol index 28586c650..ee4e16477 100644 --- a/contracts/crowdsale/validation/WhitelistedCrowdsale.sol +++ b/contracts/crowdsale/validation/WhitelistedCrowdsale.sol @@ -51,7 +51,13 @@ contract WhitelistedCrowdsale is Crowdsale, Ownable { * @param _beneficiary Token beneficiary * @param _weiAmount Amount of wei contributed */ - function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal isWhitelisted(_beneficiary) { + function _preValidatePurchase( + address _beneficiary, + uint256 _weiAmount + ) + internal + isWhitelisted(_beneficiary) + { super._preValidatePurchase(_beneficiary, _weiAmount); } diff --git a/contracts/examples/SampleCrowdsale.sol b/contracts/examples/SampleCrowdsale.sol index af11055e8..03eadaa58 100644 --- a/contracts/examples/SampleCrowdsale.sol +++ b/contracts/examples/SampleCrowdsale.sol @@ -13,7 +13,8 @@ import "../token/ERC20/MintableToken.sol"; */ contract SampleCrowdsaleToken is MintableToken { - string public constant name = "Sample Crowdsale Token"; // solium-disable-line uppercase + // solium-disable-next-line uppercase + string public constant name = "Sample Crowdsale Token"; string public constant symbol = "SCT"; // solium-disable-line uppercase uint8 public constant decimals = 18; // solium-disable-line uppercase @@ -31,6 +32,11 @@ contract SampleCrowdsaleToken is MintableToken { * After adding multiple features it's good practice to run integration tests * to ensure that subcontracts works together as intended. */ +// XXX There doesn't seem to be a way to split this line that keeps solium +// happy. See: +// https://github.com/duaraghav8/Solium/issues/205 +// --elopio - 2018-05-10 +// solium-disable-next-line max-len contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale { constructor( diff --git a/contracts/mocks/DetailedERC20Mock.sol b/contracts/mocks/DetailedERC20Mock.sol index 3bdf8de0f..3a257ba34 100644 --- a/contracts/mocks/DetailedERC20Mock.sol +++ b/contracts/mocks/DetailedERC20Mock.sol @@ -5,5 +5,12 @@ import "../token/ERC20/DetailedERC20.sol"; contract DetailedERC20Mock is StandardToken, DetailedERC20 { - constructor(string _name, string _symbol, uint8 _decimals) DetailedERC20(_name, _symbol, _decimals) public {} + constructor( + string _name, + string _symbol, + uint8 _decimals + ) + DetailedERC20(_name, _symbol, _decimals) + public + {} } diff --git a/contracts/mocks/ERC721ReceiverMock.sol b/contracts/mocks/ERC721ReceiverMock.sol index 79cfb3719..4ec0c7383 100644 --- a/contracts/mocks/ERC721ReceiverMock.sol +++ b/contracts/mocks/ERC721ReceiverMock.sol @@ -7,7 +7,12 @@ contract ERC721ReceiverMock is ERC721Receiver { bytes4 retval; bool reverts; - event Received(address _address, uint256 _tokenId, bytes _data, uint256 _gas); + event Received( + address _address, + uint256 _tokenId, + bytes _data, + uint256 _gas + ); constructor(bytes4 _retval, bool _reverts) public { retval = _retval; diff --git a/contracts/mocks/MerkleProofWrapper.sol b/contracts/mocks/MerkleProofWrapper.sol index 5985ec925..1d8823b29 100644 --- a/contracts/mocks/MerkleProofWrapper.sol +++ b/contracts/mocks/MerkleProofWrapper.sol @@ -5,7 +5,15 @@ import { MerkleProof } from "../MerkleProof.sol"; contract MerkleProofWrapper { - function verifyProof(bytes32[] _proof, bytes32 _root, bytes32 _leaf) public pure returns (bool) { + function verifyProof( + bytes32[] _proof, + bytes32 _root, + bytes32 _leaf + ) + public + pure + returns (bool) + { return MerkleProof.verifyProof(_proof, _root, _leaf); } } diff --git a/contracts/mocks/MessageHelper.sol b/contracts/mocks/MessageHelper.sol index dd80b34e4..414881414 100644 --- a/contracts/mocks/MessageHelper.sol +++ b/contracts/mocks/MessageHelper.sol @@ -6,12 +6,27 @@ contract MessageHelper { event Show(bytes32 b32, uint256 number, string text); event Buy(bytes32 b32, uint256 number, string text, uint256 value); - function showMessage( bytes32 message, uint256 number, string text ) public returns (bool) { + function showMessage( + bytes32 message, + uint256 number, + string text + ) + public + returns (bool) + { emit Show(message, number, text); return true; } - function buyMessage( bytes32 message, uint256 number, string text ) public payable returns (bool) { + function buyMessage( + bytes32 message, + uint256 number, + string text + ) + public + payable + returns (bool) + { emit Buy( message, number, diff --git a/contracts/ownership/Heritable.sol b/contracts/ownership/Heritable.sol index 9d185ea63..f64774381 100644 --- a/contracts/ownership/Heritable.sol +++ b/contracts/ownership/Heritable.sol @@ -21,8 +21,15 @@ contract Heritable is Ownable { event HeirChanged(address indexed owner, address indexed newHeir); event OwnerHeartbeated(address indexed owner); - event OwnerProclaimedDead(address indexed owner, address indexed heir, uint256 timeOfDeath); - event HeirOwnershipClaimed(address indexed previousOwner, address indexed newOwner); + event OwnerProclaimedDead( + address indexed owner, + address indexed heir, + uint256 timeOfDeath + ); + event HeirOwnershipClaimed( + address indexed previousOwner, + address indexed newOwner + ); /** @@ -106,7 +113,9 @@ contract Heritable is Ownable { timeOfDeath_ = 0; } - function setHeartbeatTimeout(uint256 newHeartbeatTimeout) internal onlyOwner { + function setHeartbeatTimeout(uint256 newHeartbeatTimeout) + internal onlyOwner + { require(ownerLives()); heartbeatTimeout_ = newHeartbeatTimeout; } diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index 5b93d3a27..f1c737427 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -11,7 +11,10 @@ contract Ownable { event OwnershipRenounced(address indexed previousOwner); - event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + event OwnershipTransferred( + address indexed previousOwner, + address indexed newOwner + ); /** diff --git a/contracts/payment/SplitPayment.sol b/contracts/payment/SplitPayment.sol index 4dc9e34f2..929666b53 100644 --- a/contracts/payment/SplitPayment.sol +++ b/contracts/payment/SplitPayment.sol @@ -43,7 +43,11 @@ contract SplitPayment { require(shares[payee] > 0); uint256 totalReceived = address(this).balance.add(totalReleased); - uint256 payment = totalReceived.mul(shares[payee]).div(totalShares).sub(released[payee]); + uint256 payment = totalReceived.mul( + shares[payee]).div( + totalShares).sub( + released[payee] + ); require(payment != 0); require(address(this).balance >= payment); diff --git a/contracts/token/ERC20/CappedToken.sol b/contracts/token/ERC20/CappedToken.sol index 95a258bba..d8e67ac63 100644 --- a/contracts/token/ERC20/CappedToken.sol +++ b/contracts/token/ERC20/CappedToken.sol @@ -22,7 +22,15 @@ contract CappedToken is MintableToken { * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ - function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { + function mint( + address _to, + uint256 _amount + ) + onlyOwner + canMint + public + returns (bool) + { require(totalSupply_.add(_amount) <= cap); return super.mint(_to, _amount); diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index d99d1dbf7..0fd454e34 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -8,8 +8,16 @@ import "./ERC20Basic.sol"; * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { - function allowance(address owner, address spender) public view returns (uint256); - function transferFrom(address from, address to, uint256 value) public returns (bool); + function allowance(address owner, address spender) + public view returns (uint256); + + function transferFrom(address from, address to, uint256 value) + public returns (bool); + function approve(address spender, uint256 value) public returns (bool); - event Approval(address indexed owner, address indexed spender, uint256 value); + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); } diff --git a/contracts/token/ERC20/MintableToken.sol b/contracts/token/ERC20/MintableToken.sol index e36d19987..590a30658 100644 --- a/contracts/token/ERC20/MintableToken.sol +++ b/contracts/token/ERC20/MintableToken.sol @@ -33,7 +33,15 @@ contract MintableToken is StandardToken, Ownable { * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ - function mint(address _to, uint256 _amount) hasMintPermission canMint public returns (bool) { + function mint( + address _to, + uint256 _amount + ) + hasMintPermission + canMint + public + returns (bool) + { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); diff --git a/contracts/token/ERC20/PausableToken.sol b/contracts/token/ERC20/PausableToken.sol index d1c04e803..28c622df5 100644 --- a/contracts/token/ERC20/PausableToken.sol +++ b/contracts/token/ERC20/PausableToken.sol @@ -10,23 +10,59 @@ import "../../lifecycle/Pausable.sol"; **/ contract PausableToken is StandardToken, Pausable { - function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { + function transfer( + address _to, + uint256 _value + ) + public + whenNotPaused + returns (bool) + { return super.transfer(_to, _value); } - function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { + function transferFrom( + address _from, + address _to, + uint256 _value + ) + public + whenNotPaused + returns (bool) + { return super.transferFrom(_from, _to, _value); } - function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { + function approve( + address _spender, + uint256 _value + ) + public + whenNotPaused + returns (bool) + { return super.approve(_spender, _value); } - function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { + function increaseApproval( + address _spender, + uint _addedValue + ) + public + whenNotPaused + returns (bool success) + { return super.increaseApproval(_spender, _addedValue); } - function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { + function decreaseApproval( + address _spender, + uint _subtractedValue + ) + public + whenNotPaused + returns (bool success) + { return super.decreaseApproval(_spender, _subtractedValue); } } diff --git a/contracts/token/ERC20/StandardBurnableToken.sol b/contracts/token/ERC20/StandardBurnableToken.sol index 184619ce5..94ca1a788 100644 --- a/contracts/token/ERC20/StandardBurnableToken.sol +++ b/contracts/token/ERC20/StandardBurnableToken.sol @@ -3,6 +3,7 @@ pragma solidity ^0.4.23; import "./BurnableToken.sol"; import "./StandardToken.sol"; + /** * @title Standard Burnable Token * @dev Adds burnFrom method to ERC20 implementations diff --git a/contracts/token/ERC20/StandardToken.sol b/contracts/token/ERC20/StandardToken.sol index 096ec25b8..67310dbc6 100644 --- a/contracts/token/ERC20/StandardToken.sol +++ b/contracts/token/ERC20/StandardToken.sol @@ -22,7 +22,14 @@ contract StandardToken is ERC20, BasicToken { * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ - function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { + function transferFrom( + address _from, + address _to, + uint256 _value + ) + public + returns (bool) + { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); @@ -56,7 +63,14 @@ contract StandardToken is ERC20, BasicToken { * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ - function allowance(address _owner, address _spender) public view returns (uint256) { + function allowance( + address _owner, + address _spender + ) + public + view + returns (uint256) + { return allowed[_owner][_spender]; } @@ -70,8 +84,15 @@ contract StandardToken is ERC20, BasicToken { * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ - function increaseApproval(address _spender, uint _addedValue) public returns (bool) { - allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); + function increaseApproval( + address _spender, + uint _addedValue + ) + public + returns (bool) + { + allowed[msg.sender][_spender] = ( + allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } @@ -86,7 +107,13 @@ contract StandardToken is ERC20, BasicToken { * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ - function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { + function decreaseApproval( + address _spender, + uint _subtractedValue + ) + public + returns (bool) + { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; diff --git a/contracts/token/ERC20/TokenTimelock.sol b/contracts/token/ERC20/TokenTimelock.sol index 2ac1114bc..8556a533a 100644 --- a/contracts/token/ERC20/TokenTimelock.sol +++ b/contracts/token/ERC20/TokenTimelock.sol @@ -20,7 +20,13 @@ contract TokenTimelock { // timestamp when token release is enabled uint256 public releaseTime; - constructor(ERC20Basic _token, address _beneficiary, uint256 _releaseTime) public { + constructor( + ERC20Basic _token, + address _beneficiary, + uint256 _releaseTime + ) + public + { // solium-disable-next-line security/no-block-members require(_releaseTime > block.timestamp); token = _token; diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index b518aa4a2..0a56c66a0 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -9,7 +9,14 @@ import "./ERC721Basic.sol"; */ contract ERC721Enumerable is ERC721Basic { function totalSupply() public view returns (uint256); - function tokenOfOwnerByIndex(address _owner, uint256 _index) public view returns (uint256 _tokenId); + function tokenOfOwnerByIndex( + address _owner, + uint256 _index + ) + public + view + returns (uint256 _tokenId); + function tokenByIndex(uint256 _index) public view returns (uint256); } diff --git a/contracts/token/ERC721/ERC721Basic.sol b/contracts/token/ERC721/ERC721Basic.sol index c1f282b78..c61938767 100644 --- a/contracts/token/ERC721/ERC721Basic.sol +++ b/contracts/token/ERC721/ERC721Basic.sol @@ -6,22 +6,38 @@ pragma solidity ^0.4.23; * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */ contract ERC721Basic { - event Transfer(address indexed _from, address indexed _to, uint256 _tokenId); - event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId); - event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); + event Transfer( + address indexed _from, + address indexed _to, + uint256 _tokenId + ); + event Approval( + address indexed _owner, + address indexed _approved, + uint256 _tokenId + ); + event ApprovalForAll( + address indexed _owner, + address indexed _operator, + bool _approved + ); function balanceOf(address _owner) public view returns (uint256 _balance); function ownerOf(uint256 _tokenId) public view returns (address _owner); function exists(uint256 _tokenId) public view returns (bool _exists); function approve(address _to, uint256 _tokenId) public; - function getApproved(uint256 _tokenId) public view returns (address _operator); + function getApproved(uint256 _tokenId) + public view returns (address _operator); function setApprovalForAll(address _operator, bool _approved) public; - function isApprovedForAll(address _owner, address _operator) public view returns (bool); + function isApprovedForAll(address _owner, address _operator) + public view returns (bool); function transferFrom(address _from, address _to, uint256 _tokenId) public; - function safeTransferFrom(address _from, address _to, uint256 _tokenId) public; + function safeTransferFrom(address _from, address _to, uint256 _tokenId) + public; + function safeTransferFrom( address _from, address _to, diff --git a/contracts/token/ERC721/ERC721BasicToken.sol b/contracts/token/ERC721/ERC721BasicToken.sol index 86b936b41..75480514d 100644 --- a/contracts/token/ERC721/ERC721BasicToken.sol +++ b/contracts/token/ERC721/ERC721BasicToken.sol @@ -125,7 +125,14 @@ contract ERC721BasicToken is ERC721Basic { * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ - function isApprovedForAll(address _owner, address _operator) public view returns (bool) { + function isApprovedForAll( + address _owner, + address _operator + ) + public + view + returns (bool) + { return operatorApprovals[_owner][_operator]; } @@ -137,7 +144,14 @@ contract ERC721BasicToken is ERC721Basic { * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ - function transferFrom(address _from, address _to, uint256 _tokenId) public canTransfer(_tokenId) { + function transferFrom( + address _from, + address _to, + uint256 _tokenId + ) + public + canTransfer(_tokenId) + { require(_from != address(0)); require(_to != address(0)); @@ -204,9 +218,23 @@ contract ERC721BasicToken is ERC721Basic { * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ - function isApprovedOrOwner(address _spender, uint256 _tokenId) internal view returns (bool) { + function isApprovedOrOwner( + address _spender, + uint256 _tokenId + ) + internal + view + returns (bool) + { address owner = ownerOf(_tokenId); - return _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender); + // Disable solium check because of + // https://github.com/duaraghav8/Solium/issues/175 + // solium-disable-next-line operator-whitespace + return ( + _spender == owner || + getApproved(_tokenId) == _spender || + isApprovedForAll(owner, _spender) + ); } /** @@ -289,7 +317,8 @@ contract ERC721BasicToken is ERC721Basic { if (!_to.isContract()) { return true; } - bytes4 retval = ERC721Receiver(_to).onERC721Received(_from, _tokenId, _data); + bytes4 retval = ERC721Receiver(_to).onERC721Received( + _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } } diff --git a/contracts/token/ERC721/ERC721Receiver.sol b/contracts/token/ERC721/ERC721Receiver.sol index d1e6d059f..851fe7270 100644 --- a/contracts/token/ERC721/ERC721Receiver.sol +++ b/contracts/token/ERC721/ERC721Receiver.sol @@ -26,5 +26,11 @@ contract ERC721Receiver { * @param _data Additional data with no specified format * @return `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))` */ - function onERC721Received(address _from, uint256 _tokenId, bytes _data) public returns(bytes4); + function onERC721Received( + address _from, + uint256 _tokenId, + bytes _data + ) + public + returns(bytes4); } diff --git a/contracts/token/ERC721/ERC721Token.sol b/contracts/token/ERC721/ERC721Token.sol index b37293f78..dc0876c51 100644 --- a/contracts/token/ERC721/ERC721Token.sol +++ b/contracts/token/ERC721/ERC721Token.sol @@ -72,7 +72,14 @@ contract ERC721Token is ERC721, ERC721BasicToken { * @param _index uint256 representing the index to be accessed of the requested tokens list * @return uint256 token ID at the given index of the tokens list owned by the requested address */ - function tokenOfOwnerByIndex(address _owner, uint256 _index) public view returns (uint256) { + function tokenOfOwnerByIndex( + address _owner, + uint256 _index + ) + public + view + returns (uint256) + { require(_index < balanceOf(_owner)); return ownedTokens[_owner][_index]; } diff --git a/contracts/token/ERC827/ERC827.sol b/contracts/token/ERC827/ERC827.sol index 7114dc7a6..76aa4a871 100644 --- a/contracts/token/ERC827/ERC827.sol +++ b/contracts/token/ERC827/ERC827.sol @@ -12,8 +12,24 @@ import "../ERC20/ERC20.sol"; * @dev approvals. */ contract ERC827 is ERC20 { - function approveAndCall( address _spender, uint256 _value, bytes _data) public payable returns (bool); - function transferAndCall( address _to, uint256 _value, bytes _data) public payable returns (bool); + function approveAndCall( + address _spender, + uint256 _value, + bytes _data + ) + public + payable + returns (bool); + + function transferAndCall( + address _to, + uint256 _value, + bytes _data + ) + public + payable + returns (bool); + function transferFromAndCall( address _from, address _to, diff --git a/contracts/token/ERC827/ERC827Token.sol b/contracts/token/ERC827/ERC827Token.sol index 0dae21920..b89ae2095 100644 --- a/contracts/token/ERC827/ERC827Token.sol +++ b/contracts/token/ERC827/ERC827Token.sol @@ -34,7 +34,15 @@ contract ERC827Token is ERC827, StandardToken { * * @return true if the call function was executed successfully */ - function approveAndCall(address _spender, uint256 _value, bytes _data) public payable returns (bool) { + function approveAndCall( + address _spender, + uint256 _value, + bytes _data + ) + public + payable + returns (bool) + { require(_spender != address(this)); super.approve(_spender, _value); @@ -55,7 +63,15 @@ contract ERC827Token is ERC827, StandardToken { * * @return true if the call function was executed successfully */ - function transferAndCall(address _to, uint256 _value, bytes _data) public payable returns (bool) { + function transferAndCall( + address _to, + uint256 _value, + bytes _data + ) + public + payable + returns (bool) + { require(_to != address(this)); super.transfer(_to, _value); @@ -106,7 +122,15 @@ contract ERC827Token is ERC827, StandardToken { * @param _addedValue The amount of tokens to increase the allowance by. * @param _data ABI-encoded contract call to call `_spender` address. */ - function increaseApprovalAndCall(address _spender, uint _addedValue, bytes _data) public payable returns (bool) { + function increaseApprovalAndCall( + address _spender, + uint _addedValue, + bytes _data + ) + public + payable + returns (bool) + { require(_spender != address(this)); super.increaseApproval(_spender, _addedValue); @@ -130,7 +154,15 @@ contract ERC827Token is ERC827, StandardToken { * @param _subtractedValue The amount of tokens to decrease the allowance by. * @param _data ABI-encoded contract call to call `_spender` address. */ - function decreaseApprovalAndCall(address _spender, uint _subtractedValue, bytes _data) public payable returns (bool) { + function decreaseApprovalAndCall( + address _spender, + uint _subtractedValue, + bytes _data + ) + public + payable + returns (bool) + { require(_spender != address(this)); super.decreaseApproval(_spender, _subtractedValue);