diff --git a/website/docs/contribution/code-style-guide.mdx b/website/docs/contribution/code-style-guide.mdx
index 8d12e6ee..a484a4c8 100644
--- a/website/docs/contribution/code-style-guide.mdx
+++ b/website/docs/contribution/code-style-guide.mdx
@@ -1,10 +1,10 @@
---
sidebar_position: 3
title: Code Style Guide
-description: Code style guidelines for developing Compose facets and libraries
+description: Code style guidelines for developing Compose facets and modules
---
-This section outlines the code style guidelines for developing new facets and Solidity libraries in **Compose**.
+This section outlines the code style guidelines for developing new facets and Solidity modules in **Compose**.
Follow [Compose's design principles](/docs/design) when contributing code.
@@ -19,11 +19,11 @@ Follow the [Solidity feature ban](/docs/design/banned-solidity-features).
error ERC20InvalidSender(address _sender);
function transfer(address _to, uint256 _amount) external {}
```
-- **Camel Case:** Use camelCase for variable, function, contract, and library names, except for standard uppercase abbreviations (e.g., ERC).
- - Example: `totalSupply`, `LibERC20`, `ERC721Facet`
+- **Camel Case:** Use camelCase for variable, function, contract, and module names, except for standard uppercase abbreviations (e.g., ERC).
+ - Example: `totalSupply`, `ERC20Mod`, `ERC721Facet`
- **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.
-- **Libraries:** All functions in libraries use the `internal` visibility specifier.
+- **Modules:** All functions in modules use the `internal` visibility specifier.
### Value Resetting
- Use `delete` to set a value to zero.
diff --git a/website/docs/design/banned-solidity-features.mdx b/website/docs/design/banned-solidity-features.mdx
index 0b99343c..8b033c46 100644
--- a/website/docs/design/banned-solidity-features.mdx
+++ b/website/docs/design/banned-solidity-features.mdx
@@ -1,10 +1,10 @@
---
sidebar_position: 4
title: Banned Solidity Features
-description: Solidity language features that are banned from Compose facets and libraries.
+description: Solidity language features that are banned from Compose facets and modules.
---
-The following Solidity language features are **banned** from Compose facets and libraries.
+The following Solidity language features are **banned** from Compose facets and modules.
Compose restricts certain Solidity features to keep facet and library code **simpler**, **more consistent**, and **easier to reason about**.
@@ -96,7 +96,7 @@ function approve(address _spender, uint256 _value) public {
-All Solidity library functions must be declared `internal`.
+All Solidity module functions must be declared `internal`.
```solidity title="🚫 Not allowed"
function transfer() external {
@@ -106,10 +106,10 @@ function transfer() external {
-
+
```solidity title="🚫 Not allowed"
-using LibSomething for uint256;
+using SomethingMod for uint256;
```
@@ -140,7 +140,7 @@ if (x < 10) {
- No contract or library may use `selfdestruct`
+ No contract or module may use `selfdestruct`
```solidity title="🚫 Not allowed"
selfdestruct(owner);
```
diff --git a/website/docs/design/design-for-composition.mdx b/website/docs/design/design-for-composition.mdx
index a930e499..5399de1a 100644
--- a/website/docs/design/design-for-composition.mdx
+++ b/website/docs/design/design-for-composition.mdx
@@ -1,7 +1,7 @@
---
sidebar_position: 5
title: Design for Composition
-description: How to design Compose facets and libraries for composition.
+description: How to design Compose facets and modules for composition.
---
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
6. Facets are fully self-contained. They do not import anything.
-## Writing Facet Libraries
+## Writing Facet Modules
-1. Facet libraries are self-contained code units. They do not import anything.
-2. Each facet should have one corresponding facet library.
-3. Facet libraries are used to initialize facets on deployment and during upgrades.
-4. Facet libraries are also used to integrate custom facets with Compose facets.
-5. Facet libraries have one or more functions which are used to initialize storage variables during deployment.
+1. Facet modules are self-contained code units. They do not import anything.
+2. Each facet should have one corresponding facet modules.
+3. Facet modules are used to initialize facets on deployment and during upgrades.
+4. Facet modules are also used to integrate custom facets with Compose facets.
+5. Facet modules have one or more functions which are used to initialize storage variables during deployment.
-## Facets & Libraries
+## Facets & Modules
-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`.
+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`.
## Extending Facets
@@ -47,7 +47,7 @@ We focus on building **small, independent, and easy-to-read facets**. Each facet
9. Never add new variables to an existing struct.
:::info Important
-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.
+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.
:::
diff --git a/website/docs/design/written-to-be-read.mdx b/website/docs/design/written-to-be-read.mdx
index bf7bf4ff..d6c2b759 100644
--- a/website/docs/design/written-to-be-read.mdx
+++ b/website/docs/design/written-to-be-read.mdx
@@ -11,7 +11,7 @@ This is the top design and guiding principle of this project. We help our users
The design of Compose includes guidelines and rules that promote readability and consistency throughout the codebase.
-Though many people may contribute to the Compose standard library of facets and libraries, it should look like it was written by one person.
+Though many people may contribute to the Compose standard library of facets and modules, it should look like it was written by one person.
***
@@ -19,13 +19,13 @@ Though many people may contribute to the Compose standard library of facets and
Each facet is a complete, standalone unit. Its source file contains all the code it needs, with no imports or dependencies on other files.
-Likewise, each Solidity library is also self-contained, with no external imports or dependencies.
+Likewise, each Solidity module is also self-contained, with no external imports or dependencies.
***
### Facets Are Read from Top to Bottom
-Compose facets and libraries are written to be read naturally from top to bottom.
+Compose facets and modules are written to be read naturally from top to bottom.
Definitions appear before their use, so readers don't need to jump around the file to understand the code.
diff --git a/website/docs/facets/authentication.mdx b/website/docs/facets/authentication.mdx
index ec0025a8..8b158421 100644
--- a/website/docs/facets/authentication.mdx
+++ b/website/docs/facets/authentication.mdx
@@ -119,7 +119,7 @@ The `AccessControlFacet` provides standard role-based access control functionali
Here's how to integrate access control in your custom facet:
```solidity
-import {LibAccessControl} from "compose/LibAccessControl.sol";
+import {AccessControlMod} from "compose/AccessControlMod.sol";
contract AdminFacet {
// Define your custom role
@@ -163,11 +163,11 @@ bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
## Integration with Custom Facets
-Your custom facets can use `LibAccessControl` to check permissions:
+Your custom facets can use `AccessControlMod` to check permissions:
```solidity
-import {LibAccessControl} from "compose/LibAccessControl.sol";
-import {LibERC20} from "compose/LibERC20.sol";
+import {AccessControlMod} from "compose/AccessControlMod.sol";
+import {ERC20Mod} from "compose/ERC20Mod.sol";
contract TokenMinterFacet {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
@@ -175,18 +175,18 @@ contract TokenMinterFacet {
function mintTokens(address to, uint256 amount) external {
// Check minter permission
require(
- LibAccessControl.hasRole(MINTER_ROLE, msg.sender),
+ AccessControlMod.hasRole(MINTER_ROLE, msg.sender),
"TokenMinter: caller is not minter"
);
// Mint using Compose's ERC20 library
- LibERC20.mint(to, amount);
+ ERC20Mod.mint(to, amount);
}
}
```
-The `LibAccessControl` library accesses the same storage as `AccessControlFacet`, so permissions set through the facet are instantly available to your custom facets!
+The `AccessControlMod` library accesses the same storage as `AccessControlFacet`, so permissions set through the facet are instantly available to your custom facets!
## Security Considerations
@@ -226,17 +226,17 @@ contract TimeLockFacet {
uint256 duration
) external {
require(
- LibAccessControl.hasRole(DEFAULT_ADMIN_ROLE, msg.sender),
+ AccessControlMod.hasRole(DEFAULT_ADMIN_ROLE, msg.sender),
"Not admin"
);
- LibAccessControl.grantRole(OPERATOR_ROLE, account);
+ AccessControlMod.grantRole(OPERATOR_ROLE, account);
roleExpiry[account] = block.timestamp + duration;
}
function revokeExpiredRoles(address account) external {
if (block.timestamp >= roleExpiry[account]) {
- LibAccessControl.revokeRole(OPERATOR_ROLE, account);
+ AccessControlMod.revokeRole(OPERATOR_ROLE, account);
}
}
}
@@ -247,9 +247,9 @@ contract TimeLockFacet {
}
- title="Facets & Libraries"
+ title="Facets & Modules"
description="Learn how authentication integrates with the facet architecture."
- href="/docs/foundations/facets-and-libraries"
+ href="/docs/foundations/facets-and-modules"
/>
}
diff --git a/website/docs/facets/facets-and-libraries.mdx b/website/docs/facets/facets-and-modules.mdx
similarity index 79%
rename from website/docs/facets/facets-and-libraries.mdx
rename to website/docs/facets/facets-and-modules.mdx
index 943620a3..35e3cd63 100644
--- a/website/docs/facets/facets-and-libraries.mdx
+++ b/website/docs/facets/facets-and-modules.mdx
@@ -1,6 +1,6 @@
---
sidebar_position: 3
-title: Facets & Libraries
+title: Facets & Modules
description: Complete guide to all 30+ components with live examples, detailed documentation, and usage
draft: true
---
@@ -11,18 +11,18 @@ import FeatureGrid, { FeatureGridItem } from '@site/src/components/features/Feat
import DocCard, { DocCardGrid } from '@site/src/components/docs/DocCard';
## Overview
-Compose uses a dual-component architecture where **facets** provide complete implementations and **libraries** provide reusable helper functions. Both work with the same shared storage, enabling seamless integration.
+Compose uses a dual-component architecture where **facets** provide complete implementations and **modules** provide reusable helper functions. Both work with the same shared storage, enabling seamless integration.
-Facets are complete implementations. Libraries are helper functions. Both access the **same storage**.
+Facets are complete implementations. Modules are helper functions. Both access the **same storage**.
## Architecture Comparison
@@ -32,7 +32,7 @@ Facets are complete implementations. Libraries are helper functions. Both access
| Component | Purpose | Use Case |
|-----------|---------|----------|
| **Facets** | Complete, self-contained implementations | Use as-is in your diamond for standard functionality |
-| **Libraries** | Helper functions for custom facets | Import into your custom facets to extend Compose |
+| **Modules** | Helper functions for custom facets | Import into your custom facets to extend Compose |
@@ -64,11 +64,11 @@ Facets are fully functional smart contracts that can be added to your diamond:
// ERC721Facet provides standard NFT functionality
contract ERC721Facet {
function balanceOf(address owner) external view returns (uint256) {
- return LibERC721.balanceOf(owner);
+ return ERC721Mod.balanceOf(owner);
}
function ownerOf(uint256 tokenId) external view returns (address) {
- return LibERC721.ownerOf(tokenId);
+ return ERC721Mod.ownerOf(tokenId);
}
function transferFrom(
@@ -76,7 +76,7 @@ contract ERC721Facet {
address to,
uint256 tokenId
) external {
- LibERC721.transferFrom(from, to, tokenId);
+ ERC721Mod.transferFrom(from, to, tokenId);
}
// ... more standard ERC721 functions
@@ -87,9 +87,9 @@ contract ERC721Facet {
You can add `ERC721Facet` to your diamond and immediately have full ERC721 functionality!
-## Libraries: Helper Functions
+## Modules: Helper Functions
-Libraries provide internal functions that your custom facets can use:
+Modules provide internal functions that your custom facets can use:
-### Example: LibERC721
+### Example: ERC721Mod
```solidity
-// LibERC721 provides helper functions for custom facets
-library LibERC721 {
+// ERC721Mod provides helper functions for custom facets
+library ERC721Mod {
function mint(address to, uint256 tokenId) internal {
// Modifies storage that ERC721Facet reads
ERC721Storage storage s = erc721Storage();
@@ -137,11 +137,11 @@ library LibERC721 {
## The Magic: Shared Storage
-Both facets and libraries access the **same storage location** in your diamond:
+Both facets and modules access the **same storage location** in your diamond:
```solidity
// Your custom facet
-import {LibERC721} from "compose/LibERC721.sol";
+import {ERC721Mod} from "compose/ERC721Mod.sol";
contract GameNFTFacet {
function mintWithGameLogic(
@@ -154,10 +154,10 @@ contract GameNFTFacet {
"Not enough points"
);
- // Use LibERC721 to mint
+ // Use ERC721Mod to mint
// This modifies the SAME storage that
// ERC721Facet uses!
- LibERC721.mint(player, tokenId);
+ ERC721Mod.mint(player, tokenId);
// Now ERC721Facet.ownerOf(tokenId)
// returns player!
@@ -167,16 +167,16 @@ contract GameNFTFacet {
```
-You don't need to inherit from anything. You don't need to override functions. Just use the library functions and everything works together!
+You don't need to inherit from anything. You don't need to override functions. Just use the module functions and everything works together!
## Visual Diagram
```
-┌─────────────────────────────────────────┐
-│ Diamond Contract │
-├─────────────────────────────────────────┤
-│ │
+┌────────────────────────────────────────┐
+│ Diamond Contract │
+├────────────────────────────────────────┤
+│ │
│ ┌──────────────┐ ┌───────────────┐ │
│ │ ERC721Facet │ │ GameNFTFacet │ │
│ │ │ │ │ │
@@ -188,7 +188,7 @@ You don't need to inherit from anything. You don't need to override functions. J
│ │ ┌─────────────────┘ │
│ ▼ ▼ │
│ ┌─────────────┐ │
-│ │ LibERC721 │ │
+│ │ ERC721Mod │ │
│ └──────┬──────┘ │
│ │ │
│ ▼ │
@@ -196,8 +196,8 @@ You don't need to inherit from anything. You don't need to override functions. J
│ │ Storage │ │
│ │ (Shared) │ │
│ └─────────────┘ │
-│ │
-└─────────────────────────────────────────┘
+│ │
+└────────────────────────────────────────┘
```
## When to Use Each
@@ -216,7 +216,7 @@ You don't need to inherit from anything. You don't need to override functions. J
}
- title="Use Libraries When..."
+ title="Use Modules When..."
description="You're building custom facets that need to integrate with Compose."
>
@@ -232,8 +232,8 @@ You don't need to inherit from anything. You don't need to override functions. J
Let's build a game where players earn NFTs by completing quests:
```solidity
-import {LibERC721} from "compose/LibERC721.sol";
-import {LibAccessControl} from "compose/LibAccessControl.sol";
+import {ERC721Mod} from "compose/ERC721Mod.sol";
+import {AccessControlMod} from "compose/AccessControlMod.sol";
contract QuestRewardsFacet {
bytes32 public constant GAME_MASTER = keccak256("GAME_MASTER");
@@ -245,9 +245,9 @@ contract QuestRewardsFacet {
uint256 questId,
uint256 tokenId
) external {
- // Use LibAccessControl to check permissions
+ // Use AccessControlMod to check permissions
require(
- LibAccessControl.hasRole(GAME_MASTER, msg.sender),
+ AccessControlMod.hasRole(GAME_MASTER, msg.sender),
"Not authorized"
);
@@ -255,8 +255,8 @@ contract QuestRewardsFacet {
require(!questCompleted[questId], "Quest already claimed");
questCompleted[questId] = true;
- // Use LibERC721 to mint reward NFT
- LibERC721.mint(player, tokenId);
+ // Use ERC721Mod to mint reward NFT
+ ERC721Mod.mint(player, tokenId);
// The standard ERC721Facet.ownerOf(tokenId) now works!
// The player can transfer using ERC721Facet.transferFrom()!
@@ -273,8 +273,8 @@ Your `QuestRewardsFacet` mints NFTs that work with all standard ERC721 functions
}
- title="Do: Use Libraries in Custom Facets"
- description="Import and use library functions to integrate with Compose functionality."
+ title="Do: Use Modules in Custom Facets"
+ description="Import and use module functions to integrate with Compose functionality."
/>
}
@@ -289,11 +289,11 @@ Your `QuestRewardsFacet` mints NFTs that work with all standard ERC721 functions
}
title="Don't: Call Facets from Facets"
- description="Use libraries for facet-to-facet communication, not external calls."
+ description="Use modules for facet-to-facet communication, not external calls."
/>
-## Available Facets & Libraries
+## Available Facets & Modules
}
title="Quick Start"
- description="Build your first diamond with facets and libraries."
+ description="Build your first diamond with facets and modules."
href="/docs/getting-started/quick-start"
/>
diff --git a/website/docs/foundations/custom-facets.mdx b/website/docs/foundations/custom-facets.mdx
index a38b4537..b26f01b7 100644
--- a/website/docs/foundations/custom-facets.mdx
+++ b/website/docs/foundations/custom-facets.mdx
@@ -7,18 +7,18 @@ description: "Build your own facets that work seamlessly with existing Compose F
Many projects need custom functionality beyond the standard facets.
Compose is designed for this — you can build and integrate your own facets that work seamlessly alongside existing Compose facets.
-Compose provides Solidity libraries that expose the same storage layouts and internal logic used by its on-chain facets. This lets your custom facets share data and interact directly with Compose's reusable facets.
+Compose provides Solidity modules that expose the same storage layouts and internal logic used by its on-chain facets. This lets your custom facets share data and interact directly with Compose's reusable facets.
**Example: Adding Game Logic to ERC-721**
Suppose you're building an on-chain game and want to include the `ERC721Facet` in your diamond.
-You can add your own `GameNFTFacet` that extends functionality while still sharing the same ERC-721 storage through `LibERC721`:
+You can add your own `GameNFTFacet` that extends functionality while still sharing the same ERC-721 storage through `ERC721Mod`:
```Solidity
/**
- * Your custom facet integrates with Compose using libraries
+ * Your custom facet integrates with Compose using Modules
*/
-import {LibERC721} from "compose/LibERC721.sol";
+import {ERC721Mod} from "compose/ERC721Mod.sol";
contract GameNFTFacet {
function mintWithGameLogic(address player, uint256 tokenId) external {
@@ -28,10 +28,10 @@ contract GameNFTFacet {
require(playerHasEnoughPoints(player), "Not enough points");
/**
- * Use LibERC721 to mint - this modifies the SAME storage
+ * Use ERC721Mod to mint - this modifies the SAME storage
* that ERC721Facet uses for balanceOf(), ownerOf(), etc.
*/
- LibERC721.mint(player, tokenId);
+ ERC721Mod.mint(player, tokenId);
/**
* Now the player owns this NFT and can use standard
diff --git a/website/docs/foundations/facets-and-modules.mdx b/website/docs/foundations/facets-and-modules.mdx
index 694391fc..c0b35f11 100644
--- a/website/docs/foundations/facets-and-modules.mdx
+++ b/website/docs/foundations/facets-and-modules.mdx
@@ -26,11 +26,11 @@ Compose uses two complementary patterns for smart contract development:
- **Enable composition**: Allow custom facets to interact with Compose functionality
- **Initializes Deployment**: Used to set variables when deploying diamonds
-**Example**: `ERC20.sol` provides helper functions to interact with ERC-20 storage from custom facets.
+**Example**: `ERC20Mod.sol` provides helper functions to interact with ERC-20 storage from custom facets.
### The Key Insight: Shared Storage
-**Both facets and modules access the SAME storage in your diamond.** When `ERC721Facet` and `ERC721` both define identical storage at `keccak256("compose.erc721")`, they're reading and writing the same data. This is how your custom facets can extend Compose functionality without inheritance.
+**Both facets and modules access the SAME storage in your diamond.** When `ERC721Facet` and `ERC721Mod` both define identical storage at `keccak256("compose.erc721")`, they're reading and writing the same data. This is how your custom facets can extend Compose functionality without inheritance.
### When to Use Each
diff --git a/website/docs/foundations/index.mdx b/website/docs/foundations/index.mdx
index 0cd305f6..4859a2e3 100644
--- a/website/docs/foundations/index.mdx
+++ b/website/docs/foundations/index.mdx
@@ -46,7 +46,7 @@ import CalloutBox from '@site/src/components/ui/CalloutBox';
/>
}
size="medium"
diff --git a/website/docs/foundations/overview.mdx b/website/docs/foundations/overview.mdx
index 27c18c15..0c9fb410 100644
--- a/website/docs/foundations/overview.mdx
+++ b/website/docs/foundations/overview.mdx
@@ -30,10 +30,10 @@ import Callout from '@site/src/components/ui/Callout';
href="/docs/foundations/authentication"
/>
}
- href="/docs/foundations/facets-and-libraries"
+ href="/docs/foundations/facets-and-modules"
/>
-We recommend starting with **Facets & Libraries** to understand the core architecture, then moving to **Storage Patterns** to see how it all works together.
+We recommend starting with **Facets & Modules** to understand the core architecture, then moving to **Storage Patterns** to see how it all works together.
## Why These Matter
@@ -75,7 +75,7 @@ We recommend starting with **Facets & Libraries** to understand the core archite
The concepts in this section form the foundation of everything you'll build with Compose:
- **Authentication** ensures your contracts have proper access control
-- **Facets & Libraries** explain how to structure your code
+- **Facets & Modules** explain how to structure your code
- **Diamond Standard** provides the underlying architecture
- **Storage Patterns** enable the shared state that makes it all work
diff --git a/website/docs/foundations/solidity-modules.mdx b/website/docs/foundations/solidity-modules.mdx
index 9f1626db..5427171c 100644
--- a/website/docs/foundations/solidity-modules.mdx
+++ b/website/docs/foundations/solidity-modules.mdx
@@ -27,8 +27,8 @@ Compose uses clear naming patterns to distinguish Solidity file types:
- Files ending in **`Facet.sol`** (e.g., `ERC20Facet.sol`) contain facet contracts for diamonds.
- Files ending in **`Diamond.sol`** (e.g., `ExampleDiamond.sol`) implement diamond contracts.
-- Files that do **not** end in `Facet` or `Diamond` are **Solidity modules** — intended to be imported and used within facets or diamond contracts.
+- Files ending in **`Mod`** (e.g., `ERC20Mod.sol`) are **Solidity modules** — intended to be imported and used within facets or diamond contracts.
**Exception:**
-`Diamond.sol` is a **module**, not a diamond contract. It provides core diamond functionality that diamond contracts import.
+`DiamondMod.sol` is a **module**, not a diamond contract. It provides core diamond functionality that diamond contracts import.