3.2 KiB
3.2 KiB
TokenFactory138 Compilation Analysis
Date: 2025-12-24
Status: Pre-deployment analysis
✅ Contract Structure
TokenFactory138 is well-structured with:
- ✅ Proper imports
- ✅ Interface compliance
- ✅ Error handling
- ✅ Access control
⚠️ Potential Issue: Role Permissions
Problem
TokenFactory138 calls PolicyManager functions that require POLICY_OPERATOR_ROLE:
// In TokenFactory138.deployToken()
IPolicyManager(policyManager).setLienMode(token, config.defaultLienMode);
IPolicyManager(policyManager).setBridgeOnly(token, config.bridgeOnly);
IPolicyManager(policyManager).setBridge(token, config.bridge);
But PolicyManager requires POLICY_OPERATOR_ROLE:
// In PolicyManager
function setLienMode(...) external override onlyRole(POLICY_OPERATOR_ROLE)
function setBridgeOnly(...) external override onlyRole(POLICY_OPERATOR_ROLE)
function setBridge(...) external override onlyRole(POLICY_OPERATOR_ROLE)
Solution
The deployment script (DeployChain138.s.sol) should grant POLICY_OPERATOR_ROLE to TokenFactory138:
// After deploying TokenFactory138
policyManager.grantRole(policyManager.POLICY_OPERATOR_ROLE(), address(factory));
Check: Verify this is done in the deployment script.
✅ Compilation Test Commands
Test 1: Standard Compilation
cd /home/intlc/projects/proxmox/smom-dbis-138
forge build --contracts contracts/emoney/TokenFactory138.sol 2>&1 | tee /tmp/tf138-std.log
Expected: May show "Stack too deep" error
Test 2: Via-IR Compilation (Recommended)
cd /home/intlc/projects/proxmox/smom-dbis-138
forge build --via-ir --contracts contracts/emoney/TokenFactory138.sol 2>&1 | tee /tmp/tf138-viair.log
Expected: ✅ Compilation successful
Test 3: Full Project Build
cd /home/intlc/projects/proxmox/smom-dbis-138
forge build --via-ir 2>&1 | grep -i "error\|TokenFactory138" | head -20
✅ Dependency Check
All dependencies should exist:
- ✅
contracts/emoney/interfaces/ITokenFactory138.sol - ✅
contracts/emoney/interfaces/IeMoneyToken.sol - ✅
contracts/emoney/interfaces/IPolicyManager.sol - ✅
contracts/emoney/eMoneyToken.sol - ✅
contracts/emoney/errors/FactoryErrors.sol - ✅
contracts/emoney/errors/RegistryErrors.sol - ✅ OpenZeppelin contracts (via lib/)
✅ Pre-Deployment Checklist
- Run compilation test:
./scripts/compile-and-test-tokenfactory.sh - Verify no "Stack too deep" errors (use --via-ir)
- Check all dependencies compile
- Verify deployment script grants POLICY_OPERATOR_ROLE to TokenFactory138
- Ensure all required contracts are deployed first:
- ComplianceRegistry ✅
- DebtRegistry
- PolicyManager
- eMoneyToken (implementation)
🚀 Deployment Command
Once compilation passes:
cd /home/intlc/projects/proxmox/smom-dbis-138
source .env
forge script script/emoney/DeployChain138.s.sol:DeployChain138 \
--rpc-url $RPC_URL \
--broadcast \
--legacy \
--gas-price 20000000000 \
--via-ir \
-vv
Note: This deploys the entire eMoney system, including TokenFactory138.
Last Updated: 2025-12-24