mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #4193 from ethereum/050-version
Set version to 0.5.0-develop
This commit is contained in:
commit
56eb9dd47f
@ -8,7 +8,7 @@ include(EthPolicy)
|
||||
eth_policy()
|
||||
|
||||
# project name and version should be set after cmake_policy CMP0048
|
||||
set(PROJECT_VERSION "0.4.26")
|
||||
set(PROJECT_VERSION "0.5.0")
|
||||
project(solidity VERSION ${PROJECT_VERSION})
|
||||
|
||||
option(SOLC_LINK_STATIC "Link solc executable statically on supported platforms" OFF)
|
||||
|
@ -327,7 +327,7 @@ New version:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >0.4.25;
|
||||
pragma solidity >0.4.99 <0.6.0;
|
||||
|
||||
contract OtherContract {
|
||||
uint x;
|
||||
|
@ -211,7 +211,7 @@ Given the contract:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract Foo {
|
||||
function bar(bytes3[2] memory) public pure {}
|
||||
@ -468,7 +468,7 @@ For example,
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >0.4.24;
|
||||
pragma solidity >0.4.99 <0.6.0;
|
||||
|
||||
contract Test {
|
||||
constructor() public { b = hex"12345678901234567890123456789012"; }
|
||||
@ -515,7 +515,7 @@ As an example, the code
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.19;
|
||||
pragma solidity >=0.4.19 <0.6.0;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract Test {
|
||||
|
@ -67,7 +67,7 @@ idea is that assembly libraries will be used to enhance the Solidity language.
|
||||
|
||||
.. code::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
library GetCode {
|
||||
function at(address _addr) public view returns (bytes memory o_code) {
|
||||
@ -92,7 +92,7 @@ efficient code, for example:
|
||||
|
||||
.. code::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
library VectorSum {
|
||||
// This function is less efficient because the optimizer currently fails to
|
||||
@ -381,7 +381,7 @@ Local Solidity variables are available for assignments, for example:
|
||||
|
||||
.. code::
|
||||
|
||||
pragma solidity ^0.4.11;
|
||||
pragma solidity >=0.4.11 <0.6.0;
|
||||
|
||||
contract C {
|
||||
uint b;
|
||||
@ -420,7 +420,7 @@ be just ``0``, but it can also be a complex functional-style expression.
|
||||
|
||||
.. code::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract C {
|
||||
function f(uint x) public view returns (uint b) {
|
||||
@ -685,7 +685,7 @@ Example:
|
||||
We will follow an example compilation from Solidity to assembly.
|
||||
We consider the runtime bytecode of the following Solidity program::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract C {
|
||||
function f(uint x) public pure returns (uint y) {
|
||||
|
@ -28,7 +28,7 @@ become the new richest.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >0.4.24;
|
||||
pragma solidity >0.4.99 <0.6.0;
|
||||
|
||||
contract WithdrawalContract {
|
||||
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 {
|
||||
address payable public richest;
|
||||
@ -130,7 +130,7 @@ restrictions highly readable.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.22;
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
|
||||
contract AccessRestriction {
|
||||
// These will be assigned at the construction
|
||||
@ -282,7 +282,7 @@ function finishes.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.22;
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
|
||||
contract StateMachine {
|
||||
enum Stages {
|
||||
|
@ -42,7 +42,7 @@ This means that cyclic creation dependencies are impossible.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.22;
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
|
||||
contract OwnedToken {
|
||||
// TokenCreator is a contract type that is defined below.
|
||||
@ -173,7 +173,7 @@ return parameter list for functions.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract C {
|
||||
function f(uint a) private pure returns (uint b) { return a + 1; }
|
||||
@ -187,7 +187,7 @@ In the following example, ``D``, can call ``c.getData()`` to retrieve the value
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract C {
|
||||
uint private data;
|
||||
@ -231,7 +231,7 @@ when they are declared.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract C {
|
||||
uint public data = 42;
|
||||
@ -251,7 +251,7 @@ it evaluates to a state variable. If it is accessed externally
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract C {
|
||||
uint public data;
|
||||
@ -270,7 +270,8 @@ to write a function, for example:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract arrayExample {
|
||||
// public state variable
|
||||
uint[] public myArray;
|
||||
@ -295,7 +296,7 @@ The next example is more complex:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract Complex {
|
||||
struct Data {
|
||||
@ -330,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 {
|
||||
constructor() public { owner = msg.sender; }
|
||||
@ -456,7 +457,7 @@ value types and strings.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract C {
|
||||
uint constant x = 32**22 + 8;
|
||||
@ -499,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 {
|
||||
function f(uint a, uint b) public view returns (uint) {
|
||||
@ -544,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 {
|
||||
function f(uint a, uint b) public pure returns (uint) {
|
||||
@ -632,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 {
|
||||
// This function is called for all messages sent to
|
||||
@ -683,7 +684,7 @@ The following example shows overloading of the function
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract A {
|
||||
function f(uint _in) public pure returns (uint out) {
|
||||
@ -701,7 +702,7 @@ externally visible functions differ by their Solidity types but not by their ext
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
// This will not compile
|
||||
contract A {
|
||||
@ -734,7 +735,7 @@ candidate, resolution fails.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract A {
|
||||
function f(uint8 _in) public pure returns (uint8 out) {
|
||||
@ -794,7 +795,7 @@ All non-indexed arguments will be :ref:`ABI-encoded <ABI>` into the data part of
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.21;
|
||||
pragma solidity >=0.4.21 <0.6.0;
|
||||
|
||||
contract ClientReceipt {
|
||||
event Deposit(
|
||||
@ -851,7 +852,7 @@ as topics. The event call above can be performed in the same way as
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.10;
|
||||
pragma solidity >=0.4.10 <0.6.0;
|
||||
|
||||
contract C {
|
||||
function f() public payable {
|
||||
@ -899,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 {
|
||||
constructor() public { owner = msg.sender; }
|
||||
@ -971,7 +972,7 @@ Note that above, we call ``mortal.kill()`` to "forward" the
|
||||
destruction request. The way this is done is problematic, as
|
||||
seen in the following example::
|
||||
|
||||
pragma solidity ^0.4.22;
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
|
||||
contract owned {
|
||||
constructor() public { owner = msg.sender; }
|
||||
@ -1000,7 +1001,7 @@ derived override, but this function will bypass
|
||||
``Base1.kill``, basically because it does not even know about
|
||||
``Base1``. The way around this is to use ``super``::
|
||||
|
||||
pragma solidity ^0.4.22;
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
|
||||
contract owned {
|
||||
constructor() public { owner = msg.sender; }
|
||||
@ -1059,7 +1060,7 @@ equivalent to ``constructor() public {}``. For example:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >0.4.24;
|
||||
pragma solidity >0.4.99 <0.6.0;
|
||||
|
||||
contract A {
|
||||
uint public a;
|
||||
@ -1089,7 +1090,7 @@ The constructors of all the base contracts will be called following the
|
||||
linearization rules explained below. If the base constructors have arguments,
|
||||
derived contracts need to specify all of them. This can be done in two ways::
|
||||
|
||||
pragma solidity ^0.4.22;
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
|
||||
contract Base {
|
||||
uint x;
|
||||
@ -1148,7 +1149,7 @@ error "Linearization of inheritance graph impossible".
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract X {}
|
||||
contract A is X {}
|
||||
@ -1179,7 +1180,7 @@ Abstract Contracts
|
||||
|
||||
Contracts are marked as abstract when at least one of their functions lacks an implementation as in the following example (note that the function declaration header is terminated by ``;``)::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract Feline {
|
||||
function utterance() public returns (bytes32);
|
||||
@ -1187,7 +1188,7 @@ Contracts are marked as abstract when at least one of their functions lacks an i
|
||||
|
||||
Such contracts cannot be compiled (even if they contain implemented functions alongside non-implemented functions), but they can be used as base contracts::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract Feline {
|
||||
function utterance() public returns (bytes32);
|
||||
@ -1238,7 +1239,7 @@ Interfaces are denoted by their own keyword:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.11;
|
||||
pragma solidity >=0.4.11 <0.6.0;
|
||||
|
||||
interface Token {
|
||||
enum TokenType { Fungible, NonFungible }
|
||||
@ -1300,7 +1301,7 @@ more advanced example to implement a set).
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.22;
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
|
||||
library Set {
|
||||
// We define a new struct datatype that will be used to
|
||||
@ -1374,7 +1375,7 @@ custom types without the overhead of external function calls:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
library BigInt {
|
||||
struct bigint {
|
||||
@ -1515,7 +1516,7 @@ available without having to add further code.
|
||||
Let us rewrite the set example from the
|
||||
:ref:`libraries` in this way::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
// This is the same code as before, just without comments
|
||||
library Set {
|
||||
@ -1565,7 +1566,7 @@ Let us rewrite the set example from the
|
||||
|
||||
It is also possible to extend elementary types in that way::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
library Search {
|
||||
function indexOf(uint[] storage self, uint value)
|
||||
|
@ -20,7 +20,7 @@ For example, suppose we want our contract to
|
||||
accept one kind of external calls with two integers, we would write
|
||||
something like::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract Simple {
|
||||
uint sum;
|
||||
@ -40,7 +40,7 @@ The output parameters can be declared with the same syntax after the
|
||||
the sum and the product of the two given integers, then we would
|
||||
write::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract Simple {
|
||||
function arithmetic(uint _a, uint _b)
|
||||
@ -99,7 +99,7 @@ Internal Function Calls
|
||||
Functions of the current contract can be called directly ("internally"), also recursively, as seen in
|
||||
this nonsensical example::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract C {
|
||||
function g(uint a) public pure returns (uint ret) { return a + f(); }
|
||||
@ -129,7 +129,7 @@ all function arguments have to be copied to memory.
|
||||
When calling functions of other contracts, the amount of Wei sent with the call and
|
||||
the gas can be specified with special options ``.value()`` and ``.gas()``, respectively::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract InfoFeed {
|
||||
function info() public payable returns (uint ret) { return 42; }
|
||||
@ -176,7 +176,7 @@ parameters from the function declaration, but can be in arbitrary order.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract C {
|
||||
mapping(uint => uint) data;
|
||||
@ -199,7 +199,7 @@ Those parameters will still be present on the stack, but they are inaccessible.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract C {
|
||||
// omitted name for parameter
|
||||
@ -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 {
|
||||
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 {
|
||||
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
|
||||
contract C {
|
||||
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
|
||||
contract C {
|
||||
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 {
|
||||
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 {
|
||||
function buy(uint amount) public payable {
|
||||
|
@ -57,7 +57,7 @@ array in the return statement. Pretty cool, huh?
|
||||
|
||||
Example::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract C {
|
||||
function f() public pure returns (uint8[5] memory) {
|
||||
@ -87,7 +87,7 @@ should be noted that you must declare them as static memory arrays.
|
||||
|
||||
Examples::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract C {
|
||||
struct S {
|
||||
@ -127,7 +127,7 @@ which will be extended in the future. In addition, Arachnid has written `solidit
|
||||
For now, if you want to modify a string (even when you only want to know its length),
|
||||
you should always convert it to a ``bytes`` first::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract C {
|
||||
string s;
|
||||
@ -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.
|
||||
In this example::
|
||||
|
||||
pragma solidity >0.4.24;
|
||||
pragma solidity >0.4.99 <0.6.0;
|
||||
|
||||
contract B {
|
||||
constructor() public payable {}
|
||||
@ -330,7 +330,7 @@ Can a contract pass an array (static size) or string or ``bytes`` (dynamic size)
|
||||
Sure. Take care that if you cross the memory / storage boundary,
|
||||
independent copies will be created::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract C {
|
||||
uint[20] x;
|
||||
@ -367,7 +367,7 @@ contract level) with ``arrayname.length = <some new length>;``. If you get the
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.18;
|
||||
pragma solidity >=0.4.18 <0.6.0;
|
||||
|
||||
// This will not compile
|
||||
contract C {
|
||||
|
@ -16,7 +16,7 @@ Storage
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract SimpleStorage {
|
||||
uint storedData;
|
||||
@ -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 {
|
||||
// The keyword "public" makes those variables
|
||||
|
@ -261,7 +261,7 @@ for the two input parameters and two returned values.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
/** @title Shape calculator. */
|
||||
contract ShapeCalculator {
|
||||
|
@ -48,7 +48,7 @@ non-elementary type, the positions are found by adding an offset of ``keccak256(
|
||||
|
||||
So for the following contract snippet::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract C {
|
||||
struct s { uint a; uint b; }
|
||||
|
@ -55,7 +55,7 @@ complete contract):
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
// THIS CONTRACT CONTAINS A BUG - DO NOT USE
|
||||
contract Fund {
|
||||
@ -78,7 +78,7 @@ as it uses ``call`` which forwards all remaining gas by default:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
// THIS CONTRACT CONTAINS A BUG - DO NOT USE
|
||||
contract Fund {
|
||||
@ -97,7 +97,7 @@ outlined further below:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.11;
|
||||
pragma solidity >=0.4.11 <0.6.0;
|
||||
|
||||
contract Fund {
|
||||
/// Mapping of ether shares of the contract.
|
||||
@ -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
|
||||
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 {
|
||||
function transferTo(address payable dest, uint amount) external;
|
||||
|
@ -36,7 +36,7 @@ of votes.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.22;
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
|
||||
/// @title Voting with delegation.
|
||||
contract Ballot {
|
||||
@ -225,7 +225,7 @@ activate themselves.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.22;
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
|
||||
contract SimpleAuction {
|
||||
// Parameters of the auction. Times are either
|
||||
@ -542,7 +542,7 @@ Safe Remote Purchase
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.22;
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
|
||||
contract Purchase {
|
||||
uint public value;
|
||||
@ -793,7 +793,7 @@ The full contract
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.24;
|
||||
pragma solidity >=0.4.24 <0.6.0;
|
||||
|
||||
contract ReceiverPays {
|
||||
address owner = msg.sender;
|
||||
@ -988,7 +988,7 @@ The full contract
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.24;
|
||||
pragma solidity >=0.4.24 <0.6.0;
|
||||
|
||||
contract SimplePaymentChannel {
|
||||
address payable public sender; // The account sending payments.
|
||||
|
@ -26,7 +26,7 @@ storage.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract SimpleStorage {
|
||||
uint storedData; // State variable
|
||||
@ -46,7 +46,7 @@ Functions are the executable units of code within a contract.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract SimpleAuction {
|
||||
function bid() public payable { // Function
|
||||
@ -68,7 +68,7 @@ Function modifiers can be used to amend the semantics of functions in a declarat
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.22;
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
|
||||
contract Purchase {
|
||||
address public seller;
|
||||
@ -95,7 +95,7 @@ Events are convenience interfaces with the EVM logging facilities.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.21;
|
||||
pragma solidity >=0.4.21 <0.6.0;
|
||||
|
||||
contract SimpleAuction {
|
||||
event HighestBidIncreased(address bidder, uint amount); // Event
|
||||
@ -119,7 +119,7 @@ Structs are custom defined types that can group several variables (see
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract Ballot {
|
||||
struct Voter { // Struct
|
||||
@ -140,7 +140,7 @@ Enums can be used to create custom types with a finite set of 'constant values'
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract Purchase {
|
||||
enum State { Created, Locked, Inactive } // Enum
|
||||
|
@ -52,7 +52,7 @@ Surround top level declarations in solidity source with two blank lines.
|
||||
|
||||
Yes::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract A {
|
||||
// ...
|
||||
@ -70,7 +70,7 @@ Yes::
|
||||
|
||||
No::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract A {
|
||||
// ...
|
||||
@ -89,7 +89,7 @@ Blank lines may be omitted between groups of related one-liners (such as stub fu
|
||||
|
||||
Yes::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract A {
|
||||
function spam() public pure;
|
||||
@ -109,7 +109,7 @@ Yes::
|
||||
|
||||
No::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract A {
|
||||
function spam() public pure {
|
||||
@ -237,7 +237,7 @@ Import statements should always be placed at the top of the file.
|
||||
|
||||
Yes::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
import "./Owned.sol";
|
||||
|
||||
@ -251,7 +251,7 @@ Yes::
|
||||
|
||||
No::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract A {
|
||||
// ...
|
||||
@ -283,7 +283,7 @@ Within a grouping, place the ``view`` and ``pure`` functions last.
|
||||
|
||||
Yes::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract A {
|
||||
constructor() public {
|
||||
@ -315,7 +315,7 @@ Yes::
|
||||
|
||||
No::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract A {
|
||||
|
||||
@ -411,7 +411,7 @@ should:
|
||||
|
||||
Yes::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract Coin {
|
||||
struct Bank {
|
||||
@ -422,7 +422,7 @@ Yes::
|
||||
|
||||
No::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract Coin
|
||||
{
|
||||
@ -723,7 +723,7 @@ manner as modifiers if the function declaration is long or hard to read.
|
||||
|
||||
Yes::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
// Base contracts just to make this compile
|
||||
contract B {
|
||||
@ -755,7 +755,7 @@ Yes::
|
||||
|
||||
No::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
// Base contracts just to make this compile
|
||||
contract B {
|
||||
@ -955,7 +955,7 @@ As shown in the example below, if the contract name is `Congress` and the librar
|
||||
|
||||
Yes::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
// Owned.sol
|
||||
contract Owned {
|
||||
@ -984,7 +984,7 @@ Yes::
|
||||
|
||||
No::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
// owned.sol
|
||||
contract owned {
|
||||
|
@ -484,7 +484,7 @@ subsequent unsigned integer values starting from ``0``.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract test {
|
||||
enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill }
|
||||
@ -583,7 +583,7 @@ Members:
|
||||
Public (or external) functions also have a special member called ``selector``,
|
||||
which returns the :ref:`ABI function selector <abi_function_selector>`::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract Selector {
|
||||
function f() public pure returns (bytes4) {
|
||||
@ -593,7 +593,7 @@ which returns the :ref:`ABI function selector <abi_function_selector>`::
|
||||
|
||||
Example that shows how to use internal function types::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
library ArrayUtils {
|
||||
// internal functions can be used in internal library functions because
|
||||
@ -644,7 +644,7 @@ Example that shows how to use internal function types::
|
||||
|
||||
Another example that uses external function types::
|
||||
|
||||
pragma solidity ^0.4.22;
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
|
||||
contract Oracle {
|
||||
struct Request {
|
||||
@ -727,7 +727,7 @@ memory-stored reference type do not create a copy.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract C {
|
||||
uint[] x; // the data location of x is storage
|
||||
@ -809,7 +809,7 @@ or create a new memory array and copy every element.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract C {
|
||||
function f(uint len) public pure {
|
||||
@ -831,7 +831,7 @@ assigned to a variable right away.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract C {
|
||||
function f() public pure {
|
||||
@ -852,7 +852,7 @@ possible:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
// This will not compile.
|
||||
contract C {
|
||||
@ -890,7 +890,7 @@ Members
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.16;
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
|
||||
contract ArrayContract {
|
||||
uint[2**20] m_aLotOfIntegers;
|
||||
@ -970,7 +970,7 @@ shown in the following example:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.11;
|
||||
pragma solidity >=0.4.11 <0.6.0;
|
||||
|
||||
contract CrowdFunding {
|
||||
// Defines a new type with two fields.
|
||||
@ -1066,7 +1066,7 @@ each ``_KeyType``, recursively. For example with a mapping:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract MappingExample {
|
||||
mapping(address => uint) public balances;
|
||||
@ -1111,7 +1111,7 @@ value it referred to previously.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract DeleteExample {
|
||||
uint data;
|
||||
|
@ -177,6 +177,8 @@ do
|
||||
then
|
||||
echo " - $dir"
|
||||
cd "$dir"
|
||||
# Replace version pragmas
|
||||
find . -name '*.sol' -type f -print0 | xargs -0 sed -i -e 's/pragma solidity [\^0-9\.]*/pragma solidity >=0.0/'
|
||||
compileFull -w *.sol */*.sol
|
||||
cd ..
|
||||
fi
|
||||
|
@ -40,7 +40,7 @@ namespace
|
||||
{
|
||||
|
||||
static char const* registrarCode = R"DELIMITER(
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract NameRegister {
|
||||
function addr(string memory _name) public view returns (address o_owner);
|
||||
|
@ -53,7 +53,7 @@ static char const* registrarCode = R"DELIMITER(
|
||||
// @authors:
|
||||
// Gav Wood <g@ethdev.com>
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract Registrar {
|
||||
event Changed(string indexed name);
|
||||
|
@ -56,7 +56,7 @@ static char const* walletCode = R"DELIMITER(
|
||||
// some number (specified in constructor) of the set of owners (specified in the constructor, modifiable) before the
|
||||
// interior is executed.
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
|
||||
contract multiowned {
|
||||
|
||||
|
@ -56,10 +56,10 @@ function test_truffle
|
||||
echo "Current commit hash: `git rev-parse HEAD`"
|
||||
npm install
|
||||
find . -name soljson.js -exec cp "$SOLJSON" {} \;
|
||||
if [ "$name" == "Gnosis" ]; then
|
||||
if [ "$name" == "Zeppelin" -o "$name" == "Gnosis" ]; then
|
||||
echo "Replaced fixed-version pragmas..."
|
||||
# Replace fixed-version pragmas in Gnosis (part of Consensys best practice)
|
||||
find contracts test -name '*.sol' -type f -print0 | xargs -0 sed -i -e 's/pragma solidity 0/pragma solidity ^0/'
|
||||
find contracts test -name '*.sol' -type f -print0 | xargs -0 sed -i -e 's/pragma solidity [\^0-9\.]*/pragma solidity >=0.0/'
|
||||
fi
|
||||
assertsol="node_modules/truffle/build/Assert.sol"
|
||||
if [ -f "$assertsol" ]
|
||||
|
Loading…
Reference in New Issue
Block a user