From 4d4f8cedad7c9c76d622b2f9c539e5e5a42ff053 Mon Sep 17 00:00:00 2001 From: defiQUG Date: Tue, 23 Dec 2025 16:19:10 -0800 Subject: [PATCH] Initial commit: Chain 138 Explorer monorepo structure --- .gitignore | 43 ++ README.md | 78 +++ config/deployment.json | 16 + docs/DEPLOYMENT.md | 59 ++ frontend/public/index.html | 1200 ++++++++++++++++++++++++++++++++++++ package.json | 26 + scripts/deploy.sh | 67 ++ scripts/test.sh | 56 ++ 8 files changed, 1545 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 config/deployment.json create mode 100644 docs/DEPLOYMENT.md create mode 100644 frontend/public/index.html create mode 100644 package.json create mode 100755 scripts/deploy.sh create mode 100755 scripts/test.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c7281e --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# Dependencies +node_modules/ +vendor/ + +# Build outputs +dist/ +build/ +*.min.js +*.min.css + +# Environment files +.env +.env.local +.env.*.local + +# IDE +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS +.DS_Store +Thumbs.db + +# Logs +*.log +logs/ + +# Temporary files +tmp/ +temp/ +*.tmp + +# Deployment +deployment/.env +deployment/secrets/ + +# Testing +coverage/ +.nyc_output/ + diff --git a/README.md b/README.md new file mode 100644 index 0000000..99632db --- /dev/null +++ b/README.md @@ -0,0 +1,78 @@ +# Chain 138 Explorer Monorepo + +A comprehensive blockchain explorer for ChainID 138 with bridge monitoring and WETH utilities. + +## 🏗️ Monorepo Structure + +``` +explorer-monorepo/ +├── frontend/ # Frontend application +│ ├── src/ # Source files (if using build tools) +│ ├── assets/ # Static assets (images, fonts, etc.) +│ └── public/ # Public HTML/CSS/JS files +├── backend/ # Backend services (if needed) +│ └── api/ # API services +├── scripts/ # Deployment and utility scripts +├── docs/ # Documentation +├── deployment/ # Deployment configurations +├── config/ # Configuration files +└── package.json # Root package.json for monorepo +``` + +## ✨ Features + +- **Block Explorer**: Browse blocks, transactions, and addresses +- **Bridge Monitoring**: Monitor CCIP bridge contracts and cross-chain activity +- **WETH Utilities**: Wrap/unwrap ETH using WETH9 and WETH10 contracts +- **MetaMask Integration**: Full wallet connectivity and transaction signing +- **Real-time Updates**: Live network statistics and data + +## 🚀 Quick Start + +### Installation + +```bash +# Clone the repository +git clone +cd explorer-monorepo + +# Or if used as submodule +git submodule update --init --recursive +``` + +### Deployment + +```bash +# Deploy to production +./scripts/deploy.sh +``` + +## 📚 Documentation + +See the `docs/` directory for detailed documentation: +- API documentation +- Deployment guides +- Configuration references +- Feature documentation + +## 🔧 Development + +### Local Development + +```bash +# Serve locally +cd frontend/public +python3 -m http.server 8000 +``` + +### Build + +```bash +# If using build tools +npm run build +``` + +## 📝 License + +See LICENSE file for details. + diff --git a/config/deployment.json b/config/deployment.json new file mode 100644 index 0000000..62f5844 --- /dev/null +++ b/config/deployment.json @@ -0,0 +1,16 @@ +{ + "production": { + "host": "192.168.11.140", + "domain": "explorer.d-bis.org", + "deployment_path": "/var/www/html", + "backup_enabled": true, + "ssl_enabled": true + }, + "development": { + "host": "localhost", + "domain": "localhost", + "deployment_path": "./frontend/public", + "port": 8000 + } +} + diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.md new file mode 100644 index 0000000..bb7dd89 --- /dev/null +++ b/docs/DEPLOYMENT.md @@ -0,0 +1,59 @@ +# Deployment Guide + +## Production Deployment + +### Prerequisites + +- SSH access to production server (192.168.11.140) +- Password for root user +- `sshpass` installed (or use SSH keys) + +### Quick Deploy + +```bash +# From explorer-monorepo root +./scripts/deploy.sh +``` + +### Manual Deploy + +```bash +# Copy files manually +scp frontend/public/index.html root@192.168.11.140:/var/www/html/index.html +``` + +### Environment Variables + +The deployment script uses these environment variables: + +- `IP`: Production server IP (default: 192.168.11.140) +- `DOMAIN`: Domain name (default: explorer.d-bis.org) +- `PASSWORD`: SSH password (default: L@kers2010) + +```bash +IP=192.168.11.140 DOMAIN=explorer.d-bis.org ./scripts/deploy.sh +``` + +## Rollback + +If deployment fails, rollback to previous version: + +```bash +ssh root@192.168.11.140 +cp /var/www/html/index.html.backup.* /var/www/html/index.html +``` + +## Testing + +After deployment, test the explorer: + +```bash +./scripts/test.sh +``` + +Or manually: + +```bash +curl -k -I https://explorer.d-bis.org/ +``` + diff --git a/frontend/public/index.html b/frontend/public/index.html new file mode 100644 index 0000000..7b1a43f --- /dev/null +++ b/frontend/public/index.html @@ -0,0 +1,1200 @@ + + + + + + Chain 138 Explorer | d-bis.org | Bridge Monitoring & WETH Utilities + + + + + + + +
+ +
+
+ +
+ +
+
+

Latest Blocks

+ +
+
+
Loading blocks...
+
+
+ +
+
+

Latest Transactions

+ +
+
+
Loading transactions...
+
+
+
+ + +
+
+
+

WETH9 & WETH10 Utilities

+ +
+ + +
+ + MetaMask not connected + +
+ +
+ + + +
+ + +
+
+
WETH9 Token
+
+ Contract: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 +
+ +
+
+ ETH Balance: + - +
+
+ WETH9 Balance: + - +
+
+ +
+

Wrap ETH → WETH9

+
+ +
+ + +
+
+ +
+ +
+

Unwrap WETH9 → ETH

+
+ +
+ + +
+
+ +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+

All Blocks

+
+
+
Loading blocks...
+
+
+
+ +
+
+
+

All Transactions

+
+
+
Loading transactions...
+
+
+
+ +
+
+
+ +

Block Details

+
+
+
+
+ +
+
+
+ +

Transaction Details

+
+
+
+
+ +
+
+
+ +

Address Details

+
+
+
+
+
+ + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..4c9afc5 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "chain-138-explorer", + "version": "1.0.0", + "description": "Comprehensive blockchain explorer for ChainID 138", + "main": "frontend/public/index.html", + "scripts": { + "deploy": "./scripts/deploy.sh", + "test": "./scripts/test.sh", + "lint": "echo 'Linting not configured'" + }, + "keywords": [ + "blockchain", + "explorer", + "ethereum", + "blockscout", + "bridge", + "weth" + ], + "author": "", + "license": "MIT", + "repository": { + "type": "git", + "url": "" + } +} + diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100755 index 0000000..23705bc --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +# Deploy Explorer to Production +# Copies frontend files to the Blockscout container + +set -euo pipefail + +IP="${IP:-192.168.11.140}" +DOMAIN="${DOMAIN:-explorer.d-bis.org}" +PASSWORD="${PASSWORD:-L@kers2010}" + +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +CYAN='\033[0;36m' +NC='\033[0m' + +log_info() { echo -e "${BLUE}[INFO]${NC} $1"; } +log_success() { echo -e "${GREEN}[✓]${NC} $1"; } +log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } +log_error() { echo -e "${RED}[ERROR]${NC} $1"; } +log_step() { echo -e "${CYAN}[STEP]${NC} $1"; } + +# Get script directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" + +echo "════════════════════════════════════════════════════════" +echo "Deploy Chain 138 Explorer to Production" +echo "════════════════════════════════════════════════════════" +echo "" + +# Check if files exist +if [ ! -f "$REPO_ROOT/frontend/public/index.html" ]; then + log_error "Frontend file not found: $REPO_ROOT/frontend/public/index.html" + exit 1 +fi + +log_step "Step 1: Backing up current deployment..." +sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no root@"$IP" \ + "cp /var/www/html/index.html /var/www/html/index.html.backup.$(date +%Y%m%d_%H%M%S) 2>/dev/null || true" + +log_success "Backup created" + +log_step "Step 2: Deploying frontend files..." +sshpass -p "$PASSWORD" scp -o StrictHostKeyChecking=no \ + "$REPO_ROOT/frontend/public/index.html" \ + root@"$IP":/var/www/html/index.html + +log_success "Frontend deployed" + +log_step "Step 3: Verifying deployment..." +sleep 2 +if curl -k -sI "https://$DOMAIN/" 2>&1 | grep -qi "HTTP.*200"; then + log_success "Deployment verified - Explorer is accessible" +else + log_warn "Deployment completed but verification failed - check manually" +fi + +echo "" +log_success "Deployment complete!" +echo "" +log_info "Explorer URL: https://$DOMAIN/" +log_info "To rollback: ssh root@$IP 'cp /var/www/html/index.html.backup.* /var/www/html/index.html'" +echo "" + diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 0000000..6bf55a8 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# Test Explorer Functionality +# Runs basic tests on the deployed explorer + +set -euo pipefail + +DOMAIN="${DOMAIN:-explorer.d-bis.org}" + +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +CYAN='\033[0;36m' +NC='\033[0m' + +log_info() { echo -e "${BLUE}[INFO]${NC} $1"; } +log_success() { echo -e "${GREEN}[✓]${NC} $1"; } +log_error() { echo -e "${RED}[ERROR]${NC} $1"; } + +PASSED=0 +FAILED=0 + +test_endpoint() { + local name="$1" + local url="$2" + + if curl -k -sI "$url" 2>&1 | grep -qi "HTTP.*200"; then + log_success "$name: Passed" + ((PASSED++)) + return 0 + else + log_error "$name: Failed" + ((FAILED++)) + return 1 + fi +} + +echo "════════════════════════════════════════════════════════" +echo "Explorer Functionality Test" +echo "════════════════════════════════════════════════════════" +echo "" + +test_endpoint "Home Page" "https://$DOMAIN/" +test_endpoint "API Stats" "https://$DOMAIN/api/v2/stats" + +echo "" +echo "Tests Passed: $PASSED" +echo "Tests Failed: $FAILED" + +if [ $FAILED -eq 0 ]; then + exit 0 +else + exit 1 +fi +