-
Notifications
You must be signed in to change notification settings - Fork 25
add README to contracts dir #403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
emnul
wants to merge
1
commit into
main
Choose a base branch
from
feat/add-contracts-README
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Contracts README | ||
|
|
||
| This package contains the Compact smart contract source files, compiled artifacts, witness implementations, and test infrastructure for OpenZeppelin Contracts for Compact. | ||
|
|
||
| ## Directory Structure | ||
|
|
||
| ``` | ||
| contracts/ | ||
| ├── src/ # Source files | ||
| │ ├── access/ # Access control contracts | ||
| │ ├── security/ # Security utility contracts | ||
| │ ├── token/ # Token standard contracts | ||
| │ ├── utils/ # General utility contracts | ||
| │ ├── archive/ # Archived/deprecated contracts | ||
| │ └── test-utils/ # Shared test helpers | ||
| ├── artifacts/ # Compiled contract outputs (generated) | ||
| └── dist/ # Compiled TypeScript witness outputs (generated) | ||
| ``` | ||
|
|
||
| ## src/ | ||
|
|
||
| The `src/` directory is organized by module category. Each module follows the same internal layout: | ||
|
|
||
| ``` | ||
| <module>/ | ||
| ├── <Contract>.compact # Contract source | ||
| ├── witnesses/ # TypeScript witness implementations | ||
| └── test/ | ||
| ├── <Contract>.test.ts # Test suite | ||
| ├── mocks/ # Mock contracts (test-only — see warning below) | ||
| └── simulators/ # Simulator helpers for testing | ||
| ``` | ||
|
|
||
| ### src/access/ | ||
|
|
||
| Access control primitives for restricting who can call contract circuits. | ||
|
|
||
| | File | Description | | ||
| |------|-------------| | ||
| | `AccessControl.compact` | Role-based access control | | ||
| | `Ownable.compact` | Single-owner access control | | ||
| | `ShieldedAccessControl.compact` | Role-based access control with shielded (private) role assignments | | ||
| | `ZOwnablePK.compact` | Single-owner access control with shielded ownership | | ||
|
|
||
| ### src/security/ | ||
|
|
||
| Contracts that add common security patterns on top of other modules. | ||
|
|
||
| | File | Description | | ||
| |------|-------------| | ||
| | `Initializable.compact` | One-time initialization mechanism | | ||
| | `Pausable.compact` | Emergency pause/unpause mechanism | | ||
|
|
||
| ### src/token/ | ||
|
|
||
| Implementations of standard token interfaces. | ||
|
|
||
| | File | Description | | ||
| |------|-------------| | ||
| | `FungibleToken.compact` | ERC-20-style fungible token | | ||
| | `NonFungibleToken.compact` | ERC-721-style non-fungible token | | ||
| | `MultiToken.compact` | ERC-1155-style multi-token | | ||
|
|
||
| ### src/utils/ | ||
|
|
||
| Low-level utilities shared across modules. | ||
|
|
||
| | File | Description | | ||
| |------|-------------| | ||
| | `Utils.compact` | Common helper circuits | | ||
|
|
||
| ### src/archive/ | ||
|
|
||
| Contracts that are no longer actively maintained. Do not use in new projects. | ||
|
|
||
| ### src/test-utils/ | ||
|
|
||
| Shared TypeScript helpers used across test suites (e.g. address utilities). Not part of the public API. | ||
|
|
||
| --- | ||
|
|
||
| ## > ⚠️ Mock Contracts Are For Testing Only | ||
|
|
||
| Each module's `test/mocks/` directory contains `Mock*.compact` files (e.g. `MockFungibleToken.compact`, `MockOwnable.compact`, `MockAccessControl.compact`). | ||
|
|
||
| **These contracts exist solely to expose internal state and circuits for testing purposes. They must never be used in production.** | ||
|
|
||
| Mock contracts typically: | ||
| - Expose internal or protected circuits publicly for direct testing | ||
| - Skip access control or safety checks to isolate specific behaviors | ||
| - Introduce additional state that makes testing easier but is unsafe in deployment | ||
|
|
||
| **Using a Mock contract in production would undermine the security guarantees the corresponding production contract is designed to provide.** | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add fenced code block languages to satisfy markdownlint (MD040).
Line 7 and Line 24 use unlabeled fences. Add a language (e.g.,
text) to avoid lint noise in docs CI.Proposed fix
@@
-
+text/
├── .compact # Contract source
├── witnesses/ # TypeScript witness implementations
└── test/
├── .test.ts # Test suite
├── mocks/ # Mock contracts (test-only — see warning below)
└── simulators/ # Simulator helpers for testing
Also applies to: 24-32
🧰 Tools
🪛 markdownlint-cli2 (0.21.0)
[warning] 7-7: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We dont use this tool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emnul, understood — I'll skip markdownlint-specific suggestions for this repository going forward. Thanks for clarifying!✏️ Learnings added
🧠 Learnings used