Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

made all the required changes #47

Open
wants to merge 22 commits into
base: fix/tutorial-09
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1dca9c4
Resolved lint warnings for tutorial-09
willitscale Oct 26, 2018
d3f6e08
Merge pull request #29 from willitscale/fix/tutorial-09
willitscale Oct 26, 2018
d15f6ff
Resolved lint warnings for tutorial-10
willitscale Oct 26, 2018
db18e1d
Resolved lint warnings for tutorial-10
willitscale Oct 26, 2018
bbfeafc
Resolved lint warnings for tutorial-10
willitscale Oct 26, 2018
479043e
Resolved lint warnings for tutorial-10
willitscale Oct 26, 2018
b6fed4e
Issue with address param and the use of external
willitscale Oct 26, 2018
3c070c5
Merge pull request #30 from willitscale/fix/tutorial-10
willitscale Oct 26, 2018
c2983c3
Resolved lint warnings and transfer in tutorial-24
willitscale Oct 26, 2018
b4e2731
Merge pull request #31 from willitscale/fix/tutorial-24
willitscale Oct 26, 2018
17cd3d5
Fixed tutorial 14 to work with the latest version of solidity
Oct 24, 2019
b05eb91
Made tutorial 15 compatible with the latest version of Solidity
Oct 24, 2019
2016d53
Merge pull request #34 from willitscale/fix/tutorial-15-for-solidity-5
willitscale Oct 24, 2019
8f5f6ea
Merge pull request #33 from willitscale/fix/tutorial-14-for-solidity-5
willitscale Oct 24, 2019
9683c0d
Fixed tutorial 16 for the latest version of Solidity
Oct 24, 2019
63b1522
Merge pull request #35 from willitscale/fix/tutorial-16-for-solidity-5
willitscale Oct 24, 2019
ab35274
Made tutorial 1 work for the latest version of Solidity
Oct 24, 2019
3bbaab7
Merge pull request #36 from willitscale/fix/tutorial-1-for-solidity-5
willitscale Oct 24, 2019
c7f3096
Made tutorial 2 work with the latest version of Solidity
Oct 24, 2019
4a11dd7
Merge pull request #37 from willitscale/fix/tutorial-2-for-solidity-5
willitscale Oct 24, 2019
14bab28
Updated line endings
willitscale Oct 29, 2019
b4a9898
Merge pull request #38 from willitscale/willitscale-patch-1
willitscale Oct 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tutorial-01/myfirstcontract.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
pragma solidity ^0.4.0;
pragma solidity ^0.5.0;

contract MyFirstContract {
string private name;
uint private age;

function setName(string newName) public {
function setName(string memory newName) public {
name = newName;
}

function getName() public view returns (string) {
function getName() public view returns (string memory) {
return name;
}

Expand Down
6 changes: 3 additions & 3 deletions tutorial-02/myfirstcontract.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.0;
pragma solidity ^0.5.0;

interface Regulator {
function checkValue(uint amount) external returns (bool);
Expand Down Expand Up @@ -40,11 +40,11 @@ contract MyFirstContract is Bank(10) {
string private name;
uint private age;

function setName(string newName) public {
function setName(string memory newName) public {
name = newName;
}

function getName() public view returns (string) {
function getName() public view returns (string memory) {
return name;
}

Expand Down
14 changes: 7 additions & 7 deletions tutorial-09/MyToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ contract MyFirstToken is ERC20 {
mapping (address => uint) private __balanceOf;
mapping (address => mapping (address => uint)) private __allowances;

function MyFirstToken() {
constructor() public {
__balanceOf[msg.sender] = __totalSupply;
}

function totalSupply() constant returns (uint _totalSupply) {
function totalSupply() public constant returns (uint _totalSupply) {
_totalSupply = __totalSupply;
}

function balanceOf(address _addr) constant returns (uint balance) {
function balanceOf(address _addr) public constant returns (uint balance) {
return __balanceOf[_addr];
}

function transfer(address _to, uint _value) returns (bool success) {
function transfer(address _to, uint _value) public returns (bool success) {
if (_value > 0 && _value <= balanceOf(msg.sender)) {
__balanceOf[msg.sender] -= _value;
__balanceOf[_to] += _value;
Expand All @@ -32,7 +32,7 @@ contract MyFirstToken is ERC20 {
return false;
}

function transferFrom(address _from, address _to, uint _value) returns (bool success) {
function transferFrom(address _from, address _to, uint _value) public returns (bool success) {
if (__allowances[_from][msg.sender] > 0 &&
_value > 0 &&
__allowances[_from][msg.sender] >= _value &&
Expand All @@ -46,12 +46,12 @@ contract MyFirstToken is ERC20 {
return false;
}

function approve(address _spender, uint _value) returns (bool success) {
function approve(address _spender, uint _value) public returns (bool success) {
__allowances[msg.sender][_spender] = _value;
return true;
}

function allowance(address _owner, address _spender) constant returns (uint remaining) {
function allowance(address _owner, address _spender) public constant returns (uint remaining) {
return __allowances[_owner][_spender];
}
}
8 changes: 4 additions & 4 deletions tutorial-10/ERC20.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity ^0.4.0;

interface ERC20 {
function transferFrom(address _from, address _to, uint _value) public returns (bool);
function approve(address _spender, uint _value) public returns (bool);
function allowance(address _owner, address _spender) public constant returns (uint);
function transferFrom(address _from, address _to, uint _value) external returns (bool);
function approve(address _spender, uint _value) external returns (bool);
function allowance(address _owner, address _spender) external constant returns (uint);
event Approval(address indexed _owner, address indexed _spender, uint _value);
}
}
2 changes: 1 addition & 1 deletion tutorial-10/ERC223.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ pragma solidity ^0.4.0;
interface ERC223 {
function transfer(address _to, uint _value, bytes _data) public returns (bool);
event Transfer(address indexed from, address indexed to, uint value, bytes indexed data);
}
}
14 changes: 7 additions & 7 deletions tutorial-10/MyFirstToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "browser/ERC223ReceivingContract.sol";

contract MyFirstToken is Token("MFT", "My First Token", 18, 1000), ERC20, ERC223 {

function MyFirstToken() public {
constructor() public {
_balanceOf[msg.sender] = _totalSupply;
}

Expand All @@ -25,7 +25,7 @@ contract MyFirstToken is Token("MFT", "My First Token", 18, 1000), ERC20, ERC223
!isContract(_to)) {
_balanceOf[msg.sender] -= _value;
_balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
return false;
Expand All @@ -39,13 +39,13 @@ contract MyFirstToken is Token("MFT", "My First Token", 18, 1000), ERC20, ERC223
_balanceOf[_to] += _value;
ERC223ReceivingContract _contract = ERC223ReceivingContract(_to);
_contract.tokenFallback(msg.sender, _value, _data);
Transfer(msg.sender, _to, _value, _data);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
return false;
}

function isContract(address _addr) returns (bool) {
function isContract(address _addr) public view returns (bool) {
uint codeSize;
assembly {
codeSize := extcodesize(_addr)
Expand All @@ -61,19 +61,19 @@ contract MyFirstToken is Token("MFT", "My First Token", 18, 1000), ERC20, ERC223
_balanceOf[_from] -= _value;
_balanceOf[_to] += _value;
_allowances[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
emit Transfer(_from, _to, _value);
return true;
}
return false;
}

function approve(address _spender, uint _value) public returns (bool) {
_allowances[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
emit Approval(msg.sender, _spender, _value);
return true;
}

function allowance(address _owner, address _spender) public constant returns (uint) {
return _allowances[_owner][_spender];
}
}
}
4 changes: 2 additions & 2 deletions tutorial-10/Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ contract Token {
mapping (address => uint) internal _balanceOf;
mapping (address => mapping (address => uint)) internal _allowances;

function Token(string symbol, string name, uint8 decimals, uint totalSupply) public {
constructor(string symbol, string name, uint8 decimals, uint totalSupply) public {
_symbol = symbol;
_name = name;
_decimals = decimals;
Expand All @@ -34,4 +34,4 @@ contract Token {
function balanceOf(address _addr) public constant returns (uint);
function transfer(address _to, uint _value) public returns (bool);
event Transfer(address indexed _from, address indexed _to, uint _value);
}
}
8 changes: 4 additions & 4 deletions tutorial-14/EtherTransfer.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.0;
pragma solidity ^0.5.0;

contract EtherTransferTo {
function () public payable {
function () external payable {
}

function getBalance() public returns (uint) {
Expand All @@ -13,7 +13,7 @@ contract EtherTransferFrom {

EtherTransferTo private _instance;

function EtherTransferFrom() public {
constructor() public {
// _instance = EtherTransferTo(address(this));
_instance = new EtherTransferTo();
}
Expand All @@ -27,7 +27,7 @@ contract EtherTransferFrom {
return _instance.getBalance();
}

function () public payable {
function () external payable {
//msg.sender.send(msg.value);
address(_instance).send(msg.value);
}
Expand Down
8 changes: 4 additions & 4 deletions tutorial-15/ExternalContract.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pragma solidity ^0.4.0;
pragma solidity ^0.5.0;

contract ExternalContract {
function externalCall(string x) external returns (uint) {
function externalCall(string calldata x) external returns (uint) {
return 123;
}

function publicCall(string x) public returns (uint) {
function publicCall(string memory x) public returns (uint) {
return 123;
}
}
}
12 changes: 6 additions & 6 deletions tutorial-16/AlarmTrigger.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.0;
pragma solidity ^0.5.0;

interface AlarmWakeUp {
function callback(bytes _data) public;
function callback(bytes calldata _data) external;
}

contract AlarmService {
Expand All @@ -16,15 +16,15 @@ contract AlarmService {
function set(uint _time)
public
returns (bool) {
TimeEvent _timeEvent;
TimeEvent memory _timeEvent;
_timeEvent.addr = msg.sender;
_timeEvent.data = msg.data;
_events[_time].push(_timeEvent);
}

function call(uint _time)
public {
TimeEvent[] timeEvents = _events[_time];
TimeEvent[] memory timeEvents = _events[_time];
for(uint i = 0; i < timeEvents.length; i++) {
AlarmWakeUp(timeEvents[i].addr).callback(timeEvents[i].data);
}
Expand All @@ -35,11 +35,11 @@ contract AlarmTrigger is AlarmWakeUp {

AlarmService private _alarmService;

function AlarmTrigger() {
constructor() public {
_alarmService = new AlarmService();
}

function callback(bytes _data)
function callback(bytes memory _data)
public {
// Do something
}
Expand Down
2 changes: 1 addition & 1 deletion tutorial-16/TimeBased.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.0;
pragma solidity ^0.5.0;

contract TimeBased {

Expand Down
12 changes: 6 additions & 6 deletions tutorial-24/MultiSigWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract MultiSigWallet {
event WithdrawFunds(address to, uint amount);
event TransferFunds(address from, address to, uint amount);

function MultiSigWallet()
constructor()
public {
_owner = msg.sender;
}
Expand All @@ -39,23 +39,23 @@ contract MultiSigWallet {
function ()
public
payable {
DepositFunds(msg.sender, msg.value);
emit DepositFunds(msg.sender, msg.value);
}

function withdraw(uint amount)
validOwner
public {
require(address(this).balance >= amount);
msg.sender.transfer(amount);
WithdrawFunds(msg.sender, amount);
emit WithdrawFunds(msg.sender, amount);
}

function transferTo(address to, uint amount)
validOwner
public {
require(address(this).balance >= amount);
msg.sender.transfer(amount);
TransferFunds(msg.sender, to, amount);
to.transfer(amount);
emit TransferFunds(msg.sender, to, amount);
}

}
}