How decentdao/decent-contracts works
Project Type & Purpose
• This is a specialized smart contracts repository focused on governance – it implements the Azorius Protocol (a Safe module patterned after Zodiac and inspired by Usul from SekerDAO). Its purpose is to serve as a modular backend for DAOs, handling proposals and delegating voting to various BaseStrategy implementations.
• The project includes deployment scripts for several networks (e.g., mainnet, optimism, polygon, sepolia) and extensive tests. It is intended for use both as a standalone repository and as an npm package, to be consumed by other projects.
File Structure
a. Contracts Structure:
• The main logic is under the “contracts” folder. Notice further subdivisions:
• “deployables” – these are the primary deployable contract implementations (Azorius, ERC20, FreezeGuard, etc.).
• “interfaces” – contains interface definitions (for Decent, ERC6551, Hats, Sablier, etc.) that support composability and integration with external protocols.
• “mocks” – mock contracts for testing specific scenarios.
• “singletons” and “utilities” – helper contracts that serve as supporting infrastructure.
b. Deployment and Testing:
• There’s a “deploy” directory containing TypeScript deployment scripts (organized into “core” and “helpers”) that coordinate how contracts are deployed.
• “deployments” holds output artifacts (JSON files) for different networks, which signifies that the project supports multiple blockchain environments.
• “test” directory clearly separates tests for various contracts (deployables, modules, strategies, singletons) ensuring robust verification of functionality.
c. CI/CD and Configuration:
• Configuration files like “hardhat.config.ts”, “package.json”, and several configuration files for linting (.eslintrc.json), formatting (.prettierrc), and node versions show standard development practices.
• GitHub workflows under the “.github/workflows” directory indicate automated testing, syntax checking, and publishing steps.
a. Components to Include:
• Smart Contracts – break these into logical groups:
• Core Governance Module: Azorius contract (central manager) and its associated BaseStrategy implementations (voting modules).
• Deployable Contracts: ERC20Claim, Freeze Voting/Guard contracts, modules (account-abstraction, autonomous-admin, etc.), and strategies contracts.
• Interfaces and Singletons: Representing external connection points and supporting records.
• Deployment Infrastructure:
• Deployment Scripts (“deploy/core” and “deploy/helpers”) that manage the sequence of contract deployments.
• Deployment Artifacts: JSON files under “deployments” for different networks (Base, Mainnet, Optimism, Polygon, Sepolia) capturing deployed addresses, configuration, and input details.
• Testing and CI:
• Test Suites showing how each module is verified.
• GitHub CI workflows and scripts for continuous integration and publishing.
b. Relationships and Data Flow:
• Testing components become “consumers” of the contracts, validating behavior and upgradeability, and can be shown separately linked to the respective contract modules.
• External dependencies such as the Hardhat framework, deployment commands, and verification (Etherscan) can be represented as external services/tools.
c. Architectural Patterns & Design Principles:
• Modular design: The separation into deployables, interfaces, mocks, and singletons shows a modular approach enabling easy swapping or upgrading of contract components.
• Separation of concerns: The clear distinction between deployment logic, contract code, and testing artifacts.
• Extensibility: Provided by interfaces and multiple strategy implementations, which allow DAOs to customize governance features.
• Create adjacent clusters for supporting contracts (interfaces, singletons, deployables) grouped by purpose.