Skip to content

Commit

Permalink
Merge pull request #10626 from ethereum/howToUpdateYourCode
Browse files Browse the repository at this point in the history
How to update your code.
  • Loading branch information
chriseth authored Dec 16, 2020
2 parents 8f833f4 + f31cf6b commit eec1e2a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/080-breaking-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ This section lists changes that might cause existing contracts to not compile an

* Remove support for the ``\b``, ``\f``, and ``\v`` escape sequences in code.
They can still be inserted via hexadecimal escapes, e.g. ``\x08``, ``\x0c``, and ``\x0b``, respectively.

* The global variables ``tx.origin`` and ``msg.sender`` have the type ``address`` instead of
``address payable``. One can convert them into ``address payable`` by using an explicit
conversion, i.e., ``payable(tx.origin)`` or ``payable(msg.sender)``.
Expand Down Expand Up @@ -155,3 +156,18 @@ Interface Changes
Use the "compact AST" (``--ast-compact--json`` resp. ``AST``) as replacement.

* The old error reporter (``--old-reporter``) has been removed.


How to update your code
=======================

- If you rely on wrapping arithmetic, surround each operation with ``unchecked { ... }``.
- Optional: If you use SafeMath or a similar library, change ``x.add(y)`` to ``x + y``, ``x.mul(y)`` to ``x * y`` etc.
- Add ``pragma abicoder v1;`` if you want to stay with the old ABI coder.
- Optionally remove ``pragma experimental ABIEncoderV2`` or ``pragma abicoder v2`` since it is redundant.
- Change ``byte`` to ``bytes1``.
- Add intermediate explicit type conversions if required.
- Combine ``c.f{gas: 10000}{value: 1}()`` to ``c.f{gas: 10000, value: 1}()``.
- Change ``msg.sender.transfer(x)`` to ``payable(msg.sender).transfer(x)`` or use a stored variable of ``address payable`` type.
- Change ``x**y**z`` to ``(x**y)**z``.
- Use inline assembly as a replacement for ``log0``, ..., ``log4``.

0 comments on commit eec1e2a

Please sign in to comment.