First off, thank you for considering contributing to NFT Marketplace Diamond! It's people like you that make this project such a great tool.
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code.
We use GitHub to host code, to track issues and feature requests, as well as accept pull requests.
- Fork the repo and create your branch from
main
. - If you've added code that should be tested, add tests.
- If you've changed APIs, update the documentation.
- Ensure the test suite passes.
- Make sure your code lints.
- Issue that pull request!
-
Clone the repository:
git clone https://github.com/your-username/nft-marketplace-diamond.git cd nft-marketplace-diamond
-
Install dependencies:
npm install
-
Set up your environment:
- Copy
.env.example
to.env
- Fill in required environment variables
- Copy
-
Testing
npm run test # Run all tests
-
Linting
npm run lint:all # Check code style
-
Compilation
npm run compile # Compile contracts
-
Adding a New Facet
- Create a new file in
contracts/diamond/facets/
- Implement the facet interface
- Add tests in
test/
- Update deployment scripts if necessary
Example structure:
// contracts/diamond/facets/NewFacet.sol contract NewFacet { event NewEvent(...); error CustomError(); function newFunction() external { // Implementation } }
- Create a new file in
-
Modifying Existing Facets
- Ensure backward compatibility
- Update tests accordingly
- Document changes in the facet's comments
-
Diamond Cuts
- Use the DiamondCutFacet for adding/replacing/removing functions
- Test all diamond cut operations thoroughly
- Follow the pattern in
test/DiamondCut.test.js
-
Test Structure
- Group tests by facet functionality
- Use descriptive test names
- Follow the existing test patterns
Example:
describe('NewFacet', function () { describe('Main Functionality', function () { it('Should perform expected operation', async function () { // Test implementation }); }); });
-
Test Coverage
- Aim for 100% coverage
- Test both success and failure cases
- Test edge cases and boundary conditions
-
Code Comments
- Use NatSpec format for contract documentation
- Document all public functions
- Explain complex logic
-
README Updates
- Update feature documentation
- Add new deployment instructions if needed
- Document breaking changes
-
Commit Messages
- Use clear, descriptive commit messages
- Reference issues and pull requests
- Follow conventional commits format
-
Pull Request Process
- Create a feature branch
- Add tests and documentation
- Update CHANGELOG.md
- Request review from maintainers
-
Code Review
- Address review comments
- Keep discussions focused
- Be respectful and constructive
-
Smart Contract Security
- Follow Solidity best practices
- Consider reentrancy and other common vulnerabilities
- Test edge cases thoroughly
-
Diamond Standard Specifics
- Understand diamond storage patterns
- Test facet interactions
- Verify selector conflicts
- Open an issue for bugs
- Join our community Discord for discussions
- Check existing documentation and issues first
By contributing, you agree that your contributions will be licensed under the project's MIT License.
Thank you for contributing to NFT Marketplace Diamond! 🎉