Skip to content

Commit

Permalink
fixes to contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
hayeah committed Jun 27, 2019
1 parent f620d92 commit 399dee2
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions contracts/A.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pragma solidity ^0.4.11;
pragma solidity ^0.5.8;

contract A {
uint256 a;

function A(uint256 _a) {
constructor(uint256 _a) public {
a = _a;
}
}
12 changes: 6 additions & 6 deletions contracts/AB.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
pragma solidity ^0.4.11;
pragma solidity ^0.5.8;

contract AB {
uint256 a;
int256 b;

uint256 fund;

function AB(uint256 _a, int256 _b) public {
constructor(uint256 _a, int256 _b) public {
a = _a;
b = _b;
}
Expand All @@ -15,7 +15,7 @@ contract AB {
fund += msg.value;
}

function getBurnedFund() public constant returns(uint256) {
function getBurnedFund() public view returns(uint256) {
return fund;
}

Expand All @@ -32,15 +32,15 @@ contract AB {
b = _b;
}

function getA() public constant returns(uint256) {
function getA() public view returns(uint256) {
return a;
}

function getB() public constant returns(int256) {
function getB() public view returns(int256) {
return b;
}

function getAB() public constant returns(uint256, int256) {
function getAB() public view returns(uint256, int256) {
return (a, b);
}
}
6 changes: 3 additions & 3 deletions contracts/ContractCreation.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.11;
pragma solidity ^0.5.1;

import "./Set.sol";

Expand All @@ -8,11 +8,11 @@ contract C1 {
using Set for Set.Data; // this is the crucial change
Set.Data knownValues;

function C1() {
constructor() {
c2 = new C2();
}

function register(uint value) {
function register(uint value) public {
// Here, all variables of type Set.Data have
// corresponding member functions.
// The following function call is identical to
Expand Down
6 changes: 3 additions & 3 deletions contracts/Logger.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity ^0.4.11;
pragma solidity ^0.5.1;

contract Logger {
event EventLog(uint256 a, uint256 b);
function log(uint256 a, uint256 b) {
EventLog(a, b);
function log(uint256 a, uint256 b) public {
emit EventLog(a, b);
}
}
6 changes: 3 additions & 3 deletions contracts/LoggerWithIndex.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity ^0.4.11;
pragma solidity ^0.5.1;

contract LoggerWithIndex {
event EventLog(uint256 a, uint256 indexed b, uint256 c);
function log(uint256 a, uint256 b, uint256 c) {
EventLog(a, b, c);
function log(uint256 a, uint256 b, uint256 c) public {
emit EventLog(a, b, c);
}
}
14 changes: 7 additions & 7 deletions contracts/QtumTest.sol
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
pragma solidity ^0.4.0;
pragma solidity ^0.5.1;

contract QtumTest {
uint storedNumber;
function QtumTest() {
storedNumber=1;
constructor() public {
storedNumber = 1;
}
function setNumber(uint number) public{
storedNumber = number;
}
function logNumber() constant public{
function logNumber() view public{
log1("storedNumber", uintToBytes(storedNumber));
}
function returnNumber() constant public returns (uint){
function returnNumber() view public returns (uint){
return storedNumber;
}
function deposit() public payable{
}
function withdraw() public{
if(!msg.sender.send(this.balance)){
throw;
revert();
}
}
//utility function
function uintToBytes(uint v) constant returns (bytes32 ret) {
function uintToBytes(uint v) view public returns (bytes32 ret) {
if (v == 0) {
ret = '0';
}
Expand Down
8 changes: 4 additions & 4 deletions contracts/Set.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pragma solidity ^0.4.11;
pragma solidity ^0.5.1;

// This is the same code as before, just without comments
library Set {
struct Data { mapping(uint => bool) flags; }

function insert(Data storage self, uint value)
function insert(Data storage self, uint value) public
returns (bool)
{
if (self.flags[value])
Expand All @@ -13,7 +13,7 @@ library Set {
return true;
}

function remove(Data storage self, uint value)
function remove(Data storage self, uint value) public
returns (bool)
{
if (!self.flags[value])
Expand All @@ -22,7 +22,7 @@ library Set {
return true;
}

function contains(Data storage self, uint value)
function contains(Data storage self, uint value) public view
returns (bool)
{
return self.flags[value];
Expand Down

0 comments on commit 399dee2

Please sign in to comment.