|
| 1 | +# Project Structure |
| 2 | + |
| 3 | +This document provides an overview of the project's directory structure and explains the purpose of key files. |
| 4 | + |
| 5 | +## Directory Structure |
| 6 | + |
| 7 | +``` |
| 8 | +oracle-contracts/ |
| 9 | +├── contracts/ # Smart contract source files |
| 10 | +│ ├── Core/ # Core contract implementations |
| 11 | +│ │ ├── interface/ # Contract interfaces |
| 12 | +│ │ ├── parameters/ # Contract parameters |
| 13 | +│ │ └── storage/ # Storage contracts |
| 14 | +│ ├── lib/ # Utility libraries |
| 15 | +│ ├── mocks/ # Mock contracts for testing |
| 16 | +│ ├── randomNumber/ # Random number generation |
| 17 | +│ └── tokenization/ # Token-related contracts |
| 18 | +├── deploy/ # Deployment scripts |
| 19 | +├── deployed/ # Deployment addresses |
| 20 | +├── docker/ # Docker configuration |
| 21 | +├── migrations/ # Migration scripts |
| 22 | +├── scenarios/ # Test scenarios |
| 23 | +├── scripts/ # Utility scripts |
| 24 | +└── test/ # Test files |
| 25 | +``` |
| 26 | + |
| 27 | +## Key Files and Their Purpose |
| 28 | + |
| 29 | +### Root Directory Files |
| 30 | + |
| 31 | +- `hardhat.config.js` - Hardhat configuration including network settings, compiler options, and task definitions |
| 32 | +- `package.json` - Project dependencies and scripts |
| 33 | +- `.env.tpl` - Template for environment variables |
| 34 | +- `.solhint.json` - Solidity linting rules |
| 35 | +- `.prettierrc` - Code formatting rules |
| 36 | +- `codechecks.yml` - Code quality checks configuration |
| 37 | + |
| 38 | +### Contract Files |
| 39 | + |
| 40 | +#### Core Contracts |
| 41 | + |
| 42 | +``` |
| 43 | +contracts/Core/ |
| 44 | +├── BlockManager.sol # Manages epoch blocks and confirmations |
| 45 | +├── BondManager.sol # Handles data bond creation and management |
| 46 | +├── CollectionManager.sol # Manages data collections and jobs |
| 47 | +├── RewardManager.sol # Distributes rewards to participants |
| 48 | +├── StakeManager.sol # Handles staking and delegation |
| 49 | +└── VoteManager.sol # Manages voting and consensus |
| 50 | +``` |
| 51 | + |
| 52 | +#### Interfaces |
| 53 | + |
| 54 | +``` |
| 55 | +contracts/Core/interface/ |
| 56 | +├── IBlockManager.sol # Block management interface |
| 57 | +├── IBondManager.sol # Bond management interface |
| 58 | +├── ICollectionManager.sol # Collection management interface |
| 59 | +├── IRewardManager.sol # Reward distribution interface |
| 60 | +├── IStakeManager.sol # Stake management interface |
| 61 | +└── IVoteManager.sol # Vote management interface |
| 62 | +``` |
| 63 | + |
| 64 | +#### Parameters |
| 65 | + |
| 66 | +``` |
| 67 | +contracts/Core/parameters/ |
| 68 | +├── ACL.sol # Access control settings |
| 69 | +├── Governance.sol # Governance parameters |
| 70 | +└── child/ # Individual parameter contracts |
| 71 | + ├── BlockManagerParams.sol |
| 72 | + ├── BondManagerParams.sol |
| 73 | + ├── CollectionManagerParams.sol |
| 74 | + ├── RandomNoManagerParams.sol |
| 75 | + ├── RewardManagerParams.sol |
| 76 | + ├── StakeManagerParams.sol |
| 77 | + └── VoteManagerParams.sol |
| 78 | +``` |
| 79 | + |
| 80 | +#### Storage |
| 81 | + |
| 82 | +``` |
| 83 | +contracts/Core/storage/ |
| 84 | +├── BlockStorage.sol # Block-related storage |
| 85 | +├── BondStorage.sol # Bond-related storage |
| 86 | +├── CollectionStorage.sol # Collection-related storage |
| 87 | +├── Constants.sol # System constants |
| 88 | +├── StakeStorage.sol # Stake-related storage |
| 89 | +└── VoteStorage.sol # Vote-related storage |
| 90 | +``` |
| 91 | + |
| 92 | +### Libraries |
| 93 | + |
| 94 | +``` |
| 95 | +contracts/lib/ |
| 96 | +├── MerklePosAware.sol # Merkle tree utilities |
| 97 | +├── Random.sol # Random number utilities |
| 98 | +└── Structs.sol # Common data structures |
| 99 | +``` |
| 100 | + |
| 101 | +### Deployment |
| 102 | + |
| 103 | +``` |
| 104 | +deploy/ |
| 105 | +├── 001_deploy_governance.js # Governance deployment |
| 106 | +├── 002_deploy_block_manager.js # Block manager deployment |
| 107 | +├── 003_deploy_collection_manager.js # Collection manager deployment |
| 108 | +└── ... # Additional deployment scripts |
| 109 | +``` |
| 110 | + |
| 111 | +### Testing |
| 112 | + |
| 113 | +``` |
| 114 | +test/ |
| 115 | +├── helpers/ # Test helper functions |
| 116 | +│ ├── constants.js # Test constants |
| 117 | +│ ├── InternalEngine.js # Test engine |
| 118 | +│ └── testSetup.js # Test setup utilities |
| 119 | +├── ACL.js # Access control tests |
| 120 | +├── BlockManager.js # Block manager tests |
| 121 | +└── ... # Additional test files |
| 122 | +``` |
| 123 | + |
| 124 | +## File Categories and Their Uses |
| 125 | + |
| 126 | +### For Smart Contract Development |
| 127 | +- `contracts/Core/` - Main contract implementations |
| 128 | +- `contracts/Core/interface/` - Contract interfaces |
| 129 | +- `contracts/lib/` - Reusable libraries |
| 130 | +- `test/` - Contract tests |
| 131 | + |
| 132 | +### For Deployment |
| 133 | +- `deploy/` - Deployment scripts |
| 134 | +- `deployed/` - Network addresses |
| 135 | +- `migrations/` - Migration scripts |
| 136 | +- `.env.tpl` - Environment configuration |
| 137 | + |
| 138 | +### For Testing |
| 139 | +- `test/` - Test files |
| 140 | +- `test/helpers/` - Test utilities |
| 141 | +- `scenarios/` - Complex test scenarios |
| 142 | + |
| 143 | +### For Development Tools |
| 144 | +- `scripts/` - Utility scripts |
| 145 | +- `docker/` - Container configuration |
| 146 | +- `.solhint.json` - Linting rules |
| 147 | +- `.prettierrc` - Formatting rules |
| 148 | + |
| 149 | +## Common Development Workflows |
| 150 | + |
| 151 | +### 1. Contract Development |
| 152 | +Key files: |
| 153 | +- `contracts/Core/` for implementations |
| 154 | +- `contracts/Core/interface/` for interfaces |
| 155 | +- `test/` for tests |
| 156 | +- `.solhint.json` for linting rules |
| 157 | + |
| 158 | +### 2. Deployment Process |
| 159 | +Key files: |
| 160 | +- `deploy/` for deployment scripts |
| 161 | +- `.env` for configuration |
| 162 | +- `hardhat.config.js` for network settings |
| 163 | +- `deployed/` for addresses |
| 164 | + |
| 165 | +### 3. Testing |
| 166 | +Key files: |
| 167 | +- `test/` for test files |
| 168 | +- `test/helpers/` for utilities |
| 169 | +- `scenarios/` for complex tests |
| 170 | +- `contracts/mocks/` for mock contracts |
| 171 | + |
| 172 | +## Related Documentation |
| 173 | +- [Architecture Overview](architecture.md) |
| 174 | +- [Setup Guide](setup-and-installation.md) |
| 175 | +- [Contributing Guidelines](contributing.md) |
0 commit comments