# Next Steps Checklist - Integration, Testing, and Deployment

**Date**: 2025-12-24  
**Status**: Ready for Execution

---

## Overview

This checklist provides a detailed, step-by-step guide for:
1. Testing all new contracts
2. Deploying contracts to ChainID 138
3. Integrating with existing system
4. End-to-end verification

---

## Phase 1: Testing ✅ (First Priority)

### 1.1 Compile Contracts
- [ ] Navigate to project directory
- [ ] Run `forge build --via-ir`
- [ ] Verify no compilation errors
- [ ] Check for warnings
- [ ] Verify all contracts compile successfully

### 1.2 Run Unit Tests
- [ ] Run CompliantUSDT tests: `forge test --match-path "test/compliance/CompliantUSDTTest.t.sol" -vv`
- [ ] Run TokenRegistry tests: `forge test --match-path "test/utils/TokenRegistryTest.t.sol" -vv`
- [ ] Run FeeCollector tests: `forge test --match-path "test/utils/FeeCollectorTest.t.sol" -vv`
- [ ] Run all tests: `forge test -vv`
- [ ] Verify all tests pass
- [ ] Check test coverage

### 1.3 Fix Issues
- [ ] Address any compilation errors
- [ ] Fix failing tests
- [ ] Verify test coverage is adequate
- [ ] Document any known issues

---

## Phase 2: Deployment

### 2.1 Environment Preparation
- [ ] Copy `.env.template` to `.env` (if not exists)
- [ ] Set `PRIVATE_KEY` environment variable
- [ ] Set `RPC_URL` or `RPC_URL_138` environment variable
- [ ] Set `COMPLIANCE_ADMIN` (defaults to deployer if not set)
- [ ] Set `USDT_OWNER` (defaults to deployer if not set)
- [ ] Set `USDC_OWNER` (defaults to deployer if not set)
- [ ] Set `TOKEN_REGISTRY_OWNER` (defaults to deployer if not set)
- [ ] Set `FEE_COLLECTOR_OWNER` (defaults to deployer if not set)
- [ ] Verify deployer has sufficient balance (minimum 0.1 ETH)
- [ ] Verify RPC connection: `cast block-number --rpc-url $RPC_URL`

### 2.2 Deploy Compliance Contracts
- [ ] Deploy ComplianceRegistry
  - [ ] Run deployment script
  - [ ] Save deployed address
  - [ ] Verify contract code on-chain
  - [ ] Update `.env` file
- [ ] Deploy CompliantUSDT
  - [ ] Run deployment script
  - [ ] Save deployed address
  - [ ] Verify contract code on-chain
  - [ ] Update `.env` file
- [ ] Deploy CompliantUSDC
  - [ ] Run deployment script
  - [ ] Save deployed address
  - [ ] Verify contract code on-chain
  - [ ] Update `.env` file

### 2.3 Deploy Utility Contracts
- [ ] Deploy TokenRegistry
  - [ ] Run deployment script
  - [ ] Save deployed address
  - [ ] Verify contract code on-chain
  - [ ] Update `.env` file
- [ ] Deploy FeeCollector
  - [ ] Run deployment script
  - [ ] Save deployed address
  - [ ] Verify contract code on-chain
  - [ ] Update `.env` file

### 2.4 Verify Deployments
- [ ] Check all contracts have code on-chain
- [ ] Verify contract addresses are correct
- [ ] Check transaction receipts
- [ ] Verify on block explorer
- [ ] Document all deployed addresses

---

## Phase 3: Integration

### 3.1 Register Contracts in ComplianceRegistry
- [ ] Register CompliantUSDT
  - [ ] Call `registerContract(address)` with CompliantUSDT address
  - [ ] Verify registration: `isContractRegistered(address)`
  - [ ] Check compliance status
- [ ] Register CompliantUSDC
  - [ ] Call `registerContract(address)` with CompliantUSDC address
  - [ ] Verify registration: `isContractRegistered(address)`
  - [ ] Check compliance status

### 3.2 Register Tokens in TokenRegistry
- [ ] Register CompliantUSDT
  - [ ] Call `registerToken(...)` with token details
  - [ ] Verify registration: `isTokenRegistered(address)`
  - [ ] Verify token info: `getTokenInfo(address)`
- [ ] Register CompliantUSDC
  - [ ] Call `registerToken(...)` with token details
  - [ ] Verify registration: `isTokenRegistered(address)`
  - [ ] Verify token info: `getTokenInfo(address)`

### 3.3 Configure FeeCollector
- [ ] Add fee recipients for ETH (if needed)
  - [ ] Call `addFeeRecipient(address,address,uint256)` for each recipient
  - [ ] Verify recipients: `getFeeRecipients(address)`
  - [ ] Verify shares total 10000 (100%)
- [ ] Add fee recipients for tokens (if needed)
  - [ ] Configure recipients for each token
  - [ ] Verify configuration

### 3.4 Update Service Configurations
- [ ] Update Oracle Publisher service `.env`
  - [ ] Add new contract addresses
  - [ ] Restart service if needed
- [ ] Update CCIP Monitor service `.env`
  - [ ] Add new contract addresses
  - [ ] Restart service if needed
- [ ] Update Keeper service `.env`
  - [ ] Add new contract addresses
  - [ ] Restart service if needed
- [ ] Update Tokenization service `.env`
  - [ ] Add new contract addresses
  - [ ] Restart service if needed

---

## Phase 4: End-to-End Testing

### 4.1 Test Token Operations
- [ ] Test CompliantUSDT transfer
  - [ ] Transfer tokens between addresses
  - [ ] Verify balances updated
  - [ ] Check events emitted
- [ ] Test CompliantUSDT pause/unpause
  - [ ] Pause contract
  - [ ] Verify transfers blocked
  - [ ] Unpause contract
  - [ ] Verify transfers work again
- [ ] Test CompliantUSDT mint/burn
  - [ ] Mint new tokens
  - [ ] Verify supply increased
  - [ ] Burn tokens
  - [ ] Verify supply decreased
- [ ] Repeat tests for CompliantUSDC

### 4.2 Test Registry Queries
- [ ] Query TokenRegistry
  - [ ] Get token info by address
  - [ ] Get token by symbol
  - [ ] List all tokens
  - [ ] Check token count
- [ ] Query ComplianceRegistry
  - [ ] Get compliance status
  - [ ] Check registration status
  - [ ] Verify legal framework version

### 4.3 Test Fee Collection
- [ ] Test ETH fee collection
  - [ ] Send ETH to FeeCollector
  - [ ] Verify balance increased
  - [ ] Distribute fees
  - [ ] Verify recipients received funds
- [ ] Test token fee collection
  - [ ] Approve and send tokens
  - [ ] Verify balance increased
  - [ ] Distribute fees
  - [ ] Verify recipients received tokens

### 4.4 Test Error Cases
- [ ] Test invalid operations
- [ ] Test access control
- [ ] Test pause functionality
- [ ] Test edge cases

---

## Phase 5: Documentation and Verification

### 5.1 Update Documentation
- [ ] Update deployment records
- [ ] Document all deployed addresses
- [ ] Document configuration steps
- [ ] Create deployment summary
- [ ] Update integration guides

### 5.2 Block Explorer Verification
- [ ] Verify ComplianceRegistry on explorer
- [ ] Verify CompliantUSDT on explorer
- [ ] Verify CompliantUSDC on explorer
- [ ] Verify TokenRegistry on explorer
- [ ] Verify FeeCollector on explorer
- [ ] Check transaction history
- [ ] Verify events are emitted correctly

### 5.3 Final Checklist
- [ ] All contracts deployed
- [ ] All contracts verified on-chain
- [ ] All contracts registered
- [ ] All configurations updated
- [ ] All tests passing
- [ ] All documentation updated
- [ ] All services configured
- [ ] System ready for production

---

## Quick Reference Commands

### Testing
```bash
cd /home/intlc/projects/proxmox/smom-dbis-138
forge build --via-ir
forge test -vv
```

### Deployment
```bash
# Automated
./scripts/deploy-all-compliance.sh
./scripts/deploy-all-utilities.sh

# Manual
forge script script/DeployComplianceRegistry.s.sol:DeployComplianceRegistry \
  --rpc-url $RPC_URL --broadcast --legacy --gas-price 20000000000 --via-ir -vv
```

### Verification
```bash
cast code <address> --rpc-url $RPC_URL
cast call <address> "<function>" --rpc-url $RPC_URL
```

---

## Troubleshooting

### Common Issues

1. **Compilation Errors**
   - Check Solidity version
   - Verify imports are correct
   - Use `--via-ir` for stack too deep errors

2. **Deployment Failures**
   - Check deployer balance
   - Verify RPC connection
   - Check gas price
   - Verify constructor parameters

3. **Test Failures**
   - Check test setup
   - Verify mock contracts
   - Check event expectations

4. **Integration Issues**
   - Verify contract addresses
   - Check access control
   - Verify function parameters

---

**Last Updated**: 2025-12-24  
**Status**: Ready for Execution

