Skip to content

Commit

Permalink
Remove formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
anikaraghu committed May 14, 2024
1 parent 47c73b0 commit ec2ed93
Showing 1 changed file with 10 additions and 30 deletions.
40 changes: 10 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ using Library for bytes
bytes._function()
```

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:
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:

> ... 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))
Expand All @@ -67,12 +67,6 @@ Events should track things that _happened_ and so should be past tense. Using pa

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).

YES:

```solidity
event OwnerUpdated(address newOwner);
```

NO:

```solidity
Expand All @@ -87,6 +81,8 @@ YES:
event OwnerUpdated(address newOwner);
```

##### B. Prefer `SubjectVerb` naming format.

NO:

```solidity
Expand Down Expand Up @@ -115,19 +111,6 @@ function validate(UserOperation calldata userOp) external returns (bytes memory

However, it is important to be explicit when returning early.

YES:

```solidity
function validate(UserOperation calldata userOp) external returns (bytes memory context, uint256 validationData) {
context = "";
validationData = 1;
if (condition) {
return (context, validationData);
}
}
```

NO:

```solidity
Expand Down Expand Up @@ -200,22 +183,16 @@ pragma solidity ^0.8.0;

#### 5. Struct and Error Definitions

This helps with clarity.
##### A. Prefer declaring structs and errors within the interface, contract, or library where they are used.

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.
##### 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.

#### 6. Imports

##### A. Use named imports.

Named imports help readers understand what exactly is being used and where it is originally declared.

YES:

```solidity
import {Contract} from "./contract.sol"
```

NO:

```solidity
Expand All @@ -229,10 +206,13 @@ For convenience, named imports do not have to be used in test files.
YES:

```solidity
import {A} from './A.sol'
import {B} from './B.sol'
import {Contract} from "./contract.sol"
```

For convenience, named imports do not have to be used in test files.

##### B. Order imports alphabetically (A to Z) by file name.

NO:

```solidity
Expand Down

0 comments on commit ec2ed93

Please sign in to comment.