diff --git a/CODE_STYLE.md b/CODE_STYLE.md index 46aaa2e6bd2..2eaac05c93b 100644 --- a/CODE_STYLE.md +++ b/CODE_STYLE.md @@ -16,35 +16,19 @@ Any exception or additions specific to our project are documented below. * Try to avoid acronyms and abbreviations. -* Parameters must be prefixed with an underscore. - - ``` - function test(uint256 _testParameter1, uint256 _testParameter2) { - ... - } - ``` - - The exception are the parameters of events. There is no chance of ambiguity - with these, so they should not have underscores. Not even if they are - specified on an ERC with underscores; removing them doesn't change the ABI, - so we should be consistent with the rest of the events in this repository - and remove them. - -* Internal and private state variables should have an underscore suffix. +* Private state variables should have an underscore prefix. ``` contract TestContract { - uint256 internal internalVar_; - uint256 private privateVar_; + uint256 private _privateVar; } ``` - Variables declared in a function should not follow this rule. +* Parameters must not be prefixed with an underscore. ``` - function test() { - uint256 functionVar; - ... + function test(uint256 testParameter1, uint256 testParameter2) { + ... } ``` diff --git a/contracts/access/roles/CapperRole.sol b/contracts/access/roles/CapperRole.sol index 28836eba318..a37a119e889 100644 --- a/contracts/access/roles/CapperRole.sol +++ b/contracts/access/roles/CapperRole.sol @@ -20,21 +20,21 @@ contract CapperRole { _; } - function isCapper(address _account) public view returns (bool) { - return cappers.has(_account); + function isCapper(address account) public view returns (bool) { + return cappers.has(account); } - function addCapper(address _account) public onlyCapper { - cappers.add(_account); - emit CapperAdded(_account); + function addCapper(address account) public onlyCapper { + cappers.add(account); + emit CapperAdded(account); } function renounceCapper() public { cappers.remove(msg.sender); } - function _removeCapper(address _account) internal { - cappers.remove(_account); - emit CapperRemoved(_account); + function _removeCapper(address account) internal { + cappers.remove(account); + emit CapperRemoved(account); } } diff --git a/contracts/access/roles/MinterRole.sol b/contracts/access/roles/MinterRole.sol index 6d19c0cc548..74b22ccf3e1 100644 --- a/contracts/access/roles/MinterRole.sol +++ b/contracts/access/roles/MinterRole.sol @@ -20,21 +20,21 @@ contract MinterRole { _; } - function isMinter(address _account) public view returns (bool) { - return minters.has(_account); + function isMinter(address account) public view returns (bool) { + return minters.has(account); } - function addMinter(address _account) public onlyMinter { - minters.add(_account); - emit MinterAdded(_account); + function addMinter(address account) public onlyMinter { + minters.add(account); + emit MinterAdded(account); } function renounceMinter() public { minters.remove(msg.sender); } - function _removeMinter(address _account) internal { - minters.remove(_account); - emit MinterRemoved(_account); + function _removeMinter(address account) internal { + minters.remove(account); + emit MinterRemoved(account); } } diff --git a/contracts/access/roles/PauserRole.sol b/contracts/access/roles/PauserRole.sol index 9ae0959436c..e6c4e6da7c6 100644 --- a/contracts/access/roles/PauserRole.sol +++ b/contracts/access/roles/PauserRole.sol @@ -20,21 +20,21 @@ contract PauserRole { _; } - function isPauser(address _account) public view returns (bool) { - return pausers.has(_account); + function isPauser(address account) public view returns (bool) { + return pausers.has(account); } - function addPauser(address _account) public onlyPauser { - pausers.add(_account); - emit PauserAdded(_account); + function addPauser(address account) public onlyPauser { + pausers.add(account); + emit PauserAdded(account); } function renouncePauser() public { pausers.remove(msg.sender); } - function _removePauser(address _account) internal { - pausers.remove(_account); - emit PauserRemoved(_account); + function _removePauser(address account) internal { + pausers.remove(account); + emit PauserRemoved(account); } } diff --git a/contracts/access/roles/SignerRole.sol b/contracts/access/roles/SignerRole.sol index 0a315eb4565..a6ab48305e3 100644 --- a/contracts/access/roles/SignerRole.sol +++ b/contracts/access/roles/SignerRole.sol @@ -20,21 +20,21 @@ contract SignerRole { _; } - function isSigner(address _account) public view returns (bool) { - return signers.has(_account); + function isSigner(address account) public view returns (bool) { + return signers.has(account); } - function addSigner(address _account) public onlySigner { - signers.add(_account); - emit SignerAdded(_account); + function addSigner(address account) public onlySigner { + signers.add(account); + emit SignerAdded(account); } function renounceSigner() public { signers.remove(msg.sender); } - function _removeSigner(address _account) internal { - signers.remove(_account); - emit SignerRemoved(_account); + function _removeSigner(address account) internal { + signers.remove(account); + emit SignerRemoved(account); } } diff --git a/contracts/bounties/BreakInvariantBounty.sol b/contracts/bounties/BreakInvariantBounty.sol index f41bfb77548..58d72598048 100644 --- a/contracts/bounties/BreakInvariantBounty.sol +++ b/contracts/bounties/BreakInvariantBounty.sol @@ -10,8 +10,8 @@ import "../ownership/Ownable.sol"; * @dev This bounty will pay out to a researcher if they break invariant logic of the contract. */ contract BreakInvariantBounty is PullPayment, Ownable { - bool private claimed_; - mapping(address => address) private researchers; + bool private _claimed; + mapping(address => address) private _researchers; event TargetCreated(address createdAddress); @@ -19,7 +19,7 @@ contract BreakInvariantBounty is PullPayment, Ownable { * @dev Fallback function allowing the contract to receive funds, if they haven't already been claimed. */ function() external payable { - require(!claimed_); + require(!_claimed); } /** @@ -27,7 +27,7 @@ contract BreakInvariantBounty is PullPayment, Ownable { * @return true if the bounty was claimed, false otherwise. */ function claimed() public view returns(bool) { - return claimed_; + return _claimed; } /** @@ -37,22 +37,22 @@ contract BreakInvariantBounty is PullPayment, Ownable { */ function createTarget() public returns(Target) { Target target = Target(_deployContract()); - researchers[target] = msg.sender; + _researchers[target] = msg.sender; emit TargetCreated(target); return target; } /** * @dev Transfers the contract funds to the researcher that proved the contract is broken. - * @param _target contract + * @param target contract */ - function claim(Target _target) public { - address researcher = researchers[_target]; + function claim(Target target) public { + address researcher = _researchers[target]; require(researcher != address(0)); // Check Target contract invariants - require(!_target.checkInvariant()); + require(!target.checkInvariant()); _asyncTransfer(researcher, address(this).balance); - claimed_ = true; + _claimed = true; } /** diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index f600174d019..dd036a35226 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -22,19 +22,19 @@ contract Crowdsale { using SafeERC20 for IERC20; // The token being sold - IERC20 private token_; + IERC20 private _token; // Address where funds are collected - address private wallet_; + address private _wallet; // How many token units a buyer gets per wei. // The rate is the conversion between wei and the smallest and indivisible token unit. // So, if you are using a rate of 1 with a ERC20Detailed token with 3 decimals called TOK // 1 wei will give you 1 unit, or 0.001 TOK. - uint256 private rate_; + uint256 private _rate; // Amount of wei raised - uint256 private weiRaised_; + uint256 private _weiRaised; /** * Event for token purchase logging @@ -51,21 +51,21 @@ contract Crowdsale { ); /** - * @param _rate Number of token units a buyer gets per wei + * @param rate Number of token units a buyer gets per wei * @dev The rate is the conversion between wei and the smallest and indivisible * token unit. So, if you are using a rate of 1 with a ERC20Detailed token * with 3 decimals called TOK, 1 wei will give you 1 unit, or 0.001 TOK. - * @param _wallet Address where collected funds will be forwarded to - * @param _token Address of the token being sold + * @param wallet Address where collected funds will be forwarded to + * @param token Address of the token being sold */ - constructor(uint256 _rate, address _wallet, IERC20 _token) public { - require(_rate > 0); - require(_wallet != address(0)); - require(_token != address(0)); - - rate_ = _rate; - wallet_ = _wallet; - token_ = _token; + constructor(uint256 rate, address wallet, IERC20 token) public { + require(rate > 0); + require(wallet != address(0)); + require(token != address(0)); + + _rate = rate; + _wallet = wallet; + _token = token; } // ----------------------------------------- @@ -83,57 +83,57 @@ contract Crowdsale { * @return the token being sold. */ function token() public view returns(IERC20) { - return token_; + return _token; } /** * @return the address where funds are collected. */ function wallet() public view returns(address) { - return wallet_; + return _wallet; } /** * @return the number of token units a buyer gets per wei. */ function rate() public view returns(uint256) { - return rate_; + return _rate; } /** * @return the mount of wei raised. */ function weiRaised() public view returns (uint256) { - return weiRaised_; + return _weiRaised; } /** * @dev low level token purchase ***DO NOT OVERRIDE*** - * @param _beneficiary Address performing the token purchase + * @param beneficiary Address performing the token purchase */ - function buyTokens(address _beneficiary) public payable { + function buyTokens(address beneficiary) public payable { uint256 weiAmount = msg.value; - _preValidatePurchase(_beneficiary, weiAmount); + _preValidatePurchase(beneficiary, weiAmount); // calculate token amount to be created uint256 tokens = _getTokenAmount(weiAmount); // update state - weiRaised_ = weiRaised_.add(weiAmount); + _weiRaised = _weiRaised.add(weiAmount); - _processPurchase(_beneficiary, tokens); + _processPurchase(beneficiary, tokens); emit TokensPurchased( msg.sender, - _beneficiary, + beneficiary, weiAmount, tokens ); - _updatePurchasingState(_beneficiary, weiAmount); + _updatePurchasingState(beneficiary, weiAmount); _forwardFunds(); - _postValidatePurchase(_beneficiary, weiAmount); + _postValidatePurchase(beneficiary, weiAmount); } // ----------------------------------------- @@ -143,29 +143,29 @@ contract Crowdsale { /** * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use `super` in contracts that inherit from Crowdsale to extend their validations. * Example from CappedCrowdsale.sol's _preValidatePurchase method: - * super._preValidatePurchase(_beneficiary, _weiAmount); - * require(weiRaised().add(_weiAmount) <= cap); - * @param _beneficiary Address performing the token purchase - * @param _weiAmount Value in wei involved in the purchase + * super._preValidatePurchase(beneficiary, weiAmount); + * require(weiRaised().add(weiAmount) <= cap); + * @param beneficiary Address performing the token purchase + * @param weiAmount Value in wei involved in the purchase */ function _preValidatePurchase( - address _beneficiary, - uint256 _weiAmount + address beneficiary, + uint256 weiAmount ) internal { - require(_beneficiary != address(0)); - require(_weiAmount != 0); + require(beneficiary != address(0)); + require(weiAmount != 0); } /** * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met. - * @param _beneficiary Address performing the token purchase - * @param _weiAmount Value in wei involved in the purchase + * @param beneficiary Address performing the token purchase + * @param weiAmount Value in wei involved in the purchase */ function _postValidatePurchase( - address _beneficiary, - uint256 _weiAmount + address beneficiary, + uint256 weiAmount ) internal { @@ -174,40 +174,40 @@ contract Crowdsale { /** * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens. - * @param _beneficiary Address performing the token purchase - * @param _tokenAmount Number of tokens to be emitted + * @param beneficiary Address performing the token purchase + * @param tokenAmount Number of tokens to be emitted */ function _deliverTokens( - address _beneficiary, - uint256 _tokenAmount + address beneficiary, + uint256 tokenAmount ) internal { - token_.safeTransfer(_beneficiary, _tokenAmount); + _token.safeTransfer(beneficiary, tokenAmount); } /** * @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens. - * @param _beneficiary Address receiving the tokens - * @param _tokenAmount Number of tokens to be purchased + * @param beneficiary Address receiving the tokens + * @param tokenAmount Number of tokens to be purchased */ function _processPurchase( - address _beneficiary, - uint256 _tokenAmount + address beneficiary, + uint256 tokenAmount ) internal { - _deliverTokens(_beneficiary, _tokenAmount); + _deliverTokens(beneficiary, tokenAmount); } /** * @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.) - * @param _beneficiary Address receiving the tokens - * @param _weiAmount Value in wei involved in the purchase + * @param beneficiary Address receiving the tokens + * @param weiAmount Value in wei involved in the purchase */ function _updatePurchasingState( - address _beneficiary, - uint256 _weiAmount + address beneficiary, + uint256 weiAmount ) internal { @@ -216,19 +216,19 @@ contract Crowdsale { /** * @dev Override to extend the way in which ether is converted to tokens. - * @param _weiAmount Value in wei to be converted into tokens + * @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) + function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) { - return _weiAmount.mul(rate_); + return weiAmount.mul(_rate); } /** * @dev Determines how ETH is stored/forwarded on purchases. */ function _forwardFunds() internal { - wallet_.transfer(msg.value); + _wallet.transfer(msg.value); } } diff --git a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol index d8aa1eeabae..c6995a44dec 100644 --- a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol +++ b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol @@ -12,7 +12,7 @@ import "../validation/TimedCrowdsale.sol"; contract FinalizableCrowdsale is TimedCrowdsale { using SafeMath for uint256; - bool private finalized_ = false; + bool private _finalized = false; event CrowdsaleFinalized(); @@ -20,7 +20,7 @@ contract FinalizableCrowdsale is TimedCrowdsale { * @return true if the crowdsale is finalized, false otherwise. */ function finalized() public view returns (bool) { - return finalized_; + return _finalized; } /** @@ -28,13 +28,13 @@ contract FinalizableCrowdsale is TimedCrowdsale { * work. Calls the contract's finalization function. */ function finalize() public { - require(!finalized_); + require(!_finalized); require(hasClosed()); _finalization(); emit CrowdsaleFinalized(); - finalized_ = true; + _finalized = true; } /** diff --git a/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol b/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol index aca5e5e8294..5a7d89c7ee0 100644 --- a/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol +++ b/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol @@ -12,39 +12,39 @@ import "../../math/SafeMath.sol"; contract PostDeliveryCrowdsale is TimedCrowdsale { using SafeMath for uint256; - mapping(address => uint256) private balances_; + mapping(address => uint256) private _balances; /** * @dev Withdraw tokens only after crowdsale ends. - * @param _beneficiary Whose tokens will be withdrawn. + * @param beneficiary Whose tokens will be withdrawn. */ - function withdrawTokens(address _beneficiary) public { + function withdrawTokens(address beneficiary) public { require(hasClosed()); - uint256 amount = balances_[_beneficiary]; + uint256 amount = _balances[beneficiary]; require(amount > 0); - balances_[_beneficiary] = 0; - _deliverTokens(_beneficiary, amount); + _balances[beneficiary] = 0; + _deliverTokens(beneficiary, amount); } /** * @return the balance of an account. */ - function balanceOf(address _account) public view returns(uint256) { - return balances_[_account]; + function balanceOf(address account) public view returns(uint256) { + return _balances[account]; } /** * @dev Overrides parent by storing balances instead of issuing tokens right away. - * @param _beneficiary Token purchaser - * @param _tokenAmount Amount of tokens purchased + * @param beneficiary Token purchaser + * @param tokenAmount Amount of tokens purchased */ function _processPurchase( - address _beneficiary, - uint256 _tokenAmount + address beneficiary, + uint256 tokenAmount ) internal { - balances_[_beneficiary] = balances_[_beneficiary].add(_tokenAmount); + _balances[beneficiary] = _balances[beneficiary].add(tokenAmount); } } diff --git a/contracts/crowdsale/distribution/RefundableCrowdsale.sol b/contracts/crowdsale/distribution/RefundableCrowdsale.sol index 6e8f368238f..80db88d41b0 100644 --- a/contracts/crowdsale/distribution/RefundableCrowdsale.sol +++ b/contracts/crowdsale/distribution/RefundableCrowdsale.sol @@ -15,37 +15,37 @@ contract RefundableCrowdsale is FinalizableCrowdsale { using SafeMath for uint256; // minimum amount of funds to be raised in weis - uint256 private goal_; + uint256 private _goal; // refund escrow used to hold funds while crowdsale is running - RefundEscrow private escrow_; + RefundEscrow private _escrow; /** * @dev Constructor, creates RefundEscrow. - * @param _goal Funding goal + * @param goal Funding goal */ - constructor(uint256 _goal) public { - require(_goal > 0); - escrow_ = new RefundEscrow(wallet()); - goal_ = _goal; + constructor(uint256 goal) public { + require(goal > 0); + _escrow = new RefundEscrow(wallet()); + _goal = goal; } /** * @return minimum amount of funds to be raised in wei. */ function goal() public view returns(uint256) { - return goal_; + return _goal; } /** * @dev Investors can claim refunds here if crowdsale is unsuccessful - * @param _beneficiary Whose refund will be claimed. + * @param beneficiary Whose refund will be claimed. */ - function claimRefund(address _beneficiary) public { + function claimRefund(address beneficiary) public { require(finalized()); require(!goalReached()); - escrow_.withdraw(_beneficiary); + _escrow.withdraw(beneficiary); } /** @@ -53,7 +53,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale { * @return Whether funding goal was reached */ function goalReached() public view returns (bool) { - return weiRaised() >= goal_; + return weiRaised() >= _goal; } /** @@ -61,10 +61,10 @@ contract RefundableCrowdsale is FinalizableCrowdsale { */ function _finalization() internal { if (goalReached()) { - escrow_.close(); - escrow_.beneficiaryWithdraw(); + _escrow.close(); + _escrow.beneficiaryWithdraw(); } else { - escrow_.enableRefunds(); + _escrow.enableRefunds(); } super._finalization(); @@ -74,7 +74,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale { * @dev Overrides Crowdsale fund forwarding, sending funds to escrow. */ function _forwardFunds() internal { - escrow_.deposit.value(msg.value)(msg.sender); + _escrow.deposit.value(msg.value)(msg.sender); } } diff --git a/contracts/crowdsale/emission/AllowanceCrowdsale.sol b/contracts/crowdsale/emission/AllowanceCrowdsale.sol index 54db50af1c9..2af6752fbfe 100644 --- a/contracts/crowdsale/emission/AllowanceCrowdsale.sol +++ b/contracts/crowdsale/emission/AllowanceCrowdsale.sol @@ -14,22 +14,22 @@ contract AllowanceCrowdsale is Crowdsale { using SafeMath for uint256; using SafeERC20 for IERC20; - address private tokenWallet_; + address private _tokenWallet; /** * @dev Constructor, takes token wallet address. - * @param _tokenWallet Address holding the tokens, which has approved allowance to the crowdsale + * @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale */ - constructor(address _tokenWallet) public { - require(_tokenWallet != address(0)); - tokenWallet_ = _tokenWallet; + constructor(address tokenWallet) public { + require(tokenWallet != address(0)); + _tokenWallet = tokenWallet; } /** * @return the address of the wallet that will hold the tokens. */ function tokenWallet() public view returns(address) { - return tokenWallet_; + return _tokenWallet; } /** @@ -37,20 +37,20 @@ contract AllowanceCrowdsale is Crowdsale { * @return Amount of tokens left in the allowance */ function remainingTokens() public view returns (uint256) { - return token().allowance(tokenWallet_, this); + return token().allowance(_tokenWallet, this); } /** * @dev Overrides parent behavior by transferring tokens from wallet. - * @param _beneficiary Token purchaser - * @param _tokenAmount Amount of tokens purchased + * @param beneficiary Token purchaser + * @param tokenAmount Amount of tokens purchased */ function _deliverTokens( - address _beneficiary, - uint256 _tokenAmount + address beneficiary, + uint256 tokenAmount ) internal { - token().safeTransferFrom(tokenWallet_, _beneficiary, _tokenAmount); + token().safeTransferFrom(_tokenWallet, beneficiary, tokenAmount); } } diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index 1b676e07767..a57c7b80727 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -13,17 +13,17 @@ contract MintedCrowdsale is Crowdsale { /** * @dev Overrides delivery by minting tokens upon purchase. - * @param _beneficiary Token purchaser - * @param _tokenAmount Number of tokens to be minted + * @param beneficiary Token purchaser + * @param tokenAmount Number of tokens to be minted */ function _deliverTokens( - address _beneficiary, - uint256 _tokenAmount + address beneficiary, + uint256 tokenAmount ) internal { // Potentially dangerous assumption about the type of the token. require( - ERC20Mintable(address(token())).mint(_beneficiary, _tokenAmount)); + ERC20Mintable(address(token())).mint(beneficiary, tokenAmount)); } } diff --git a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol index ad448b319a4..2d07c676371 100644 --- a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol +++ b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol @@ -13,33 +13,33 @@ import "../../math/SafeMath.sol"; contract IncreasingPriceCrowdsale is TimedCrowdsale { using SafeMath for uint256; - uint256 private initialRate_; - uint256 private finalRate_; + uint256 private _initialRate; + uint256 private _finalRate; /** * @dev Constructor, takes initial and final rates of tokens received per wei contributed. - * @param _initialRate Number of tokens a buyer gets per wei at the start of the crowdsale - * @param _finalRate Number of tokens a buyer gets per wei at the end of the crowdsale + * @param initialRate Number of tokens a buyer gets per wei at the start of the crowdsale + * @param finalRate Number of tokens a buyer gets per wei at the end of the crowdsale */ - constructor(uint256 _initialRate, uint256 _finalRate) public { - require(_finalRate > 0); - require(_initialRate >= _finalRate); - initialRate_ = _initialRate; - finalRate_ = _finalRate; + constructor(uint256 initialRate, uint256 finalRate) public { + require(finalRate > 0); + require(initialRate >= finalRate); + _initialRate = initialRate; + _finalRate = finalRate; } /** * @return the initial rate of the crowdsale. */ function initialRate() public view returns(uint256) { - return initialRate_; + return _initialRate; } /** * @return the final rate of the crowdsale. */ function finalRate() public view returns (uint256) { - return finalRate_; + return _finalRate; } /** @@ -51,20 +51,20 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale { // solium-disable-next-line security/no-block-members uint256 elapsedTime = block.timestamp.sub(openingTime()); uint256 timeRange = closingTime().sub(openingTime()); - uint256 rateRange = initialRate_.sub(finalRate_); - return initialRate_.sub(elapsedTime.mul(rateRange).div(timeRange)); + uint256 rateRange = _initialRate.sub(_finalRate); + return _initialRate.sub(elapsedTime.mul(rateRange).div(timeRange)); } /** * @dev Overrides parent method taking into account variable rate. - * @param _weiAmount The value in wei to be converted into tokens + * @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) + function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) { uint256 currentRate = getCurrentRate(); - return currentRate.mul(_weiAmount); + return currentRate.mul(weiAmount); } } diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index 99b188a9883..67a7d7c92c6 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -11,22 +11,22 @@ import "../Crowdsale.sol"; contract CappedCrowdsale is Crowdsale { using SafeMath for uint256; - uint256 private cap_; + uint256 private _cap; /** * @dev Constructor, takes maximum amount of wei accepted in the crowdsale. - * @param _cap Max amount of wei to be contributed + * @param cap Max amount of wei to be contributed */ - constructor(uint256 _cap) public { - require(_cap > 0); - cap_ = _cap; + constructor(uint256 cap) public { + require(cap > 0); + _cap = cap; } /** * @return the cap of the crowdsale. */ function cap() public view returns(uint256) { - return cap_; + return _cap; } /** @@ -34,22 +34,22 @@ contract CappedCrowdsale is Crowdsale { * @return Whether the cap was reached */ function capReached() public view returns (bool) { - return weiRaised() >= cap_; + return weiRaised() >= _cap; } /** * @dev Extend parent behavior requiring purchase to respect the funding cap. - * @param _beneficiary Token purchaser - * @param _weiAmount Amount of wei contributed + * @param beneficiary Token purchaser + * @param weiAmount Amount of wei contributed */ function _preValidatePurchase( - address _beneficiary, - uint256 _weiAmount + address beneficiary, + uint256 weiAmount ) internal { - super._preValidatePurchase(_beneficiary, _weiAmount); - require(weiRaised().add(_weiAmount) <= cap_); + super._preValidatePurchase(beneficiary, weiAmount); + require(weiRaised().add(weiAmount) <= _cap); } } diff --git a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol index 139099e50a2..d2033984f5d 100644 --- a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol +++ b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol @@ -12,68 +12,68 @@ import "../../access/roles/CapperRole.sol"; contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole { using SafeMath for uint256; - mapping(address => uint256) private contributions_; - mapping(address => uint256) private caps_; + mapping(address => uint256) private _contributions; + mapping(address => uint256) private _caps; /** * @dev Sets a specific beneficiary's maximum contribution. - * @param _beneficiary Address to be capped - * @param _cap Wei limit for individual contribution + * @param beneficiary Address to be capped + * @param cap Wei limit for individual contribution */ - function setCap(address _beneficiary, uint256 _cap) external onlyCapper { - caps_[_beneficiary] = _cap; + function setCap(address beneficiary, uint256 cap) external onlyCapper { + _caps[beneficiary] = cap; } /** * @dev Returns the cap of a specific beneficiary. - * @param _beneficiary Address whose cap is to be checked + * @param beneficiary Address whose cap is to be checked * @return Current cap for individual beneficiary */ - function getCap(address _beneficiary) public view returns (uint256) { - return caps_[_beneficiary]; + function getCap(address beneficiary) public view returns (uint256) { + return _caps[beneficiary]; } /** * @dev Returns the amount contributed so far by a specific beneficiary. - * @param _beneficiary Address of contributor + * @param beneficiary Address of contributor * @return Beneficiary contribution so far */ - function getContribution(address _beneficiary) + function getContribution(address beneficiary) public view returns (uint256) { - return contributions_[_beneficiary]; + return _contributions[beneficiary]; } /** * @dev Extend parent behavior requiring purchase to respect the beneficiary's funding cap. - * @param _beneficiary Token purchaser - * @param _weiAmount Amount of wei contributed + * @param beneficiary Token purchaser + * @param weiAmount Amount of wei contributed */ function _preValidatePurchase( - address _beneficiary, - uint256 _weiAmount + address beneficiary, + uint256 weiAmount ) internal { - super._preValidatePurchase(_beneficiary, _weiAmount); + super._preValidatePurchase(beneficiary, weiAmount); require( - contributions_[_beneficiary].add(_weiAmount) <= caps_[_beneficiary]); + _contributions[beneficiary].add(weiAmount) <= _caps[beneficiary]); } /** * @dev Extend parent behavior to update beneficiary contributions - * @param _beneficiary Token purchaser - * @param _weiAmount Amount of wei contributed + * @param beneficiary Token purchaser + * @param weiAmount Amount of wei contributed */ function _updatePurchasingState( - address _beneficiary, - uint256 _weiAmount + address beneficiary, + uint256 weiAmount ) internal { - super._updatePurchasingState(_beneficiary, _weiAmount); - contributions_[_beneficiary] = contributions_[_beneficiary].add( - _weiAmount); + 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 c9726d9402b..abbf1d116dd 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -11,8 +11,8 @@ import "../Crowdsale.sol"; contract TimedCrowdsale is Crowdsale { using SafeMath for uint256; - uint256 private openingTime_; - uint256 private closingTime_; + uint256 private _openingTime; + uint256 private _closingTime; /** * @dev Reverts if not in crowdsale time range. @@ -24,30 +24,30 @@ contract TimedCrowdsale is Crowdsale { /** * @dev Constructor, takes crowdsale opening and closing times. - * @param _openingTime Crowdsale opening time - * @param _closingTime Crowdsale closing time + * @param openingTime Crowdsale opening time + * @param closingTime Crowdsale closing time */ - constructor(uint256 _openingTime, uint256 _closingTime) public { + constructor(uint256 openingTime, uint256 closingTime) public { // solium-disable-next-line security/no-block-members - require(_openingTime >= block.timestamp); - require(_closingTime >= _openingTime); + require(openingTime >= block.timestamp); + require(closingTime >= openingTime); - openingTime_ = _openingTime; - closingTime_ = _closingTime; + _openingTime = openingTime; + _closingTime = closingTime; } /** * @return the crowdsale opening time. */ function openingTime() public view returns(uint256) { - return openingTime_; + return _openingTime; } /** * @return the crowdsale closing time. */ function closingTime() public view returns(uint256) { - return closingTime_; + return _closingTime; } /** @@ -55,7 +55,7 @@ contract TimedCrowdsale is Crowdsale { */ function isOpen() public view returns (bool) { // solium-disable-next-line security/no-block-members - return block.timestamp >= openingTime_ && block.timestamp <= closingTime_; + return block.timestamp >= _openingTime && block.timestamp <= _closingTime; } /** @@ -64,22 +64,22 @@ contract TimedCrowdsale is Crowdsale { */ function hasClosed() public view returns (bool) { // solium-disable-next-line security/no-block-members - return block.timestamp > closingTime_; + return block.timestamp > _closingTime; } /** * @dev Extend parent behavior requiring to be within contributing period - * @param _beneficiary Token purchaser - * @param _weiAmount Amount of wei contributed + * @param beneficiary Token purchaser + * @param weiAmount Amount of wei contributed */ function _preValidatePurchase( - address _beneficiary, - uint256 _weiAmount + address beneficiary, + uint256 weiAmount ) internal onlyWhileOpen { - super._preValidatePurchase(_beneficiary, _weiAmount); + super._preValidatePurchase(beneficiary, weiAmount); } } diff --git a/contracts/cryptography/ECDSA.sol b/contracts/cryptography/ECDSA.sol index fc14498bc4c..61d19f20c97 100644 --- a/contracts/cryptography/ECDSA.sol +++ b/contracts/cryptography/ECDSA.sol @@ -12,10 +12,10 @@ library ECDSA { /** * @dev Recover signer address from a message by using their signature - * @param _hash bytes32 message, the hash is the signed message. What is recovered is the signer address. - * @param _signature bytes signature, the signature is generated using web3.eth.sign() + * @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address. + * @param signature bytes signature, the signature is generated using web3.eth.sign() */ - function recover(bytes32 _hash, bytes _signature) + function recover(bytes32 hash, bytes signature) internal pure returns (address) @@ -25,7 +25,7 @@ library ECDSA { uint8 v; // Check the signature length - if (_signature.length != 65) { + if (signature.length != 65) { return (address(0)); } @@ -34,9 +34,9 @@ library ECDSA { // currently is to use assembly. // solium-disable-next-line security/no-inline-assembly assembly { - r := mload(add(_signature, 32)) - s := mload(add(_signature, 64)) - v := byte(0, mload(add(_signature, 96))) + r := mload(add(signature, 32)) + s := mload(add(signature, 64)) + v := byte(0, mload(add(signature, 96))) } // Version of signature should be 27 or 28, but 0 and 1 are also possible versions @@ -49,7 +49,7 @@ library ECDSA { return (address(0)); } else { // solium-disable-next-line arg-overflow - return ecrecover(_hash, v, r, s); + return ecrecover(hash, v, r, s); } } @@ -58,7 +58,7 @@ library ECDSA { * @dev prefix a bytes32 value with "\x19Ethereum Signed Message:" * and hash the result */ - function toEthSignedMessageHash(bytes32 _hash) + function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) @@ -66,7 +66,7 @@ library ECDSA { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256( - abi.encodePacked("\x19Ethereum Signed Message:\n32", _hash) + abi.encodePacked("\x19Ethereum Signed Message:\n32", hash) ); } } diff --git a/contracts/cryptography/MerkleProof.sol b/contracts/cryptography/MerkleProof.sol index e46d08de597..d490e7ff52e 100644 --- a/contracts/cryptography/MerkleProof.sol +++ b/contracts/cryptography/MerkleProof.sol @@ -10,23 +10,23 @@ library MerkleProof { /** * @dev Verifies a Merkle proof proving the existence of a leaf in a Merkle tree. Assumes that each pair of leaves * and each pair of pre-images are sorted. - * @param _proof Merkle proof containing sibling hashes on the branch from the leaf to the root of the Merkle tree - * @param _root Merkle root - * @param _leaf Leaf of Merkle tree + * @param proof Merkle proof containing sibling hashes on the branch from the leaf to the root of the Merkle tree + * @param root Merkle root + * @param leaf Leaf of Merkle tree */ function verify( - bytes32[] _proof, - bytes32 _root, - bytes32 _leaf + bytes32[] proof, + bytes32 root, + bytes32 leaf ) internal pure returns (bool) { - bytes32 computedHash = _leaf; + bytes32 computedHash = leaf; - for (uint256 i = 0; i < _proof.length; i++) { - bytes32 proofElement = _proof[i]; + for (uint256 i = 0; i < proof.length; i++) { + bytes32 proofElement = proof[i]; if (computedHash < proofElement) { // Hash(current computed hash + current element of the proof) @@ -38,6 +38,6 @@ library MerkleProof { } // Check if the computed hash (root) is equal to the provided root - return computedHash == _root; + return computedHash == root; } } diff --git a/contracts/drafts/ERC1046/TokenMetadata.sol b/contracts/drafts/ERC1046/TokenMetadata.sol index 31fe31029ed..a85dac1f3d3 100644 --- a/contracts/drafts/ERC1046/TokenMetadata.sol +++ b/contracts/drafts/ERC1046/TokenMetadata.sol @@ -15,15 +15,15 @@ contract ERC20TokenMetadata is IERC20 { contract ERC20WithMetadata is ERC20TokenMetadata { - string private tokenURI_ = ""; + string private _tokenURI = ""; - constructor(string _tokenURI) + constructor(string tokenURI) public { - tokenURI_ = _tokenURI; + _tokenURI = tokenURI; } function tokenURI() external view returns (string) { - return tokenURI_; + return _tokenURI; } } diff --git a/contracts/drafts/SignatureBouncer.sol b/contracts/drafts/SignatureBouncer.sol index 024cfd75c46..d583c7399ba 100644 --- a/contracts/drafts/SignatureBouncer.sol +++ b/contracts/drafts/SignatureBouncer.sol @@ -33,34 +33,34 @@ contract SignatureBouncer is SignerRole { // Function selectors are 4 bytes long, as documented in // https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector - uint256 private constant METHOD_ID_SIZE = 4; + uint256 private constant _METHOD_ID_SIZE = 4; // Signature size is 65 bytes (tightly packed v + r + s), but gets padded to 96 bytes - uint256 private constant SIGNATURE_SIZE = 96; + uint256 private constant _SIGNATURE_SIZE = 96; /** * @dev requires that a valid signature of a signer was provided */ - modifier onlyValidSignature(bytes _signature) + modifier onlyValidSignature(bytes signature) { - require(_isValidSignature(msg.sender, _signature)); + require(_isValidSignature(msg.sender, signature)); _; } /** * @dev requires that a valid signature with a specifed method of a signer was provided */ - modifier onlyValidSignatureAndMethod(bytes _signature) + modifier onlyValidSignatureAndMethod(bytes signature) { - require(_isValidSignatureAndMethod(msg.sender, _signature)); + require(_isValidSignatureAndMethod(msg.sender, signature)); _; } /** * @dev requires that a valid signature with a specifed method and params of a signer was provided */ - modifier onlyValidSignatureAndData(bytes _signature) + modifier onlyValidSignatureAndData(bytes signature) { - require(_isValidSignatureAndData(msg.sender, _signature)); + require(_isValidSignatureAndData(msg.sender, signature)); _; } @@ -68,14 +68,14 @@ contract SignatureBouncer is SignerRole { * @dev is the signature of `this + sender` from a signer? * @return bool */ - function _isValidSignature(address _address, bytes _signature) + function _isValidSignature(address account, bytes signature) internal view returns (bool) { return _isValidDataHash( - keccak256(abi.encodePacked(address(this), _address)), - _signature + keccak256(abi.encodePacked(address(this), account)), + signature ); } @@ -83,39 +83,39 @@ contract SignatureBouncer is SignerRole { * @dev is the signature of `this + sender + methodId` from a signer? * @return bool */ - function _isValidSignatureAndMethod(address _address, bytes _signature) + function _isValidSignatureAndMethod(address account, bytes signature) internal view returns (bool) { - bytes memory data = new bytes(METHOD_ID_SIZE); + bytes memory data = new bytes(_METHOD_ID_SIZE); for (uint i = 0; i < data.length; i++) { data[i] = msg.data[i]; } return _isValidDataHash( - keccak256(abi.encodePacked(address(this), _address, data)), - _signature + keccak256(abi.encodePacked(address(this), account, data)), + signature ); } /** * @dev is the signature of `this + sender + methodId + params(s)` from a signer? - * @notice the _signature parameter of the method being validated must be the "last" parameter + * @notice the signature parameter of the method being validated must be the "last" parameter * @return bool */ - function _isValidSignatureAndData(address _address, bytes _signature) + function _isValidSignatureAndData(address account, bytes signature) internal view returns (bool) { - require(msg.data.length > SIGNATURE_SIZE); - bytes memory data = new bytes(msg.data.length - SIGNATURE_SIZE); + require(msg.data.length > _SIGNATURE_SIZE); + bytes memory data = new bytes(msg.data.length - _SIGNATURE_SIZE); for (uint i = 0; i < data.length; i++) { data[i] = msg.data[i]; } return _isValidDataHash( - keccak256(abi.encodePacked(address(this), _address, data)), - _signature + keccak256(abi.encodePacked(address(this), account, data)), + signature ); } @@ -124,14 +124,14 @@ contract SignatureBouncer is SignerRole { * and then recover the signature and check it against the signer role * @return bool */ - function _isValidDataHash(bytes32 _hash, bytes _signature) + function _isValidDataHash(bytes32 hash, bytes signature) internal view returns (bool) { - address signer = _hash + address signer = hash .toEthSignedMessageHash() - .recover(_signature); + .recover(signature); return isSigner(signer); } } diff --git a/contracts/drafts/TokenVesting.sol b/contracts/drafts/TokenVesting.sol index cfe7697d093..75b2aaa6613 100644 --- a/contracts/drafts/TokenVesting.sol +++ b/contracts/drafts/TokenVesting.sol @@ -21,107 +21,107 @@ contract TokenVesting is Ownable { event Revoked(); // beneficiary of tokens after they are released - address private beneficiary_; + address private _beneficiary; - uint256 private cliff_; - uint256 private start_; - uint256 private duration_; + uint256 private _cliff; + uint256 private _start; + uint256 private _duration; - bool private revocable_; + bool private _revocable; - mapping (address => uint256) private released_; - mapping (address => bool) private revoked_; + mapping (address => uint256) private _released; + mapping (address => bool) private _revoked; /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the - * _beneficiary, gradually in a linear fashion until _start + _duration. By then all + * beneficiary, gradually in a linear fashion until start + duration. By then all * of the balance will have vested. - * @param _beneficiary address of the beneficiary to whom vested tokens are transferred - * @param _cliffDuration duration in seconds of the cliff in which tokens will begin to vest - * @param _start the time (as Unix time) at which point vesting starts - * @param _duration duration in seconds of the period in which the tokens will vest - * @param _revocable whether the vesting is revocable or not + * @param beneficiary address of the beneficiary to whom vested tokens are transferred + * @param cliffDuration duration in seconds of the cliff in which tokens will begin to vest + * @param start the time (as Unix time) at which point vesting starts + * @param duration duration in seconds of the period in which the tokens will vest + * @param revocable whether the vesting is revocable or not */ constructor( - address _beneficiary, - uint256 _start, - uint256 _cliffDuration, - uint256 _duration, - bool _revocable + address beneficiary, + uint256 start, + uint256 cliffDuration, + uint256 duration, + bool revocable ) public { - require(_beneficiary != address(0)); - require(_cliffDuration <= _duration); - - beneficiary_ = _beneficiary; - revocable_ = _revocable; - duration_ = _duration; - cliff_ = _start.add(_cliffDuration); - start_ = _start; + require(beneficiary != address(0)); + require(cliffDuration <= duration); + + _beneficiary = beneficiary; + _revocable = revocable; + _duration = duration; + _cliff = start.add(cliffDuration); + _start = start; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view returns(address) { - return beneficiary_; + return _beneficiary; } /** * @return the cliff time of the token vesting. */ function cliff() public view returns(uint256) { - return cliff_; + return _cliff; } /** * @return the start time of the token vesting. */ function start() public view returns(uint256) { - return start_; + return _start; } /** * @return the duration of the token vesting. */ function duration() public view returns(uint256) { - return duration_; + return _duration; } /** * @return true if the vesting is revocable. */ function revocable() public view returns(bool) { - return revocable_; + return _revocable; } /** * @return the amount of the token released. */ - function released(address _token) public view returns(uint256) { - return released_[_token]; + function released(address token) public view returns(uint256) { + return _released[token]; } /** * @return true if the token is revoked. */ - function revoked(address _token) public view returns(bool) { - return revoked_[_token]; + function revoked(address token) public view returns(bool) { + return _revoked[token]; } /** * @notice Transfers vested tokens to beneficiary. - * @param _token ERC20 token which is being vested + * @param token ERC20 token which is being vested */ - function release(IERC20 _token) public { - uint256 unreleased = releasableAmount(_token); + function release(IERC20 token) public { + uint256 unreleased = releasableAmount(token); require(unreleased > 0); - released_[_token] = released_[_token].add(unreleased); + _released[token] = _released[token].add(unreleased); - _token.safeTransfer(beneficiary_, unreleased); + token.safeTransfer(_beneficiary, unreleased); emit Released(unreleased); } @@ -129,46 +129,46 @@ contract TokenVesting is Ownable { /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. - * @param _token ERC20 token which is being vested + * @param token ERC20 token which is being vested */ - function revoke(IERC20 _token) public onlyOwner { - require(revocable_); - require(!revoked_[_token]); + function revoke(IERC20 token) public onlyOwner { + require(_revocable); + require(!_revoked[token]); - uint256 balance = _token.balanceOf(address(this)); + uint256 balance = token.balanceOf(address(this)); - uint256 unreleased = releasableAmount(_token); + uint256 unreleased = releasableAmount(token); uint256 refund = balance.sub(unreleased); - revoked_[_token] = true; + _revoked[token] = true; - _token.safeTransfer(owner(), refund); + token.safeTransfer(owner(), refund); emit Revoked(); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. - * @param _token ERC20 token which is being vested + * @param token ERC20 token which is being vested */ - function releasableAmount(IERC20 _token) public view returns (uint256) { - return vestedAmount(_token).sub(released_[_token]); + function releasableAmount(IERC20 token) public view returns (uint256) { + return vestedAmount(token).sub(_released[token]); } /** * @dev Calculates the amount that has already vested. - * @param _token ERC20 token which is being vested + * @param token ERC20 token which is being vested */ - function vestedAmount(IERC20 _token) public view returns (uint256) { - uint256 currentBalance = _token.balanceOf(this); - uint256 totalBalance = currentBalance.add(released_[_token]); + function vestedAmount(IERC20 token) public view returns (uint256) { + uint256 currentBalance = token.balanceOf(this); + uint256 totalBalance = currentBalance.add(_released[token]); - if (block.timestamp < cliff_) { + if (block.timestamp < _cliff) { return 0; - } else if (block.timestamp >= start_.add(duration_) || revoked_[_token]) { + } else if (block.timestamp >= _start.add(_duration) || _revoked[token]) { return totalBalance; } else { - return totalBalance.mul(block.timestamp.sub(start_)).div(duration_); + return totalBalance.mul(block.timestamp.sub(_start)).div(_duration); } } } diff --git a/contracts/examples/SampleCrowdsale.sol b/contracts/examples/SampleCrowdsale.sol index 5773f5d8646..293a9e438e5 100644 --- a/contracts/examples/SampleCrowdsale.sol +++ b/contracts/examples/SampleCrowdsale.sol @@ -38,22 +38,22 @@ contract SampleCrowdsaleToken is ERC20Mintable { contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale { constructor( - uint256 _openingTime, - uint256 _closingTime, - uint256 _rate, - address _wallet, - uint256 _cap, - ERC20Mintable _token, - uint256 _goal + uint256 openingTime, + uint256 closingTime, + uint256 rate, + address wallet, + uint256 cap, + ERC20Mintable token, + uint256 goal ) public - Crowdsale(_rate, _wallet, _token) - CappedCrowdsale(_cap) - TimedCrowdsale(_openingTime, _closingTime) - RefundableCrowdsale(_goal) + Crowdsale(rate, wallet, token) + CappedCrowdsale(cap) + TimedCrowdsale(openingTime, closingTime) + RefundableCrowdsale(goal) { //As goal needs to be met for a successful crowdsale //the value needs to less or equal than a cap which is limit for accepted funds - require(_goal <= _cap); + require(goal <= cap); } } diff --git a/contracts/introspection/ERC165.sol b/contracts/introspection/ERC165.sol index 70868ff676e..849cdf0c125 100644 --- a/contracts/introspection/ERC165.sol +++ b/contracts/introspection/ERC165.sol @@ -10,7 +10,7 @@ import "./IERC165.sol"; */ contract ERC165 is IERC165 { - bytes4 private constant InterfaceId_ERC165 = 0x01ffc9a7; + bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7; /** * 0x01ffc9a7 === * bytes4(keccak256('supportsInterface(bytes4)')) @@ -19,7 +19,7 @@ contract ERC165 is IERC165 { /** * @dev a mapping of interface id to whether or not it's supported */ - mapping(bytes4 => bool) internal supportedInterfaces_; + mapping(bytes4 => bool) internal _supportedInterfaces; /** * @dev A contract implementing SupportsInterfaceWithLookup @@ -28,27 +28,27 @@ contract ERC165 is IERC165 { constructor() public { - _registerInterface(InterfaceId_ERC165); + _registerInterface(_InterfaceId_ERC165); } /** * @dev implement supportsInterface(bytes4) using a lookup table */ - function supportsInterface(bytes4 _interfaceId) + function supportsInterface(bytes4 interfaceId) external view returns (bool) { - return supportedInterfaces_[_interfaceId]; + return _supportedInterfaces[interfaceId]; } /** * @dev private method for registering an interface */ - function _registerInterface(bytes4 _interfaceId) + function _registerInterface(bytes4 interfaceId) internal { - require(_interfaceId != 0xffffffff); - supportedInterfaces_[_interfaceId] = true; + require(interfaceId != 0xffffffff); + _supportedInterfaces[interfaceId] = true; } } diff --git a/contracts/introspection/ERC165Checker.sol b/contracts/introspection/ERC165Checker.sol index 9bb88130936..36bc2095981 100644 --- a/contracts/introspection/ERC165Checker.sol +++ b/contracts/introspection/ERC165Checker.sol @@ -8,9 +8,9 @@ pragma solidity ^0.4.24; */ library ERC165Checker { // As per the EIP-165 spec, no interface should ever match 0xffffffff - bytes4 private constant InterfaceId_Invalid = 0xffffffff; + bytes4 private constant _InterfaceId_Invalid = 0xffffffff; - bytes4 private constant InterfaceId_ERC165 = 0x01ffc9a7; + bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7; /** * 0x01ffc9a7 === * bytes4(keccak256('supportsInterface(bytes4)')) @@ -19,59 +19,59 @@ library ERC165Checker { /** * @notice Query if a contract supports ERC165 - * @param _address The address of the contract to query for support of ERC165 - * @return true if the contract at _address implements ERC165 + * @param account The address of the contract to query for support of ERC165 + * @return true if the contract at account implements ERC165 */ - function supportsERC165(address _address) + function supportsERC165(address account) internal view returns (bool) { // Any contract that implements ERC165 must explicitly indicate support of // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid - return supportsERC165Interface(_address, InterfaceId_ERC165) && - !supportsERC165Interface(_address, InterfaceId_Invalid); + return supportsERC165Interface(account, _InterfaceId_ERC165) && + !supportsERC165Interface(account, _InterfaceId_Invalid); } /** * @notice Query if a contract implements an interface, also checks support of ERC165 - * @param _address The address of the contract to query for support of an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 - * @return true if the contract at _address indicates support of the interface with - * identifier _interfaceId, false otherwise + * @param account The address of the contract to query for support of an interface + * @param interfaceId The interface identifier, as specified in ERC-165 + * @return true if the contract at account indicates support of the interface with + * identifier interfaceId, false otherwise * @dev Interface identification is specified in ERC-165. */ - function supportsInterface(address _address, bytes4 _interfaceId) + function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { // query support of both ERC165 as per the spec and support of _interfaceId - return supportsERC165(_address) && - supportsERC165Interface(_address, _interfaceId); + return supportsERC165(account) && + supportsERC165Interface(account, interfaceId); } /** * @notice Query if a contract implements interfaces, also checks support of ERC165 - * @param _address The address of the contract to query for support of an interface - * @param _interfaceIds A list of interface identifiers, as specified in ERC-165 - * @return true if the contract at _address indicates support all interfaces in the - * _interfaceIds list, false otherwise + * @param account The address of the contract to query for support of an interface + * @param interfaceIds A list of interface identifiers, as specified in ERC-165 + * @return true if the contract at account indicates support all interfaces in the + * interfaceIds list, false otherwise * @dev Interface identification is specified in ERC-165. */ - function supportsInterfaces(address _address, bytes4[] _interfaceIds) + function supportsInterfaces(address account, bytes4[] interfaceIds) internal view returns (bool) { // query support of ERC165 itself - if (!supportsERC165(_address)) { + if (!supportsERC165(account)) { return false; } // query support of each interface in _interfaceIds - for (uint256 i = 0; i < _interfaceIds.length; i++) { - if (!supportsERC165Interface(_address, _interfaceIds[i])) { + for (uint256 i = 0; i < interfaceIds.length; i++) { + if (!supportsERC165Interface(account, interfaceIds[i])) { return false; } } @@ -82,47 +82,47 @@ library ERC165Checker { /** * @notice Query if a contract implements an interface, does not check ERC165 support - * @param _address The address of the contract to query for support of an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 - * @return true if the contract at _address indicates support of the interface with - * identifier _interfaceId, false otherwise - * @dev Assumes that _address contains a contract that supports ERC165, otherwise + * @param account The address of the contract to query for support of an interface + * @param interfaceId The interface identifier, as specified in ERC-165 + * @return true if the contract at account indicates support of the interface with + * identifier interfaceId, false otherwise + * @dev Assumes that account contains a contract that supports ERC165, otherwise * the behavior of this method is undefined. This precondition can be checked * with the `supportsERC165` method in this library. * Interface identification is specified in ERC-165. */ - function supportsERC165Interface(address _address, bytes4 _interfaceId) + function supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) { // success determines whether the staticcall succeeded and result determines - // whether the contract at _address indicates support of _interfaceId + // whether the contract at account indicates support of _interfaceId (bool success, bool result) = callERC165SupportsInterface( - _address, _interfaceId); + account, interfaceId); return (success && result); } /** * @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw - * @param _address The address of the contract to query for support of an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 + * @param account The address of the contract to query for support of an interface + * @param interfaceId The interface identifier, as specified in ERC-165 * @return success true if the STATICCALL succeeded, false otherwise - * @return result true if the STATICCALL succeeded and the contract at _address - * indicates support of the interface with identifier _interfaceId, false otherwise + * @return result true if the STATICCALL succeeded and the contract at account + * indicates support of the interface with identifier interfaceId, false otherwise */ function callERC165SupportsInterface( - address _address, - bytes4 _interfaceId + address account, + bytes4 interfaceId ) private view returns (bool success, bool result) { bytes memory encodedParams = abi.encodeWithSelector( - InterfaceId_ERC165, - _interfaceId + _InterfaceId_ERC165, + interfaceId ); // solium-disable-next-line security/no-inline-assembly @@ -135,7 +135,7 @@ library ERC165Checker { success := staticcall( 30000, // 30k gas - _address, // To addr + account, // To addr encodedParams_data, encodedParams_size, output, @@ -146,4 +146,3 @@ library ERC165Checker { } } } - diff --git a/contracts/introspection/IERC165.sol b/contracts/introspection/IERC165.sol index f3361f0a46d..4d8b5b69f4c 100644 --- a/contracts/introspection/IERC165.sol +++ b/contracts/introspection/IERC165.sol @@ -9,11 +9,11 @@ interface IERC165 { /** * @notice Query if a contract implements an interface - * @param _interfaceId The interface identifier, as specified in ERC-165 + * @param interfaceId The interface identifier, as specified in ERC-165 * @dev Interface identification is specified in ERC-165. This function * uses less than 30,000 gas. */ - function supportsInterface(bytes4 _interfaceId) + function supportsInterface(bytes4 interfaceId) external view returns (bool); diff --git a/contracts/lifecycle/Pausable.sol b/contracts/lifecycle/Pausable.sol index 28bcac96682..6d5aec99439 100644 --- a/contracts/lifecycle/Pausable.sol +++ b/contracts/lifecycle/Pausable.sol @@ -11,21 +11,21 @@ contract Pausable is PauserRole { event Paused(); event Unpaused(); - bool private paused_ = false; + bool private _paused = false; /** * @return true if the contract is paused, false otherwise. */ function paused() public view returns(bool) { - return paused_; + return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { - require(!paused_); + require(!_paused); _; } @@ -33,7 +33,7 @@ contract Pausable is PauserRole { * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { - require(paused_); + require(_paused); _; } @@ -41,7 +41,7 @@ contract Pausable is PauserRole { * @dev called by the owner to pause, triggers stopped state */ function pause() public onlyPauser whenNotPaused { - paused_ = true; + _paused = true; emit Paused(); } @@ -49,7 +49,7 @@ contract Pausable is PauserRole { * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyPauser whenPaused { - paused_ = false; + _paused = false; emit Unpaused(); } } diff --git a/contracts/math/Math.sol b/contracts/math/Math.sol index 101b35d49ca..78ef1ae2b4d 100644 --- a/contracts/math/Math.sol +++ b/contracts/math/Math.sol @@ -6,16 +6,16 @@ pragma solidity ^0.4.24; * @dev Assorted math operations */ library Math { - function max(uint256 _a, uint256 _b) internal pure returns (uint256) { - return _a >= _b ? _a : _b; + function max(uint256 a, uint256 b) internal pure returns (uint256) { + return a >= b ? a : b; } - function min(uint256 _a, uint256 _b) internal pure returns (uint256) { - return _a < _b ? _a : _b; + function min(uint256 a, uint256 b) internal pure returns (uint256) { + return a < b ? a : b; } - function average(uint256 _a, uint256 _b) internal pure returns (uint256) { - // (_a + _b) / 2 can overflow, so we distribute - return (_a / 2) + (_b / 2) + ((_a % 2 + _b % 2) / 2); + function average(uint256 a, uint256 b) internal pure returns (uint256) { + // (a + b) / 2 can overflow, so we distribute + return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } diff --git a/contracts/math/SafeMath.sol b/contracts/math/SafeMath.sol index da591c3b207..d183fa361bf 100644 --- a/contracts/math/SafeMath.sol +++ b/contracts/math/SafeMath.sol @@ -10,16 +10,16 @@ library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ - function mul(uint256 _a, uint256 _b) internal pure returns (uint256) { + function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 - if (_a == 0) { + if (a == 0) { return 0; } - uint256 c = _a * _b; - require(c / _a == _b); + uint256 c = a * b; + require(c / a == b); return c; } @@ -27,10 +27,10 @@ library SafeMath { /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ - function div(uint256 _a, uint256 _b) internal pure returns (uint256) { - require(_b > 0); // Solidity only automatically asserts when dividing by 0 - uint256 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold + function div(uint256 a, uint256 b) internal pure returns (uint256) { + require(b > 0); // Solidity only automatically asserts when dividing by 0 + uint256 c = a / b; + // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } @@ -38,9 +38,9 @@ library SafeMath { /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ - function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { - require(_b <= _a); - uint256 c = _a - _b; + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + require(b <= a); + uint256 c = a - b; return c; } @@ -48,9 +48,9 @@ library SafeMath { /** * @dev Adds two numbers, reverts on overflow. */ - function add(uint256 _a, uint256 _b) internal pure returns (uint256) { - uint256 c = _a + _b; - require(c >= _a); + function add(uint256 a, uint256 b) internal pure returns (uint256) { + uint256 c = a + b; + require(c >= a); return c; } diff --git a/contracts/mocks/AllowanceCrowdsaleImpl.sol b/contracts/mocks/AllowanceCrowdsaleImpl.sol index 872dd66e193..be01ccdf938 100644 --- a/contracts/mocks/AllowanceCrowdsaleImpl.sol +++ b/contracts/mocks/AllowanceCrowdsaleImpl.sol @@ -7,14 +7,14 @@ import "../crowdsale/emission/AllowanceCrowdsale.sol"; contract AllowanceCrowdsaleImpl is AllowanceCrowdsale { constructor ( - uint256 _rate, - address _wallet, - IERC20 _token, - address _tokenWallet + uint256 rate, + address wallet, + IERC20 token, + address tokenWallet ) public - Crowdsale(_rate, _wallet, _token) - AllowanceCrowdsale(_tokenWallet) + Crowdsale(rate, wallet, token) + AllowanceCrowdsale(tokenWallet) { } diff --git a/contracts/mocks/AutoIncrementingImpl.sol b/contracts/mocks/AutoIncrementingImpl.sol index 86c498f6954..ea15e8e394c 100644 --- a/contracts/mocks/AutoIncrementingImpl.sol +++ b/contracts/mocks/AutoIncrementingImpl.sol @@ -9,13 +9,13 @@ contract AutoIncrementingImpl { uint256 public theId; // use whatever key you want to track your counters - mapping(string => AutoIncrementing.Counter) private counters; + mapping(string => AutoIncrementing.Counter) private _counters; - function doThing(string _key) + function doThing(string key) public returns (uint256) { - theId = counters[_key].nextId(); + theId = _counters[key].nextId(); return theId; } } diff --git a/contracts/mocks/CappedCrowdsaleImpl.sol b/contracts/mocks/CappedCrowdsaleImpl.sol index a05fbd7d25f..e92cec204f9 100644 --- a/contracts/mocks/CappedCrowdsaleImpl.sol +++ b/contracts/mocks/CappedCrowdsaleImpl.sol @@ -7,14 +7,14 @@ import "../crowdsale/validation/CappedCrowdsale.sol"; contract CappedCrowdsaleImpl is CappedCrowdsale { constructor ( - uint256 _rate, - address _wallet, - IERC20 _token, - uint256 _cap + uint256 rate, + address wallet, + IERC20 token, + uint256 cap ) public - Crowdsale(_rate, _wallet, _token) - CappedCrowdsale(_cap) + Crowdsale(rate, wallet, token) + CappedCrowdsale(cap) { } diff --git a/contracts/mocks/CapperRoleMock.sol b/contracts/mocks/CapperRoleMock.sol index f4f58a05fdb..05c15c9dd32 100644 --- a/contracts/mocks/CapperRoleMock.sol +++ b/contracts/mocks/CapperRoleMock.sol @@ -4,15 +4,15 @@ import "../access/roles/CapperRole.sol"; contract CapperRoleMock is CapperRole { - function removeCapper(address _account) public { - _removeCapper(_account); + 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); + function _removeCapper(address account) internal { + super._removeCapper(account); } } diff --git a/contracts/mocks/ConditionalEscrowMock.sol b/contracts/mocks/ConditionalEscrowMock.sol index dfcab519503..d3723ad7d4a 100644 --- a/contracts/mocks/ConditionalEscrowMock.sol +++ b/contracts/mocks/ConditionalEscrowMock.sol @@ -6,13 +6,13 @@ import "../payment/ConditionalEscrow.sol"; // mock class using ConditionalEscrow contract ConditionalEscrowMock is ConditionalEscrow { - mapping(address => bool) public allowed; + mapping(address => bool) private _allowed; - function setAllowed(address _payee, bool _allowed) public { - allowed[_payee] = _allowed; + function setAllowed(address payee, bool allowed) public { + _allowed[payee] = allowed; } - function withdrawalAllowed(address _payee) public view returns (bool) { - return allowed[_payee]; + function withdrawalAllowed(address payee) public view returns (bool) { + return _allowed[payee]; } } diff --git a/contracts/mocks/DetailedERC20Mock.sol b/contracts/mocks/DetailedERC20Mock.sol index e9aab88e95d..082c451be3c 100644 --- a/contracts/mocks/DetailedERC20Mock.sol +++ b/contracts/mocks/DetailedERC20Mock.sol @@ -6,11 +6,11 @@ import "../token/ERC20/ERC20Detailed.sol"; contract ERC20DetailedMock is ERC20, ERC20Detailed { constructor( - string _name, - string _symbol, - uint8 _decimals + string name, + string symbol, + uint8 decimals ) - ERC20Detailed(_name, _symbol, _decimals) + ERC20Detailed(name, symbol, decimals) public {} } diff --git a/contracts/mocks/ECDSAMock.sol b/contracts/mocks/ECDSAMock.sol index 42570569e0e..fa3f223488f 100644 --- a/contracts/mocks/ECDSAMock.sol +++ b/contracts/mocks/ECDSAMock.sol @@ -7,19 +7,19 @@ import "../cryptography/ECDSA.sol"; contract ECDSAMock { using ECDSA for bytes32; - function recover(bytes32 _hash, bytes _signature) + function recover(bytes32 hash, bytes signature) public pure returns (address) { - return _hash.recover(_signature); + return hash.recover(signature); } - function toEthSignedMessageHash(bytes32 _hash) + function toEthSignedMessageHash(bytes32 hash) public pure returns (bytes32) { - return _hash.toEthSignedMessageHash(); + return hash.toEthSignedMessageHash(); } } diff --git a/contracts/mocks/ERC165/ERC165InterfacesSupported.sol b/contracts/mocks/ERC165/ERC165InterfacesSupported.sol index 9f472b64825..6573d972cdc 100644 --- a/contracts/mocks/ERC165/ERC165InterfacesSupported.sol +++ b/contracts/mocks/ERC165/ERC165InterfacesSupported.sol @@ -37,33 +37,33 @@ contract SupportsInterfaceWithLookupMock is IERC165 { /** * @dev implement supportsInterface(bytes4) using a lookup table */ - function supportsInterface(bytes4 _interfaceId) + function supportsInterface(bytes4 interfaceId) external view returns (bool) { - return supportedInterfaces[_interfaceId]; + return supportedInterfaces[interfaceId]; } /** * @dev private method for registering an interface */ - function _registerInterface(bytes4 _interfaceId) + function _registerInterface(bytes4 interfaceId) internal { - require(_interfaceId != 0xffffffff); - supportedInterfaces[_interfaceId] = true; + require(interfaceId != 0xffffffff); + supportedInterfaces[interfaceId] = true; } } contract ERC165InterfacesSupported is SupportsInterfaceWithLookupMock { - constructor (bytes4[] _interfaceIds) + constructor (bytes4[] interfaceIds) public { - for (uint256 i = 0; i < _interfaceIds.length; i++) { - _registerInterface(_interfaceIds[i]); + for (uint256 i = 0; i < interfaceIds.length; i++) { + _registerInterface(interfaceIds[i]); } } } diff --git a/contracts/mocks/ERC165CheckerMock.sol b/contracts/mocks/ERC165CheckerMock.sol index 13ab1ccd60a..f4d6219f9f3 100644 --- a/contracts/mocks/ERC165CheckerMock.sol +++ b/contracts/mocks/ERC165CheckerMock.sol @@ -6,27 +6,27 @@ import "../introspection/ERC165Checker.sol"; contract ERC165CheckerMock { using ERC165Checker for address; - function supportsERC165(address _address) + function supportsERC165(address account) public view returns (bool) { - return _address.supportsERC165(); + return account.supportsERC165(); } - function supportsInterface(address _address, bytes4 _interfaceId) + function supportsInterface(address account, bytes4 interfaceId) public view returns (bool) { - return _address.supportsInterface(_interfaceId); + return account.supportsInterface(interfaceId); } - function supportsInterfaces(address _address, bytes4[] _interfaceIds) + function supportsInterfaces(address account, bytes4[] interfaceIds) public view returns (bool) { - return _address.supportsInterfaces(_interfaceIds); + return account.supportsInterfaces(interfaceIds); } } diff --git a/contracts/mocks/ERC165Mock.sol b/contracts/mocks/ERC165Mock.sol index 63a39bbb27e..cbedcdb74e5 100644 --- a/contracts/mocks/ERC165Mock.sol +++ b/contracts/mocks/ERC165Mock.sol @@ -4,9 +4,9 @@ import "../introspection/ERC165.sol"; contract ERC165Mock is ERC165 { - function registerInterface(bytes4 _interfaceId) + function registerInterface(bytes4 interfaceId) public { - _registerInterface(_interfaceId); + _registerInterface(interfaceId); } } diff --git a/contracts/mocks/ERC20BurnableMock.sol b/contracts/mocks/ERC20BurnableMock.sol index 79819b748c7..bbc7c4d1a64 100644 --- a/contracts/mocks/ERC20BurnableMock.sol +++ b/contracts/mocks/ERC20BurnableMock.sol @@ -5,8 +5,8 @@ import "../token/ERC20/ERC20Burnable.sol"; contract ERC20BurnableMock is ERC20Burnable { - constructor(address _initialAccount, uint256 _initialBalance) public { - _mint(_initialAccount, _initialBalance); + constructor(address initialAccount, uint256 initialBalance) public { + _mint(initialAccount, initialBalance); } } diff --git a/contracts/mocks/ERC20Mock.sol b/contracts/mocks/ERC20Mock.sol index 600169743b3..046730750de 100644 --- a/contracts/mocks/ERC20Mock.sol +++ b/contracts/mocks/ERC20Mock.sol @@ -6,20 +6,20 @@ import "../token/ERC20/ERC20.sol"; // mock class using ERC20 contract ERC20Mock is ERC20 { - constructor(address _initialAccount, uint256 _initialBalance) public { - _mint(_initialAccount, _initialBalance); + constructor(address initialAccount, uint256 initialBalance) public { + _mint(initialAccount, initialBalance); } - function mint(address _account, uint256 _amount) public { - _mint(_account, _amount); + function mint(address account, uint256 amount) public { + _mint(account, amount); } - function burn(address _account, uint256 _amount) public { - _burn(_account, _amount); + function burn(address account, uint256 amount) public { + _burn(account, amount); } - function burnFrom(address _account, uint256 _amount) public { - _burnFrom(_account, _amount); + function burnFrom(address account, uint256 amount) public { + _burnFrom(account, amount); } } diff --git a/contracts/mocks/ERC20PausableMock.sol b/contracts/mocks/ERC20PausableMock.sol index 8dad33cd40f..c4aa05d062b 100644 --- a/contracts/mocks/ERC20PausableMock.sol +++ b/contracts/mocks/ERC20PausableMock.sol @@ -7,8 +7,8 @@ import "./PauserRoleMock.sol"; // mock class using ERC20Pausable contract ERC20PausableMock is ERC20Pausable, PauserRoleMock { - constructor(address _initialAccount, uint _initialBalance) public { - _mint(_initialAccount, _initialBalance); + constructor(address initialAccount, uint initialBalance) public { + _mint(initialAccount, initialBalance); } } diff --git a/contracts/mocks/ERC20WithMetadataMock.sol b/contracts/mocks/ERC20WithMetadataMock.sol index c7ad978f827..cdc1fe365b2 100644 --- a/contracts/mocks/ERC20WithMetadataMock.sol +++ b/contracts/mocks/ERC20WithMetadataMock.sol @@ -5,8 +5,8 @@ import "../drafts/ERC1046/TokenMetadata.sol"; contract ERC20WithMetadataMock is ERC20, ERC20WithMetadata { - constructor(string _tokenURI) public - ERC20WithMetadata(_tokenURI) + constructor(string tokenURI) public + ERC20WithMetadata(tokenURI) { } } diff --git a/contracts/mocks/ERC721BasicMock.sol b/contracts/mocks/ERC721BasicMock.sol index 5b8417fd5fb..fdb464be421 100644 --- a/contracts/mocks/ERC721BasicMock.sol +++ b/contracts/mocks/ERC721BasicMock.sol @@ -8,11 +8,11 @@ import "../token/ERC721/ERC721Basic.sol"; * This mock just provides a public mint and burn functions for testing purposes */ contract ERC721BasicMock is ERC721Basic { - function mint(address _to, uint256 _tokenId) public { - _mint(_to, _tokenId); + function mint(address to, uint256 tokenId) public { + _mint(to, tokenId); } - function burn(uint256 _tokenId) public { - _burn(ownerOf(_tokenId), _tokenId); + function burn(uint256 tokenId) public { + _burn(ownerOf(tokenId), tokenId); } } diff --git a/contracts/mocks/ERC721Mock.sol b/contracts/mocks/ERC721Mock.sol index 88ac56a5682..a1eb59e04af 100644 --- a/contracts/mocks/ERC721Mock.sol +++ b/contracts/mocks/ERC721Mock.sol @@ -11,20 +11,20 @@ import "../token/ERC721/ERC721Burnable.sol"; * and a public setter for metadata URI */ contract ERC721Mock is ERC721, ERC721Mintable, ERC721Burnable { - constructor(string _name, string _symbol) public + constructor(string name, string symbol) public ERC721Mintable() - ERC721(_name, _symbol) + ERC721(name, symbol) {} - function exists(uint256 _tokenId) public view returns (bool) { - return _exists(_tokenId); + function exists(uint256 tokenId) public view returns (bool) { + return _exists(tokenId); } - function setTokenURI(uint256 _tokenId, string _uri) public { - _setTokenURI(_tokenId, _uri); + function setTokenURI(uint256 tokenId, string uri) public { + _setTokenURI(tokenId, uri); } - function removeTokenFrom(address _from, uint256 _tokenId) public { - _removeTokenFrom(_from, _tokenId); + function removeTokenFrom(address from, uint256 tokenId) public { + _removeTokenFrom(from, tokenId); } } diff --git a/contracts/mocks/ERC721PausableMock.sol b/contracts/mocks/ERC721PausableMock.sol index 8382518468c..0efcbb9254b 100644 --- a/contracts/mocks/ERC721PausableMock.sol +++ b/contracts/mocks/ERC721PausableMock.sol @@ -9,15 +9,15 @@ import "./PauserRoleMock.sol"; * This mock just provides a public mint, burn and exists functions for testing purposes */ contract ERC721PausableMock is ERC721Pausable, PauserRoleMock { - function mint(address _to, uint256 _tokenId) public { - super._mint(_to, _tokenId); + function mint(address to, uint256 tokenId) public { + super._mint(to, tokenId); } - function burn(uint256 _tokenId) public { - super._burn(ownerOf(_tokenId), _tokenId); + function burn(uint256 tokenId) public { + super._burn(ownerOf(tokenId), tokenId); } - function exists(uint256 _tokenId) public view returns (bool) { - return super._exists(_tokenId); + function exists(uint256 tokenId) public view returns (bool) { + return super._exists(tokenId); } } diff --git a/contracts/mocks/ERC721ReceiverMock.sol b/contracts/mocks/ERC721ReceiverMock.sol index 3d747f32b11..4e21ff6ac95 100644 --- a/contracts/mocks/ERC721ReceiverMock.sol +++ b/contracts/mocks/ERC721ReceiverMock.sol @@ -4,8 +4,8 @@ import "../token/ERC721/IERC721Receiver.sol"; contract ERC721ReceiverMock is IERC721Receiver { - bytes4 internal retval_; - bool internal reverts_; + bytes4 private _retval; + bool private _reverts; event Received( address operator, @@ -15,28 +15,28 @@ contract ERC721ReceiverMock is IERC721Receiver { uint256 gas ); - constructor(bytes4 _retval, bool _reverts) public { - retval_ = _retval; - reverts_ = _reverts; + constructor(bytes4 retval, bool reverts) public { + _retval = retval; + _reverts = reverts; } function onERC721Received( - address _operator, - address _from, - uint256 _tokenId, - bytes _data + address operator, + address from, + uint256 tokenId, + bytes data ) public returns(bytes4) { - require(!reverts_); + require(!_reverts); emit Received( - _operator, - _from, - _tokenId, - _data, + operator, + from, + tokenId, + data, gasleft() // msg.gas was deprecated in solidityv0.4.21 ); - return retval_; + return _retval; } } diff --git a/contracts/mocks/FinalizableCrowdsaleImpl.sol b/contracts/mocks/FinalizableCrowdsaleImpl.sol index def19e6bf24..20076bdd1fc 100644 --- a/contracts/mocks/FinalizableCrowdsaleImpl.sol +++ b/contracts/mocks/FinalizableCrowdsaleImpl.sol @@ -7,15 +7,15 @@ import "../crowdsale/distribution/FinalizableCrowdsale.sol"; contract FinalizableCrowdsaleImpl is FinalizableCrowdsale { constructor ( - uint256 _openingTime, - uint256 _closingTime, - uint256 _rate, - address _wallet, - IERC20 _token + uint256 openingTime, + uint256 closingTime, + uint256 rate, + address wallet, + IERC20 token ) public - Crowdsale(_rate, _wallet, _token) - TimedCrowdsale(_openingTime, _closingTime) + Crowdsale(rate, wallet, token) + TimedCrowdsale(openingTime, closingTime) { } diff --git a/contracts/mocks/ForceEther.sol b/contracts/mocks/ForceEther.sol index 2823ae94877..41cde563c54 100644 --- a/contracts/mocks/ForceEther.sol +++ b/contracts/mocks/ForceEther.sol @@ -10,7 +10,7 @@ contract ForceEther { constructor() public payable { } - function destroyAndSend(address _recipient) public { - selfdestruct(_recipient); + function destroyAndSend(address recipient) public { + selfdestruct(recipient); } } diff --git a/contracts/mocks/IncreasingPriceCrowdsaleImpl.sol b/contracts/mocks/IncreasingPriceCrowdsaleImpl.sol index 95e4e367c54..29d71ec8a3d 100644 --- a/contracts/mocks/IncreasingPriceCrowdsaleImpl.sol +++ b/contracts/mocks/IncreasingPriceCrowdsaleImpl.sol @@ -7,17 +7,17 @@ import "../math/SafeMath.sol"; contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale { constructor ( - uint256 _openingTime, - uint256 _closingTime, - address _wallet, - IERC20 _token, - uint256 _initialRate, - uint256 _finalRate + uint256 openingTime, + uint256 closingTime, + address wallet, + IERC20 token, + uint256 initialRate, + uint256 finalRate ) public - Crowdsale(_initialRate, _wallet, _token) - TimedCrowdsale(_openingTime, _closingTime) - IncreasingPriceCrowdsale(_initialRate, _finalRate) + Crowdsale(initialRate, wallet, token) + TimedCrowdsale(openingTime, closingTime) + IncreasingPriceCrowdsale(initialRate, finalRate) { } diff --git a/contracts/mocks/IndividuallyCappedCrowdsaleImpl.sol b/contracts/mocks/IndividuallyCappedCrowdsaleImpl.sol index 552e9f8c5ca..d47600f8de6 100644 --- a/contracts/mocks/IndividuallyCappedCrowdsaleImpl.sol +++ b/contracts/mocks/IndividuallyCappedCrowdsaleImpl.sol @@ -9,12 +9,12 @@ contract IndividuallyCappedCrowdsaleImpl is IndividuallyCappedCrowdsale, CapperRoleMock { constructor( - uint256 _rate, - address _wallet, - IERC20 _token + uint256 rate, + address wallet, + IERC20 token ) public - Crowdsale(_rate, _wallet, _token) + Crowdsale(rate, wallet, token) { } } diff --git a/contracts/mocks/MathMock.sol b/contracts/mocks/MathMock.sol index 53f61a5f686..60341bc6514 100644 --- a/contracts/mocks/MathMock.sol +++ b/contracts/mocks/MathMock.sol @@ -5,15 +5,15 @@ import "../../contracts/math/Math.sol"; contract MathMock { - function max(uint256 _a, uint256 _b) public pure returns (uint256) { - return Math.max(_a, _b); + function max(uint256 a, uint256 b) public pure returns (uint256) { + return Math.max(a, b); } - function min(uint256 _a, uint256 _b) public pure returns (uint256) { - return Math.min(_a, _b); + function min(uint256 a, uint256 b) public pure returns (uint256) { + return Math.min(a, b); } - function average(uint256 _a, uint256 _b) public pure returns (uint256) { - return Math.average(_a, _b); + function average(uint256 a, uint256 b) public pure returns (uint256) { + return Math.average(a, b); } } diff --git a/contracts/mocks/MerkleProofWrapper.sol b/contracts/mocks/MerkleProofWrapper.sol index 5458acc94ea..7909098f6ea 100644 --- a/contracts/mocks/MerkleProofWrapper.sol +++ b/contracts/mocks/MerkleProofWrapper.sol @@ -6,14 +6,14 @@ import { MerkleProof } from "../cryptography/MerkleProof.sol"; contract MerkleProofWrapper { function verify( - bytes32[] _proof, - bytes32 _root, - bytes32 _leaf + bytes32[] proof, + bytes32 root, + bytes32 leaf ) public pure returns (bool) { - return MerkleProof.verify(_proof, _root, _leaf); + return MerkleProof.verify(proof, root, leaf); } } diff --git a/contracts/mocks/MintedCrowdsaleImpl.sol b/contracts/mocks/MintedCrowdsaleImpl.sol index 77e3430b52e..afdd3b8c764 100644 --- a/contracts/mocks/MintedCrowdsaleImpl.sol +++ b/contracts/mocks/MintedCrowdsaleImpl.sol @@ -7,12 +7,12 @@ import "../crowdsale/emission/MintedCrowdsale.sol"; contract MintedCrowdsaleImpl is MintedCrowdsale { constructor ( - uint256 _rate, - address _wallet, - ERC20Mintable _token + uint256 rate, + address wallet, + ERC20Mintable token ) public - Crowdsale(_rate, _wallet, _token) + Crowdsale(rate, wallet, token) { } diff --git a/contracts/mocks/MinterRoleMock.sol b/contracts/mocks/MinterRoleMock.sol index 232cbc19b20..bedf3d45f8d 100644 --- a/contracts/mocks/MinterRoleMock.sol +++ b/contracts/mocks/MinterRoleMock.sol @@ -4,15 +4,15 @@ import "../access/roles/MinterRole.sol"; contract MinterRoleMock is MinterRole { - function removeMinter(address _account) public { - _removeMinter(_account); + 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); + function _removeMinter(address account) internal { + super._removeMinter(account); } } diff --git a/contracts/mocks/PauserRoleMock.sol b/contracts/mocks/PauserRoleMock.sol index 21b0b0c0346..df02133265d 100644 --- a/contracts/mocks/PauserRoleMock.sol +++ b/contracts/mocks/PauserRoleMock.sol @@ -4,15 +4,15 @@ import "../access/roles/PauserRole.sol"; contract PauserRoleMock is PauserRole { - function removePauser(address _account) public { - _removePauser(_account); + 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); + function _removePauser(address account) internal { + super._removePauser(account); } } diff --git a/contracts/mocks/PostDeliveryCrowdsaleImpl.sol b/contracts/mocks/PostDeliveryCrowdsaleImpl.sol index b4dea2700e5..c6dca89a520 100644 --- a/contracts/mocks/PostDeliveryCrowdsaleImpl.sol +++ b/contracts/mocks/PostDeliveryCrowdsaleImpl.sol @@ -7,15 +7,15 @@ import "../crowdsale/distribution/PostDeliveryCrowdsale.sol"; contract PostDeliveryCrowdsaleImpl is PostDeliveryCrowdsale { constructor ( - uint256 _openingTime, - uint256 _closingTime, - uint256 _rate, - address _wallet, - IERC20 _token + uint256 openingTime, + uint256 closingTime, + uint256 rate, + address wallet, + IERC20 token ) public - TimedCrowdsale(_openingTime, _closingTime) - Crowdsale(_rate, _wallet, _token) + TimedCrowdsale(openingTime, closingTime) + Crowdsale(rate, wallet, token) { } diff --git a/contracts/mocks/PullPaymentMock.sol b/contracts/mocks/PullPaymentMock.sol index 639095dcbb8..d6da3ed70f9 100644 --- a/contracts/mocks/PullPaymentMock.sol +++ b/contracts/mocks/PullPaymentMock.sol @@ -10,8 +10,8 @@ contract PullPaymentMock is PullPayment { constructor() public payable { } // test helper function to call asyncTransfer - function callTransfer(address _dest, uint256 _amount) public { - _asyncTransfer(_dest, _amount); + function callTransfer(address dest, uint256 amount) public { + _asyncTransfer(dest, amount); } } diff --git a/contracts/mocks/ReentrancyAttack.sol b/contracts/mocks/ReentrancyAttack.sol index 96700bd16c1..05ef748e7a1 100644 --- a/contracts/mocks/ReentrancyAttack.sol +++ b/contracts/mocks/ReentrancyAttack.sol @@ -3,9 +3,9 @@ pragma solidity ^0.4.24; contract ReentrancyAttack { - function callSender(bytes4 _data) public { + function callSender(bytes4 data) public { // solium-disable-next-line security/no-low-level-calls - require(msg.sender.call(abi.encodeWithSelector(_data))); + require(msg.sender.call(abi.encodeWithSelector(data))); } } diff --git a/contracts/mocks/ReentrancyMock.sol b/contracts/mocks/ReentrancyMock.sol index 93afdd6dc28..130a8fd90f3 100644 --- a/contracts/mocks/ReentrancyMock.sol +++ b/contracts/mocks/ReentrancyMock.sol @@ -16,26 +16,26 @@ contract ReentrancyMock is ReentrancyGuard { count(); } - function countLocalRecursive(uint256 _n) public nonReentrant { - if (_n > 0) { + function countLocalRecursive(uint256 n) public nonReentrant { + if (n > 0) { count(); - countLocalRecursive(_n - 1); + countLocalRecursive(n - 1); } } - function countThisRecursive(uint256 _n) public nonReentrant { - if (_n > 0) { + function countThisRecursive(uint256 n) public nonReentrant { + if (n > 0) { count(); // solium-disable-next-line security/no-low-level-calls - bool result = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", _n - 1)); + bool result = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1)); require(result == true); } } - function countAndCall(ReentrancyAttack _attacker) public nonReentrant { + function countAndCall(ReentrancyAttack attacker) public nonReentrant { count(); bytes4 func = bytes4(keccak256("callback()")); - _attacker.callSender(func); + attacker.callSender(func); } function count() private { diff --git a/contracts/mocks/RefundableCrowdsaleImpl.sol b/contracts/mocks/RefundableCrowdsaleImpl.sol index b581031bfd5..631f29d0428 100644 --- a/contracts/mocks/RefundableCrowdsaleImpl.sol +++ b/contracts/mocks/RefundableCrowdsaleImpl.sol @@ -7,17 +7,17 @@ import "../crowdsale/distribution/RefundableCrowdsale.sol"; contract RefundableCrowdsaleImpl is RefundableCrowdsale { constructor ( - uint256 _openingTime, - uint256 _closingTime, - uint256 _rate, - address _wallet, - ERC20Mintable _token, - uint256 _goal + uint256 openingTime, + uint256 closingTime, + uint256 rate, + address wallet, + ERC20Mintable token, + uint256 goal ) public - Crowdsale(_rate, _wallet, _token) - TimedCrowdsale(_openingTime, _closingTime) - RefundableCrowdsale(_goal) + Crowdsale(rate, wallet, token) + TimedCrowdsale(openingTime, closingTime) + RefundableCrowdsale(goal) { } diff --git a/contracts/mocks/RolesMock.sol b/contracts/mocks/RolesMock.sol index 6baf873988e..cd2922289ed 100644 --- a/contracts/mocks/RolesMock.sol +++ b/contracts/mocks/RolesMock.sol @@ -8,15 +8,15 @@ contract RolesMock { Roles.Role private dummyRole; - function add(address _account) public { - dummyRole.add(_account); + function add(address account) public { + dummyRole.add(account); } - function remove(address _account) public { - dummyRole.remove(_account); + function remove(address account) public { + dummyRole.remove(account); } - function has(address _account) public view returns (bool) { - return dummyRole.has(_account); + function has(address account) public view returns (bool) { + return dummyRole.has(account); } } diff --git a/contracts/mocks/SafeERC20Helper.sol b/contracts/mocks/SafeERC20Helper.sol index dfc2fb2c0b5..0009fd01c4e 100644 --- a/contracts/mocks/SafeERC20Helper.sol +++ b/contracts/mocks/SafeERC20Helper.sol @@ -61,35 +61,35 @@ contract ERC20SucceedingMock is IERC20 { contract SafeERC20Helper { using SafeERC20 for IERC20; - IERC20 internal failing_; - IERC20 internal succeeding_; + IERC20 private _failing; + IERC20 private _succeeding; constructor() public { - failing_ = new ERC20FailingMock(); - succeeding_ = new ERC20SucceedingMock(); + _failing = new ERC20FailingMock(); + _succeeding = new ERC20SucceedingMock(); } function doFailingTransfer() public { - failing_.safeTransfer(address(0), 0); + _failing.safeTransfer(address(0), 0); } function doFailingTransferFrom() public { - failing_.safeTransferFrom(address(0), address(0), 0); + _failing.safeTransferFrom(address(0), address(0), 0); } function doFailingApprove() public { - failing_.safeApprove(address(0), 0); + _failing.safeApprove(address(0), 0); } function doSucceedingTransfer() public { - succeeding_.safeTransfer(address(0), 0); + _succeeding.safeTransfer(address(0), 0); } function doSucceedingTransferFrom() public { - succeeding_.safeTransferFrom(address(0), address(0), 0); + _succeeding.safeTransferFrom(address(0), address(0), 0); } function doSucceedingApprove() public { - succeeding_.safeApprove(address(0), 0); + _succeeding.safeApprove(address(0), 0); } } diff --git a/contracts/mocks/SafeMathMock.sol b/contracts/mocks/SafeMathMock.sol index d69d6e5cc3d..c5464ec16ec 100644 --- a/contracts/mocks/SafeMathMock.sol +++ b/contracts/mocks/SafeMathMock.sol @@ -6,20 +6,20 @@ import "../math/SafeMath.sol"; contract SafeMathMock { - function mul(uint256 _a, uint256 _b) public pure returns (uint256) { - return SafeMath.mul(_a, _b); + function mul(uint256 a, uint256 b) public pure returns (uint256) { + return SafeMath.mul(a, b); } - function div(uint256 _a, uint256 _b) public pure returns (uint256) { - return SafeMath.div(_a, _b); + function div(uint256 a, uint256 b) public pure returns (uint256) { + return SafeMath.div(a, b); } - function sub(uint256 _a, uint256 _b) public pure returns (uint256) { - return SafeMath.sub(_a, _b); + function sub(uint256 a, uint256 b) public pure returns (uint256) { + return SafeMath.sub(a, b); } - function add(uint256 _a, uint256 _b) public pure returns (uint256) { - return SafeMath.add(_a, _b); + function add(uint256 a, uint256 b) public pure returns (uint256) { + return SafeMath.add(a, b); } function mod(uint256 a, uint256 b) public pure returns (uint256) { diff --git a/contracts/mocks/SignatureBouncerMock.sol b/contracts/mocks/SignatureBouncerMock.sol index d2663d2c527..1ac00bfa298 100644 --- a/contracts/mocks/SignatureBouncerMock.sol +++ b/contracts/mocks/SignatureBouncerMock.sol @@ -5,54 +5,54 @@ import "./SignerRoleMock.sol"; contract SignatureBouncerMock is SignatureBouncer, SignerRoleMock { - function checkValidSignature(address _address, bytes _signature) + function checkValidSignature(address account, bytes signature) public view returns (bool) { - return _isValidSignature(_address, _signature); + return _isValidSignature(account, signature); } - function onlyWithValidSignature(bytes _signature) + function onlyWithValidSignature(bytes signature) public - onlyValidSignature(_signature) + onlyValidSignature(signature) view { } - function checkValidSignatureAndMethod(address _address, bytes _signature) + function checkValidSignatureAndMethod(address account, bytes signature) public view returns (bool) { - return _isValidSignatureAndMethod(_address, _signature); + return _isValidSignatureAndMethod(account, signature); } - function onlyWithValidSignatureAndMethod(bytes _signature) + function onlyWithValidSignatureAndMethod(bytes signature) public - onlyValidSignatureAndMethod(_signature) + onlyValidSignatureAndMethod(signature) view { } function checkValidSignatureAndData( - address _address, + address account, bytes, uint, - bytes _signature + bytes signature ) public view returns (bool) { - return _isValidSignatureAndData(_address, _signature); + return _isValidSignatureAndData(account, signature); } - function onlyWithValidSignatureAndData(uint, bytes _signature) + function onlyWithValidSignatureAndData(uint, bytes signature) public - onlyValidSignatureAndData(_signature) + onlyValidSignatureAndData(signature) view { diff --git a/contracts/mocks/SignerRoleMock.sol b/contracts/mocks/SignerRoleMock.sol index 0157884e41c..ba71cdeaa11 100644 --- a/contracts/mocks/SignerRoleMock.sol +++ b/contracts/mocks/SignerRoleMock.sol @@ -4,15 +4,15 @@ import "../access/roles/SignerRole.sol"; contract SignerRoleMock is SignerRole { - function removeSigner(address _account) public { - _removeSigner(_account); + 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); + function _removeSigner(address account) internal { + super._removeSigner(account); } } diff --git a/contracts/mocks/TimedCrowdsaleImpl.sol b/contracts/mocks/TimedCrowdsaleImpl.sol index b99178aee7c..296484ed1f4 100644 --- a/contracts/mocks/TimedCrowdsaleImpl.sol +++ b/contracts/mocks/TimedCrowdsaleImpl.sol @@ -7,15 +7,15 @@ import "../crowdsale/validation/TimedCrowdsale.sol"; contract TimedCrowdsaleImpl is TimedCrowdsale { constructor ( - uint256 _openingTime, - uint256 _closingTime, - uint256 _rate, - address _wallet, - IERC20 _token + uint256 openingTime, + uint256 closingTime, + uint256 rate, + address wallet, + IERC20 token ) public - Crowdsale(_rate, _wallet, _token) - TimedCrowdsale(_openingTime, _closingTime) + Crowdsale(rate, wallet, token) + TimedCrowdsale(openingTime, closingTime) { } diff --git a/contracts/ownership/CanReclaimToken.sol b/contracts/ownership/CanReclaimToken.sol index e4f7e88a638..cdbeb547bf9 100644 --- a/contracts/ownership/CanReclaimToken.sol +++ b/contracts/ownership/CanReclaimToken.sol @@ -16,11 +16,11 @@ contract CanReclaimToken is Ownable { /** * @dev Reclaim all ERC20 compatible tokens - * @param _token ERC20 The address of the token contract + * @param token ERC20 The address of the token contract */ - function reclaimToken(IERC20 _token) external onlyOwner { - uint256 balance = _token.balanceOf(this); - _token.safeTransfer(owner(), balance); + function reclaimToken(IERC20 token) external onlyOwner { + uint256 balance = token.balanceOf(this); + token.safeTransfer(owner(), balance); } } diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index c6ea3e16fa0..e7d2810de8b 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -7,7 +7,7 @@ pragma solidity ^0.4.24; * functions, this simplifies the implementation of "user permissions". */ contract Ownable { - address private owner_; + address private _owner; event OwnershipRenounced(address indexed previousOwner); @@ -22,14 +22,14 @@ contract Ownable { * account. */ constructor() public { - owner_ = msg.sender; + _owner = msg.sender; } /** * @return the address of the owner. */ function owner() public view returns(address) { - return owner_; + return _owner; } /** @@ -44,7 +44,7 @@ contract Ownable { * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { - return msg.sender == owner_; + return msg.sender == _owner; } /** @@ -54,25 +54,25 @@ contract Ownable { * modifier anymore. */ function renounceOwnership() public onlyOwner { - emit OwnershipRenounced(owner_); - owner_ = address(0); + emit OwnershipRenounced(_owner); + _owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. + * @param newOwner The address to transfer ownership to. */ - function transferOwnership(address _newOwner) public onlyOwner { - _transferOwnership(_newOwner); + function transferOwnership(address newOwner) public onlyOwner { + _transferOwnership(newOwner); } /** * @dev Transfers control of the contract to a newOwner. - * @param _newOwner The address to transfer ownership to. + * @param newOwner The address to transfer ownership to. */ - function _transferOwnership(address _newOwner) internal { - require(_newOwner != address(0)); - emit OwnershipTransferred(owner_, _newOwner); - owner_ = _newOwner; + function _transferOwnership(address newOwner) internal { + require(newOwner != address(0)); + emit OwnershipTransferred(_owner, newOwner); + _owner = newOwner; } } diff --git a/contracts/ownership/Secondary.sol b/contracts/ownership/Secondary.sol index e0397216cd1..055db51d52a 100644 --- a/contracts/ownership/Secondary.sol +++ b/contracts/ownership/Secondary.sol @@ -6,30 +6,30 @@ pragma solidity ^0.4.24; * @dev A Secondary contract can only be used by its primary account (the one that created it) */ contract Secondary { - address private primary_; + address private _primary; /** * @dev Sets the primary account to the one that is creating the Secondary contract. */ constructor() public { - primary_ = msg.sender; + _primary = msg.sender; } /** * @dev Reverts if called from any account other than the primary. */ modifier onlyPrimary() { - require(msg.sender == primary_); + require(msg.sender == _primary); _; } function primary() public view returns (address) { - return primary_; + return _primary; } - function transferPrimary(address _recipient) public onlyPrimary { - require(_recipient != address(0)); + function transferPrimary(address recipient) public onlyPrimary { + require(recipient != address(0)); - primary_ = _recipient; + _primary = recipient; } } diff --git a/contracts/payment/ConditionalEscrow.sol b/contracts/payment/ConditionalEscrow.sol index 7108911b587..933243a2579 100644 --- a/contracts/payment/ConditionalEscrow.sol +++ b/contracts/payment/ConditionalEscrow.sol @@ -11,12 +11,12 @@ contract ConditionalEscrow is Escrow { /** * @dev Returns whether an address is allowed to withdraw their funds. To be * implemented by derived contracts. - * @param _payee The destination address of the funds. + * @param payee The destination address of the funds. */ - function withdrawalAllowed(address _payee) public view returns (bool); + function withdrawalAllowed(address payee) public view returns (bool); - function withdraw(address _payee) public { - require(withdrawalAllowed(_payee)); - super.withdraw(_payee); + function withdraw(address payee) public { + require(withdrawalAllowed(payee)); + super.withdraw(payee); } } diff --git a/contracts/payment/Escrow.sol b/contracts/payment/Escrow.sol index 0c6bf7fdca2..2e6c5565ab5 100644 --- a/contracts/payment/Escrow.sol +++ b/contracts/payment/Escrow.sol @@ -17,35 +17,35 @@ contract Escrow is Secondary { event Deposited(address indexed payee, uint256 weiAmount); event Withdrawn(address indexed payee, uint256 weiAmount); - mapping(address => uint256) private deposits_; + mapping(address => uint256) private _deposits; - function depositsOf(address _payee) public view returns (uint256) { - return deposits_[_payee]; + function depositsOf(address payee) public view returns (uint256) { + return _deposits[payee]; } /** * @dev Stores the sent amount as credit to be withdrawn. - * @param _payee The destination address of the funds. + * @param payee The destination address of the funds. */ - function deposit(address _payee) public onlyPrimary payable { + function deposit(address payee) public onlyPrimary payable { uint256 amount = msg.value; - deposits_[_payee] = deposits_[_payee].add(amount); + _deposits[payee] = _deposits[payee].add(amount); - emit Deposited(_payee, amount); + emit Deposited(payee, amount); } /** * @dev Withdraw accumulated balance for a payee. - * @param _payee The address whose funds will be withdrawn and transferred to. + * @param payee The address whose funds will be withdrawn and transferred to. */ - function withdraw(address _payee) public onlyPrimary { - uint256 payment = deposits_[_payee]; + function withdraw(address payee) public onlyPrimary { + uint256 payment = _deposits[payee]; assert(address(this).balance >= payment); - deposits_[_payee] = 0; + _deposits[payee] = 0; - _payee.transfer(payment); + payee.transfer(payment); - emit Withdrawn(_payee, payment); + emit Withdrawn(payee, payment); } } diff --git a/contracts/payment/PullPayment.sol b/contracts/payment/PullPayment.sol index 4c6df8150e0..8399fa4e114 100644 --- a/contracts/payment/PullPayment.sol +++ b/contracts/payment/PullPayment.sol @@ -9,34 +9,34 @@ import "./Escrow.sol"; * contract and use _asyncTransfer instead of send or transfer. */ contract PullPayment { - Escrow private escrow; + Escrow private _escrow; constructor() public { - escrow = new Escrow(); + _escrow = new Escrow(); } /** * @dev Withdraw accumulated balance. - * @param _payee Whose balance will be withdrawn. + * @param payee Whose balance will be withdrawn. */ - function withdrawPayments(address _payee) public { - escrow.withdraw(_payee); + function withdrawPayments(address payee) public { + _escrow.withdraw(payee); } /** * @dev Returns the credit owed to an address. - * @param _dest The creditor's address. + * @param dest The creditor's address. */ - function payments(address _dest) public view returns (uint256) { - return escrow.depositsOf(_dest); + function payments(address dest) public view returns (uint256) { + return _escrow.depositsOf(dest); } /** * @dev Called by the payer to store the sent amount as credit to be pulled. - * @param _dest The destination address of the funds. - * @param _amount The amount to transfer. + * @param dest The destination address of the funds. + * @param amount The amount to transfer. */ - function _asyncTransfer(address _dest, uint256 _amount) internal { - escrow.deposit.value(_amount)(_dest); + function _asyncTransfer(address dest, uint256 amount) internal { + _escrow.deposit.value(amount)(dest); } } diff --git a/contracts/payment/RefundEscrow.sol b/contracts/payment/RefundEscrow.sol index 1031a952f24..ae7f9c463d1 100644 --- a/contracts/payment/RefundEscrow.sol +++ b/contracts/payment/RefundEscrow.sol @@ -16,40 +16,40 @@ contract RefundEscrow is Secondary, ConditionalEscrow { event Closed(); event RefundsEnabled(); - State private state_; - address private beneficiary_; + State private _state; + address private _beneficiary; /** * @dev Constructor. - * @param _beneficiary The beneficiary of the deposits. + * @param beneficiary The beneficiary of the deposits. */ - constructor(address _beneficiary) public { - require(_beneficiary != address(0)); - beneficiary_ = _beneficiary; - state_ = State.Active; + constructor(address beneficiary) public { + require(beneficiary != address(0)); + _beneficiary = beneficiary; + _state = State.Active; } /** * @return the current state of the escrow. */ function state() public view returns (State) { - return state_; + return _state; } /** * @return the beneficiary of the escrow. */ function beneficiary() public view returns (address) { - return beneficiary_; + return _beneficiary; } /** * @dev Stores funds that may later be refunded. - * @param _refundee The address funds will be sent to if a refund occurs. + * @param refundee The address funds will be sent to if a refund occurs. */ - function deposit(address _refundee) public payable { - require(state_ == State.Active); - super.deposit(_refundee); + function deposit(address refundee) public payable { + require(_state == State.Active); + super.deposit(refundee); } /** @@ -57,8 +57,8 @@ contract RefundEscrow is Secondary, ConditionalEscrow { * further deposits. */ function close() public onlyPrimary { - require(state_ == State.Active); - state_ = State.Closed; + require(_state == State.Active); + _state = State.Closed; emit Closed(); } @@ -66,8 +66,8 @@ contract RefundEscrow is Secondary, ConditionalEscrow { * @dev Allows for refunds to take place, rejecting further deposits. */ function enableRefunds() public onlyPrimary { - require(state_ == State.Active); - state_ = State.Refunding; + require(_state == State.Active); + _state = State.Refunding; emit RefundsEnabled(); } @@ -75,14 +75,14 @@ contract RefundEscrow is Secondary, ConditionalEscrow { * @dev Withdraws the beneficiary's funds. */ function beneficiaryWithdraw() public { - require(state_ == State.Closed); - beneficiary_.transfer(address(this).balance); + require(_state == State.Closed); + _beneficiary.transfer(address(this).balance); } /** * @dev Returns whether refundees can withdraw their deposits (be refunded). */ - function withdrawalAllowed(address _payee) public view returns (bool) { - return state_ == State.Refunding; + function withdrawalAllowed(address payee) public view returns (bool) { + return _state == State.Refunding; } } diff --git a/contracts/payment/SplitPayment.sol b/contracts/payment/SplitPayment.sol index 0d4a2e0956d..19df9b7064a 100644 --- a/contracts/payment/SplitPayment.sol +++ b/contracts/payment/SplitPayment.sol @@ -11,22 +11,22 @@ import "../math/SafeMath.sol"; contract SplitPayment { using SafeMath for uint256; - uint256 private totalShares_ = 0; - uint256 private totalReleased_ = 0; + uint256 private _totalShares = 0; + uint256 private _totalReleased = 0; - mapping(address => uint256) private shares_; - mapping(address => uint256) private released_; - address[] private payees_; + mapping(address => uint256) private _shares; + mapping(address => uint256) private _released; + address[] private _payees; /** * @dev Constructor */ - constructor(address[] _payees, uint256[] _shares) public payable { - require(_payees.length == _shares.length); - require(_payees.length > 0); + constructor(address[] payees, uint256[] shares) public payable { + require(payees.length == shares.length); + require(payees.length > 0); - for (uint256 i = 0; i < _payees.length; i++) { - _addPayee(_payees[i], _shares[i]); + for (uint256 i = 0; i < payees.length; i++) { + _addPayee(payees[i], shares[i]); } } @@ -39,72 +39,72 @@ contract SplitPayment { * @return the total shares of the contract. */ function totalShares() public view returns(uint256) { - return totalShares_; + return _totalShares; } /** * @return the total amount already released. */ function totalReleased() public view returns(uint256) { - return totalReleased_; + return _totalReleased; } /** * @return the shares of an account. */ - function shares(address _account) public view returns(uint256) { - return shares_[_account]; + function shares(address account) public view returns(uint256) { + return _shares[account]; } /** * @return the amount already released to an account. */ - function released(address _account) public view returns(uint256) { - return released_[_account]; + function released(address account) public view returns(uint256) { + return _released[account]; } /** * @return the address of a payee. */ function payee(uint256 index) public view returns(address) { - return payees_[index]; + return _payees[index]; } /** * @dev Release one of the payee's proportional payment. - * @param _payee Whose payments will be released. + * @param account Whose payments will be released. */ - function release(address _payee) public { - require(shares_[_payee] > 0); + function release(address account) public { + require(_shares[account] > 0); - uint256 totalReceived = address(this).balance.add(totalReleased_); + uint256 totalReceived = address(this).balance.add(_totalReleased); uint256 payment = totalReceived.mul( - shares_[_payee]).div( - totalShares_).sub( - released_[_payee] + _shares[account]).div( + _totalShares).sub( + _released[account] ); require(payment != 0); assert(address(this).balance >= payment); - released_[_payee] = released_[_payee].add(payment); - totalReleased_ = totalReleased_.add(payment); + _released[account] = _released[account].add(payment); + _totalReleased = _totalReleased.add(payment); - _payee.transfer(payment); + account.transfer(payment); } /** * @dev Add a new payee to the contract. - * @param _payee The address of the payee to add. - * @param _shares The number of shares owned by the payee. + * @param account The address of the payee to add. + * @param shares_ The number of shares owned by the payee. */ - function _addPayee(address _payee, uint256 _shares) internal { - require(_payee != address(0)); - require(_shares > 0); - require(shares_[_payee] == 0); - - payees_.push(_payee); - shares_[_payee] = _shares; - totalShares_ = totalShares_.add(_shares); + function _addPayee(address account, uint256 shares_) internal { + require(account != address(0)); + require(shares_ > 0); + require(_shares[account] == 0); + + _payees.push(account); + _shares[account] = shares_; + _totalShares = _totalShares.add(shares_); } } diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index ad2b9aa91ea..d1f3094d4c1 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -14,57 +14,57 @@ import "../../math/SafeMath.sol"; contract ERC20 is IERC20 { using SafeMath for uint256; - mapping (address => uint256) private balances_; + mapping (address => uint256) private _balances; - mapping (address => mapping (address => uint256)) private allowed_; + mapping (address => mapping (address => uint256)) private _allowed; - uint256 private totalSupply_; + uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { - return totalSupply_; + return _totalSupply; } /** * @dev Gets the balance of the specified address. - * @param _owner The address to query the the balance of. + * @param owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ - function balanceOf(address _owner) public view returns (uint256) { - return balances_[_owner]; + function balanceOf(address owner) public view returns (uint256) { + return _balances[owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. - * @param _owner address The address which owns the funds. - * @param _spender address The address which will spend the funds. + * @param owner address The address which owns the funds. + * @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 + address owner, + address spender ) public view returns (uint256) { - return allowed_[_owner][_spender]; + return _allowed[owner][spender]; } /** * @dev Transfer token for a specified address - * @param _to The address to transfer to. - * @param _value The amount to be transferred. + * @param to The address to transfer to. + * @param value The amount to be transferred. */ - function transfer(address _to, uint256 _value) public returns (bool) { - require(_value <= balances_[msg.sender]); - require(_to != address(0)); + function transfer(address to, uint256 value) public returns (bool) { + require(value <= _balances[msg.sender]); + require(to != address(0)); - balances_[msg.sender] = balances_[msg.sender].sub(_value); - balances_[_to] = balances_[_to].add(_value); - emit Transfer(msg.sender, _to, _value); + _balances[msg.sender] = _balances[msg.sender].sub(value); + _balances[to] = _balances[to].add(value); + emit Transfer(msg.sender, to, value); return true; } @@ -74,39 +74,39 @@ contract ERC20 is IERC20 { * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 - * @param _spender The address which will spend the funds. - * @param _value The amount of tokens to be spent. + * @param spender The address which will spend the funds. + * @param value The amount of tokens to be spent. */ - function approve(address _spender, uint256 _value) public returns (bool) { - require(_spender != address(0)); + function approve(address spender, uint256 value) public returns (bool) { + require(spender != address(0)); - allowed_[msg.sender][_spender] = _value; - emit Approval(msg.sender, _spender, _value); + _allowed[msg.sender][spender] = value; + emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another - * @param _from address The address which you want to send tokens from - * @param _to address The address which you want to transfer to - * @param _value uint256 the amount of tokens to be transferred + * @param from address The address which you want to send tokens from + * @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 + address from, + address to, + uint256 value ) public returns (bool) { - require(_value <= balances_[_from]); - require(_value <= allowed_[_from][msg.sender]); - require(_to != address(0)); - - balances_[_from] = balances_[_from].sub(_value); - balances_[_to] = balances_[_to].add(_value); - allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value); - emit Transfer(_from, _to, _value); + require(value <= _balances[from]); + require(value <= _allowed[from][msg.sender]); + require(to != address(0)); + + _balances[from] = _balances[from].sub(value); + _balances[to] = _balances[to].add(value); + _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); + emit Transfer(from, to, value); return true; } @@ -116,21 +116,21 @@ contract ERC20 is IERC20 { * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol - * @param _spender The address which will spend the funds. - * @param _addedValue The amount of tokens to increase the allowance by. + * @param spender The address which will spend the funds. + * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance( - address _spender, - uint256 _addedValue + address spender, + uint256 addedValue ) public returns (bool) { - require(_spender != address(0)); + require(spender != address(0)); - allowed_[msg.sender][_spender] = ( - allowed_[msg.sender][_spender].add(_addedValue)); - emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]); + _allowed[msg.sender][spender] = ( + _allowed[msg.sender][spender].add(addedValue)); + emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } @@ -140,21 +140,21 @@ contract ERC20 is IERC20 { * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol - * @param _spender The address which will spend the funds. - * @param _subtractedValue The amount of tokens to decrease the allowance by. + * @param spender The address which will spend the funds. + * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance( - address _spender, - uint256 _subtractedValue + address spender, + uint256 subtractedValue ) public returns (bool) { - require(_spender != address(0)); + require(spender != address(0)); - allowed_[msg.sender][_spender] = ( - allowed_[msg.sender][_spender].sub(_subtractedValue)); - emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]); + _allowed[msg.sender][spender] = ( + _allowed[msg.sender][spender].sub(subtractedValue)); + emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } @@ -162,45 +162,45 @@ contract ERC20 is IERC20 { * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. - * @param _account The account that will receive the created tokens. - * @param _amount The amount that will be created. + * @param account The account that will receive the created tokens. + * @param amount The amount that will be created. */ - function _mint(address _account, uint256 _amount) internal { - require(_account != 0); - totalSupply_ = totalSupply_.add(_amount); - balances_[_account] = balances_[_account].add(_amount); - emit Transfer(address(0), _account, _amount); + function _mint(address account, uint256 amount) internal { + require(account != 0); + _totalSupply = _totalSupply.add(amount); + _balances[account] = _balances[account].add(amount); + emit Transfer(address(0), account, amount); } /** * @dev Internal function that burns an amount of the token of a given * account. - * @param _account The account whose tokens will be burnt. - * @param _amount The amount that will be burnt. + * @param account The account whose tokens will be burnt. + * @param amount The amount that will be burnt. */ - function _burn(address _account, uint256 _amount) internal { - require(_account != 0); - require(_amount <= balances_[_account]); + function _burn(address account, uint256 amount) internal { + require(account != 0); + require(amount <= _balances[account]); - totalSupply_ = totalSupply_.sub(_amount); - balances_[_account] = balances_[_account].sub(_amount); - emit Transfer(_account, address(0), _amount); + _totalSupply = _totalSupply.sub(amount); + _balances[account] = _balances[account].sub(amount); + emit Transfer(account, address(0), amount); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the - * internal _burn function. - * @param _account The account whose tokens will be burnt. - * @param _amount The amount that will be burnt. + * internal burn function. + * @param account The account whose tokens will be burnt. + * @param amount The amount that will be burnt. */ - function _burnFrom(address _account, uint256 _amount) internal { - require(_amount <= allowed_[_account][msg.sender]); + function _burnFrom(address account, uint256 amount) internal { + require(amount <= _allowed[account][msg.sender]); // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted, // this function needs to emit an event with the updated approval. - allowed_[_account][msg.sender] = allowed_[_account][msg.sender].sub( - _amount); - _burn(_account, _amount); + _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( + amount); + _burn(account, amount); } } diff --git a/contracts/token/ERC20/ERC20Burnable.sol b/contracts/token/ERC20/ERC20Burnable.sol index 1fc83b77a00..ee2f98b8273 100644 --- a/contracts/token/ERC20/ERC20Burnable.sol +++ b/contracts/token/ERC20/ERC20Burnable.sol @@ -13,27 +13,27 @@ contract ERC20Burnable is ERC20 { /** * @dev Burns a specific amount of tokens. - * @param _value The amount of token to be burned. + * @param value The amount of token to be burned. */ - function burn(uint256 _value) public { - _burn(msg.sender, _value); + function burn(uint256 value) public { + _burn(msg.sender, value); } /** * @dev Burns a specific amount of tokens from the target address and decrements allowance - * @param _from address The address which you want to send tokens from - * @param _value uint256 The amount of token to be burned + * @param from address The address which you want to send tokens from + * @param value uint256 The amount of token to be burned */ - function burnFrom(address _from, uint256 _value) public { - _burnFrom(_from, _value); + function burnFrom(address from, uint256 value) public { + _burnFrom(from, value); } /** * @dev Overrides ERC20._burn in order for burn and burnFrom to emit * an additional Burn event. */ - function _burn(address _who, uint256 _value) internal { - super._burn(_who, _value); - emit TokensBurned(_who, _value); + function _burn(address who, uint256 value) internal { + super._burn(who, value); + emit TokensBurned(who, value); } } diff --git a/contracts/token/ERC20/ERC20Capped.sol b/contracts/token/ERC20/ERC20Capped.sol index bc1e8eee04e..1222034cd60 100644 --- a/contracts/token/ERC20/ERC20Capped.sol +++ b/contracts/token/ERC20/ERC20Capped.sol @@ -9,38 +9,38 @@ import "./ERC20Mintable.sol"; */ contract ERC20Capped is ERC20Mintable { - uint256 private cap_; + uint256 private _cap; - constructor(uint256 _cap) + constructor(uint256 cap) public { - require(_cap > 0); - cap_ = _cap; + require(cap > 0); + _cap = cap; } /** * @return the cap for the token minting. */ function cap() public view returns(uint256) { - return cap_; + return _cap; } /** * @dev Function to mint tokens - * @param _to The address that will receive the minted tokens. - * @param _amount The amount of tokens to mint. + * @param to The address that will receive the minted tokens. + * @param amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint( - address _to, - uint256 _amount + address to, + uint256 amount ) public returns (bool) { - require(totalSupply().add(_amount) <= cap_); + require(totalSupply().add(amount) <= _cap); - return super.mint(_to, _amount); + return super.mint(to, amount); } } diff --git a/contracts/token/ERC20/ERC20Detailed.sol b/contracts/token/ERC20/ERC20Detailed.sol index 6becdee1086..ba411aa1fcc 100644 --- a/contracts/token/ERC20/ERC20Detailed.sol +++ b/contracts/token/ERC20/ERC20Detailed.sol @@ -10,34 +10,34 @@ import "./IERC20.sol"; * just as on Ethereum all the operations are done in wei. */ contract ERC20Detailed is IERC20 { - string private name_; - string private symbol_; - uint8 private decimals_; + string private _name; + string private _symbol; + uint8 private _decimals; - constructor(string _name, string _symbol, uint8 _decimals) public { - name_ = _name; - symbol_ = _symbol; - decimals_ = _decimals; + constructor(string name, string symbol, uint8 decimals) public { + _name = name; + _symbol = symbol; + _decimals = decimals; } /** * @return the name of the token. */ function name() public view returns(string) { - return name_; + return _name; } /** * @return the symbol of the token. */ function symbol() public view returns(string) { - return symbol_; + return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns(uint8) { - return decimals_; + return _decimals; } } diff --git a/contracts/token/ERC20/ERC20Mintable.sol b/contracts/token/ERC20/ERC20Mintable.sol index 430a3cdf795..50e03a7ec2d 100644 --- a/contracts/token/ERC20/ERC20Mintable.sol +++ b/contracts/token/ERC20/ERC20Mintable.sol @@ -12,10 +12,10 @@ contract ERC20Mintable is ERC20, MinterRole { event Minted(address indexed to, uint256 amount); event MintingFinished(); - bool private mintingFinished_ = false; + bool private _mintingFinished = false; modifier onlyBeforeMintingFinished() { - require(!mintingFinished_); + require(!_mintingFinished); _; } @@ -23,26 +23,26 @@ contract ERC20Mintable is ERC20, MinterRole { * @return true if the minting is finished. */ function mintingFinished() public view returns(bool) { - return mintingFinished_; + return _mintingFinished; } /** * @dev Function to mint tokens - * @param _to The address that will receive the minted tokens. - * @param _amount The amount of tokens to mint. + * @param to The address that will receive the minted tokens. + * @param amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint( - address _to, - uint256 _amount + address to, + uint256 amount ) public onlyMinter onlyBeforeMintingFinished returns (bool) { - _mint(_to, _amount); - emit Minted(_to, _amount); + _mint(to, amount); + emit Minted(to, amount); return true; } @@ -56,7 +56,7 @@ contract ERC20Mintable is ERC20, MinterRole { onlyBeforeMintingFinished returns (bool) { - mintingFinished_ = true; + _mintingFinished = true; emit MintingFinished(); return true; } diff --git a/contracts/token/ERC20/ERC20Pausable.sol b/contracts/token/ERC20/ERC20Pausable.sol index 4bacd0cae2c..32932355d8b 100644 --- a/contracts/token/ERC20/ERC20Pausable.sol +++ b/contracts/token/ERC20/ERC20Pausable.sol @@ -11,58 +11,58 @@ import "../../lifecycle/Pausable.sol"; contract ERC20Pausable is ERC20, Pausable { function transfer( - address _to, - uint256 _value + address to, + uint256 value ) public whenNotPaused returns (bool) { - return super.transfer(_to, _value); + return super.transfer(to, value); } function transferFrom( - address _from, - address _to, - uint256 _value + address from, + address to, + uint256 value ) public whenNotPaused returns (bool) { - return super.transferFrom(_from, _to, _value); + return super.transferFrom(from, to, value); } function approve( - address _spender, - uint256 _value + address spender, + uint256 value ) public whenNotPaused returns (bool) { - return super.approve(_spender, _value); + return super.approve(spender, value); } function increaseAllowance( - address _spender, - uint _addedValue + address spender, + uint addedValue ) public whenNotPaused returns (bool success) { - return super.increaseAllowance(_spender, _addedValue); + return super.increaseAllowance(spender, addedValue); } function decreaseAllowance( - address _spender, - uint _subtractedValue + address spender, + uint subtractedValue ) public whenNotPaused returns (bool success) { - return super.decreaseAllowance(_spender, _subtractedValue); + return super.decreaseAllowance(spender, subtractedValue); } } diff --git a/contracts/token/ERC20/IERC20.sol b/contracts/token/ERC20/IERC20.sol index 155c1cd9dbc..34d68fd62cb 100644 --- a/contracts/token/ERC20/IERC20.sol +++ b/contracts/token/ERC20/IERC20.sol @@ -8,17 +8,17 @@ pragma solidity ^0.4.24; interface IERC20 { function totalSupply() external view returns (uint256); - function balanceOf(address _who) external view returns (uint256); + function balanceOf(address who) external view returns (uint256); - function allowance(address _owner, address _spender) + function allowance(address owner, address spender) external view returns (uint256); - function transfer(address _to, uint256 _value) external returns (bool); + function transfer(address to, uint256 value) external returns (bool); - function approve(address _spender, uint256 _value) + function approve(address spender, uint256 value) external returns (bool); - function transferFrom(address _from, address _to, uint256 _value) + function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer( diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index 451cf136c81..48b15fba933 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -12,33 +12,33 @@ import "./IERC20.sol"; */ library SafeERC20 { function safeTransfer( - IERC20 _token, - address _to, - uint256 _value + IERC20 token, + address to, + uint256 value ) internal { - require(_token.transfer(_to, _value)); + require(token.transfer(to, value)); } function safeTransferFrom( - IERC20 _token, - address _from, - address _to, - uint256 _value + IERC20 token, + address from, + address to, + uint256 value ) internal { - require(_token.transferFrom(_from, _to, _value)); + require(token.transferFrom(from, to, value)); } function safeApprove( - IERC20 _token, - address _spender, - uint256 _value + IERC20 token, + address spender, + uint256 value ) internal { - require(_token.approve(_spender, _value)); + require(token.approve(spender, value)); } } diff --git a/contracts/token/ERC20/TokenTimelock.sol b/contracts/token/ERC20/TokenTimelock.sol index d8f96fa6668..9989ce77ada 100644 --- a/contracts/token/ERC20/TokenTimelock.sol +++ b/contracts/token/ERC20/TokenTimelock.sol @@ -12,47 +12,47 @@ contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held - IERC20 private token_; + IERC20 private _token; // beneficiary of tokens after they are released - address private beneficiary_; + address private _beneficiary; // timestamp when token release is enabled - uint256 private releaseTime_; + uint256 private _releaseTime; constructor( - IERC20 _token, - address _beneficiary, - uint256 _releaseTime + IERC20 token, + address beneficiary, + uint256 releaseTime ) public { // solium-disable-next-line security/no-block-members - require(_releaseTime > block.timestamp); - token_ = _token; - beneficiary_ = _beneficiary; - releaseTime_ = _releaseTime; + require(releaseTime > block.timestamp); + _token = token; + _beneficiary = beneficiary; + _releaseTime = releaseTime; } /** * @return the token being held. */ function token() public view returns(IERC20) { - return token_; + return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view returns(address) { - return beneficiary_; + return _beneficiary; } /** * @return the time when the tokens are released. */ function releaseTime() public view returns(uint256) { - return releaseTime_; + return _releaseTime; } /** @@ -60,11 +60,11 @@ contract TokenTimelock { */ function release() public { // solium-disable-next-line security/no-block-members - require(block.timestamp >= releaseTime_); + require(block.timestamp >= _releaseTime); - uint256 amount = token_.balanceOf(address(this)); + uint256 amount = _token.balanceOf(address(this)); require(amount > 0); - token_.safeTransfer(beneficiary_, amount); + _token.safeTransfer(_beneficiary, amount); } } diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index ca6d7b89d22..adfbc5f3771 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -14,27 +14,27 @@ import "../../introspection/ERC165.sol"; contract ERC721 is ERC165, ERC721Basic, IERC721 { // Token name - string internal name_; + string internal _name; // Token symbol - string internal symbol_; + string internal _symbol; // Mapping from owner to list of owned token IDs - mapping(address => uint256[]) private ownedTokens_; + mapping(address => uint256[]) private _ownedTokens; // Mapping from token ID to index of the owner tokens list - mapping(uint256 => uint256) private ownedTokensIndex_; + mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration - uint256[] private allTokens_; + uint256[] private _allTokens; // Mapping from token id to position in the allTokens array - mapping(uint256 => uint256) private allTokensIndex_; + mapping(uint256 => uint256) private _allTokensIndex; // Optional mapping for token URIs - mapping(uint256 => string) private tokenURIs_; + mapping(uint256 => string) private _tokenURIs; - bytes4 private constant InterfaceId_ERC721Enumerable = 0x780e9d63; + bytes4 private constant _InterfaceId_ERC721Enumerable = 0x780e9d63; /** * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ @@ -42,7 +42,7 @@ contract ERC721 is ERC165, ERC721Basic, IERC721 { * bytes4(keccak256('tokenByIndex(uint256)')) */ - bytes4 private constant InterfaceId_ERC721Metadata = 0x5b5e139f; + bytes4 private constant _InterfaceId_ERC721Metadata = 0x5b5e139f; /** * 0x5b5e139f === * bytes4(keccak256('name()')) ^ @@ -53,13 +53,13 @@ contract ERC721 is ERC165, ERC721Basic, IERC721 { /** * @dev Constructor function */ - constructor(string _name, string _symbol) public { - name_ = _name; - symbol_ = _symbol; + constructor(string name, string symbol) public { + _name = name; + _symbol = symbol; // register the supported interfaces to conform to ERC721 via ERC165 - _registerInterface(InterfaceId_ERC721Enumerable); - _registerInterface(InterfaceId_ERC721Metadata); + _registerInterface(_InterfaceId_ERC721Enumerable); + _registerInterface(_InterfaceId_ERC721Metadata); } /** @@ -67,7 +67,7 @@ contract ERC721 is ERC165, ERC721Basic, IERC721 { * @return string representing the token name */ function name() external view returns (string) { - return name_; + return _name; } /** @@ -75,35 +75,35 @@ contract ERC721 is ERC165, ERC721Basic, IERC721 { * @return string representing the token symbol */ function symbol() external view returns (string) { - return symbol_; + return _symbol; } /** * @dev Returns an URI for a given token ID * Throws if the token ID does not exist. May return an empty string. - * @param _tokenId uint256 ID of the token to query + * @param tokenId uint256 ID of the token to query */ - function tokenURI(uint256 _tokenId) public view returns (string) { - require(_exists(_tokenId)); - return tokenURIs_[_tokenId]; + function tokenURI(uint256 tokenId) public view returns (string) { + require(_exists(tokenId)); + return _tokenURIs[tokenId]; } /** * @dev Gets the token ID at a given index of the tokens list of the requested owner - * @param _owner address owning the tokens list to be accessed - * @param _index uint256 representing the index to be accessed of the requested tokens list + * @param owner address owning the tokens list to be accessed + * @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 + address owner, + uint256 index ) public view returns (uint256) { - require(_index < balanceOf(_owner)); - return ownedTokens_[_owner][_index]; + require(index < balanceOf(owner)); + return _ownedTokens[owner][index]; } /** @@ -111,107 +111,107 @@ contract ERC721 is ERC165, ERC721Basic, IERC721 { * @return uint256 representing the total amount of tokens */ function totalSupply() public view returns (uint256) { - return allTokens_.length; + return _allTokens.length; } /** * @dev Gets the token ID at a given index of all the tokens in this contract * Reverts if the index is greater or equal to the total number of tokens - * @param _index uint256 representing the index to be accessed of the tokens list + * @param index uint256 representing the index to be accessed of the tokens list * @return uint256 token ID at the given index of the tokens list */ - function tokenByIndex(uint256 _index) public view returns (uint256) { - require(_index < totalSupply()); - return allTokens_[_index]; + function tokenByIndex(uint256 index) public view returns (uint256) { + require(index < totalSupply()); + return _allTokens[index]; } /** * @dev Internal function to set the token URI for a given token * Reverts if the token ID does not exist - * @param _tokenId uint256 ID of the token to set its URI - * @param _uri string URI to assign + * @param tokenId uint256 ID of the token to set its URI + * @param uri string URI to assign */ - function _setTokenURI(uint256 _tokenId, string _uri) internal { - require(_exists(_tokenId)); - tokenURIs_[_tokenId] = _uri; + function _setTokenURI(uint256 tokenId, string uri) internal { + require(_exists(tokenId)); + _tokenURIs[tokenId] = uri; } /** * @dev Internal function to add a token ID to the list of a given address - * @param _to address representing the new owner of the given token ID - * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address + * @param to address representing the new owner of the given token ID + * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ - function _addTokenTo(address _to, uint256 _tokenId) internal { - super._addTokenTo(_to, _tokenId); - uint256 length = ownedTokens_[_to].length; - ownedTokens_[_to].push(_tokenId); - ownedTokensIndex_[_tokenId] = length; + function _addTokenTo(address to, uint256 tokenId) internal { + super._addTokenTo(to, tokenId); + uint256 length = _ownedTokens[to].length; + _ownedTokens[to].push(tokenId); + _ownedTokensIndex[tokenId] = length; } /** * @dev Internal function to remove a token ID from the list of a given address - * @param _from address representing the previous owner of the given token ID - * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address + * @param from address representing the previous owner of the given token ID + * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ - function _removeTokenFrom(address _from, uint256 _tokenId) internal { - super._removeTokenFrom(_from, _tokenId); + function _removeTokenFrom(address from, uint256 tokenId) internal { + super._removeTokenFrom(from, tokenId); // To prevent a gap in the array, we store the last token in the index of the token to delete, and // then delete the last slot. - uint256 tokenIndex = ownedTokensIndex_[_tokenId]; - uint256 lastTokenIndex = ownedTokens_[_from].length.sub(1); - uint256 lastToken = ownedTokens_[_from][lastTokenIndex]; + uint256 tokenIndex = _ownedTokensIndex[tokenId]; + uint256 lastTokenIndex = _ownedTokens[from].length.sub(1); + 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--; // 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 // the lastToken to the first position, and then dropping the element placed in the last position of the list - ownedTokensIndex_[_tokenId] = 0; - ownedTokensIndex_[lastToken] = tokenIndex; + _ownedTokensIndex[tokenId] = 0; + _ownedTokensIndex[lastToken] = tokenIndex; } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists - * @param _to address the beneficiary that will own the minted token - * @param _tokenId uint256 ID of the token to be minted by the msg.sender + * @param to address the beneficiary that will own the minted token + * @param tokenId uint256 ID of the token to be minted by the msg.sender */ - function _mint(address _to, uint256 _tokenId) internal { - super._mint(_to, _tokenId); + function _mint(address to, uint256 tokenId) internal { + super._mint(to, tokenId); - allTokensIndex_[_tokenId] = allTokens_.length; - allTokens_.push(_tokenId); + _allTokensIndex[tokenId] = _allTokens.length; + _allTokens.push(tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist - * @param _owner owner of the token to burn - * @param _tokenId uint256 ID of the token being burned by the msg.sender + * @param owner owner of the token to burn + * @param tokenId uint256 ID of the token being burned by the msg.sender */ - function _burn(address _owner, uint256 _tokenId) internal { - super._burn(_owner, _tokenId); + function _burn(address owner, uint256 tokenId) internal { + super._burn(owner, tokenId); // Clear metadata (if any) - if (bytes(tokenURIs_[_tokenId]).length != 0) { - delete tokenURIs_[_tokenId]; + if (bytes(_tokenURIs[tokenId]).length != 0) { + delete _tokenURIs[tokenId]; } // Reorg all tokens array - uint256 tokenIndex = allTokensIndex_[_tokenId]; - uint256 lastTokenIndex = allTokens_.length.sub(1); - uint256 lastToken = allTokens_[lastTokenIndex]; + uint256 tokenIndex = _allTokensIndex[tokenId]; + uint256 lastTokenIndex = _allTokens.length.sub(1); + uint256 lastToken = _allTokens[lastTokenIndex]; - allTokens_[tokenIndex] = lastToken; - allTokens_[lastTokenIndex] = 0; + _allTokens[tokenIndex] = lastToken; + _allTokens[lastTokenIndex] = 0; - allTokens_.length--; - allTokensIndex_[_tokenId] = 0; - allTokensIndex_[lastToken] = tokenIndex; + _allTokens.length--; + _allTokensIndex[tokenId] = 0; + _allTokensIndex[lastToken] = tokenIndex; } } diff --git a/contracts/token/ERC721/ERC721Basic.sol b/contracts/token/ERC721/ERC721Basic.sol index 866640a0f4d..ea15012a168 100644 --- a/contracts/token/ERC721/ERC721Basic.sol +++ b/contracts/token/ERC721/ERC721Basic.sol @@ -18,21 +18,21 @@ contract ERC721Basic is ERC165, IERC721Basic { // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` - bytes4 private constant ERC721_RECEIVED = 0x150b7a02; + bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from token ID to owner - mapping (uint256 => address) private tokenOwner_; + mapping (uint256 => address) private _tokenOwner; // Mapping from token ID to approved address - mapping (uint256 => address) private tokenApprovals_; + mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to number of owned token - mapping (address => uint256) private ownedTokensCount_; + mapping (address => uint256) private _ownedTokensCount; // Mapping from owner to operator approvals - mapping (address => mapping (address => bool)) private operatorApprovals_; + mapping (address => mapping (address => bool)) private _operatorApprovals; - bytes4 private constant InterfaceId_ERC721 = 0x80ac58cd; + bytes4 private constant _InterfaceId_ERC721 = 0x80ac58cd; /* * 0x80ac58cd === * bytes4(keccak256('balanceOf(address)')) ^ @@ -50,26 +50,26 @@ contract ERC721Basic is ERC165, IERC721Basic { public { // register the supported interfaces to conform to ERC721 via ERC165 - _registerInterface(InterfaceId_ERC721); + _registerInterface(_InterfaceId_ERC721); } /** * @dev Gets the balance of the specified address - * @param _owner address to query the balance of + * @param owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ - function balanceOf(address _owner) public view returns (uint256) { - require(_owner != address(0)); - return ownedTokensCount_[_owner]; + function balanceOf(address owner) public view returns (uint256) { + require(owner != address(0)); + return _ownedTokensCount[owner]; } /** * @dev Gets the owner of the specified token ID - * @param _tokenId uint256 ID of the token to query the owner of + * @param tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ - function ownerOf(uint256 _tokenId) public view returns (address) { - address owner = tokenOwner_[_tokenId]; + function ownerOf(uint256 tokenId) public view returns (address) { + address owner = _tokenOwner[tokenId]; require(owner != address(0)); return owner; } @@ -79,81 +79,80 @@ contract ERC721Basic is ERC165, IERC721Basic { * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. - * @param _to address to be approved for the given token ID - * @param _tokenId uint256 ID of the token to be approved + * @param to address to be approved for the given token ID + * @param tokenId uint256 ID of the token to be approved */ - function approve(address _to, uint256 _tokenId) public { - address owner = ownerOf(_tokenId); - require(_to != owner); + function approve(address to, uint256 tokenId) public { + address owner = ownerOf(tokenId); + require(to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); - tokenApprovals_[_tokenId] = _to; - emit Approval(owner, _to, _tokenId); + _tokenApprovals[tokenId] = to; + emit Approval(owner, to, tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set - * Reverts if the token ID does not exist. - * @param _tokenId uint256 ID of the token to query the approval of + * @param tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ - function getApproved(uint256 _tokenId) public view returns (address) { - require(_exists(_tokenId)); - return tokenApprovals_[_tokenId]; + function getApproved(uint256 tokenId) public view returns (address) { + require(_exists(tokenId)); + return _tokenApprovals[tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf - * @param _to operator address to set the approval - * @param _approved representing the status of the approval to be set + * @param to operator address to set the approval + * @param approved representing the status of the approval to be set */ - function setApprovalForAll(address _to, bool _approved) public { - require(_to != msg.sender); - operatorApprovals_[msg.sender][_to] = _approved; - emit ApprovalForAll(msg.sender, _to, _approved); + function setApprovalForAll(address to, bool approved) public { + require(to != msg.sender); + _operatorApprovals[msg.sender][to] = approved; + emit ApprovalForAll(msg.sender, to, approved); } /** * @dev Tells whether an operator is approved by a given owner - * @param _owner owner address which you want to query the approval of - * @param _operator operator address which you want to query the approval of + * @param owner owner address which you want to query the approval of + * @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 + address owner, + address operator ) public view returns (bool) { - return operatorApprovals_[_owner][_operator]; + return _operatorApprovals[owner][operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator - * @param _from current owner of the token - * @param _to address to receive the ownership of the given token ID - * @param _tokenId uint256 ID of the token to be transferred + * @param from current owner of the token + * @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 + address from, + address to, + uint256 tokenId ) public { - require(_isApprovedOrOwner(msg.sender, _tokenId)); - require(_to != address(0)); + require(_isApprovedOrOwner(msg.sender, tokenId)); + require(to != address(0)); - _clearApproval(_from, _tokenId); - _removeTokenFrom(_from, _tokenId); - _addTokenTo(_to, _tokenId); + _clearApproval(from, tokenId); + _removeTokenFrom(from, tokenId); + _addTokenTo(to, tokenId); - emit Transfer(_from, _to, _tokenId); + emit Transfer(from, to, tokenId); } /** @@ -164,19 +163,19 @@ contract ERC721Basic is ERC165, IERC721Basic { * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator - * @param _from current owner of the token - * @param _to address to receive the ownership of the given token ID - * @param _tokenId uint256 ID of the token to be transferred + * @param from current owner of the token + * @param to address to receive the ownership of the given token ID + * @param tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( - address _from, - address _to, - uint256 _tokenId + address from, + address to, + uint256 tokenId ) public { // solium-disable-next-line arg-overflow - safeTransferFrom(_from, _to, _tokenId, ""); + safeTransferFrom(from, to, tokenId, ""); } /** @@ -186,141 +185,141 @@ contract ERC721Basic is ERC165, IERC721Basic { * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator - * @param _from current owner of the token - * @param _to address to receive the ownership of the given token ID - * @param _tokenId uint256 ID of the token to be transferred - * @param _data bytes data to send along with a safe transfer check + * @param from current owner of the token + * @param to address to receive the ownership of the given token ID + * @param tokenId uint256 ID of the token to be transferred + * @param data bytes data to send along with a safe transfer check */ function safeTransferFrom( - address _from, - address _to, - uint256 _tokenId, - bytes _data + address from, + address to, + uint256 tokenId, + bytes data ) public { - transferFrom(_from, _to, _tokenId); + transferFrom(from, to, tokenId); // solium-disable-next-line arg-overflow - require(_checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); + require(_checkAndCallSafeTransfer(from, to, tokenId, data)); } /** * @dev Returns whether the specified token exists - * @param _tokenId uint256 ID of the token to query the existence of + * @param tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ - function _exists(uint256 _tokenId) internal view returns (bool) { - address owner = tokenOwner_[_tokenId]; + function _exists(uint256 tokenId) internal view returns (bool) { + address owner = _tokenOwner[tokenId]; return owner != address(0); } /** * @dev Returns whether the given spender can transfer a given token ID - * @param _spender address of the spender to query - * @param _tokenId uint256 ID of the token to be transferred + * @param spender address of the spender to query + * @param tokenId uint256 ID of the token to be transferred * @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 + address spender, + uint256 tokenId ) internal view returns (bool) { - address owner = ownerOf(_tokenId); + address owner = ownerOf(tokenId); // 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) + spender == owner || + getApproved(tokenId) == spender || + isApprovedForAll(owner, spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists - * @param _to The address that will own the minted token - * @param _tokenId uint256 ID of the token to be minted by the msg.sender + * @param to The address that will own the minted token + * @param tokenId uint256 ID of the token to be minted by the msg.sender */ - function _mint(address _to, uint256 _tokenId) internal { - require(_to != address(0)); - _addTokenTo(_to, _tokenId); - emit Transfer(address(0), _to, _tokenId); + function _mint(address to, uint256 tokenId) internal { + require(to != address(0)); + _addTokenTo(to, tokenId); + emit Transfer(address(0), to, tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist - * @param _tokenId uint256 ID of the token being burned by the msg.sender + * @param tokenId uint256 ID of the token being burned by the msg.sender */ - function _burn(address _owner, uint256 _tokenId) internal { - _clearApproval(_owner, _tokenId); - _removeTokenFrom(_owner, _tokenId); - emit Transfer(_owner, address(0), _tokenId); + function _burn(address owner, uint256 tokenId) internal { + _clearApproval(owner, tokenId); + _removeTokenFrom(owner, tokenId); + emit Transfer(owner, address(0), tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token - * @param _owner owner of the token - * @param _tokenId uint256 ID of the token to be transferred + * @param owner owner of the token + * @param tokenId uint256 ID of the token to be transferred */ - function _clearApproval(address _owner, uint256 _tokenId) internal { - require(ownerOf(_tokenId) == _owner); - if (tokenApprovals_[_tokenId] != address(0)) { - tokenApprovals_[_tokenId] = address(0); + function _clearApproval(address owner, uint256 tokenId) internal { + require(ownerOf(tokenId) == owner); + if (_tokenApprovals[tokenId] != address(0)) { + _tokenApprovals[tokenId] = address(0); } } /** * @dev Internal function to add a token ID to the list of a given address - * @param _to address representing the new owner of the given token ID - * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address + * @param to address representing the new owner of the given token ID + * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ - function _addTokenTo(address _to, uint256 _tokenId) internal { - require(tokenOwner_[_tokenId] == address(0)); - tokenOwner_[_tokenId] = _to; - ownedTokensCount_[_to] = ownedTokensCount_[_to].add(1); + function _addTokenTo(address to, uint256 tokenId) internal { + require(_tokenOwner[tokenId] == address(0)); + _tokenOwner[tokenId] = to; + _ownedTokensCount[to] = _ownedTokensCount[to].add(1); } /** * @dev Internal function to remove a token ID from the list of a given address - * @param _from address representing the previous owner of the given token ID - * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address + * @param from address representing the previous owner of the given token ID + * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ - function _removeTokenFrom(address _from, uint256 _tokenId) internal { - require(ownerOf(_tokenId) == _from); - ownedTokensCount_[_from] = ownedTokensCount_[_from].sub(1); - tokenOwner_[_tokenId] = address(0); + function _removeTokenFrom(address from, uint256 tokenId) internal { + require(ownerOf(tokenId) == from); + _ownedTokensCount[from] = _ownedTokensCount[from].sub(1); + _tokenOwner[tokenId] = address(0); } /** * @dev Internal function to invoke `onERC721Received` on a target address * The call is not executed if the target address is not a contract - * @param _from address representing the previous owner of the given token ID - * @param _to target address that will receive the tokens - * @param _tokenId uint256 ID of the token to be transferred - * @param _data bytes optional data to send along with the call + * @param from address representing the previous owner of the given token ID + * @param to target address that will receive the tokens + * @param tokenId uint256 ID of the token to be transferred + * @param data bytes optional data to send along with the call * @return whether the call correctly returned the expected magic value */ function _checkAndCallSafeTransfer( - address _from, - address _to, - uint256 _tokenId, - bytes _data + address from, + address to, + uint256 tokenId, + bytes data ) internal returns (bool) { - if (!_to.isContract()) { + if (!to.isContract()) { return true; } - bytes4 retval = IERC721Receiver(_to).onERC721Received( - msg.sender, _from, _tokenId, _data); - return (retval == ERC721_RECEIVED); + bytes4 retval = IERC721Receiver(to).onERC721Received( + msg.sender, from, tokenId, data); + return (retval == _ERC721_RECEIVED); } } diff --git a/contracts/token/ERC721/ERC721Burnable.sol b/contracts/token/ERC721/ERC721Burnable.sol index ea42dab0528..3195cd42429 100644 --- a/contracts/token/ERC721/ERC721Burnable.sol +++ b/contracts/token/ERC721/ERC721Burnable.sol @@ -4,10 +4,10 @@ import "./ERC721.sol"; contract ERC721Burnable is ERC721 { - function burn(uint256 _tokenId) + function burn(uint256 tokenId) public { - require(_isApprovedOrOwner(msg.sender, _tokenId)); - _burn(ownerOf(_tokenId), _tokenId); + require(_isApprovedOrOwner(msg.sender, tokenId)); + _burn(ownerOf(tokenId), tokenId); } } diff --git a/contracts/token/ERC721/ERC721Mintable.sol b/contracts/token/ERC721/ERC721Mintable.sol index adee3595200..481fa471563 100644 --- a/contracts/token/ERC721/ERC721Mintable.sol +++ b/contracts/token/ERC721/ERC721Mintable.sol @@ -12,10 +12,10 @@ contract ERC721Mintable is ERC721, MinterRole { event Minted(address indexed to, uint256 tokenId); event MintingFinished(); - bool private mintingFinished_ = false; + bool private _mintingFinished = false; modifier onlyBeforeMintingFinished() { - require(!mintingFinished_); + require(!_mintingFinished); _; } @@ -23,41 +23,41 @@ contract ERC721Mintable is ERC721, MinterRole { * @return true if the minting is finished. */ function mintingFinished() public view returns(bool) { - return mintingFinished_; + return _mintingFinished; } /** * @dev Function to mint tokens - * @param _to The address that will receive the minted tokens. - * @param _tokenId The token id to mint. + * @param to The address that will receive the minted tokens. + * @param tokenId The token id to mint. * @return A boolean that indicates if the operation was successful. */ function mint( - address _to, - uint256 _tokenId + address to, + uint256 tokenId ) public onlyMinter onlyBeforeMintingFinished returns (bool) { - _mint(_to, _tokenId); - emit Minted(_to, _tokenId); + _mint(to, tokenId); + emit Minted(to, tokenId); return true; } function mintWithTokenURI( - address _to, - uint256 _tokenId, - string _tokenURI + address to, + uint256 tokenId, + string tokenURI ) public onlyMinter onlyBeforeMintingFinished returns (bool) { - mint(_to, _tokenId); - _setTokenURI(_tokenId, _tokenURI); + mint(to, tokenId); + _setTokenURI(tokenId, tokenURI); return true; } @@ -71,7 +71,7 @@ contract ERC721Mintable is ERC721, MinterRole { onlyBeforeMintingFinished returns (bool) { - mintingFinished_ = true; + _mintingFinished = true; emit MintingFinished(); return true; } diff --git a/contracts/token/ERC721/ERC721Pausable.sol b/contracts/token/ERC721/ERC721Pausable.sol index 4604597d923..0378373a957 100644 --- a/contracts/token/ERC721/ERC721Pausable.sol +++ b/contracts/token/ERC721/ERC721Pausable.sol @@ -10,33 +10,33 @@ import "../../lifecycle/Pausable.sol"; **/ contract ERC721Pausable is ERC721Basic, Pausable { function approve( - address _to, - uint256 _tokenId + address to, + uint256 tokenId ) public whenNotPaused { - super.approve(_to, _tokenId); + super.approve(to, tokenId); } function setApprovalForAll( - address _to, - bool _approved + address to, + bool approved ) public whenNotPaused { - super.setApprovalForAll(_to, _approved); + super.setApprovalForAll(to, approved); } function transferFrom( - address _from, - address _to, - uint256 _tokenId + address from, + address to, + uint256 tokenId ) public whenNotPaused { - super.transferFrom(_from, _to, _tokenId); + super.transferFrom(from, to, tokenId); } } diff --git a/contracts/token/ERC721/IERC721.sol b/contracts/token/ERC721/IERC721.sol index 24b7e01ceeb..ebf7060a199 100644 --- a/contracts/token/ERC721/IERC721.sol +++ b/contracts/token/ERC721/IERC721.sol @@ -10,14 +10,14 @@ import "./IERC721Basic.sol"; contract IERC721Enumerable is IERC721Basic { function totalSupply() public view returns (uint256); function tokenOfOwnerByIndex( - address _owner, - uint256 _index + address owner, + uint256 index ) public view - returns (uint256 _tokenId); + returns (uint256 tokenId); - function tokenByIndex(uint256 _index) public view returns (uint256); + function tokenByIndex(uint256 index) public view returns (uint256); } @@ -26,9 +26,9 @@ contract IERC721Enumerable is IERC721Basic { * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */ contract IERC721Metadata is IERC721Basic { - function name() external view returns (string _name); - function symbol() external view returns (string _symbol); - function tokenURI(uint256 _tokenId) public view returns (string); + function name() external view returns (string); + function symbol() external view returns (string); + function tokenURI(uint256 tokenId) public view returns (string); } diff --git a/contracts/token/ERC721/IERC721Basic.sol b/contracts/token/ERC721/IERC721Basic.sol index 6e71d1cf589..9dc6d946885 100644 --- a/contracts/token/ERC721/IERC721Basic.sol +++ b/contracts/token/ERC721/IERC721Basic.sol @@ -25,26 +25,26 @@ contract IERC721Basic is IERC165 { bool approved ); - function balanceOf(address _owner) public view returns (uint256 _balance); - function ownerOf(uint256 _tokenId) public view returns (address _owner); + function balanceOf(address owner) public view returns (uint256 balance); + function ownerOf(uint256 tokenId) public view returns (address owner); - function approve(address _to, uint256 _tokenId) public; - function getApproved(uint256 _tokenId) - public view returns (address _operator); + function approve(address to, uint256 tokenId) public; + function getApproved(uint256 tokenId) + public view returns (address operator); - function setApprovalForAll(address _operator, bool _approved) public; - function isApprovedForAll(address _owner, address _operator) + function setApprovalForAll(address operator, bool approved) public; + 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) + 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, - bytes _data + address from, + address to, + uint256 tokenId, + bytes data ) public; } diff --git a/contracts/token/ERC721/IERC721Receiver.sol b/contracts/token/ERC721/IERC721Receiver.sol index a94fabc77b0..946582f7ed2 100644 --- a/contracts/token/ERC721/IERC721Receiver.sol +++ b/contracts/token/ERC721/IERC721Receiver.sol @@ -15,17 +15,17 @@ contract IERC721Receiver { * returned can be obtained as `this.onERC721Received.selector`. This * function MAY throw to revert and reject the transfer. * Note: the ERC721 contract address is always the message sender. - * @param _operator The address which called `safeTransferFrom` function - * @param _from The address which previously owned the token - * @param _tokenId The NFT identifier which is being transferred - * @param _data Additional data with no specified format + * @param operator The address which called `safeTransferFrom` function + * @param from The address which previously owned the token + * @param tokenId The NFT identifier which is being transferred + * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` */ function onERC721Received( - address _operator, - address _from, - uint256 _tokenId, - bytes _data + address operator, + address from, + uint256 tokenId, + bytes data ) public returns(bytes4); diff --git a/contracts/utils/Address.sol b/contracts/utils/Address.sol index 7c972200518..1f27c93f101 100644 --- a/contracts/utils/Address.sol +++ b/contracts/utils/Address.sol @@ -10,10 +10,10 @@ library Address { * Returns whether the target address is a contract * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. - * @param _account address of the account to check + * @param account address of the account to check * @return whether the target address is a contract */ - function isContract(address _account) internal view returns (bool) { + function isContract(address account) internal view returns (bool) { uint256 size; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. @@ -22,7 +22,7 @@ library Address { // TODO Check this again before the Serenity release, because all addresses will be // contracts then. // solium-disable-next-line security/no-inline-assembly - assembly { size := extcodesize(_account) } + assembly { size := extcodesize(account) } return size > 0; } diff --git a/contracts/utils/AutoIncrementing.sol b/contracts/utils/AutoIncrementing.sol index 8c01861fb68..f739e539d8e 100644 --- a/contracts/utils/AutoIncrementing.sol +++ b/contracts/utils/AutoIncrementing.sol @@ -19,11 +19,11 @@ library AutoIncrementing { uint256 prevId; // default: 0 } - function nextId(Counter storage _counter) + function nextId(Counter storage counter) internal returns (uint256) { - _counter.prevId = _counter.prevId + 1; - return _counter.prevId; + counter.prevId = counter.prevId + 1; + return counter.prevId; } } diff --git a/contracts/utils/ReentrancyGuard.sol b/contracts/utils/ReentrancyGuard.sol index c588df5b925..7f232cce579 100644 --- a/contracts/utils/ReentrancyGuard.sol +++ b/contracts/utils/ReentrancyGuard.sol @@ -10,7 +10,7 @@ pragma solidity ^0.4.24; contract ReentrancyGuard { /// @dev counter to allow mutex lock with only one SSTORE operation - uint256 private guardCounter = 1; + uint256 private _guardCounter = 1; /** * @dev Prevents a contract from calling itself, directly or indirectly. @@ -21,10 +21,10 @@ contract ReentrancyGuard { * wrapper marked as `nonReentrant`. */ modifier nonReentrant() { - guardCounter += 1; - uint256 localCounter = guardCounter; + _guardCounter += 1; + uint256 localCounter = _guardCounter; _; - require(localCounter == guardCounter); + require(localCounter == _guardCounter); } }