From 1dca9c414d949cbf99f97f9ddd1dc73e2379f42c Mon Sep 17 00:00:00 2001 From: James Date: Fri, 26 Oct 2018 03:23:50 +0100 Subject: [PATCH 01/13] Resolved lint warnings for tutorial-09 --- tutorial-09/MyToken.sol | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tutorial-09/MyToken.sol b/tutorial-09/MyToken.sol index 0bd4728..635e9d3 100644 --- a/tutorial-09/MyToken.sol +++ b/tutorial-09/MyToken.sol @@ -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; @@ -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 && @@ -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]; } } From d15f6ff1afcec7c88c55023988abaca9bdc71fbb Mon Sep 17 00:00:00 2001 From: James Date: Fri, 26 Oct 2018 03:26:54 +0100 Subject: [PATCH 02/13] Resolved lint warnings for tutorial-10 --- tutorial-10/ERC20.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tutorial-10/ERC20.sol b/tutorial-10/ERC20.sol index 92c9657..313b5d7 100644 --- a/tutorial-10/ERC20.sol +++ b/tutorial-10/ERC20.sol @@ -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); -} \ No newline at end of file +} From db18e1d563966e60f0aaa068cf7779f81b737680 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 26 Oct 2018 03:27:20 +0100 Subject: [PATCH 03/13] Resolved lint warnings for tutorial-10 --- tutorial-10/ERC223.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorial-10/ERC223.sol b/tutorial-10/ERC223.sol index ed72fee..11169e6 100644 --- a/tutorial-10/ERC223.sol +++ b/tutorial-10/ERC223.sol @@ -1,6 +1,6 @@ pragma solidity ^0.4.0; interface ERC223 { - function transfer(address _to, uint _value, bytes _data) public returns (bool); + function transfer(address _to, uint _value, bytes _data) external returns (bool); event Transfer(address indexed from, address indexed to, uint value, bytes indexed data); -} \ No newline at end of file +} From bbfeafce7740644b3311b92e3cd1bd7e0e7b940b Mon Sep 17 00:00:00 2001 From: James Date: Fri, 26 Oct 2018 03:28:16 +0100 Subject: [PATCH 04/13] Resolved lint warnings for tutorial-10 --- tutorial-10/Token.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorial-10/Token.sol b/tutorial-10/Token.sol index b2670bf..13a2024 100644 --- a/tutorial-10/Token.sol +++ b/tutorial-10/Token.sol @@ -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; @@ -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); -} \ No newline at end of file +} From 479043e23d4fdcb43c456f3ae03626222e8848b7 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 26 Oct 2018 03:31:54 +0100 Subject: [PATCH 05/13] Resolved lint warnings for tutorial-10 --- tutorial-10/MyFirstToken.sol | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tutorial-10/MyFirstToken.sol b/tutorial-10/MyFirstToken.sol index c1ae1ca..36321be 100644 --- a/tutorial-10/MyFirstToken.sol +++ b/tutorial-10/MyFirstToken.sol @@ -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; } @@ -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; @@ -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) @@ -61,7 +61,7 @@ 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; @@ -69,11 +69,11 @@ contract MyFirstToken is Token("MFT", "My First Token", 18, 1000), ERC20, ERC223 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]; } -} \ No newline at end of file +} From b6fed4e1d486bc29da2c61ec1ba5bc3603b9ac5d Mon Sep 17 00:00:00 2001 From: James Date: Fri, 26 Oct 2018 03:33:25 +0100 Subject: [PATCH 06/13] Issue with address param and the use of external ``` browser/ballot.sol:5:5: TypeError: Function overload clash during conversion to external types for arguments. function transfer(address _to, uint _value, bytes _data) external returns (bool); ^-------------------------------------------------------------------------------^ ``` --- tutorial-10/ERC223.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorial-10/ERC223.sol b/tutorial-10/ERC223.sol index 11169e6..c8b8cf5 100644 --- a/tutorial-10/ERC223.sol +++ b/tutorial-10/ERC223.sol @@ -1,6 +1,6 @@ pragma solidity ^0.4.0; interface ERC223 { - function transfer(address _to, uint _value, bytes _data) external returns (bool); + function transfer(address _to, uint _value, bytes _data) public returns (bool); event Transfer(address indexed from, address indexed to, uint value, bytes indexed data); } From c2983c318c58c1e1c619a45c65c37b7ecf8657fb Mon Sep 17 00:00:00 2001 From: James Date: Fri, 26 Oct 2018 03:45:02 +0100 Subject: [PATCH 07/13] Resolved lint warnings and transfer in tutorial-24 --- tutorial-24/MultiSigWallet.sol | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tutorial-24/MultiSigWallet.sol b/tutorial-24/MultiSigWallet.sol index c1375f8..71d30f3 100644 --- a/tutorial-24/MultiSigWallet.sol +++ b/tutorial-24/MultiSigWallet.sol @@ -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; } @@ -39,7 +39,7 @@ contract MultiSigWallet { function () public payable { - DepositFunds(msg.sender, msg.value); + emit DepositFunds(msg.sender, msg.value); } function withdraw(uint amount) @@ -47,15 +47,15 @@ contract MultiSigWallet { 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); } -} \ No newline at end of file +} From 17cd3d52fab220062d7c2ef6de027e941eceb4d7 Mon Sep 17 00:00:00 2001 From: James Lockhart Date: Thu, 24 Oct 2019 19:28:03 +0100 Subject: [PATCH 08/13] Fixed tutorial 14 to work with the latest version of solidity --- tutorial-14/EtherTransfer.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tutorial-14/EtherTransfer.sol b/tutorial-14/EtherTransfer.sol index a61a92a..1d50789 100644 --- a/tutorial-14/EtherTransfer.sol +++ b/tutorial-14/EtherTransfer.sol @@ -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) { @@ -13,7 +13,7 @@ contract EtherTransferFrom { EtherTransferTo private _instance; - function EtherTransferFrom() public { + constructor() public { // _instance = EtherTransferTo(address(this)); _instance = new EtherTransferTo(); } @@ -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); } From b05eb916ef9b6a56ffbed3a5d9ba4fcc6b850d15 Mon Sep 17 00:00:00 2001 From: James Lockhart Date: Thu, 24 Oct 2019 19:34:38 +0100 Subject: [PATCH 09/13] Made tutorial 15 compatible with the latest version of Solidity --- tutorial-15/ExternalContract.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tutorial-15/ExternalContract.sol b/tutorial-15/ExternalContract.sol index 346c076..17e7328 100644 --- a/tutorial-15/ExternalContract.sol +++ b/tutorial-15/ExternalContract.sol @@ -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; } -} \ No newline at end of file +} From 9683c0df00991b1284706bbefd7d373baca00508 Mon Sep 17 00:00:00 2001 From: James Lockhart Date: Thu, 24 Oct 2019 19:40:53 +0100 Subject: [PATCH 10/13] Fixed tutorial 16 for the latest version of Solidity --- tutorial-16/AlarmTrigger.sol | 12 ++++++------ tutorial-16/TimeBased.sol | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tutorial-16/AlarmTrigger.sol b/tutorial-16/AlarmTrigger.sol index 04a13d7..b474f57 100644 --- a/tutorial-16/AlarmTrigger.sol +++ b/tutorial-16/AlarmTrigger.sol @@ -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 { @@ -16,7 +16,7 @@ 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); @@ -24,7 +24,7 @@ contract AlarmService { 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); } @@ -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 } diff --git a/tutorial-16/TimeBased.sol b/tutorial-16/TimeBased.sol index 27f22c0..c921a61 100644 --- a/tutorial-16/TimeBased.sol +++ b/tutorial-16/TimeBased.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.0; +pragma solidity ^0.5.0; contract TimeBased { From ab35274531b58dc5c32efeb1e2c0edad95064405 Mon Sep 17 00:00:00 2001 From: James Lockhart Date: Thu, 24 Oct 2019 19:45:51 +0100 Subject: [PATCH 11/13] Made tutorial 1 work for the latest version of Solidity --- tutorial-01/myfirstcontract.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tutorial-01/myfirstcontract.sol b/tutorial-01/myfirstcontract.sol index b921078..a2ae8b4 100644 --- a/tutorial-01/myfirstcontract.sol +++ b/tutorial-01/myfirstcontract.sol @@ -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; } From c7f30962c7ab6a2c62255c095326723b0ddba50f Mon Sep 17 00:00:00 2001 From: James Lockhart Date: Thu, 24 Oct 2019 19:49:10 +0100 Subject: [PATCH 12/13] Made tutorial 2 work with the latest version of Solidity --- tutorial-02/myfirstcontract.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tutorial-02/myfirstcontract.sol b/tutorial-02/myfirstcontract.sol index af0d797..f94fce1 100644 --- a/tutorial-02/myfirstcontract.sol +++ b/tutorial-02/myfirstcontract.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.0; +pragma solidity ^0.5.0; interface Regulator { function checkValue(uint amount) external returns (bool); @@ -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; } From 14bab281e515f167b17312e6643cead15a304256 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 29 Oct 2019 23:01:00 +0000 Subject: [PATCH 13/13] Updated line endings