mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Update compilation tests.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,14 +18,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;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ contract Crowdsale {
|
||||
}
|
||||
|
||||
// @return true if the transaction can buy tokens
|
||||
function validPurchase() internal constant returns (bool) {
|
||||
function validPurchase() internal view returns (bool) {
|
||||
uint256 current = block.number;
|
||||
bool withinPeriod = current >= startBlock && current <= endBlock;
|
||||
bool nonZeroPurchase = msg.value != 0;
|
||||
@@ -100,7 +100,7 @@ contract Crowdsale {
|
||||
}
|
||||
|
||||
// @return true if crowdsale event has ended
|
||||
function hasEnded() public constant returns (bool) {
|
||||
function hasEnded() public view returns (bool) {
|
||||
return block.number > endBlock;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
|
||||
super.finalization();
|
||||
}
|
||||
|
||||
function goalReached() public constant returns (bool) {
|
||||
function goalReached() public view returns (bool) {
|
||||
return weiRaised >= goal;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,19 +6,19 @@ pragma solidity ^0.4.11;
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,25 +6,25 @@ pragma solidity ^0.4.11;
|
||||
* @dev Math operations with safety checks that throw on error
|
||||
*/
|
||||
library SafeMath {
|
||||
function mul(uint256 a, uint256 b) internal returns (uint256) {
|
||||
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
uint256 c = a * b;
|
||||
assert(a == 0 || c / a == b);
|
||||
return c;
|
||||
}
|
||||
|
||||
function div(uint256 a, uint256 b) internal 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 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 returns (uint256) {
|
||||
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
||||
uint256 c = a + b;
|
||||
assert(c >= a);
|
||||
return c;
|
||||
|
||||
@@ -96,7 +96,7 @@ contract Shareable {
|
||||
* @param ownerIndex uint256 The index of the owner
|
||||
* @return The address of the owner
|
||||
*/
|
||||
function getOwner(uint256 ownerIndex) external constant returns (address) {
|
||||
function getOwner(uint256 ownerIndex) external view returns (address) {
|
||||
return address(owners[ownerIndex + 1]);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ contract Shareable {
|
||||
* @param _addr address The address which you want to check.
|
||||
* @return True if the address is an owner and fase otherwise.
|
||||
*/
|
||||
function isOwner(address _addr) constant returns (bool) {
|
||||
function isOwner(address _addr) view returns (bool) {
|
||||
return ownerIndex[_addr] > 0;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ contract Shareable {
|
||||
* @param _owner The owner address.
|
||||
* @return True if the owner has confirmed and false otherwise.
|
||||
*/
|
||||
function hasConfirmed(bytes32 _operation, address _owner) constant returns (bool) {
|
||||
function hasConfirmed(bytes32 _operation, address _owner) view returns (bool) {
|
||||
PendingState memory pending = pendings[_operation];
|
||||
uint256 index = ownerIndex[_owner];
|
||||
|
||||
|
||||
@@ -30,7 +30,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) constant returns (uint256 balance) {
|
||||
function balanceOf(address _owner) view returns (uint256 balance) {
|
||||
return balances[_owner];
|
||||
}
|
||||
|
||||
|
||||
@@ -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) constant returns (uint256);
|
||||
function allowance(address owner, address spender) view returns (uint256);
|
||||
function transferFrom(address from, address to, uint256 value);
|
||||
function approve(address spender, uint256 value);
|
||||
event Approval(address indexed owner, address indexed spender, uint256 value);
|
||||
|
||||
@@ -8,7 +8,7 @@ pragma solidity ^0.4.11;
|
||||
*/
|
||||
contract ERC20Basic {
|
||||
uint256 public totalSupply;
|
||||
function balanceOf(address who) constant returns (uint256);
|
||||
function balanceOf(address who) view returns (uint256);
|
||||
function transfer(address to, uint256 value);
|
||||
event Transfer(address indexed from, address indexed to, uint256 value);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import "./ERC20.sol";
|
||||
* LimitedTransferToken has been designed to allow for different limiting factors,
|
||||
* this can be achieved by recursively calling super.transferableTokens() until the base class is
|
||||
* hit. For example:
|
||||
* function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
|
||||
* function transferableTokens(address holder, uint64 time) view public returns (uint256) {
|
||||
* return min256(unlockedTokens, super.transferableTokens(holder, time));
|
||||
* }
|
||||
* A working example is VestedToken.sol:
|
||||
@@ -51,7 +51,7 @@ contract LimitedTransferToken is ERC20 {
|
||||
* @dev Overwriting transferableTokens(address holder, uint64 time) is the way to provide the
|
||||
* specific logic for limiting token transferability for a holder over time.
|
||||
*/
|
||||
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
|
||||
function transferableTokens(address holder, uint64 time) view public returns (uint256) {
|
||||
return balanceOf(holder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ contract StandardToken is ERC20, BasicToken {
|
||||
* @param _spender address The address which will spend the funds.
|
||||
* @return A uint256 specifing the amount of tokens still avaible for the spender.
|
||||
*/
|
||||
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
|
||||
function allowance(address _owner, address _spender) view returns (uint256 remaining) {
|
||||
return allowed[_owner][_spender];
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
|
||||
* @param time uint64 The specific time.
|
||||
* @return An uint256 representing a holder's total amount of transferable tokens.
|
||||
*/
|
||||
function transferableTokens(address holder, uint64 time) constant public returns (uint256) {
|
||||
function transferableTokens(address holder, uint64 time) view public returns (uint256) {
|
||||
uint256 grantIndex = tokenGrantsCount(holder);
|
||||
|
||||
if (grantIndex == 0) return balanceOf(holder); // shortcut for holder without grants
|
||||
@@ -130,7 +130,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
|
||||
* @param _holder The holder of the grants.
|
||||
* @return A uint256 representing the total amount of grants.
|
||||
*/
|
||||
function tokenGrantsCount(address _holder) constant returns (uint256 index) {
|
||||
function tokenGrantsCount(address _holder) view returns (uint256 index) {
|
||||
return grants[_holder].length;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
|
||||
uint256 time,
|
||||
uint256 start,
|
||||
uint256 cliff,
|
||||
uint256 vesting) constant returns (uint256)
|
||||
uint256 vesting) view returns (uint256)
|
||||
{
|
||||
// Shortcuts for before cliff and after vesting cases.
|
||||
if (time < cliff) return 0;
|
||||
@@ -192,7 +192,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
|
||||
* @return Returns all the values that represent a TokenGrant(address, value, start, cliff,
|
||||
* revokability, burnsOnRevoke, and vesting) plus the vested value at the current time.
|
||||
*/
|
||||
function tokenGrant(address _holder, uint256 _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) {
|
||||
function tokenGrant(address _holder, uint256 _grantId) view returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting, bool revokable, bool burnsOnRevoke) {
|
||||
TokenGrant grant = grants[_holder][_grantId];
|
||||
|
||||
granter = grant.granter;
|
||||
@@ -212,7 +212,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
|
||||
* @param time The time to be checked
|
||||
* @return An uint256 representing the amount of vested tokens of a specific grant at a specific time.
|
||||
*/
|
||||
function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
|
||||
function vestedTokens(TokenGrant grant, uint64 time) private view returns (uint256) {
|
||||
return calculateVestedTokens(
|
||||
grant.value,
|
||||
uint256(time),
|
||||
@@ -229,7 +229,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
|
||||
* @return An uint256 representing the amount of non vested tokens of a specifc grant on the
|
||||
* passed time frame.
|
||||
*/
|
||||
function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) {
|
||||
function nonVestedTokens(TokenGrant grant, uint64 time) private view returns (uint256) {
|
||||
return grant.value.sub(vestedTokens(grant, time));
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ contract VestedToken is StandardToken, LimitedTransferToken {
|
||||
* @param holder address The address of the holder
|
||||
* @return An uint256 representing the date of the last transferable tokens.
|
||||
*/
|
||||
function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) {
|
||||
function lastTokenIsTransferableDate(address holder) view public returns (uint64 date) {
|
||||
date = uint64(now);
|
||||
uint256 grantIndex = grants[holder].length;
|
||||
for (uint256 i = 0; i < grantIndex; i++) {
|
||||
|
||||
Reference in New Issue
Block a user