From 0a139c7b739b55d14a7905a16145666445784ec4 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 21 Oct 2017 15:01:09 -0400 Subject: [PATCH] update test contracts to solc 0.4.17 --- demo/app/contracts/simple_storage.sol | 6 ++--- test_app/app/contracts/another_storage.sol | 2 +- test_app/app/contracts/ownable.sol | 6 ++--- test_app/app/contracts/simple_storage.sol | 12 +++++----- test_app/app/contracts/test.sol | 4 ++-- test_app/app/contracts/token.sol | 26 +++++++++++----------- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/demo/app/contracts/simple_storage.sol b/demo/app/contracts/simple_storage.sol index 13957b2d..955ad899 100644 --- a/demo/app/contracts/simple_storage.sol +++ b/demo/app/contracts/simple_storage.sol @@ -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; } diff --git a/test_app/app/contracts/another_storage.sol b/test_app/app/contracts/another_storage.sol index e00c236a..6bad7106 100644 --- a/test_app/app/contracts/another_storage.sol +++ b/test_app/app/contracts/another_storage.sol @@ -3,7 +3,7 @@ contract AnotherStorage { address public simpleStorageAddress; address simpleStorageAddress2; - function AnotherStorage(address addr) { + function AnotherStorage(address addr) public { simpleStorageAddress = addr; } diff --git a/test_app/app/contracts/ownable.sol b/test_app/app/contracts/ownable.sol index 640f1e4c..0e2562c0 100644 --- a/test_app/app/contracts/ownable.sol +++ b/test_app/app/contracts/ownable.sol @@ -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; } diff --git a/test_app/app/contracts/simple_storage.sol b/test_app/app/contracts/simple_storage.sol index 2a243a77..4098c6f0 100644 --- a/test_app/app/contracts/simple_storage.sol +++ b/test_app/app/contracts/simple_storage.sol @@ -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"; } diff --git a/test_app/app/contracts/test.sol b/test_app/app/contracts/test.sol index da76aa29..20070e0b 100644 --- a/test_app/app/contracts/test.sol +++ b/test_app/app/contracts/test.sol @@ -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); } diff --git a/test_app/app/contracts/token.sol b/test_app/app/contracts/token.sol index 0eff9e71..98c9bd49 100644 --- a/test_app/app/contracts/token.sol +++ b/test_app/app/contracts/token.sol @@ -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); } }