From 9d019ecbdafa8d88462851dd33326d7cafec46a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 15 Sep 2023 14:52:28 +0200 Subject: [PATCH 1/4] docs: Remove an outdated reference to Serenity --- docs/contracts/events.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contracts/events.rst b/docs/contracts/events.rst index 84b5293c0..8c73c3160 100644 --- a/docs/contracts/events.rst +++ b/docs/contracts/events.rst @@ -15,7 +15,7 @@ arguments to be stored in the transaction's log - a special data structure in the blockchain. These logs are associated with the address of the contract that emitted them, are incorporated into the blockchain, and stay there as long as a block is accessible (forever as of now, but this might -change with Serenity). The Log and its event data is not accessible from within +change in the future). The Log and its event data is not accessible from within contracts (not even from the contract that created them). It is possible to request a Merkle proof for logs, so if From 3141b343a98ce2ce76dfa5bcd244ede5a7b3c584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 15 Sep 2023 14:53:47 +0200 Subject: [PATCH 2/4] docs: Update the list of definitions in a contract whose names do not clash when inherited --- docs/contracts/inheritance.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/contracts/inheritance.rst b/docs/contracts/inheritance.rst index 7756ce93d..c787c5af6 100644 --- a/docs/contracts/inheritance.rst +++ b/docs/contracts/inheritance.rst @@ -590,9 +590,11 @@ One area where inheritance linearization is especially important and perhaps not Inheriting Different Kinds of Members of the Same Name ====================================================== -It is an error when any of the following pairs in a contract have the same name due to inheritance: - - a function and a modifier - - a function and an event - - an event and a modifier +The only situations where, due to inheritance, a contract may contain multiple definitions sharing +the same name are: -As an exception, a state variable getter can override an external function. +- Overloading of functions. +- Overriding of virtual functions. +- Overriding of external virtual functions by state variable getters. +- Overriding of virtual modifiers. +- Overloading of events. From aad10bda9713cae1ceb0c42dda186830d9c7c86d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 15 Sep 2023 14:54:07 +0200 Subject: [PATCH 3/4] style guide: Use emit keyword when emitting events --- docs/style-guide.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/style-guide.rst b/docs/style-guide.rst index 266c1817f..4e42ea575 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -233,7 +233,7 @@ Yes: bytes32[] options ); - LongAndLotsOfArgs( + emit LongAndLotsOfArgs( sender, recipient, publicKey, @@ -251,7 +251,7 @@ No: uint256 amount, bytes32[] options); - LongAndLotsOfArgs(sender, + emit LongAndLotsOfArgs(sender, recipient, publicKey, amount, From 9c454b353846b90fde82d66e889a04c3d9725304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 15 Sep 2023 14:54:38 +0200 Subject: [PATCH 4/4] style guide: Add events and errors to the order of definitions at file level --- docs/style-guide.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/style-guide.rst b/docs/style-guide.rst index 4e42ea575..427ede5ee 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -1045,13 +1045,15 @@ No: Order of Layout *************** -Layout contract elements in the following order: +Contract elements should be laid out in the following order: 1. Pragma statements 2. Import statements -3. Interfaces -4. Libraries -5. Contracts +3. Events +4. Errors +5. Interfaces +6. Libraries +7. Contracts Inside each contract, library or interface, use the following order: