How bcnmy/nexus works
This project is a smart contract foundation for modular smart accounts built on the ERC-7579 standard. The repository supports both Foundry and Hardhat development environments, which is evident from the presence of configuration files (foundry.toml, hardhat.config.ts), separate deployment scripts (in scripts/foundry and scripts/hardhat), and extensive test directories for both frameworks. The README further confirms that this solution is aimed at streamlining contract development with a major focus on security, best practices, and efficiency in the blockchain space.
Main Components
• Smart Contracts: Represented by the “contracts” directory which is organized into several subdirectories such as base, common, factory, interfaces, modules, and utilities. This communicates that the project is highly modular with clearly separated contract concerns.
• Testing Frameworks: Two main testing components are present:
• Foundry-based tests (test/foundry) – includes unit tests, integration tests, and tests for forking networks.
• Hardhat-based tests (test/hardhat) – covers similar areas including deployment and smart account executions.
• Deployment Scripts: Found in the “scripts” directory with sub-folders for Foundry and Hardhat. These are used for deploying contracts to various networks (e.g., mainnet and testnet), which indicates a separation of deployment concerns.
• CI/CD & Automation: The .github directory with workflows, issue templates, and pull request templates outlines the inclusion of automated checks, branch naming policies, and gas/diff reporting through GitHub Actions.
• Development & Configuration: Files such as .env.example, package.json, tsconfig.json, and various YAML configuration files indicate the project’s reliance on both JavaScript/TypeScript tooling and Ethereum-specific tooling.
• Documentation & Audit Resources: The README links to additional documentation (wiki, external deployment references, security audits, and gas optimization details), and directories like audits provide external audit documentation.
Relationships and Interactions
• The contracts serve as the core business logic; they interact with each other via interfaces and library functions, and any factory modules help in creating instances of accounts or modules.
• Deployment scripts act as orchestrators that deploy these contracts to a blockchain. They often take into account network-specific configurations through dynamic network configuration scripts.
• Testing components ensure that each contract module is unit, integration, or fuzz tested, with Foundry and Hardhat tests working in parallel to ensure comprehensive coverage.
• CI/CD pipelines (configured via GitHub workflows) automatically run tests (both for Foundry and Hardhat), lint the code, generate gas and coverage reports, and ensure adherence to code quality standards.
Architectural Patterns and Design Principles
• Modularity: The repository is highly modularized. Contracts are split into interfaces, concrete implementations, factories, modules, and libraries, supporting a clean separation of concerns.
• Dual-Environment Support: By having both Foundry and Hardhat setups, developers can choose their preferred framework. This dual support suggests the use of wrappers or abstraction layers that ensure consistency across environments.
• Test-Driven Development (TDD): A comprehensive test suite across both frameworks highlights a strong commitment to TDD and ensures that each component from unit tests to end-to-end tests is well-covered.
• CI/CD and Automation: Integration with GitHub Actions for automated linting, testing, and deployment processes reinforces a modern DevOps approach.