Skip to content

Commit 54bb3c8

Browse files
authored
Merge pull request #241 from jhuhnke/documentation-lib-to-mod
library --> module in website documentation
2 parents fc227a6 + cf51907 commit 54bb3c8

File tree

11 files changed

+90
-90
lines changed

11 files changed

+90
-90
lines changed

website/docs/contribution/code-style-guide.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
sidebar_position: 3
33
title: Code Style Guide
4-
description: Code style guidelines for developing Compose facets and libraries
4+
description: Code style guidelines for developing Compose facets and modules
55
---
66

7-
This section outlines the code style guidelines for developing new facets and Solidity libraries in **Compose**.
7+
This section outlines the code style guidelines for developing new facets and Solidity modules in **Compose**.
88

99
Follow [Compose's design principles](/docs/design) when contributing code.
1010

@@ -19,11 +19,11 @@ Follow the [Solidity feature ban](/docs/design/banned-solidity-features).
1919
error ERC20InvalidSender(address _sender);
2020
function transfer(address _to, uint256 _amount) external {}
2121
```
22-
- **Camel Case:** Use camelCase for variable, function, contract, and library names, except for standard uppercase abbreviations (e.g., ERC).
23-
- Example: `totalSupply`, `LibERC20`, `ERC721Facet`
22+
- **Camel Case:** Use camelCase for variable, function, contract, and module names, except for standard uppercase abbreviations (e.g., ERC).
23+
- Example: `totalSupply`, `ERC20Mod`, `ERC721Facet`
2424

2525
- **Facets:** Internal function names in facets should be prefixed with `internal` if they otherwise have the same name as an external function in the same facet. Usually, there should be few or no internal functions in facets; repeat code if it improves readability.
26-
- **Libraries:** All functions in libraries use the `internal` visibility specifier.
26+
- **Modules:** All functions in modules use the `internal` visibility specifier.
2727

2828
### Value Resetting
2929
- Use `delete` to set a value to zero.

website/docs/design/banned-solidity-features.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
sidebar_position: 4
33
title: Banned Solidity Features
4-
description: Solidity language features that are banned from Compose facets and libraries.
4+
description: Solidity language features that are banned from Compose facets and modules.
55
---
66

7-
The following Solidity language features are **banned** from Compose facets and libraries.
7+
The following Solidity language features are **banned** from Compose facets and modules.
88

99
Compose restricts certain Solidity features to keep facet and library code **simpler**, **more consistent**, and **easier to reason about**.
1010

@@ -96,7 +96,7 @@ function approve(address _spender, uint256 _value) public {
9696

9797
<Accordion title="No external functions in Solidity libraries">
9898

99-
All Solidity library functions must be declared `internal`.
99+
All Solidity module functions must be declared `internal`.
100100

101101
```solidity title="🚫 Not allowed"
102102
function transfer() external {
@@ -106,10 +106,10 @@ function transfer() external {
106106

107107
</Accordion>
108108

109-
<Accordion title="No `using` directives in libraries">
109+
<Accordion title="No `using` directives in modules">
110110

111111
```solidity title="🚫 Not allowed"
112-
using LibSomething for uint256;
112+
using SomethingMod for uint256;
113113
```
114114

115115
</Accordion>
@@ -140,7 +140,7 @@ if (x < 10) {
140140

141141
</Accordion>
142142
<Accordion title="No selfdestruct">
143-
No contract or library may use `selfdestruct`
143+
No contract or module may use `selfdestruct`
144144
```solidity title="🚫 Not allowed"
145145
selfdestruct(owner);
146146
```

website/docs/design/design-for-composition.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
sidebar_position: 5
33
title: Design for Composition
4-
description: How to design Compose facets and libraries for composition.
4+
description: How to design Compose facets and modules for composition.
55
---
66

77
Here are the guidelines and rules for creating composable facets.
@@ -20,17 +20,17 @@ We focus on building **small, independent, and easy-to-read facets**. Each facet
2020
6. Facets are fully self-contained. They do not import anything.
2121

2222

23-
## Writing Facet Libraries
23+
## Writing Facet Modules
2424

25-
1. Facet libraries are self-contained code units. They do not import anything.
26-
2. Each facet should have one corresponding facet library.
27-
3. Facet libraries are used to initialize facets on deployment and during upgrades.
28-
4. Facet libraries are also used to integrate custom facets with Compose facets.
29-
5. Facet libraries have one or more functions which are used to initialize storage variables during deployment.
25+
1. Facet modules are self-contained code units. They do not import anything.
26+
2. Each facet should have one corresponding facet modules.
27+
3. Facet modules are used to initialize facets on deployment and during upgrades.
28+
4. Facet modules are also used to integrate custom facets with Compose facets.
29+
5. Facet modules have one or more functions which are used to initialize storage variables during deployment.
3030

31-
## Facets & Libraries
31+
## Facets & Modules
3232

33-
1. Facets and facet libraries should not contain owner/admin authorization checks unless absolutely required or fundamental to the functionality being implemented. If permission or authorization checks are required, the facet should integrate with `OwnerFacet` or `AccessControlFacet`.
33+
1. Facets and facet modules should not contain owner/admin authorization checks unless absolutely required or fundamental to the functionality being implemented. If permission or authorization checks are required, the facet should integrate with `OwnerFacet` or `AccessControlFacet`.
3434

3535

3636
## Extending Facets
@@ -47,7 +47,7 @@ We focus on building **small, independent, and easy-to-read facets**. Each facet
4747
9. Never add new variables to an existing struct.
4848

4949
:::info Important
50-
Maintain the same order of variables in structs when reusing them across facets or libraries. Unused variables may only be removed from the end of a struct.
50+
Maintain the same order of variables in structs when reusing them across facets or modules. Unused variables may only be removed from the end of a struct.
5151
:::
5252

5353

website/docs/design/written-to-be-read.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ This is the top design and guiding principle of this project. We help our users
1111

1212
The design of Compose includes guidelines and rules that promote readability and consistency throughout the codebase.
1313

14-
Though many people may contribute to the Compose standard library of facets and libraries, it should look like it was written by one person.
14+
Though many people may contribute to the Compose standard library of facets and modules, it should look like it was written by one person.
1515

1616
***
1717

1818
### Facets Are Self-Contained
1919

2020
Each facet is a complete, standalone unit. Its source file contains all the code it needs, with no imports or dependencies on other files.
2121

22-
Likewise, each Solidity library is also self-contained, with no external imports or dependencies.
22+
Likewise, each Solidity module is also self-contained, with no external imports or dependencies.
2323

2424
***
2525

2626
### Facets Are Read from Top to Bottom
2727

28-
Compose facets and libraries are written to be read naturally from top to bottom.
28+
Compose facets and modules are written to be read naturally from top to bottom.
2929

3030
Definitions appear before their use, so readers don't need to jump around the file to understand the code.
3131

website/docs/facets/authentication.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ The `AccessControlFacet` provides standard role-based access control functionali
119119
Here's how to integrate access control in your custom facet:
120120

121121
```solidity
122-
import {LibAccessControl} from "compose/LibAccessControl.sol";
122+
import {AccessControlMod} from "compose/AccessControlMod.sol";
123123
124124
contract AdminFacet {
125125
// Define your custom role
@@ -163,30 +163,30 @@ bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
163163

164164
## Integration with Custom Facets
165165

166-
Your custom facets can use `LibAccessControl` to check permissions:
166+
Your custom facets can use `AccessControlMod` to check permissions:
167167

168168
```solidity
169-
import {LibAccessControl} from "compose/LibAccessControl.sol";
170-
import {LibERC20} from "compose/LibERC20.sol";
169+
import {AccessControlMod} from "compose/AccessControlMod.sol";
170+
import {ERC20Mod} from "compose/ERC20Mod.sol";
171171
172172
contract TokenMinterFacet {
173173
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
174174
175175
function mintTokens(address to, uint256 amount) external {
176176
// Check minter permission
177177
require(
178-
LibAccessControl.hasRole(MINTER_ROLE, msg.sender),
178+
AccessControlMod.hasRole(MINTER_ROLE, msg.sender),
179179
"TokenMinter: caller is not minter"
180180
);
181181
182182
// Mint using Compose's ERC20 library
183-
LibERC20.mint(to, amount);
183+
ERC20Mod.mint(to, amount);
184184
}
185185
}
186186
```
187187

188188
<Callout type="success" title="Shared Storage Power">
189-
The `LibAccessControl` library accesses the same storage as `AccessControlFacet`, so permissions set through the facet are instantly available to your custom facets!
189+
The `AccessControlMod` library accesses the same storage as `AccessControlFacet`, so permissions set through the facet are instantly available to your custom facets!
190190
</Callout>
191191

192192
## Security Considerations
@@ -226,17 +226,17 @@ contract TimeLockFacet {
226226
uint256 duration
227227
) external {
228228
require(
229-
LibAccessControl.hasRole(DEFAULT_ADMIN_ROLE, msg.sender),
229+
AccessControlMod.hasRole(DEFAULT_ADMIN_ROLE, msg.sender),
230230
"Not admin"
231231
);
232232
233-
LibAccessControl.grantRole(OPERATOR_ROLE, account);
233+
AccessControlMod.grantRole(OPERATOR_ROLE, account);
234234
roleExpiry[account] = block.timestamp + duration;
235235
}
236236
237237
function revokeExpiredRoles(address account) external {
238238
if (block.timestamp >= roleExpiry[account]) {
239-
LibAccessControl.revokeRole(OPERATOR_ROLE, account);
239+
AccessControlMod.revokeRole(OPERATOR_ROLE, account);
240240
}
241241
}
242242
}
@@ -247,9 +247,9 @@ contract TimeLockFacet {
247247
<FeatureGrid columns={2}>
248248
<FeatureGridItem
249249
icon={<Icon name="diamond" size={32} />}
250-
title="Facets & Libraries"
250+
title="Facets & Modules"
251251
description="Learn how authentication integrates with the facet architecture."
252-
href="/docs/foundations/facets-and-libraries"
252+
href="/docs/foundations/facets-and-modules"
253253
/>
254254
<FeatureGridItem
255255
icon={<Icon name="shield" size={32} />}

0 commit comments

Comments
 (0)