From b77adf4e56c025cc1975ceb1c38cd6b42ad8511c Mon Sep 17 00:00:00 2001 From: libaice Date: Tue, 14 Apr 2026 03:06:20 +0800 Subject: [PATCH 1/2] chore: add installation script, Makefile, github actions, and update package metadata --- .github/workflows/ci.yml | 43 ++++++++++ .github/workflows/release.yml | 95 ++++++++++++++++++++ Cargo.toml | 5 ++ Makefile | 46 ++++++++++ README.md | 39 ++++++++- ghostguardup | 157 ++++++++++++++++++++++++++++++++++ 6 files changed, 384 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 Makefile create mode 100755 ghostguardup diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6e316c8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +env: + CARGO_TERM_COLOR: always + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo check --all-targets + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo test + + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - run: cargo fmt --check + + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - run: cargo clippy --all-targets -- -D warnings diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..078b040 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,95 @@ +name: Release + +on: + push: + tags: + - "v*" + +permissions: + contents: write + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + strategy: + matrix: + include: + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + name: linux-amd64 + - target: aarch64-unknown-linux-gnu + os: ubuntu-latest + name: linux-arm64 + - target: x86_64-apple-darwin + os: macos-13 + name: darwin-amd64 + - target: aarch64-apple-darwin + os: macos-14 + name: darwin-arm64 + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Install cross-compilation tools (Linux ARM64) + if: matrix.target == 'aarch64-unknown-linux-gnu' + run: | + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu + echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV + + - name: Build release binary + run: cargo build --release --target ${{ matrix.target }} + + - name: Package binary + run: | + cd target/${{ matrix.target }}/release + tar -czf ../../../ghostguard-${{ matrix.name }}.tar.gz ghostguard + cd ../../.. + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ghostguard-${{ matrix.name }} + path: ghostguard-${{ matrix.name }}.tar.gz + + release: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + merge-multiple: true + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: artifacts/ghostguard-*.tar.gz + generate_release_notes: true + draft: false + prerelease: false + + # Verify the install script works with the new release + verify-install: + needs: release + strategy: + matrix: + os: [ubuntu-latest, macos-14] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Test ghostguardup installer + run: | + bash ghostguardup + ghostguard --version diff --git a/Cargo.toml b/Cargo.toml index 8d6d13d..1e511d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,11 @@ version = "0.1.0" edition = "2021" description = "Detect ghost fills on Polymarket CLOB" license = "MIT" +repository = "https://github.com/libaice/GhostGuard" +homepage = "https://github.com/libaice/GhostGuard" +keywords = ["polymarket", "ghost-fill", "clob", "polygon", "trading"] +categories = ["command-line-utilities", "cryptography::cryptocurrencies"] +readme = "README.md" [lib] name = "ghostguard" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..698c935 --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +.PHONY: build install uninstall test fmt clippy clean release + +# Default install location (same as ghostguardup) +INSTALL_DIR ?= $(HOME)/.ghostguard/bin + +build: + cargo build --release + +install: build + @mkdir -p $(INSTALL_DIR) + @cp target/release/ghostguard $(INSTALL_DIR)/ghostguard + @chmod +x $(INSTALL_DIR)/ghostguard + @echo "installed: $(INSTALL_DIR)/ghostguard" + @echo "" + @echo "Make sure $(INSTALL_DIR) is in your PATH:" + @echo ' export PATH="$$HOME/.ghostguard/bin:$$PATH"' + +uninstall: + @rm -f $(INSTALL_DIR)/ghostguard + @echo "removed: $(INSTALL_DIR)/ghostguard" + +test: + cargo test + +test-live: + cargo test -- --ignored + +fmt: + cargo fmt + +clippy: + cargo clippy --all-targets -- -D warnings + +clean: + cargo clean + +# Create a release tarball for the current platform +release: build + @mkdir -p dist + @cd target/release && tar -czf ../../dist/ghostguard-$(shell uname -s | tr '[:upper:]' '[:lower:]')-$(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/').tar.gz ghostguard + @echo "tarball: dist/" + @ls -lh dist/ + +# Quick verify with known ghost fill tx +verify-ghost: + cargo run --release -- --verify-tx 0x9e3230abde0f569da87511a6f8823076f7b211bb00d10689db3b7c50d6652df0 diff --git a/README.md b/README.md index 1cdec59..99f4347 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,49 @@ Three known attack variants all produce the same on-chain result (status=0): GhostGuard detects the **result**, not the method. +## Installation + +### One-liner (recommended) + +```bash +curl -L https://raw.githubusercontent.com/libaice/GhostGuard/main/ghostguardup | bash +``` + +This downloads the prebuilt binary for your platform to `~/.ghostguard/bin` and adds it to your PATH. Works on macOS (Intel/Apple Silicon) and Linux (x86_64/ARM64). + +### From source (cargo) + +```bash +cargo install --git https://github.com/libaice/GhostGuard +``` + +### From source (clone + make) + +```bash +git clone https://github.com/libaice/GhostGuard +cd GhostGuard +make install +``` + +### As a Rust dependency + +```toml +[dependencies] +ghostguard = { git = "https://github.com/libaice/GhostGuard" } +``` + +### Verify installation + +```bash +ghostguard --version +``` + ## Quick start ### Verify a single transaction ```bash -cargo run --release -- \ +ghostguard \ --verify-tx 0x9e3230abde0f569da87511a6f8823076f7b211bb00d10689db3b7c50d6652df0 ``` diff --git a/ghostguardup b/ghostguardup new file mode 100755 index 0000000..3a8fe1c --- /dev/null +++ b/ghostguardup @@ -0,0 +1,157 @@ +#!/usr/bin/env bash +set -euo pipefail + +# ghostguardup — installer for GhostGuard CLI +# Usage: curl -L https://raw.githubusercontent.com/libaice/GhostGuard/main/ghostguardup | bash + +REPO="libaice/GhostGuard" +INSTALL_DIR="${GHOSTGUARD_INSTALL_DIR:-$HOME/.ghostguard/bin}" +BASE_URL="https://github.com/${REPO}/releases/latest/download" + +main() { + echo "ghostguardup: installing ghostguard..." + echo "" + + detect_platform + download_binary + configure_path + verify_install + + echo "" + echo "ghostguard installed successfully!" + echo "" + echo " ghostguard --help Show usage" + echo " ghostguard --verify-tx Verify a single tx" + echo " ghostguard --rpc Run as sidecar" + echo "" + echo "Repo: https://github.com/${REPO}" +} + +detect_platform() { + OS=$(uname -s | tr '[:upper:]' '[:lower:]') + ARCH=$(uname -m) + + case "$OS" in + linux) OS="linux" ;; + darwin) OS="darwin" ;; + msys*|mingw*|cygwin*) OS="windows" ;; + *) + echo "error: unsupported OS: $OS" + exit 1 + ;; + esac + + case "$ARCH" in + x86_64|amd64) ARCH="amd64" ;; + arm64|aarch64) ARCH="arm64" ;; + *) + echo "error: unsupported architecture: $ARCH" + exit 1 + ;; + esac + + if [ "$OS" = "windows" ]; then + EXT=".exe" + else + EXT="" + fi + + PLATFORM="${OS}-${ARCH}" + echo " platform: ${PLATFORM}" +} + +download_binary() { + TARBALL="ghostguard-${PLATFORM}.tar.gz" + DOWNLOAD_URL="${BASE_URL}/${TARBALL}" + + echo " download: ${DOWNLOAD_URL}" + + mkdir -p "$INSTALL_DIR" + + TMPDIR=$(mktemp -d) + trap 'rm -rf "$TMPDIR"' EXIT + + # Try curl first, fall back to wget + if command -v curl &>/dev/null; then + HTTP_CODE=$(curl -sL -o "$TMPDIR/$TARBALL" -w "%{http_code}" "$DOWNLOAD_URL" 2>/dev/null) || true + elif command -v wget &>/dev/null; then + wget -q -O "$TMPDIR/$TARBALL" "$DOWNLOAD_URL" 2>/dev/null && HTTP_CODE="200" || HTTP_CODE="404" + else + echo "error: curl or wget required" + exit 1 + fi + + if [ "$HTTP_CODE" != "200" ]; then + echo "" + echo "error: no prebuilt binary for ${PLATFORM}" + echo "" + echo "Build from source instead:" + echo " cargo install --git https://github.com/${REPO}" + echo "" + echo "Or clone and build:" + echo " git clone https://github.com/${REPO}" + echo " cd GhostGuard && cargo install --path ." + exit 1 + fi + + tar -xzf "$TMPDIR/$TARBALL" -C "$INSTALL_DIR" + chmod +x "$INSTALL_DIR/ghostguard${EXT}" + + echo " installed: ${INSTALL_DIR}/ghostguard${EXT}" +} + +configure_path() { + # Check if INSTALL_DIR is already in PATH + case ":$PATH:" in + *":$INSTALL_DIR:"*) return ;; + esac + + echo "" + echo " Adding $INSTALL_DIR to PATH..." + + # Detect shell and config file + SHELL_NAME=$(basename "$SHELL") + case "$SHELL_NAME" in + zsh) PROFILE="$HOME/.zshrc" ;; + bash) + if [ -f "$HOME/.bash_profile" ]; then + PROFILE="$HOME/.bash_profile" + else + PROFILE="$HOME/.bashrc" + fi + ;; + fish) PROFILE="$HOME/.config/fish/config.fish" ;; + *) PROFILE="$HOME/.profile" ;; + esac + + PATH_EXPORT="export PATH=\"\$HOME/.ghostguard/bin:\$PATH\"" + + if [ "$SHELL_NAME" = "fish" ]; then + PATH_EXPORT="fish_add_path $HOME/.ghostguard/bin" + fi + + # Only add if not already present + if ! grep -q ".ghostguard/bin" "$PROFILE" 2>/dev/null; then + echo "" >> "$PROFILE" + echo "# GhostGuard" >> "$PROFILE" + echo "$PATH_EXPORT" >> "$PROFILE" + echo " updated: ${PROFILE}" + fi + + export PATH="$INSTALL_DIR:$PATH" +} + +verify_install() { + if command -v ghostguard &>/dev/null; then + VERSION=$(ghostguard --version 2>/dev/null || echo "unknown") + echo " version: ${VERSION}" + elif [ -x "$INSTALL_DIR/ghostguard${EXT}" ]; then + VERSION=$("$INSTALL_DIR/ghostguard${EXT}" --version 2>/dev/null || echo "unknown") + echo " version: ${VERSION}" + echo "" + echo " NOTE: restart your shell or run:" + echo " source ${PROFILE}" + fi +} + +main "$@" From 42999bc27b9906f958f6fdc49a650bfb6f257019 Mon Sep 17 00:00:00 2001 From: libaice Date: Tue, 14 Apr 2026 03:09:43 +0800 Subject: [PATCH 2/2] docs: use OrderBookTrade org instead of libaice in README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 99f4347..ef3e0f5 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ GhostGuard detects the **result**, not the method. ### One-liner (recommended) ```bash -curl -L https://raw.githubusercontent.com/libaice/GhostGuard/main/ghostguardup | bash +curl -L https://raw.githubusercontent.com/orderbooktrade/GhostGuard/main/ghostguardup | bash ``` This downloads the prebuilt binary for your platform to `~/.ghostguard/bin` and adds it to your PATH. Works on macOS (Intel/Apple Silicon) and Linux (x86_64/ARM64). @@ -40,13 +40,13 @@ This downloads the prebuilt binary for your platform to `~/.ghostguard/bin` and ### From source (cargo) ```bash -cargo install --git https://github.com/libaice/GhostGuard +cargo install --git https://github.com/OrderBookTrade/GhostGuard ``` ### From source (clone + make) ```bash -git clone https://github.com/libaice/GhostGuard +git clone https://github.com/OrderBookTrade/GhostGuard cd GhostGuard make install ``` @@ -55,7 +55,7 @@ make install ```toml [dependencies] -ghostguard = { git = "https://github.com/libaice/GhostGuard" } +ghostguard = { git = "https://github.com/OrderBookTrade/GhostGuard" } ``` ### Verify installation