Replace constant with view/pure

pull/573/head
Alejandro Santander 7 years ago
parent e6213767fa
commit 815d9e1f45
  1. 0
      .node-xmlhttprequest-sync-22450
  2. 2
      contracts/DayLimit.sol
  3. 2
      contracts/ECRecovery.sol
  4. 2
      contracts/MerkleProof.sol
  5. 4
      contracts/crowdsale/CappedCrowdsale.sol
  6. 4
      contracts/crowdsale/Crowdsale.sol
  7. 2
      contracts/crowdsale/RefundableCrowdsale.sol
  8. 8
      contracts/math/Math.sol
  9. 8
      contracts/math/SafeMath.sol
  10. 2
      contracts/token/BasicToken.sol
  11. 2
      contracts/token/ERC20.sol
  12. 2
      contracts/token/ERC20Basic.sol
  13. 2
      contracts/token/StandardToken.sol
  14. 4
      contracts/token/TokenVesting.sol

@ -59,7 +59,7 @@ contract DayLimit {
* @dev Private function to determine today's index * @dev Private function to determine today's index
* @return uint256 of 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; return now / 1 days;
} }

@ -14,7 +14,7 @@ library ECRecovery {
* @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address. * @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() * @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 r;
bytes32 s; bytes32 s;
uint8 v; uint8 v;

@ -13,7 +13,7 @@ library MerkleProof {
* @param _root Merkle root * @param _root Merkle root
* @param _leaf Leaf of Merkle tree * @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 // Check if proof length is a multiple of 32
if (_proof.length % 32 != 0) return false; if (_proof.length % 32 != 0) return false;

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

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

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

@ -6,19 +6,19 @@ pragma solidity ^0.4.18;
*/ */
library Math { 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; 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; 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; 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; return a < b ? a : b;
} }
} }

@ -6,7 +6,7 @@ pragma solidity ^0.4.18;
* @dev Math operations with safety checks that throw on error * @dev Math operations with safety checks that throw on error
*/ */
library SafeMath { 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) { if (a == 0) {
return 0; return 0;
} }
@ -15,19 +15,19 @@ library SafeMath {
return c; 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 // assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b; uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold // assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c; 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); assert(b <= a);
return a - b; 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; uint256 c = a + b;
assert(c >= a); assert(c >= a);
return c; return c;

@ -35,7 +35,7 @@ contract BasicToken is ERC20Basic {
* @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. * @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]; return balances[_owner];
} }

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

@ -8,7 +8,7 @@ pragma solidity ^0.4.18;
*/ */
contract ERC20Basic { contract ERC20Basic {
uint256 public totalSupply; 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); function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value);
} }

@ -57,7 +57,7 @@ contract StandardToken is ERC20, BasicToken {
* @param _spender address The address which will spend 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. * @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]; return allowed[_owner][_spender];
} }

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

Loading…
Cancel
Save