Protocol
Reviewing the core modules to understand their purpose and architecture.
[6 tools called]
1. ModuleRegistry.sol Purpose
Purpose: Central service registry for module discovery and versioning.
Current Implementation:
Maps
bytes32 moduleId→address moduleAddressOwner-controlled registration (one-time, immutable)
Version query via
getModuleVersion()calling module'sgetVersion()
Problems:
No update mechanism (can't replace modules)
No version history tracking
No dependency management
Silent failures if module not registered
2. Versioning Management Spec
2.1 Directory Structure
2.2 Versioning Strategy
Semantic Versioning:
Major (v1, v2): Breaking changes, new architecture
Minor (v1.1, v1.2): New features, backward compatible
Patch (v1.1.1): Bug fixes only
Archive Process:
Create
archive/v{N}/directoryMove entire
contracts/XFT/→archive/v{N}/Add
archive/v{N}/README.mdwith:Deprecation date
Migration guide
Known issues
Deployment addresses (if on-chain)
Update
contracts/XFT/with new versionTag git commit:
v{N}-archive
Module Version Tracking:
3. Archive Migration Script
Proposed structure:
4. Core Module Functionality Specs
4.1 ModuleRegistry
Purpose: Service discovery and version management
Core Functions:
Use Cases:
Module discovery:
TransactionalModulefindsAuthorizationModuleVersion checking: Ensure compatible module versions
Upgrade coordination: Track module upgrades
4.2 AuthorizationModule
Purpose: Account whitelisting and role management
Core Functions:
Use Cases:
KYC/whitelisting: Only authorized accounts can transact
Admin control: Fund admins can settle transactions
Account freezing: Suspend compromised accounts
Role-based access: Different permissions for different roles
Dependencies:
ModuleRegistry (to find TransactionalModule for pending tx checks)
TokenRegistry (to get token address for balance checks)
4.3 TransactionalModule
Purpose: Transaction request storage and lifecycle management
Core Functions:
Use Cases:
Transaction queuing: Store buy/sell requests before settlement
Self-service: Allow users to create their own requests
Transaction lifecycle: Track pending → settled → cancelled
Batch operations: Support end-of-day settlement
Dependencies:
ModuleRegistry (to find AuthorizationModule for access checks)
TokenRegistry (to get token address for holdings checks)
4.4 TransferAgentModule
Purpose: Transaction settlement and share minting/burning
Core Functions:
Use Cases:
Settlement: Convert pending transactions to share mints/burns
Dividend distribution: Calculate and distribute dividends
End-of-day processing: Batch settlement + dividends
Account recovery: Recover funds from compromised accounts
Dependencies:
ModuleRegistry (to find AuthorizationModule, TransactionalModule)
TokenRegistry (to get token address)
MoneyMarketFund (to mint/burn shares)
5. Redesigned Architecture
5.1 Problems with Current Design
Deep nesting:
contracts/XFT/infrastructure/modules/upgrade_history/...Unclear dependencies: Modules don't initialize properly
No dependency injection: Hard-coded registry lookups
Version confusion:
_V3,_V5suffixes mixed withupgrade_history/Circular dependencies: Modules depend on each other via ModuleRegistry
5.2 Proposed Architecture
5.3 Key Design Changes
1. Flattened Structure
Remove
infrastructure/nestingRemove
upgrade_history/(use git tags instead)Clear separation:
core/,modules/,registry/
2. Explicit Dependencies
3. Initialization Pattern
4. Enhanced ModuleRegistry
5. Dependency Graph
5.4 Migration Checklist
This design improves clarity, maintainability, and upgradeability while preserving core functionality.
Last updated