From c983f8035e44f1469195b80304eec47e0f988162 Mon Sep 17 00:00:00 2001 From: Baptiste Oueriagli Date: Mon, 15 Apr 2024 13:19:11 +0000 Subject: [PATCH 1/4] precise event naming convention --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 27cf693..b484546 100644 --- a/README.md +++ b/README.md @@ -57,9 +57,9 @@ For example, `InsufficientBalance`. #### 3. Event names should be past tense. -For example, `UpdatedOwner` not `UpdateOwner`. +For example, `OwnerUpdated` not `UpdateOwner`. -Events should track things that _happened_ and so should be past tense. Using past tense also helps avoid naming collisions with structs or functions. +Events should track things that _happened_ and so should be past tense. Using past tense also helps avoid naming collisions with structs or functions. We also recommend following the `WhatAction`(e.g. `OwnerUpdated`) format rather than `ActionWhat` (e.g. `UpdatedOwner`). We are aware this does not follow precedent from early ERCs, like [ERC-20](https://eips.ethereum.org/EIPS/eip-20). However it does align with some more recent high profile Solidity, e.g. [1](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/976a3d53624849ecaef1231019d2052a16a39ce4/contracts/access/Ownable.sol#L33), [2](https://github.com/aave/aave-v3-core/blob/724a9ef43adf139437ba87dcbab63462394d4601/contracts/interfaces/IAaveOracle.sol#L25-L31), [3](https://github.com/ProjectOpenSea/seaport/blob/1d12e33b71b6988cbbe955373ddbc40a87bd5b16/contracts/zones/interfaces/PausableZoneEventsAndErrors.sol#L25-L41). From 9735033b9dc96c6da50a25212e37674d889e5bd2 Mon Sep 17 00:00:00 2001 From: Baptiste Oueriagli Date: Fri, 19 Apr 2024 14:45:11 +0000 Subject: [PATCH 2/4] make event format clearer --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b484546..af3c225 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ For example, `InsufficientBalance`. For example, `OwnerUpdated` not `UpdateOwner`. -Events should track things that _happened_ and so should be past tense. Using past tense also helps avoid naming collisions with structs or functions. We also recommend following the `WhatAction`(e.g. `OwnerUpdated`) format rather than `ActionWhat` (e.g. `UpdatedOwner`). +Events should track things that _happened_ and so should be past tense. Using past tense also helps avoid naming collisions with structs or functions. We also recommend following the `SubjectVerb`(e.g. `OwnerUpdated`) format rather than `VerbSubject` (e.g. `UpdatedOwner`). We are aware this does not follow precedent from early ERCs, like [ERC-20](https://eips.ethereum.org/EIPS/eip-20). However it does align with some more recent high profile Solidity, e.g. [1](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/976a3d53624849ecaef1231019d2052a16a39ce4/contracts/access/Ownable.sol#L33), [2](https://github.com/aave/aave-v3-core/blob/724a9ef43adf139437ba87dcbab63462394d4601/contracts/interfaces/IAaveOracle.sol#L25-L31), [3](https://github.com/ProjectOpenSea/seaport/blob/1d12e33b71b6988cbbe955373ddbc40a87bd5b16/contracts/zones/interfaces/PausableZoneEventsAndErrors.sol#L25-L41). From f1a60dbf218990f16e7dbc1880b296b3b7415e63 Mon Sep 17 00:00:00 2001 From: Baptiste Oueriagli Date: Wed, 24 Apr 2024 16:48:34 +0000 Subject: [PATCH 3/4] split events section --- README.md | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index af3c225..ac4908e 100644 --- a/README.md +++ b/README.md @@ -55,14 +55,40 @@ Custom errors are in some cases more gas efficient and allow passing useful info For example, `InsufficientBalance`. -#### 3. Event names should be past tense. +#### 3. Events -For example, `OwnerUpdated` not `UpdateOwner`. +##### A. Events names should be past tense. -Events should track things that _happened_ and so should be past tense. Using past tense also helps avoid naming collisions with structs or functions. We also recommend following the `SubjectVerb`(e.g. `OwnerUpdated`) format rather than `VerbSubject` (e.g. `UpdatedOwner`). +Events should track things that _happened_ and so should be past tense. Using past tense also helps avoid naming collisions with structs or functions. We are aware this does not follow precedent from early ERCs, like [ERC-20](https://eips.ethereum.org/EIPS/eip-20). However it does align with some more recent high profile Solidity, e.g. [1](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/976a3d53624849ecaef1231019d2052a16a39ce4/contracts/access/Ownable.sol#L33), [2](https://github.com/aave/aave-v3-core/blob/724a9ef43adf139437ba87dcbab63462394d4601/contracts/interfaces/IAaveOracle.sol#L25-L31), [3](https://github.com/ProjectOpenSea/seaport/blob/1d12e33b71b6988cbbe955373ddbc40a87bd5b16/contracts/zones/interfaces/PausableZoneEventsAndErrors.sol#L25-L41). +NO: + +```solidity +event OwnerUpdate(address newOwner); +``` + +YES: + +```solidity +event OwnerUpdated(address newOwner); +``` + +##### B. Prefer `SubjectVerb` naming format + +NO: + +```solidity +event UpdatedOwner(address newOwner); +``` + +YES: + +```solidity +event OwnerUpdated(address newOwner); +``` + #### 4. Avoid using assembly. Assembly code is hard to read and audit. We should avoid it unless the gas savings are very consequential, e.g. > 25%. From e7391731d2d1e4a6fa7d52a777d29f62a42e8d02 Mon Sep 17 00:00:00 2001 From: Baptiste Oueriagli Date: Wed, 24 Apr 2024 17:21:54 +0000 Subject: [PATCH 4/4] fix syntax --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac4908e..9350822 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ YES: event OwnerUpdated(address newOwner); ``` -##### B. Prefer `SubjectVerb` naming format +##### B. Prefer `SubjectVerb` naming format. NO: