You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-30Lines changed: 10 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ using Library for bytes
43
43
bytes._function()
44
44
```
45
45
46
-
We could remedy this by insisting on the use public functions. However, developers may prefer internal functions because they are more gas efficient to call, due to how libraries are compiled in Solidity:
46
+
Insisting on the use public functions could avoid this issue. However, we should not rely on this as a remedy as developers may prefer internal functions because they are more gas efficient to call, due to how libraries are compiled in Solidity:
47
47
48
48
> ... the code of internal library functions that are called from a contract and all functions called from therein will at compile time be included in the calling contract, and a regular JUMP call will be used instead of a DELEGATECALL. ([source](https://docs.soliditylang.org/en/latest/contracts.html#libraries))
49
49
@@ -67,12 +67,6 @@ Events should track things that _happened_ and so should be past tense. Using pa
67
67
68
68
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).
##### A. Prefer declaring structs and errors within the interface, contract, or library where they are used.
204
187
205
-
However, if a struct or error is used across many files, with no interface, contract, or library reasonably being the "owner," then define them in their own file. Multiple structs and errors can be defined together in one file.
188
+
##### B. If a struct or error is used across many files, with no interface, contract, or library reasonably being the "owner," then define them in their own file. Multiple structs and errors can be defined together in one file.
206
189
207
190
#### 6. Imports
208
191
209
192
##### A. Use named imports.
210
193
211
194
Named imports help readers understand what exactly is being used and where it is originally declared.
212
195
213
-
YES:
214
-
215
-
```solidity
216
-
import {Contract} from "./contract.sol"
217
-
```
218
-
219
196
NO:
220
197
221
198
```solidity
@@ -229,10 +206,13 @@ For convenience, named imports do not have to be used in test files.
229
206
YES:
230
207
231
208
```solidity
232
-
import {A} from './A.sol'
233
-
import {B} from './B.sol'
209
+
import {Contract} from "./contract.sol"
234
210
```
235
211
212
+
For convenience, named imports do not have to be used in test files.
213
+
214
+
##### B. Order imports alphabetically (A to Z) by file name.
0 commit comments