#!/bin/bash

# Quick compilation test for TokenFactory138

cd /home/intlc/projects/proxmox/smom-dbis-138
source scripts/lib/forge-scope.sh

echo "Testing TokenFactory138 compilation..."

# Try via-ir compilation (most likely to work)
echo "Compiling with --via-ir..."
if forge build --via-ir 2>&1 | grep -q "Compiler run successful"; then
    echo "✅ Compilation successful!"
    echo ""
    echo "TokenFactory138 is ready for deployment."
    echo ""
    echo "Deploy with:"
    echo "  forge script script/emoney/DeployChain138.s.sol:DeployChain138 \\"
    echo "    --rpc-url \$RPC_URL \\"
    echo "    --broadcast \\"
    echo "    --legacy \\"
    echo "    --gas-price 20000000000 \\"
    echo "    --via-ir \\"
    echo "    -vv"
    exit 0
else
    echo "❌ Compilation failed"
    echo ""
    echo "Checking for errors..."
    forge build --via-ir 2>&1 | grep -i "error" | head -10
    exit 1
fi
