update test contracts to solc 0.4.17
This commit is contained in:
parent
398aff3af7
commit
0a139c7b73
|
@ -2,15 +2,15 @@ pragma solidity ^0.4.7;
|
|||
contract SimpleStorage {
|
||||
uint public storedData;
|
||||
|
||||
function SimpleStorage(uint initialValue) {
|
||||
function SimpleStorage(uint initialValue) public {
|
||||
storedData = initialValue;
|
||||
}
|
||||
|
||||
function set(uint x) {
|
||||
function set(uint x) public {
|
||||
storedData = x;
|
||||
}
|
||||
|
||||
function get() constant returns (uint retVal) {
|
||||
function get() public view returns (uint retVal) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ contract AnotherStorage {
|
|||
address public simpleStorageAddress;
|
||||
address simpleStorageAddress2;
|
||||
|
||||
function AnotherStorage(address addr) {
|
||||
function AnotherStorage(address addr) public {
|
||||
simpleStorageAddress = addr;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ contract Ownable {
|
|||
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
|
||||
* account.
|
||||
*/
|
||||
function Ownable() {
|
||||
function Ownable() public {
|
||||
owner = msg.sender;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ contract Ownable {
|
|||
*/
|
||||
modifier onlyOwner() {
|
||||
if (msg.sender != owner) {
|
||||
throw;
|
||||
revert();
|
||||
}
|
||||
_;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ contract Ownable {
|
|||
* @dev Allows the current owner to transfer control of the contract to a newOwner.
|
||||
* @param newOwner The address to transfer ownership to.
|
||||
*/
|
||||
function transferOwnership(address newOwner) onlyOwner {
|
||||
function transferOwnership(address newOwner) public onlyOwner {
|
||||
if (newOwner != address(0)) {
|
||||
owner = newOwner;
|
||||
}
|
||||
|
|
|
@ -5,25 +5,25 @@ import "ownable.sol";
|
|||
contract SimpleStorage is Ownable {
|
||||
uint public storedData;
|
||||
|
||||
function() payable { }
|
||||
function() public payable { }
|
||||
|
||||
function SimpleStorage(uint initialValue) {
|
||||
function SimpleStorage(uint initialValue) public {
|
||||
storedData = initialValue;
|
||||
}
|
||||
|
||||
function set(uint x) {
|
||||
function set(uint x) public {
|
||||
storedData = x;
|
||||
}
|
||||
|
||||
function set2(uint x, uint unusedGiveWarning) onlyOwner {
|
||||
function set2(uint x, uint unusedGiveWarning) public onlyOwner {
|
||||
storedData = x;
|
||||
}
|
||||
|
||||
function get() constant returns (uint retVal) {
|
||||
function get() public view returns (uint retVal) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
function getS() constant returns (string d) {
|
||||
function getS() public pure returns (string d) {
|
||||
return "hello";
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ pragma solidity ^0.4.11;
|
|||
|
||||
library ZAMyLib {
|
||||
|
||||
function add(uint _a, uint _b) returns (uint _c) {
|
||||
function add(uint _a, uint _b) public pure returns (uint _c) {
|
||||
return _a + _b;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ library ZAMyLib {
|
|||
|
||||
contract Test {
|
||||
|
||||
function testAdd() constant returns (uint _result) {
|
||||
function testAdd() public pure returns (uint _result) {
|
||||
return ZAMyLib.add(1, 2);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,39 +10,39 @@ contract Token {
|
|||
mapping( address => mapping( address => uint ) ) _approvals;
|
||||
uint public _supply;
|
||||
//uint public _supply2;
|
||||
function Token( uint initial_balance ) {
|
||||
function Token( uint initial_balance ) public {
|
||||
_balances[msg.sender] = initial_balance;
|
||||
_supply = initial_balance;
|
||||
}
|
||||
function totalSupply() constant returns (uint supply) {
|
||||
function totalSupply() public constant returns (uint supply) {
|
||||
return _supply;
|
||||
}
|
||||
function balanceOf( address who ) constant returns (uint value) {
|
||||
function balanceOf( address who ) public constant returns (uint value) {
|
||||
return _balances[who];
|
||||
}
|
||||
function transfer( address to, uint value) returns (bool ok) {
|
||||
function transfer( address to, uint value) public returns (bool ok) {
|
||||
if( _balances[msg.sender] < value ) {
|
||||
throw;
|
||||
revert();
|
||||
}
|
||||
if( !safeToAdd(_balances[to], value) ) {
|
||||
throw;
|
||||
revert();
|
||||
}
|
||||
_balances[msg.sender] -= value;
|
||||
_balances[to] += value;
|
||||
Transfer( msg.sender, to, value );
|
||||
return true;
|
||||
}
|
||||
function transferFrom( address from, address to, uint value) returns (bool ok) {
|
||||
function transferFrom( address from, address to, uint value) public returns (bool ok) {
|
||||
// if you don't have enough balance, throw
|
||||
if( _balances[from] < value ) {
|
||||
throw;
|
||||
revert();
|
||||
}
|
||||
// if you don't have approval, throw
|
||||
if( _approvals[from][msg.sender] < value ) {
|
||||
throw;
|
||||
revert();
|
||||
}
|
||||
if( !safeToAdd(_balances[to], value) ) {
|
||||
throw;
|
||||
revert();
|
||||
}
|
||||
// transfer and return true
|
||||
_approvals[from][msg.sender] -= value;
|
||||
|
@ -51,16 +51,16 @@ contract Token {
|
|||
Transfer( from, to, value );
|
||||
return true;
|
||||
}
|
||||
function approve(address spender, uint value) returns (bool ok) {
|
||||
function approve(address spender, uint value) public returns (bool ok) {
|
||||
// TODO: should increase instead
|
||||
_approvals[msg.sender][spender] = value;
|
||||
Approval( msg.sender, spender, value );
|
||||
return true;
|
||||
}
|
||||
function allowance(address owner, address spender) constant returns (uint _allowance) {
|
||||
function allowance(address owner, address spender) public constant returns (uint _allowance) {
|
||||
return _approvals[owner][spender];
|
||||
}
|
||||
function safeToAdd(uint a, uint b) internal returns (bool) {
|
||||
function safeToAdd(uint a, uint b) internal pure returns (bool) {
|
||||
return (a + b >= a);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue