Parcourir la source

Replace constant with view/pure

Alejandro Santander il y a 7 ans
Parent
commit
815d9e1f45

+ 0 - 0
.node-xmlhttprequest-sync-22450


+ 1 - 1
contracts/DayLimit.sol

@@ -59,7 +59,7 @@ contract DayLimit {
    * @dev Private function to determine today's index
    * @return uint256 of today's index.
    */
-  function today() private constant returns (uint256) {
+  function today() private view returns (uint256) {
     return now / 1 days;
   }
 

+ 1 - 1
contracts/ECRecovery.sol

@@ -14,7 +14,7 @@ library ECRecovery {
    * @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address.
    * @param sig bytes signature, the signature is generated using web3.eth.sign()
    */
-  function recover(bytes32 hash, bytes sig) public constant returns (address) {
+  function recover(bytes32 hash, bytes sig) public pure returns (address) {
     bytes32 r;
     bytes32 s;
     uint8 v;

+ 1 - 1
contracts/MerkleProof.sol

@@ -13,7 +13,7 @@ library MerkleProof {
    * @param _root Merkle root
    * @param _leaf Leaf of Merkle tree
    */
-  function verifyProof(bytes _proof, bytes32 _root, bytes32 _leaf) constant returns (bool) {
+  function verifyProof(bytes _proof, bytes32 _root, bytes32 _leaf) pure returns (bool) {
     // Check if proof length is a multiple of 32
     if (_proof.length % 32 != 0) return false;
 

+ 2 - 2
contracts/crowdsale/CappedCrowdsale.sol

@@ -19,14 +19,14 @@ contract CappedCrowdsale is Crowdsale {
 
   // overriding Crowdsale#validPurchase to add extra cap logic
   // @return true if investors can buy at the moment
-  function validPurchase() internal constant returns (bool) {
+  function validPurchase() internal view returns (bool) {
     bool withinCap = weiRaised.add(msg.value) <= cap;
     return super.validPurchase() && withinCap;
   }
 
   // overriding Crowdsale#hasEnded to add cap logic
   // @return true if crowdsale event has ended
-  function hasEnded() public constant returns (bool) {
+  function hasEnded() public view returns (bool) {
     bool capReached = weiRaised >= cap;
     return super.hasEnded() || capReached;
   }

+ 2 - 2
contracts/crowdsale/Crowdsale.sol

@@ -91,14 +91,14 @@ contract Crowdsale {
   }
 
   // @return true if the transaction can buy tokens
-  function validPurchase() internal constant returns (bool) {
+  function validPurchase() internal view returns (bool) {
     bool withinPeriod = now >= startTime && now <= endTime;
     bool nonZeroPurchase = msg.value != 0;
     return withinPeriod && nonZeroPurchase;
   }
 
   // @return true if crowdsale event has ended
-  function hasEnded() public constant returns (bool) {
+  function hasEnded() public view returns (bool) {
     return now > endTime;
   }
 

+ 1 - 1
contracts/crowdsale/RefundableCrowdsale.sol

@@ -53,7 +53,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
     super.finalization();
   }
 
-  function goalReached() public constant returns (bool) {
+  function goalReached() public view returns (bool) {
     return weiRaised >= goal;
   }
 

+ 4 - 4
contracts/math/Math.sol

@@ -6,19 +6,19 @@ pragma solidity ^0.4.18;
  */
 
 library Math {
-  function max64(uint64 a, uint64 b) internal constant returns (uint64) {
+  function max64(uint64 a, uint64 b) internal pure returns (uint64) {
     return a >= b ? a : b;
   }
 
-  function min64(uint64 a, uint64 b) internal constant returns (uint64) {
+  function min64(uint64 a, uint64 b) internal pure returns (uint64) {
     return a < b ? a : b;
   }
 
-  function max256(uint256 a, uint256 b) internal constant returns (uint256) {
+  function max256(uint256 a, uint256 b) internal pure returns (uint256) {
     return a >= b ? a : b;
   }
 
-  function min256(uint256 a, uint256 b) internal constant returns (uint256) {
+  function min256(uint256 a, uint256 b) internal pure returns (uint256) {
     return a < b ? a : b;
   }
 }

+ 4 - 4
contracts/math/SafeMath.sol

@@ -6,7 +6,7 @@ pragma solidity ^0.4.18;
  * @dev Math operations with safety checks that throw on error
  */
 library SafeMath {
-  function mul(uint256 a, uint256 b) internal constant returns (uint256) {
+  function mul(uint256 a, uint256 b) internal pure returns (uint256) {
     if (a == 0) {
       return 0;
     }
@@ -15,19 +15,19 @@ library SafeMath {
     return c;
   }
 
-  function div(uint256 a, uint256 b) internal constant returns (uint256) {
+  function div(uint256 a, uint256 b) internal pure returns (uint256) {
     // assert(b > 0); // Solidity automatically throws 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;
   }
 
-  function sub(uint256 a, uint256 b) internal constant returns (uint256) {
+  function sub(uint256 a, uint256 b) internal pure returns (uint256) {
     assert(b <= a);
     return a - b;
   }
 
-  function add(uint256 a, uint256 b) internal constant returns (uint256) {
+  function add(uint256 a, uint256 b) internal pure returns (uint256) {
     uint256 c = a + b;
     assert(c >= a);
     return c;

+ 1 - 1
contracts/token/BasicToken.sol

@@ -35,7 +35,7 @@ contract BasicToken is ERC20Basic {
   * @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 constant returns (uint256 balance) {
+  function balanceOf(address _owner) public view returns (uint256 balance) {
     return balances[_owner];
   }
 

+ 1 - 1
contracts/token/ERC20.sol

@@ -9,7 +9,7 @@ import './ERC20Basic.sol';
  * @dev see https://github.com/ethereum/EIPs/issues/20
  */
 contract ERC20 is ERC20Basic {
-  function allowance(address owner, address spender) public constant returns (uint256);
+  function allowance(address owner, address spender) public view returns (uint256);
   function transferFrom(address from, address to, uint256 value) public returns (bool);
   function approve(address spender, uint256 value) public returns (bool);
   event Approval(address indexed owner, address indexed spender, uint256 value);

+ 1 - 1
contracts/token/ERC20Basic.sol

@@ -8,7 +8,7 @@ pragma solidity ^0.4.18;
  */
 contract ERC20Basic {
   uint256 public totalSupply;
-  function balanceOf(address who) public constant returns (uint256);
+  function balanceOf(address who) public view returns (uint256);
   function transfer(address to, uint256 value) public returns (bool);
   event Transfer(address indexed from, address indexed to, uint256 value);
 }

+ 1 - 1
contracts/token/StandardToken.sol

@@ -57,7 +57,7 @@ contract StandardToken is ERC20, BasicToken {
    * @param _spender address The address which will spend the funds.
    * @return A uint256 specifying the amount of tokens still available for the spender.
    */
-  function allowance(address _owner, address _spender) public constant returns (uint256) {
+  function allowance(address _owner, address _spender) public view returns (uint256) {
     return allowed[_owner][_spender];
   }
 

+ 2 - 2
contracts/token/TokenVesting.sol

@@ -91,7 +91,7 @@ contract TokenVesting is Ownable {
    * @dev Calculates the amount that has already vested but hasn't been released yet.
    * @param token ERC20 token which is being vested
    */
-  function releasableAmount(ERC20Basic token) public constant returns (uint256) {
+  function releasableAmount(ERC20Basic token) public view returns (uint256) {
     return vestedAmount(token).sub(released[token]);
   }
 
@@ -99,7 +99,7 @@ contract TokenVesting is Ownable {
    * @dev Calculates the amount that has already vested.
    * @param token ERC20 token which is being vested
    */
-  function vestedAmount(ERC20Basic token) public constant returns (uint256) {
+  function vestedAmount(ERC20Basic token) public view returns (uint256) {
     uint256 currentBalance = token.balanceOf(this);
     uint256 totalBalance = currentBalance.add(released[token]);