Thank you for your interest in contributing. This document covers everything you need to get started.
- Rust (stable toolchain)
- Foundry (for running template tests)
- Node.js >= 16 (for Hardhat template tests)
- Git
git clone https://github.com/<your-username>/diamonds.git
cd diamondsgit remote add upstream https://github.com/collinsadi/diamonds.gitcd v2
cargo buildcargo run -- init
cargo run -- convert path/to/Contract.solv2/
├── src/
│ ├── main.rs # CLI entry point and subcommand routing
│ ├── banner.rs # ASCII banner
│ ├── prompt.rs # Interactive prompts (dialoguer)
│ ├── scaffold.rs # Template extraction and project scaffolding
│ └── convert/
│ ├── mod.rs # Convert command orchestrator
│ ├── parser.rs # Solidity AST parser (solang-parser)
│ └── codegen.rs # Diamond code generator
├── templates/ # Embedded project templates (9 variants)
└── Cargo.toml
Create a branch off main for every change. Use descriptive names:
| Prefix | Purpose | Example |
|---|---|---|
feat/ |
New feature | feat/add-erc1155-template |
fix/ |
Bug fix | fix/regex-false-positive |
refactor/ |
Code restructuring | refactor/split-codegen |
docs/ |
Documentation | docs/update-readme |
chore/ |
Maintenance | chore/bump-dependencies |
test/ |
Tests | test/convert-edge-cases |
git checkout -b feat/my-featureFollow Conventional Commits:
<type>(<scope>): <description>
Types: feat, fix, docs, style, refactor, test, chore, ci
Scopes (optional): v2, templates, npm, ci
Examples:
feat(v2): add ERC1155 template support
fix(templates): correct DiamondInit parameter encoding
docs: update installation instructions
chore(ci): add Windows ARM64 build target
Keep commits atomic — one logical change per commit. Avoid mixing unrelated changes.
Templates live in v2/templates/. There are 9 variants:
default/foundry,default/hardhat/javascript,default/hardhat/typescriptERC20/foundry,ERC20/hardhat/javascript,ERC20/hardhat/typescriptERC721/foundry,ERC721/hardhat/javascript,ERC721/hardhat/typescript
When editing a shared contract (like LibDiamond.sol or Diamond.sol), propagate the change to all variants that contain it. Inconsistencies between templates are bugs.
- Use
pragma solidity ^0.8.0;for maximum compatibility - Include
// SPDX-License-Identifier: MITin every file - Use custom errors instead of
requirestrings - Follow the Diamond Storage pattern for state management
- Run
cargo clippyand fix any warnings before committing - Run
cargo fmtto ensure consistent formatting - Keep public API surface minimal — prefer
pub(crate)overpubwhere possible
- Foundry template tests should pass with
forge testafter scaffolding - Hardhat template tests should pass with
npx hardhat testafter scaffolding - If you add a new template variant, include matching deploy scripts and test files
- Sync with upstream:
git fetch upstream
git rebase upstream/main- Make sure the CLI compiles:
cd v2 && cargo check- Test your changes by scaffolding a project and running its tests:
cargo run -- init
cd <scaffolded-project>
forge test # or npx hardhat test- Fill out the PR description: what you changed and why
- Link related issues with
Closes #<number> - Keep PRs focused — one feature or fix per PR
- PRs that touch templates should include a note confirming all affected variants were updated
- Large PRs should be broken into reviewable chunks
- A maintainer will review your PR
- Address feedback with new commits (don't force-push during review)
- Once approved, the PR will be squash-merged into
main
Before creating an issue:
- Search existing issues to avoid duplicates
- If one exists, comment on it rather than opening a new one
When creating a new issue:
- Use a clear, descriptive title:
Bug: scaffold fails with spaces in project name - Include steps to reproduce, expected behavior, and actual behavior
- Attach error output, screenshots, or logs when relevant
- Specify your OS, Rust version, and
diamonds --version
If you'd like to work on an existing issue, comment on it and wait for assignment before starting.
- Be respectful and constructive in all interactions
- Focus feedback on the code, not the person
- Ask questions when something is unclear
- Keep discussions on-topic
Open a Discussion or comment on the relevant issue.