Skip to content

Commit 0a139c7

Browse files
committed
update test contracts to solc 0.4.17
1 parent 398aff3 commit 0a139c7

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

demo/app/contracts/simple_storage.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ pragma solidity ^0.4.7;
22
contract SimpleStorage {
33
uint public storedData;
44

5-
function SimpleStorage(uint initialValue) {
5+
function SimpleStorage(uint initialValue) public {
66
storedData = initialValue;
77
}
88

9-
function set(uint x) {
9+
function set(uint x) public {
1010
storedData = x;
1111
}
1212

13-
function get() constant returns (uint retVal) {
13+
function get() public view returns (uint retVal) {
1414
return storedData;
1515
}
1616

test_app/app/contracts/another_storage.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ contract AnotherStorage {
33
address public simpleStorageAddress;
44
address simpleStorageAddress2;
55

6-
function AnotherStorage(address addr) {
6+
function AnotherStorage(address addr) public {
77
simpleStorageAddress = addr;
88
}
99

test_app/app/contracts/ownable.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ contract Ownable {
1313
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
1414
* account.
1515
*/
16-
function Ownable() {
16+
function Ownable() public {
1717
owner = msg.sender;
1818
}
1919

@@ -23,7 +23,7 @@ contract Ownable {
2323
*/
2424
modifier onlyOwner() {
2525
if (msg.sender != owner) {
26-
throw;
26+
revert();
2727
}
2828
_;
2929
}
@@ -33,7 +33,7 @@ contract Ownable {
3333
* @dev Allows the current owner to transfer control of the contract to a newOwner.
3434
* @param newOwner The address to transfer ownership to.
3535
*/
36-
function transferOwnership(address newOwner) onlyOwner {
36+
function transferOwnership(address newOwner) public onlyOwner {
3737
if (newOwner != address(0)) {
3838
owner = newOwner;
3939
}

test_app/app/contracts/simple_storage.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ import "ownable.sol";
55
contract SimpleStorage is Ownable {
66
uint public storedData;
77

8-
function() payable { }
8+
function() public payable { }
99

10-
function SimpleStorage(uint initialValue) {
10+
function SimpleStorage(uint initialValue) public {
1111
storedData = initialValue;
1212
}
1313

14-
function set(uint x) {
14+
function set(uint x) public {
1515
storedData = x;
1616
}
1717

18-
function set2(uint x, uint unusedGiveWarning) onlyOwner {
18+
function set2(uint x, uint unusedGiveWarning) public onlyOwner {
1919
storedData = x;
2020
}
2121

22-
function get() constant returns (uint retVal) {
22+
function get() public view returns (uint retVal) {
2323
return storedData;
2424
}
2525

26-
function getS() constant returns (string d) {
26+
function getS() public pure returns (string d) {
2727
return "hello";
2828
}
2929

test_app/app/contracts/test.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ pragma solidity ^0.4.11;
22

33
library ZAMyLib {
44

5-
function add(uint _a, uint _b) returns (uint _c) {
5+
function add(uint _a, uint _b) public pure returns (uint _c) {
66
return _a + _b;
77
}
88

99
}
1010

1111
contract Test {
1212

13-
function testAdd() constant returns (uint _result) {
13+
function testAdd() public pure returns (uint _result) {
1414
return ZAMyLib.add(1, 2);
1515
}
1616

test_app/app/contracts/token.sol

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,39 @@ contract Token {
1010
mapping( address => mapping( address => uint ) ) _approvals;
1111
uint public _supply;
1212
//uint public _supply2;
13-
function Token( uint initial_balance ) {
13+
function Token( uint initial_balance ) public {
1414
_balances[msg.sender] = initial_balance;
1515
_supply = initial_balance;
1616
}
17-
function totalSupply() constant returns (uint supply) {
17+
function totalSupply() public constant returns (uint supply) {
1818
return _supply;
1919
}
20-
function balanceOf( address who ) constant returns (uint value) {
20+
function balanceOf( address who ) public constant returns (uint value) {
2121
return _balances[who];
2222
}
23-
function transfer( address to, uint value) returns (bool ok) {
23+
function transfer( address to, uint value) public returns (bool ok) {
2424
if( _balances[msg.sender] < value ) {
25-
throw;
25+
revert();
2626
}
2727
if( !safeToAdd(_balances[to], value) ) {
28-
throw;
28+
revert();
2929
}
3030
_balances[msg.sender] -= value;
3131
_balances[to] += value;
3232
Transfer( msg.sender, to, value );
3333
return true;
3434
}
35-
function transferFrom( address from, address to, uint value) returns (bool ok) {
35+
function transferFrom( address from, address to, uint value) public returns (bool ok) {
3636
// if you don't have enough balance, throw
3737
if( _balances[from] < value ) {
38-
throw;
38+
revert();
3939
}
4040
// if you don't have approval, throw
4141
if( _approvals[from][msg.sender] < value ) {
42-
throw;
42+
revert();
4343
}
4444
if( !safeToAdd(_balances[to], value) ) {
45-
throw;
45+
revert();
4646
}
4747
// transfer and return true
4848
_approvals[from][msg.sender] -= value;
@@ -51,16 +51,16 @@ contract Token {
5151
Transfer( from, to, value );
5252
return true;
5353
}
54-
function approve(address spender, uint value) returns (bool ok) {
54+
function approve(address spender, uint value) public returns (bool ok) {
5555
// TODO: should increase instead
5656
_approvals[msg.sender][spender] = value;
5757
Approval( msg.sender, spender, value );
5858
return true;
5959
}
60-
function allowance(address owner, address spender) constant returns (uint _allowance) {
60+
function allowance(address owner, address spender) public constant returns (uint _allowance) {
6161
return _approvals[owner][spender];
6262
}
63-
function safeToAdd(uint a, uint b) internal returns (bool) {
63+
function safeToAdd(uint a, uint b) internal pure returns (bool) {
6464
return (a + b >= a);
6565
}
6666
}

0 commit comments

Comments
 (0)