#!/usr/bin/env bash
# Create deployment checklist based on current status

set -e

cd "$(dirname "$0")/../.."

echo "=== Creating Deployment Checklist ==="

cat > docs/DEPLOYMENT_CHECKLIST.md << 'EOF'
# Deployment Checklist

## Prerequisites

### Wallet Funding
- [ ] Mainnet ETH: Minimum 0.025 ETH (Current: Check with ./scripts/deployment/check-mainnet-balances.sh)
- [ ] Chain-138 native tokens: Minimum 1 ETH (Current: Check with ./scripts/deployment/check-wallet-balances.sh)
- [ ] LINK tokens: Recommended 10 LINK for CCIP fees

### Infrastructure
- [ ] Chain-138 RPC endpoint accessible
- [ ] Chain-138 CCIP Router address identified
- [ ] Chain-138 chain selector verified (0x000000000000008a)

### Contracts
- [ ] All contracts compiled successfully
- [ ] All tests passing
- [ ] Contract addresses documented

## Deployment Steps

### Phase 1: Mainnet Deployment
1. [ ] Deploy CCIPLogger to Ethereum Mainnet
   - Command: `npx hardhat run scripts/ccip-deployment/deploy-ccip-logger.js --network mainnet`
   - Verify: Check Etherscan
   - Update: Add address to .env

2. [ ] Verify CCIPLogger deployment
   - Check contract code on Etherscan
   - Test contract functions
   - Document address

### Phase 2: Chain-138 Infrastructure
1. [ ] Verify Chain-138 RPC endpoint
   - Test: `./scripts/deployment/check-rpc-status.sh`
   - Ensure connectivity

2. [ ] Identify CCIP Router address
   - Check Chainlink CCIP Directory
   - Verify router deployment
   - Update .env

### Phase 3: Chain-138 Bridge Deployment
1. [ ] Deploy CCIPWETH9Bridge
   - Command: `./scripts/deployment/deploy-bridges-chain138.sh`
   - Verify on-chain
   - Update .env

2. [ ] Deploy CCIPWETH10Bridge
   - Verify on-chain
   - Update .env

### Phase 4: Bridge Configuration
1. [ ] Configure WETH9 bridge destinations
   - Add Chain-138 destination to Mainnet bridge
   - Add Mainnet destination to Chain-138 bridge
   - Enable destinations

2. [ ] Configure WETH10 bridge destinations
   - Add Chain-138 destination to Mainnet bridge
   - Add Mainnet destination to Chain-138 bridge
   - Enable destinations

3. [ ] Verify bridge configuration
   - Test destination queries
   - Document configuration

### Phase 5: Testing
1. [ ] Pre-testing setup
   - Fund test wallet
   - Fund bridges with LINK
   - Verify CCIP Router connectivity

2. [ ] Test WETH9 cross-chain transfers
   - Mainnet → Chain-138
   - Chain-138 → Mainnet

3. [ ] Test WETH10 cross-chain transfers
   - Mainnet → Chain-138
   - Chain-138 → Mainnet

4. [ ] Edge case testing
   - Minimum/maximum amounts
   - Failed transfers
   - Replay protection

## Post-Deployment

### Monitoring
- [ ] Set up Etherscan alerts
- [ ] Set up event monitoring
- [ ] Set up balance monitoring
- [ ] Set up CCIP message tracking

### Documentation
- [ ] Update deployment addresses
- [ ] Document configuration
- [ ] Create operational runbooks

## Notes

- All deployment scripts are in `scripts/deployment/`
- Use `./scripts/automation/prepare-deployment.sh` to check prerequisites
- Use `./scripts/deployment/check-mainnet-deployment-status.sh` to verify deployments
EOF

echo "✅ Deployment checklist created at docs/DEPLOYMENT_CHECKLIST.md"
