diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index d37934cca..9ef1758c1 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -635,116 +635,88 @@ If you found a bug or if you have a feature request, please Example ~~~~~~~ -Assume you have the following contracts you want to update declared in ``Source.sol``: +Assume that you have the following contract in ``Source.sol``: -.. code-block:: none +.. code-block:: solidity - // This will not compile after 0.5.0 + pragma solidity >=0.6.0 <0.6.4; + // This will not compile after 0.7.0 // SPDX-License-Identifier: GPL-3.0 - pragma solidity >0.4.23 <0.5.0; - - contract Updateable { - function run() public view returns (bool); - function update() public; + contract C { + // FIXME: remove constructor visibility and make the contract abstract + constructor() internal {} } - contract Upgradable { - function run() public view returns (bool); - function upgrade(); + contract D { + uint time; + + function f() public payable { + // FIXME: change now to block.timestamp + time = now; + } } - contract Source is Updateable, Upgradable { - function Source() public {} + contract E { + D d; - function run() - public - view - returns (bool) {} + // FIXME: remove constructor visibility + constructor() public {} - function update() {} - function upgrade() {} + function g() public { + // FIXME: change .value(5) => {value: 5} + d.f.value(5)(); + } } + Required changes ^^^^^^^^^^^^^^^^ -To bring the contracts up to date with the current Solidity version, the -following upgrade modules have to be executed: ``constructor``, -``visibility``, ``abstract``, ``override`` and ``virtual``. Please read the -documentation on :ref:`available modules ` for further details. +The above contract will not compile starting from 0.7.0. To bring the contract up to date with the +current Solidity version, the following upgrade modules have to be executed: +``constructor-visibility``, ``now`` and ``dotsyntax``. Please read the documentation on +:ref:`available modules ` for further details. + Running the upgrade ^^^^^^^^^^^^^^^^^^^ -In this example, all modules needed to upgrade the contracts above, -are available and all of them are activated by default. Therefore you -do not need to specify the ``--modules`` option. +It is recommended to explicitly specify the upgrade modules by using ``--modules`` argument. .. code-block:: none - $ solidity-upgrade Source.sol --dry-run + $ solidity-upgrade --modules constructor-visibility,now,dotsyntax Source.sol -.. code-block:: none - - Running analysis (and upgrade) on given source files. - .............. - - After upgrade: - - Found 0 errors. - Found 0 upgrades. - -The above performs a dry-run upgrade on the given file and logs statistics at -the end. In this case, the upgrade was successful and no further adjustments are -needed. - -Finally, you can run the upgrade and also write to the source file. - -.. code-block:: none - - $ solidity-upgrade Source.sol - -.. code-block:: none - - Running analysis (and upgrade) on given source files. - .............. - - After upgrade: - - Found 0 errors. - Found 0 upgrades. - - -Review changes -^^^^^^^^^^^^^^ - -The command above applies all changes as shown below. Please review them carefully. +The command above applies all changes as shown below. Please review them carefully (the pragmas will +have to be updated manually.) .. code-block:: solidity - // SPDX-License-Identifier: GPL-3.0 pragma solidity >0.6.99 <0.8.0; - - abstract contract Updateable { - function run() public view virtual returns (bool); - function update() public virtual; + // SPDX-License-Identifier: GPL-3.0 + abstract contract C { + // FIXME: remove constructor visibility and make the contract abstract + constructor() {} } - abstract contract Upgradable { - function run() public view virtual returns (bool); - function upgrade() public virtual; + contract D { + uint time; + + function f() public payable { + // FIXME: change now to block.timestamp + time = block.timestamp; + } } - contract Source is Updateable, Upgradable { + contract E { + D d; + + // FIXME: remove constructor visibility constructor() {} - function run() - public - view - override(Updateable,Upgradable) - returns (bool) {} - - function update() public override {} - function upgrade() public override {} + function g() public { + // FIXME: change .value(5) => {value: 5} + d.f{value: 5}(); + } }