Set 0.5.x specific example code to be compilable with >0.4.99 <0.6.0 (e.g. 0.5.x only)

This commit is contained in:
Alex Beregszaszi 2018-09-25 17:40:45 +01:00
parent 3ca00c73f9
commit e3e9ce53d7
8 changed files with 20 additions and 20 deletions

View File

@ -327,7 +327,7 @@ New version:
:: ::
pragma solidity >0.4.25; pragma solidity >0.4.99 <0.6.0;
contract OtherContract { contract OtherContract {
uint x; uint x;

View File

@ -468,7 +468,7 @@ For example,
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract Test { contract Test {
constructor() public { b = hex"12345678901234567890123456789012"; } constructor() public { b = hex"12345678901234567890123456789012"; }

View File

@ -28,7 +28,7 @@ become the new richest.
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract WithdrawalContract { contract WithdrawalContract {
address public richest; address public richest;
@ -65,7 +65,7 @@ This is as opposed to the more intuitive sending pattern:
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract SendContract { contract SendContract {
address payable public richest; address payable public richest;

View File

@ -331,7 +331,7 @@ inheritable properties of contracts and may be overridden by derived contracts.
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract owned { contract owned {
constructor() public { owner = msg.sender; } constructor() public { owner = msg.sender; }
@ -500,7 +500,7 @@ The following statements are considered modifying the state:
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract C { contract C {
function f(uint a, uint b) public view returns (uint) { function f(uint a, uint b) public view returns (uint) {
@ -545,7 +545,7 @@ In addition to the list of state modifying statements explained above, the follo
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract C { contract C {
function f(uint a, uint b) public pure returns (uint) { function f(uint a, uint b) public pure returns (uint) {
@ -633,7 +633,7 @@ Like any function, the fallback function can execute complex operations as long
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract Test { contract Test {
// This function is called for all messages sent to // This function is called for all messages sent to
@ -900,7 +900,7 @@ Details are given in the following example.
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract owned { contract owned {
constructor() public { owner = msg.sender; } constructor() public { owner = msg.sender; }
@ -1060,7 +1060,7 @@ equivalent to ``constructor() public {}``. For example:
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract A { contract A {
uint public a; uint public a;

View File

@ -222,7 +222,7 @@ is compiled so recursive creation-dependencies are not possible.
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract D { contract D {
uint public x; uint public x;
@ -345,7 +345,7 @@ the two variables have the same name but disjoint scopes.
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract C { contract C {
function minimalScoping() pure public { function minimalScoping() pure public {
{ {
@ -366,7 +366,7 @@ In any case, you will get a warning about the outer variable being shadowed.
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
// This will report a warning // This will report a warning
contract C { contract C {
function f() pure public returns (uint) { function f() pure public returns (uint) {
@ -386,7 +386,7 @@ In any case, you will get a warning about the outer variable being shadowed.
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
// This will not compile // This will not compile
contract C { contract C {
function f() pure public returns (uint) { function f() pure public returns (uint) {
@ -433,7 +433,7 @@ a message string for ``require``, but not for ``assert``.
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract Sharer { contract Sharer {
function sendHalf(address payable addr) public payable returns (uint balance) { function sendHalf(address payable addr) public payable returns (uint balance) {
@ -479,7 +479,7 @@ The following example shows how an error string can be used together with revert
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract VendingMachine { contract VendingMachine {
function buy(uint amount) public payable { function buy(uint amount) public payable {

View File

@ -282,7 +282,7 @@ In the case of a ``contract A`` calling a new instance of ``contract B``, parent
You will need to make sure that you have both contracts aware of each other's presence and that ``contract B`` has a ``payable`` constructor. You will need to make sure that you have both contracts aware of each other's presence and that ``contract B`` has a ``payable`` constructor.
In this example:: In this example::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract B { contract B {
constructor() public payable {} constructor() public payable {}

View File

@ -80,7 +80,7 @@ registering with username and password — all you need is an Ethereum keypair.
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
contract Coin { contract Coin {
// The keyword "public" makes those variables // The keyword "public" makes those variables

View File

@ -182,7 +182,7 @@ Never use tx.origin for authorization. Let's say you have a wallet contract like
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
// THIS CONTRACT CONTAINS A BUG - DO NOT USE // THIS CONTRACT CONTAINS A BUG - DO NOT USE
contract TxUserWallet { contract TxUserWallet {
@ -202,7 +202,7 @@ Now someone tricks you into sending ether to the address of this attack wallet:
:: ::
pragma solidity >0.4.24; pragma solidity >0.4.99 <0.6.0;
interface TxUserWallet { interface TxUserWallet {
function transferTo(address payable dest, uint amount) external; function transferTo(address payable dest, uint amount) external;