chore: sync submodule state (parent ref update)

Made-with: Cursor
This commit is contained in:
defiQUG
2026-03-02 12:14:14 -08:00
parent b6a776e5d7
commit 25c96e210a
316 changed files with 29779 additions and 677 deletions

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Build the Snap companion site for https://explorer.d-bis.org/snap/
# Uses GATSBY_SNAP_API_BASE_URL=https://explorer.d-bis.org so Market data, Bridge, Swap cards work.
# For that to work, explorer.d-bis.org must serve the token-aggregation API at /api/v1/... (deploy
# smom-dbis-138/services/token-aggregation and proxy it, or set GATSBY_SNAP_API_BASE_URL to the API host).
# Output: packages/site/public/ (upload to /var/www/html/snap/ on VMID 5000).
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$ROOT"
export GATSBY_PATH_PREFIX=/snap
export GATSBY_SNAP_API_BASE_URL="${GATSBY_SNAP_API_BASE_URL:-https://explorer.d-bis.org}"
# So "Send on Chain 138" link is absolute HTTPS (avoids redirect to http and mixed-content).
export GATSBY_SNAP_SITE_URL="${GATSBY_SNAP_SITE_URL:-https://explorer.d-bis.org}"
# Production: use npm snap so MetaMask does not try to fetch localhost:8080 (GATSBY_* is inlined into client bundle).
export GATSBY_SNAP_ORIGIN="${GATSBY_SNAP_ORIGIN:-npm:chain138-snap}"
# Required for Gatsby to apply pathPrefix to script/asset URLs (see path prefix docs).
export PREFIX_PATHS=1
echo "Building Snap site: GATSBY_PATH_PREFIX=$GATSBY_PATH_PREFIX GATSBY_SNAP_SITE_URL=$GATSBY_SNAP_SITE_URL PREFIX_PATHS=$PREFIX_PATHS GATSBY_SNAP_ORIGIN=$GATSBY_SNAP_ORIGIN GATSBY_SNAP_API_BASE_URL=$GATSBY_SNAP_API_BASE_URL"
pnpm --filter site run build
echo "Done. Output in packages/site/public/ — deploy to /var/www/html/snap/ on explorer VM (VMID 5000)."

View File

@@ -1,144 +0,0 @@
#!/bin/bash
# Deploy Chain 138 Snap companion site to VMID 5000 (explorer host).
# Serves the site at https://explorer.d-bis.org/snap/
# Requires: built site (run with --build to build first), Proxmox host with pct or SSH.
set -euo pipefail
VMID=5000
VM_IP="${EXPLORER_VM_IP:-192.168.11.140}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SNAP_REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
SITE_PUBLIC="${SNAP_REPO_ROOT}/packages/site/public"
PROXMOX_HOST="${PROXMOX_HOST_R630_02:-192.168.11.12}"
BUILD_FIRST=false
for arg in "$@"; do
[ "$arg" = "--build" ] && BUILD_FIRST=true
done
echo "=========================================="
echo "Deploy Chain 138 Snap site to VMID $VMID"
echo "=========================================="
echo ""
if [ "$BUILD_FIRST" = true ]; then
echo "=== Building site (pathPrefix=/snap) ==="
BUILD_ENV="GATSBY_PATH_PREFIX=/snap GATSBY_BUILD_SHA=$(git rev-parse --short HEAD 2>/dev/null || echo 'unknown')"
[ -n "${GATSBY_SNAP_API_BASE_URL:-}" ] && BUILD_ENV="$BUILD_ENV GATSBY_SNAP_API_BASE_URL=$GATSBY_SNAP_API_BASE_URL"
(cd "$SNAP_REPO_ROOT" && eval "$BUILD_ENV" pnpm --filter site run build)
echo ""
fi
if [ ! -f "${SITE_PUBLIC}/index.html" ]; then
echo "❌ Site not built. Run from repo root: GATSBY_PATH_PREFIX=/snap pnpm --filter site run build"
echo " Or run this script with: $0 --build"
echo " For production API (market/bridge/swap): GATSBY_SNAP_API_BASE_URL=https://your-api.com $0 --build"
exit 1
fi
# Detect run context
if [ -f "/proc/1/cgroup" ] && grep -q "lxc" /proc/1/cgroup 2>/dev/null; then
echo "Running inside VMID $VMID"
DEPLOY_METHOD="direct"
run_in_vm() { "$@"; }
elif command -v pct &>/dev/null; then
echo "Running from Proxmox host (pct exec $VMID)"
DEPLOY_METHOD="pct"
run_in_vm() { pct exec $VMID -- "$@"; }
else
echo "Running from remote (SSH to $PROXMOX_HOST, then pct to $VMID)"
DEPLOY_METHOD="remote"
run_in_vm() { ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@"${PROXMOX_HOST}" "pct exec $VMID -- $*"; }
fi
echo "=== Creating tarball of site ==="
TARBALL="/tmp/snap-site-deploy-$$.tar"
(cd "$SITE_PUBLIC" && tar -cf "$TARBALL" .)
cleanup_tarball() { rm -f "$TARBALL"; }
trap cleanup_tarball EXIT
echo "✅ Tarball: $TARBALL"
# Keep last tarball for rollback (on host: /tmp/snap-site-last.tar; in VM: previous files overwritten)
LAST_TARBALL="/tmp/snap-site-last.tar"
cp "$TARBALL" "$LAST_TARBALL" 2>/dev/null || true
echo "✅ Rollback tarball saved: $LAST_TARBALL"
echo ""
echo "=== Deploying to /var/www/html/snap/ ==="
# Optional: backup current deploy for rollback (inside VM)
run_in_vm "mkdir -p /var/www/html/snap"
run_in_vm "tar -cf /var/www/html/snap-rollback.tar -C /var/www/html/snap . 2>/dev/null || true"
if [ "$DEPLOY_METHOD" = "direct" ]; then
tar -xf "$TARBALL" -C /var/www/html/snap
chown -R www-data:www-data /var/www/html/snap
elif [ "$DEPLOY_METHOD" = "remote" ]; then
TARNAME="$(basename "$TARBALL")"
scp -o ConnectTimeout=10 -o StrictHostKeyChecking=no "$TARBALL" root@"${PROXMOX_HOST}":/tmp/
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@"${PROXMOX_HOST}" "pct push $VMID /tmp/$TARNAME /tmp/snap-deploy.tar"
run_in_vm "tar -xf /tmp/snap-deploy.tar -C /var/www/html/snap"
run_in_vm "rm -f /tmp/snap-deploy.tar"
run_in_vm "chown -R www-data:www-data /var/www/html/snap"
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@"${PROXMOX_HOST}" "rm -f /tmp/$TARNAME"
else
pct push $VMID "$TARBALL" /tmp/snap-deploy.tar
run_in_vm "tar -xf /tmp/snap-deploy.tar -C /var/www/html/snap"
run_in_vm "rm -f /tmp/snap-deploy.tar"
run_in_vm "chown -R www-data:www-data /var/www/html/snap"
fi
echo "✅ Files deployed"
echo ""
echo "=== Nginx: ensure /snap/ is served ==="
if run_in_vm "grep -q 'location /snap/' /etc/nginx/sites-available/blockscout 2>/dev/null"; then
echo "✅ Nginx already has location /snap/"
run_in_vm "nginx -t && systemctl reload nginx" 2>/dev/null || true
else
echo "⚠️ Add location /snap/ to nginx on VMID $VMID (e.g. run explorer-monorepo scripts/fix-nginx-serve-custom-frontend.sh inside the VM)"
fi
echo ""
echo "=== Verification checks ==="
VERIFY_FAIL=0
if run_in_vm "test -f /var/www/html/snap/index.html"; then
echo "✅ /var/www/html/snap/index.html exists"
else
echo "❌ /var/www/html/snap/index.html missing"
VERIFY_FAIL=1
fi
if run_in_vm "grep -q 'location /snap/' /etc/nginx/sites-available/blockscout 2>/dev/null"; then
echo "✅ Nginx config has location /snap/"
else
echo "❌ Nginx config missing location /snap/"
VERIFY_FAIL=1
fi
SNAP_CODE="$(run_in_vm "curl -sS -o /dev/null -w '%{http_code}' --connect-timeout 5 http://127.0.0.1/snap/ 2>/dev/null" 2>/dev/null || echo "000")"
if [ "$SNAP_CODE" = "200" ]; then
echo "✅ http://localhost/snap/ returns 200"
else
echo "❌ http://localhost/snap/ returned $SNAP_CODE (expected 200)"
VERIFY_FAIL=1
fi
SNAP_BODY="$(run_in_vm "curl -sS --connect-timeout 5 http://127.0.0.1/snap/ 2>/dev/null | head -c 4096" 2>/dev/null || true)"
if echo "$SNAP_BODY" | grep -qE 'Connect|template-snap|Snap|MetaMask'; then
echo "✅ /snap/ response contains Snap app content"
else
echo "⚠️ /snap/ response may not contain expected content (check in browser)"
fi
if [ "$VERIFY_FAIL" -eq 1 ]; then
echo ""
echo "⚠️ Some checks failed; see above. Snap may still work if nginx is updated."
fi
echo ""
echo "=========================================="
echo "Deployment complete"
echo "=========================================="
echo "Snap site should be available at:"
echo " - https://explorer.d-bis.org/snap/"
echo " - http://${VM_IP}/snap/"
echo ""
echo "Run full verification: metamask-integration/chain138-snap/scripts/verify-snap-site-vmid5000.sh"
echo "Or explorer + snap: explorer-monorepo/scripts/verify-vmid5000-all.sh"
echo ""
echo "Rollback: re-deploy previous build with: run_in_vm 'tar -xf /var/www/html/snap-rollback.tar -C /var/www/html/snap' (or use $LAST_TARBALL from host)."
echo ""

View File

@@ -0,0 +1,55 @@
#!/usr/bin/env bash
# Run automatable items from docs/PRE_PUBLISH_TESTING.md (build, test, package contents, optional lint).
# Usage: [SKIP_LINT=1] [SKIP_E2E=1] bash scripts/verify-pre-publish.sh
set -e
cd "$(dirname "$0")/.."
ROOT="$PWD"
echo "=== Verify pre-publish (automatable items) ==="
echo "[1/5] Build..."
pnpm run build
echo "[2/5] Unit tests..."
pnpm run test
echo "[3/5] Package contents..."
SNAP_DIR="$ROOT/packages/snap"
for f in dist/bundle.js images/icon.svg snap.manifest.json; do
if [ ! -f "$SNAP_DIR/$f" ]; then
echo "Missing: packages/snap/$f"
exit 1
fi
done
echo " dist/bundle.js, images/icon.svg, snap.manifest.json OK"
echo "[4/5] Manifest vs package.json version..."
MANIFEST_VER=$(jq -r .version "$SNAP_DIR/snap.manifest.json")
PKG_VER=$(jq -r .version "$SNAP_DIR/package.json")
if [ "$MANIFEST_VER" != "$PKG_VER" ]; then
echo "Version mismatch: snap.manifest.json=$MANIFEST_VER package.json=$PKG_VER"
exit 1
fi
echo " Version $MANIFEST_VER OK"
if [ "${SKIP_LINT:-0}" != "1" ]; then
echo "[5/5] Lint (Prettier only; ESLint may have existing rules)..."
pnpm run lint:misc --check
else
echo "[5/5] Lint skipped (SKIP_LINT=1)"
fi
if [ "${SKIP_E2E:-0}" != "1" ]; then
echo "[E2E] Playwright (optional)..."
if pnpm run test:e2e 2>/dev/null; then
echo " E2E passed"
else
echo " E2E failed or not run (run 'npx playwright install' once if needed)"
fi
else
echo "[E2E] Skipped (SKIP_E2E=1)"
fi
echo "=== Automatable checks done. Complete manual items in docs/PRE_PUBLISH_TESTING.md ==="

View File

@@ -0,0 +1,159 @@
#!/usr/bin/env bash
# Verify token-aggregation API reachability, CORS, token logoURIs, and network iconUrls.
# Usage: ./verify-snap-api-and-icons.sh [API_BASE_URL]
# API_BASE_URL defaults to https://explorer.d-bis.org or from GATSBY_SNAP_API_BASE_URL.
# Requires: curl, jq
set -euo pipefail
API_BASE="${1:-${GATSBY_SNAP_API_BASE_URL:-https://explorer.d-bis.org}}"
API_BASE="${API_BASE%/}"
TOKEN_LIST_URL="${API_BASE}/api/v1/report/token-list?chainId=138"
NETWORKS_URL="${API_BASE}/api/v1/networks"
PASS=0
FAIL=0
check() {
if "$@"; then
((PASS++)) || true
return 0
else
((FAIL++)) || true
return 1
fi
}
echo "=============================================="
echo "Chain 138 Snap — API and Icons Verification"
echo "API base: $API_BASE"
echo "=============================================="
echo ""
# 1. Token list reachable
echo "1. Token list API reachable"
if body=$(curl -sS -L --connect-timeout 15 --max-time 30 "$TOKEN_LIST_URL" 2>/dev/null) && [ -n "$body" ]; then
if echo "$body" | jq -e . &>/dev/null; then
if echo "$body" | jq -e '.tokens' &>/dev/null; then
echo "$TOKEN_LIST_URL returns valid token list JSON"
((PASS++)) || true
else
echo "$TOKEN_LIST_URL returns JSON but no .tokens (proxy may route to wrong backend)"
((FAIL++)) || true
fi
else
echo "$TOKEN_LIST_URL returns invalid JSON"
((FAIL++)) || true
fi
else
echo "$TOKEN_LIST_URL failed to fetch"
((FAIL++)) || true
body=""
fi
echo ""
# 2. Networks API reachable
echo "2. Networks API reachable"
if net_body=$(curl -sS -L --connect-timeout 15 --max-time 30 "$NETWORKS_URL" 2>/dev/null) && [ -n "$net_body" ]; then
if echo "$net_body" | jq -e . &>/dev/null; then
if echo "$net_body" | jq -e '.networks' &>/dev/null; then
echo "$NETWORKS_URL returns valid networks JSON"
((PASS++)) || true
else
echo "$NETWORKS_URL returns JSON but no .networks (proxy may route to wrong backend)"
((FAIL++)) || true
fi
else
echo "$NETWORKS_URL returns invalid JSON"
((FAIL++)) || true
fi
else
echo "$NETWORKS_URL failed to fetch"
((FAIL++)) || true
net_body=""
fi
echo ""
# 3. CORS headers (allow browser/MetaMask fetch)
echo "3. CORS headers"
cors_headers=$(curl -sS -I -X OPTIONS -H "Origin: https://explorer.d-bis.org" -H "Access-Control-Request-Method: GET" "$TOKEN_LIST_URL" 2>/dev/null || true)
if echo "$cors_headers" | grep -qi "access-control-allow-origin"; then
echo " ✅ CORS headers present (token-aggregation uses cors())"
((PASS++)) || true
else
echo " ⚠ CORS headers not detected (OPTIONS preflight). GET may still work if server allows *."
echo " Token-aggregation uses cors() by default; verify in browser if issues occur."
fi
echo ""
# 4. Every token has logoURI
echo "4. Token logoURI"
if [ -n "$body" ]; then
missing=$(echo "$body" | jq -r '.tokens[]? | select(.logoURI == null or .logoURI == "") | .symbol' 2>/dev/null || true)
if [ -z "$missing" ]; then
count=$(echo "$body" | jq '.tokens | length' 2>/dev/null || echo 0)
echo " ✅ All $count tokens have logoURI"
((PASS++)) || true
else
echo " ❌ Tokens missing logoURI: $missing"
((FAIL++)) || true
fi
else
echo " ⏭ Skipped (token list not fetched)"
fi
echo ""
# 5. List-level logoURI
echo "5. List-level logoURI"
if [ -n "$body" ]; then
list_logo=$(echo "$body" | jq -r '.logoURI // empty' 2>/dev/null)
if [ -n "$list_logo" ]; then
echo " ✅ List logoURI: $list_logo"
((PASS++)) || true
else
echo " ⚠ List-level logoURI missing (optional)"
fi
else
echo " ⏭ Skipped (token list not fetched)"
fi
echo ""
# 6. Network iconUrls
echo "6. Network iconUrls"
if [ -n "$net_body" ]; then
missing=$(echo "$net_body" | jq -r '.networks[]? | select(.iconUrls == null or (.iconUrls | length) == 0) | "\(.chainName) (\(.chainIdDecimal))"' 2>/dev/null || true)
if [ -z "$missing" ]; then
count=$(echo "$net_body" | jq '.networks | length' 2>/dev/null || echo 0)
echo " ✅ All $count networks have iconUrls"
((PASS++)) || true
else
echo " ❌ Networks missing iconUrls: $missing"
((FAIL++)) || true
fi
else
echo " ⏭ Skipped (networks not fetched)"
fi
echo ""
# 7. Sample logo URL reachable
echo "7. Sample logo URLs"
if [ -n "$body" ]; then
sample_logo=$(echo "$body" | jq -r '.tokens[0].logoURI // empty' 2>/dev/null)
if [ -n "$sample_logo" ]; then
if curl -sS -o /dev/null -w "%{http_code}" -L --connect-timeout 10 "$sample_logo" 2>/dev/null | grep -qE "^(200|301|302)$"; then
echo " ✅ Sample logo reachable: ${sample_logo:0:60}..."
((PASS++)) || true
else
echo " ⚠ Sample logo may be unreachable: $sample_logo"
fi
fi
fi
echo ""
echo "=============================================="
echo "Result: $PASS passed, $FAIL failed"
echo "=============================================="
if [ "$FAIL" -gt 0 ]; then
exit 1
fi
exit 0

View File

@@ -1,82 +0,0 @@
#!/usr/bin/env bash
# Verify Chain 138 Snap site deployment on VMID 5000.
# Usage: ./verify-snap-site-vmid5000.sh [BASE_URL]
# BASE_URL defaults to https://explorer.d-bis.org (or use http://192.168.11.140 for LAN)
set -euo pipefail
BASE_URL="${1:-https://explorer.d-bis.org}"
BASE_URL="${BASE_URL%/}"
VMID=5000
VM_IP="${EXPLORER_VM_IP:-192.168.11.140}"
PROXMOX_HOST="${PROXMOX_HOST_R630_02:-192.168.11.12}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PASS=0
FAIL=0
check() {
local name="$1"
if eval "$2"; then
echo "$name"
((PASS++)) || true
return 0
else
echo "$name"
((FAIL++)) || true
return 1
fi
}
echo "=============================================="
echo "Snap site (VMID $VMID) verification"
echo "BASE_URL=$BASE_URL"
echo "=============================================="
echo ""
# 1) Public URL /snap/ returns 200 (follow redirects)
HTTP_CODE="$(curl -sS -L -o /dev/null -w "%{http_code}" --connect-timeout 10 "$BASE_URL/snap/" 2>/dev/null || echo 000)"
check "$BASE_URL/snap/ returns 200" "[ \"$HTTP_CODE\" = \"200\" ]"
# 2) /snap/ response contains Snap app content (follow redirects)
SNAP_BODY="$(curl -sS -L --connect-timeout 10 "$BASE_URL/snap/" 2>/dev/null | head -c 8192)" || true
check "/snap/ contains Snap app content (Connect|Snap|MetaMask)" "echo \"$SNAP_BODY\" | grep -qE 'Connect|template-snap|Snap|MetaMask'"
# 3) /snap/index.html returns 200 (follow redirects)
HTTP_CODE="$(curl -sS -L -o /dev/null -w "%{http_code}" --connect-timeout 10 "$BASE_URL/snap/index.html" 2>/dev/null || echo 000)"
check "$BASE_URL/snap/index.html returns 200" "[ \"$HTTP_CODE\" = \"200\" ]"
# 4) Optional: /snap/version.json returns 200 and valid JSON (build version/health)
VERSION_CODE="$(curl -sS -L -o /dev/null -w "%{http_code}" --connect-timeout 5 "$BASE_URL/snap/version.json" 2>/dev/null || echo 000)"
if [ "$VERSION_CODE" = "200" ]; then
echo "$BASE_URL/snap/version.json returns 200 (build version/health)"
((PASS++)) || true
else
echo "$BASE_URL/snap/version.json returned $VERSION_CODE (optional; set prebuild to generate)"
fi
# 6) Optional: when pct or SSH available, check inside VM
if command -v pct &>/dev/null; then
if pct exec $VMID -- test -f /var/www/html/snap/index.html 2>/dev/null; then
echo "✅ /var/www/html/snap/index.html exists in VM"
((PASS++)) || true
fi
if pct exec $VMID -- grep -q 'location /snap/' /etc/nginx/sites-available/blockscout 2>/dev/null; then
echo "✅ Nginx has location /snap/ in VM"
((PASS++)) || true
fi
elif ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@"${PROXMOX_HOST}" "pct exec $VMID -- test -f /var/www/html/snap/index.html" 2>/dev/null; then
echo "✅ /var/www/html/snap/index.html exists in VM (via SSH)"
((PASS++)) || true
fi
echo ""
echo "=============================================="
echo "Result: $PASS passed, $FAIL failed"
echo "=============================================="
if [ "$FAIL" -gt 0 ]; then
echo ""
echo "See: $SCRIPT_DIR/../DEPLOY_VMID5000.md"
exit 1
fi
exit 0