Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
912e399
首页说明更新到0.5.7
xilibi2003 Apr 22, 2019
51860ed
更新初识智能合约
xilibi2003 Apr 22, 2019
709408b
更新编译器安装
xilibi2003 Apr 22, 2019
8a01244
翻译支付通道及模块化合约
xilibi2003 Apr 23, 2019
646d057
定制化
xilibi2003 Apr 23, 2019
e5bb4c3
显示最后更新日期及github链接
xilibi2003 Apr 23, 2019
b39f5df
支付通道翻译完毕
xilibi2003 Apr 24, 2019
c877d0b
调整格式
xilibi2003 Apr 24, 2019
f97c10e
fix 统计显示
xilibi2003 Apr 24, 2019
c6786c7
translate
xilibi2003 Apr 28, 2019
820e285
完成文件结构 翻译及校对
xilibi2003 Apr 29, 2019
d194acf
structure-of-a-contract 翻译完毕
xilibi2003 Apr 29, 2019
faa7276
update
xilibi2003 Apr 29, 2019
4db9252
基本值类型 校对 翻译 OK
xilibi2003 May 3, 2019
3a6ba52
update to v0.5.8
xilibi2003 May 5, 2019
3492791
补充地址部分
xilibi2003 May 5, 2019
8bc5482
value-types translate ok
xilibi2003 May 7, 2019
3f27b85
资源翻译完成
xilibi2003 May 7, 2019
4bf42cf
引用类型
xilibi2003 May 7, 2019
57660e1
引用类型翻译完毕
xilibi2003 May 8, 2019
2ea80c1
把类型差分为多个文件
xilibi2003 May 8, 2019
cabce9a
Revert "把类型差分为多个文件"
xilibi2003 May 8, 2019
e820df3
映射OK
xilibi2003 May 8, 2019
4267f09
modify README
xilibi2003 May 8, 2019
2591e3e
add links
xilibi2003 May 10, 2019
e820fa6
modity readme add translate status
xilibi2003 May 10, 2019
ad1a4fb
Update status_0.5.8.md
Alex-toughman May 10, 2019
22a7f4f
operators translate ok
xilibi2003 May 11, 2019
21725f5
conversion done
xilibi2003 May 13, 2019
b053b64
unit doen
xilibi2003 May 13, 2019
009e92c
Update miscellaneous.rst
Alex-toughman May 13, 2019
aeff4fa
Merge pull request #2 from onecool2/patch-2
xilibi2003 May 14, 2019
969c719
Merge pull request #1 from onecool2/patch-1
xilibi2003 May 14, 2019
0a4c025
校对 miscellaneous.rst
xilibi2003 May 14, 2019
2ef850c
translate function
xilibi2003 May 25, 2019
2566e37
function and control-structure ok
xilibi2003 May 29, 2019
6bdaef1
indicate status version.
xilibi2003 Jun 10, 2019
0081e65
translate event
xilibi2003 Jun 10, 2019
4b6a3f8
translate inheritance
xilibi2003 Jun 12, 2019
4f63692
translate more
xilibi2003 Jun 17, 2019
7d92b8e
删除链接
xilibi2003 Oct 9, 2019
bfc31b7
修改title
xilibi2003 Oct 24, 2019
1721723
升级到solidity 0.6.4
xilibi2003 Mar 12, 2020
cd3d96a
fix
xilibi2003 Mar 12, 2020
9198cd5
修改一些语法错误。
xilibi2003 Mar 12, 2020
5bfbdc5
fix arrays
xilibi2003 Mar 12, 2020
cbd5da0
translate override
xilibi2003 May 26, 2020
a247cde
translate override
xilibi2003 May 26, 2020
36e5266
Update 0.6.8
xilibi2003 May 30, 2020
9747e1b
fix
xilibi2003 Jun 3, 2020
422ed5a
En:
xilibi2003 Jun 9, 2020
2624df7
update to 0.6.9
xilibi2003 Jun 9, 2020
5e71963
统一使用修改器
xilibi2003 Jun 14, 2020
6367429
updata to 0.6.11
xilibi2003 Jul 21, 2020
7f0c0c3
修改翻译说明
xilibi2003 Jul 21, 2020
1e7a98a
修改模板。
xilibi2003 Jul 21, 2020
cbb4ffc
update to 0.6.12
xilibi2003 Jul 23, 2020
ca96e27
update
xilibi2003 Jul 23, 2020
2299267
fix code bug
sirormy Sep 4, 2020
3abd6b1
Merge pull request #3 from Sirormy/patch-1
ysqi Sep 8, 2020
7d4c84f
Update 060-breaking-changes.rst
firevenus Oct 4, 2020
2afc3b8
Update 0.7.1
xilibi2003 Sep 13, 2020
c1115b4
translate contracts and types
xilibi2003 Sep 16, 2020
3731adc
translate layout calldata and memory
xilibi2003 Oct 27, 2020
edff5d3
update 0.7.5
xilibi2003 Dec 9, 2020
4f1ea46
translate
xilibi2003 Dec 10, 2020
99f3696
Update solidity-by-example.rst
Dec 30, 2020
da2f28b
Merge pull request #5 from deftones99/patch-2
xilibi2003 Dec 30, 2020
1a86b37
fix
xilibi2003 Jan 6, 2021
c2206e0
update to v0.8.0
xilibi2003 Jan 7, 2021
fb25df1
add versions
xilibi2003 Jan 7, 2021
2eeecdf
add footer on versions
xilibi2003 Jan 7, 2021
7ece783
Merge branch 'v0.8.0' into develop
xilibi2003 Jan 7, 2021
0b6eb61
modify version
xilibi2003 Jan 7, 2021
52ea67b
fix
xilibi2003 Jan 7, 2021
2ff1225
translate 溢出处理
xilibi2003 Jan 7, 2021
d1d875c
transalte 溢出
xilibi2003 Jan 7, 2021
844d383
translate
xilibi2003 Mar 16, 2021
5e0b63f
fix
xilibi2003 Apr 6, 2021
2d92ce3
Update introduction-to-smart-contracts.rst
Ceelog Apr 7, 2021
ed31e85
Merge pull request #6 from Ceelog/patch-1
xilibi2003 Apr 19, 2021
b3fc684
Fix a wrong string.
u-u-z Oct 2, 2021
1bdff92
修改mapping 描述错误
xilibi2003 Nov 9, 2021
8a125ff
typo
charliex2 Dec 12, 2021
ce56692
typo
charliex2 Dec 12, 2021
9900567
Remove redundant text
hewm Dec 31, 2021
b1154b8
Update introduction-to-smart-contracts.rst
FWangZil Feb 19, 2022
fe52ba1
Update introduction-to-smart-contracts.rst
luchenwei9266 Mar 17, 2022
4c55d35
Merge pull request #11 from luchenwei9266/patch-1
xilibi2003 Mar 18, 2022
3d88c54
Merge pull request #10 from FWangZil/patch-1
xilibi2003 Mar 18, 2022
af65f45
Merge pull request #7 from u-u-z/develop
xilibi2003 Mar 18, 2022
1a10079
Merge pull request #8 from charliex2/develop
xilibi2003 Mar 18, 2022
b450afa
Merge branch 'develop' into patch-1
xilibi2003 Mar 18, 2022
1b9f911
Merge pull request #4 from firevenus/patch-1
xilibi2003 Mar 18, 2022
4f4b164
Merge pull request #9 from hewm/develop
xilibi2003 Mar 18, 2022
0e29446
update breaking-changes on 0.8.13
xilibi2003 Apr 13, 2022
0edbdd7
update to v0.8.13
xilibi2003 Apr 20, 2022
bd7d553
update 0.8.13
xilibi2003 Apr 21, 2022
84f0fce
translate more
xilibi2003 Apr 22, 2022
75f192d
translate more
xilibi2003 Apr 24, 2022
f25cf92
tranlate more
xilibi2003 Apr 25, 2022
ed07b29
translate resources.rst
xilibi2003 Apr 26, 2022
cc8751b
translate introduction-to-smart-contracts
xilibi2003 Apr 26, 2022
4b1a2ff
translate more
xilibi2003 Apr 27, 2022
8b52a11
translate control-structures
xilibi2003 Apr 27, 2022
11babb6
translate more
xilibi2003 May 16, 2022
572debc
translate more
xilibi2003 May 19, 2022
ab78481
translate value-types
xilibi2003 May 19, 2022
2ab909b
udpate types translate
xilibi2003 May 20, 2022
6501dbf
tranlate contracts fold
xilibi2003 May 20, 2022
7c2ece1
translate examples
xilibi2003 May 21, 2022
e82316d
translate internals
xilibi2003 May 21, 2022
2bf7a4e
types translate done
xilibi2003 May 24, 2022
25f313c
update errors translate
xilibi2003 May 25, 2022
45ebb2f
translate moreve
xilibi2003 May 26, 2022
d25a158
调整格式
xilibi2003 May 26, 2022
5f5c676
update
xilibi2003 May 26, 2022
568354a
remove pycache
xilibi2003 May 26, 2022
a725ae1
translate more
xilibi2003 May 26, 2022
970def5
translate more
xilibi2003 Jun 1, 2022
809e4db
typo
zLikeMario Jun 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.DS_Store
versions.json
_build/
utils/SolidityLexer.pyc
utils/__pycache__
.vscode/
ext/__pycache__
519 changes: 519 additions & 0 deletions 050-breaking-changes.rst

Large diffs are not rendered by default.

136 changes: 136 additions & 0 deletions 060-breaking-changes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
********************************
Solidity v0.6.0重大更新
********************************

本节重点介绍Solidity 版本0.6.0 中引入的重大突破性变化,以及更改背后的原因以及如何更新受影响的代码。

有关完整列表,请检查 `更新日志 <https://github.com/ethereum/solidity/releases/tag/v0.6.0>`_.


更改编译器不用关注的修改
=========================================

本节列出了代码行为可能发生的更改, 而编译器不会告诉您。


* 求幂的结果类型是基数的类型。 曾经是最小的可以容纳基数和指数的类型, 此外,幂的基数类型允许使用带符号的类型。


需要明确指定的更改
=========================

本节列出了现在需要更明确地显示代码的更改, 但是语义不会改变。
对于大多数情况,编译器将提供建议。


* 现在,仅当函数被标记为 ``virtual`` 或在接口中定义 时,才可以覆盖。
  在接口外部没有实现的函数必须标记为 ``virtual`` 。
  覆盖函数或修饰符时,必须使用新关键字 ``override`` 。 覆盖多个基类定义的函数或修饰符时, 需要像这样 ``override(Base1, Base2)`` 列出.

* 访问数组的 ``length`` 现在是只读的, 即便是storage 数组. 不能通过修改length来调整数组的大小, 必须通过函数 ``push()``, ``push(value)`` 或 ``pop()``
或者分配一个完整的数组(不过这会覆盖现有内容)。 这个修改背后的原因是为了防止存储冲突.


* 关键字 ``abstract`` 用来标记一个抽象合约. 如果合约有没有实现的函数, 需要使用。抽象合约不能通过 ``new`` 操作符创建,并且不能在编译期生成字节码(bytecode)。

* 库需要实现所有的函数,不仅仅是内部函数.

* 内联汇编中声明的变量名称可以不再以 ``_slot`` 或 ``_offset`` 结尾。

* 内联汇编中的变量声明可能不会在内联汇编块之外屏蔽声明。
  如果名称包含一个点,则该点之前的前缀可能与内联汇编块外部的任何声明都没有冲突。

* 现在不允许状态变量屏蔽。 派生合约只能声明基类合约中都没有同名的可见状态变量 ``x`` (即如果基类合约中有共有的 状态变量 ``x``, 则派生合约不能在声明 ``x`` )。


语义和句法变化
==============================

本节列出了必须修改代码的更改.


* 现在禁止从外部函数类型到 ``address`` 的转换。 现在外部函数类型具有一个称为 ``address`` 的成员属性,类似于现有的 ``selector`` 成员。

* 对于动态的存储数组, 函数 ``push(value)`` 不再返回长度(现在什么都不返回).

* 未命名的函数通常称为 ``fallback function`` ,已拆分为一个使用 ``fallback`` 关键字定义的回退函数 和 使用关键字 ``receive`` 定义的接受以太函数.

* 如果有 ``receive`` 函数, 向合约转账的时候会调用,不管是否是调用数据(即便没有以太接收), ``receive`` 函数隐含带有 ``payable`` .

* 新的回退函数会被调用,当没有其他的函数被匹配时, (如果不存在 ``receive`` 函数,则没有调用数据的转账也会调用回退函数).
回退函数可以标记为 ``payable`` (也可以不标记). 如果没有 ``payable`` 那么附加以太的调用会revert.
    如果是需要实现升级或代理模式,则仅需要实现新的回退函数。


新特性
============

本节列出了在Solidity 0.6.0 之前不可能实现的事情,或者在Solidity 0.6.0之前很难实现的事情。


* 加入了 :ref:`try/catch 语句 <try-catch>` 使您可以对失败的外部调用做出反应。
* ``struct`` 和 ``enum`` 类型可以在文件级别声明.
* 数组切片可以用于 calldata 数组, 例如: ``abi.decode(msg.data[4:], (uint, uint))`` 是一个对函数调用payload进行解码底层方法。
* Natspec在开发人员文档中支持多个返回参数,并强制执行与 ``@param`` 的同名检查。
* Yul和Inline Assembly有一个名为 ``leave`` 的新语句,该语句退出当前函数.
* 现在可以通过 ``payable(x)`` 把 ``address`` 转换为 ``address payable`` , 当然 ``x`` 需要是 地址类型.

接口变化
=================

本节列出了与语言本身无关的更改,但这些更改会影响编译器的接口。
如果命令行上使用编译器的, 或编程方式使用, 或分析编译器输出时, 都会产生改变.


新错误报告器
~~~~~~~~~~~~~~~~~~
引入了一个新的错误报告器,能够在命令行输出可读性更强的错误信息。默认是开启的,但可以通过添加 ``--old-reporter`` 参数使用旧版本的错误报告器。


Metadata 哈希选项
~~~~~~~~~~~~~~~~~~~~~

编译器现在默认在字节码的末尾自带 `IPFS <https://ipfs.io/>`_ 元数据文件的哈希(更多的细节请参见 :doc:`contract metadata <metadata>`)。在0.6.0版本之前,编译器默认自带`Swarm <https://ethersphere.github.io/swarm-home/>`_ ,为了继续支持这个特性,引入了新的命令行选项 ``--metadata-hash`` 。在命令行选项中,可以选择将 ``ipfs`` 或 ``swarm`` 传入 ``--metadata-hash`` 来进行选择。
如果传入 ``none`` 则会不附带任何哈希值。

这些变化可以参见 :ref:`Standard JSON Interface<compiler-api>` 并且影响编译器生成的元数据JSON。

推荐阅读元数据的方法是去读最后的两字节,以决定CBOR编码,并且对数据区块选择合适的解码。参见: :ref:`metadata section<encoding-of-the-metadata-hash-in-the-bytecode>`。


Yul 优化器
~~~~~~~~~~~~~

与传统的字节码优化器一起, :doc:`Yul <yul>` 优化器现在默认开启,当你对编译器使用 ``--optimize`` 参数的时候,并且可以通过 ``--no-optimize-yul`` 参数关闭。这一选项主要影响的是 ABIEncoderV2。


C API 的变化
~~~~~~~~~~~~~

使用 ``libsolc`` 的C API的客户端代码现在由编译器使用的内存控制。 ``solidity_free`` 被重命名为 ``solidity_reset``来保持一致,添加了 ``solidity_alloc`` 函数和 ``solidity_free`` , ``solidity_compile`` 的返回值字符串现在必须通过 ``solidity_free()`` 来明确。


怎样修改代码
=======================

本节提供有关如何为每个重大变更更新先前代码的详细说明。


* 如果 ``f`` 是外部函数类型, ``address(f)`` 修改为 ``f.address``

* 接收以太的函数, ``function () external [payable] { ... }`` 修改为 ``receive() external payable { ... }``,
``fallback() external [payable] { ... }`` 或者两个度加上. 只要有可能,最好是仅仅使用 ``receive``  函数.


* 修改 ``uint length = array.push(value)`` 为 ``array.push(value);``. 通过 ``array.length``  获取长度.

* 修改 ``array.length++`` 为 ``array.push()`` 去增加storage数组长度,  用 ``pop()`` 去减少storage数组长度.

* 对于函数的 ``@dev`` 开发这文档中的每个命名返回参数,请定义一个 ``@return`` 条目,其中将返回参数名称作为第一个单词。
例如。 已定义函数 ``f()`` 是这样  ``function f() public returns (uint value)`` , 记录返回值的文档注释是这样: ``@return value 这是返回值.``
您可以混合使用命名和未命名的返回参数,只要按它们在返回元组类型中出现的顺序排列即可。

* 为内联汇编中的变量声明选择与内联汇编块外的声明不冲突的唯一标识符。

* 为每个非接口函数添加 ``virtual``. 对于单继承,请在每个重写函数中添加 ``override`` 。 对于多重继承,添加 ``override(A, B, ..)``, 在在括号中列出所有覆盖函数的的合约。
 当多个基类合约有相同定义的函数时,继承合约必须覆盖所有冲突的函数。
133 changes: 133 additions & 0 deletions 070-breaking-changes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
********************************
Solidity v0.7.0 重大更新
********************************

This section highlights the main breaking changes introduced in Solidity
version 0.7.0, along with the reasoning behind the changes and how to update
affected code.
For the full list check
`the release changelog <https://github.com/ethereum/solidity/releases/tag/v0.7.0>`_.


Silent Changes of the Semantics
===============================

* Exponentiation and shifts of literals by non-literals (e.g. ``1 << x`` or ``2 ** x``)
will always use either the type ``uint256`` (for non-negative literals) or
``int256`` (for negative literals) to perform the operation.
Previously, the operation was performed in the type of the shift amount / the
exponent which can be misleading.


Changes to the Syntax
=====================

* In external function and contract creation calls, Ether and gas is now specified using a new syntax:
``x.f{gas: 10000, value: 2 ether}(arg1, arg2)``.
The old syntax -- ``x.f.gas(10000).value(2 ether)(arg1, arg2)`` -- will cause an error.

* The global variable ``now`` is deprecated, ``block.timestamp`` should be used instead.
The single identifier ``now`` is too generic for a global variable and could give the impression
that it changes during transaction processing, whereas ``block.timestamp`` correctly
reflects the fact that it is just a property of the block.

* NatSpec comments on variables are only allowed for public state variables and not
for local or internal variables.

* The token ``gwei`` is a keyword now (used to specify, e.g. ``2 gwei`` as a number)
and cannot be used as an identifier.

* String literals now can only contain printable ASCII characters and this also includes a variety of
escape sequences, such as hexadecimal (``\xff``) and unicode escapes (``\u20ac``).

* Unicode string literals are supported now to accommodate valid UTF-8 sequences. They are identified
with the ``unicode`` prefix: ``unicode"Hello 😃"``.

* State Mutability: The state mutability of functions can now be restricted during inheritance:
Functions with default state mutability can be overridden by ``pure`` and ``view`` functions
while ``view`` functions can be overridden by ``pure`` functions.
At the same time, public state variables are considered ``view`` and even ``pure``
if they are constants.



Inline Assembly
---------------

* Disallow ``.`` in user-defined function and variable names in inline assembly.
It is still valid if you use Solidity in Yul-only mode.

* Slot and offset of storage pointer variable ``x`` are accessed via ``x.slot``
and ``x.offset`` instead of ``x_slot`` and ``x_offset``.

Removal of Unused or Unsafe Features
====================================

Mappings outside Storage
------------------------

* If a struct or array contains a mapping, it can only be used in storage.
Previously, mapping members were silently skipped in memory, which
is confusing and error-prone.

* Assignments to structs or arrays in storage does not work if they contain
mappings.
Previously, mappings were silently skipped during the copy operation, which
is misleading and error-prone.

Functions and Events
--------------------

* Visibility (``public`` / ``internal``) is not needed for constructors anymore:
To prevent a contract from being created, it can be marked ``abstract``.
This makes the visibility concept for constructors obsolete.

* Type Checker: Disallow ``virtual`` for library functions:
Since libraries cannot be inherited from, library functions should not be virtual.

* Multiple events with the same name and parameter types in the same
inheritance hierarchy are disallowed.

* ``using A for B`` only affects the contract it is mentioned in.
Previously, the effect was inherited. Now, you have to repeat the ``using``
statement in all derived contracts that make use of the feature.

Expressions
-----------

* Shifts by signed types are disallowed.
Previously, shifts by negative amounts were allowed, but reverted at runtime.

* The ``finney`` and ``szabo`` denominations are removed.
They are rarely used and do not make the actual amount readily visible. Instead, explicit
values like ``1e20`` or the very common ``gwei`` can be used.

Declarations
------------

* The keyword ``var`` cannot be used anymore.
Previously, this keyword would parse but result in a type error and
a suggestion about which type to use. Now, it results in a parser error.

Interface Changes
=================

* JSON AST: Mark hex string literals with ``kind: "hexString"``.
* JSON AST: Members with value ``null`` are removed from JSON output.
* NatSpec: Constructors and functions have consistent userdoc output.


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

This section gives detailed instructions on how to update prior code for every breaking change.

* Change ``x.f.value(...)()`` to ``x.f{value: ...}()``. Similarly ``(new C).value(...)()`` to
``new C{value: ...}()`` and ``x.f.gas(...).value(...)()`` to ``x.f{gas: ..., value: ...}()``.
* Change ``now`` to ``block.timestamp``.
* Change types of right operand in shift operators to unsigned types. For example change ``x >> (256 - y)`` to
``x >> uint(256 - y)``.
* Repeat the ``using A for B`` statements in all derived contracts if needed.
* Remove the ``public`` keyword from every constructor.
* Remove the ``internal`` keyword from every constructor and add ``abstract`` to the contract (if not already present).
* Change ``_slot`` and ``_offset`` suffixes in inline assembly to ``.slot`` and ``.offset``, respectively.
Loading