Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .claude/skills/generate-copilot-instructions/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---

Check failure on line 1 in .claude/skills/generate-copilot-instructions/SKILL.md

View workflow job for this annotation

GitHub Actions / Trunk Check

prettier

Incorrect formatting, autoformat by running 'trunk fmt'
name: generate-copilot-instructions
description: Generate `.github/copilot-instructions.md` based on the `CLAUDE.md`
---

Translate the project-specific rules and coding standards from `CLAUDE.md` into a format optimized for GitHub Copilot.

Check notice on line 6 in .claude/skills/generate-copilot-instructions/SKILL.md

View workflow job for this annotation

GitHub Actions / Trunk Check

markdownlint(MD041)

[new] First line in a file should be a top-level heading

## Usage

Check notice on line 8 in .claude/skills/generate-copilot-instructions/SKILL.md

View workflow job for this annotation

GitHub Actions / Trunk Check

markdownlint(MD022)

[new] Headings should be surrounded by blank lines
- When requested to sync or generate Copilot instructions.

Check notice on line 9 in .claude/skills/generate-copilot-instructions/SKILL.md

View workflow job for this annotation

GitHub Actions / Trunk Check

markdownlint(MD032)

[new] Lists should be surrounded by blank lines
- After significant updates to `CLAUDE.md`.

## Instructions

1. **Locate Source**: Read the `CLAUDE.md` file in the project root.
2. **Identify Target**: Prepare to write to `.github/copilot-instructions.md`.
3. **Analyze Content**:
- Extract **Coding Standards**: Language-specific rules, naming conventions, and formatting.
- Extract **Project Architecture**: Folder structures, design patterns, and tech stack details.
- Extract **Documentation Requirements**: JSDoc, TypeDoc, or README update rules.
- **Filter Out**: Remove agent-specific terminal commands (like "Build command: npm run build") as Copilot handles these differently than agentic tools like Cline.
4. **Transform**:
- Reformat the instructions into a clear, hierarchical Markdown structure.
- Use imperative language (e.g., "Always use...", "Avoid...", "Ensure...").
- Group instructions into logical sections: `Code Style`, `Architecture`, `Testing`, and `Patterns`.
5. **Execution**:
- Create the `.github` directory if it does not exist.
- Write the refined content to `.github/copilot-instructions.md`.
- Provide a brief summary of the changes made to the user.
113 changes: 113 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# GitHub Copilot Instructions

Check failure on line 1 in .github/copilot-instructions.md

View workflow job for this annotation

GitHub Actions / Trunk Check

prettier

Incorrect formatting, autoformat by running 'trunk fmt'

> Project-specific coding standards and architecture guidance for the `zilliqa-developer` monorepo.

---

## Architecture

### Repository Structure

- This is a **Bazel-based monorepo** using Bazelisk as the build wrapper.
- JS packages are managed as a **pnpm workspace** under `zilliqa/js/`.
- Products are self-contained applications under `products/`.
- Contracts live under `contracts/` — `audited/` for production, `experimental/` for in-development.

### JS SDK Packages (`zilliqa/js/`)

All packages are published under the `@zilliqa-js/*` namespace:

- `core` — HTTP/WebSocket provider, JSON-RPC
- `account` — wallet and account management
- `blockchain` — Blockchain API queries
- `contract` — Scilla contract deployment and interaction
- `crypto` — key generation, schnorr signing, address formats
- `util` — BN.js utilities, unit conversion, validation
- `subscriptions` — WebSocket event subscriptions
- `proto` — protobuf definitions
- `zilliqa` — main entry point, re-exports all sub-packages

### Products

Each product under `products/` is self-contained. Key products:

| Product | Stack |
|---|---|
| `devex` | React (CRA) |
| `neo-savant` | Vue 2 + Vite |
| `governance-snapshot` | Vue 2 |
| `governance-api` | Node.js/Express + Sequelize + PostgreSQL |
| `zillion` | React |
| `pdt` | Rust |
| `faucet-service` | Go |
| `eth-spout` | Rust |
| `laksaj` | Java (Maven via Bazel) |
| `bridge` | Solidity smart contracts (pnpm workspace) |
| `devex-apollo` | Node.js + Apollo + MongoDB |

### Governance System

- `governance-api` — Express REST API backend (TypeScript, Sequelize ORM, PostgreSQL). Uses IPFS (Pinata) for proposal storage.
- `governance-snapshot` — Vue 2 SPA frontend connecting to `governance-api` and integrating `@snapshot-labs` libraries.

### Block Explorer (`devex`)

React SPA using Apollo Client for GraphQL queries against the `devex-apollo` backend (Node.js + MongoDB).

---

## Code Style

### General

- Follow language-idiomatic conventions for each file's language (TypeScript, Go, Rust, Java, Solidity).
- Use **imperative style** for commit messages and documentation.
- Respect the linting rules enforced by [trunk.io](https://trunk.io) — it runs eslint, prettier, black, flake8, gofmt, rustfmt, shellcheck, and others.

### TypeScript / JavaScript

- Use TypeScript for all JS SDK and product code where applicable.
- Each JS SDK package targets three distribution formats: **cjs**, **esm**, and **umd** (via `tsc` and `rollup`).
- Shared TypeScript configuration is in `tsconfig.base.json` — extend it rather than duplicating settings.
- Tests match the Jest pattern: `zilliqa/js/**/test/?(*.)+(spec|test).(ts|js)`.

### Bazel

- Use `BUILD` files consistently for all Bazel targets.
- Prefer `bazelisk` over `bazel` to ensure consistent Bazel version usage.
- Use `bazelisk query` to inspect targets and dependencies before making structural changes.

---

## Testing

- JS SDK tests run via **Jest** (config at `jest.config.js` in the repo root).
- Bazel is the canonical test runner for all targets: `bazelisk test //zilliqa/js/...`.
- Always run tests after modifying SDK packages or contracts.
- For Go and Rust, use their native test frameworks (`go test`, `cargo test`).

---

## Patterns

### Dependency Management

- JS/TS packages: use **pnpm** (not npm or yarn) for the monorepo workspace.
- Install workspace deps from `zilliqa/js/`: `pnpm i`.
- Do not mix package managers within the same product.

### Linting

- Linting is managed by **trunk**. Avoid bypassing trunk checks.
- Some directories are intentionally excluded from trunk (e.g., `products/governance-api`, `products/governance-snapshot`, `products/zillion`, `products/multisig`).
- Do not add those directories back to trunk linting unless intentional.

### Deployment

- Products are deployed via the internal `z` CLI tool.
- Each deployable product has a `z.yaml` configuration — do not remove or rename it.

### Contracts

- Production-deployed contracts live in `contracts/audited/` — treat these as immutable references.
- Experimental contracts in `contracts/experimental/` may be modified, but changes must be reviewed carefully.
8 changes: 4 additions & 4 deletions .github/workflows/cicd-prd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "CICD production"

Check failure on line 1 in .github/workflows/cicd-prd.yml

View workflow job for this annotation

GitHub Actions / Trunk Check

prettier

Incorrect formatting, autoformat by running 'trunk fmt'

on:
# On merged
Expand All @@ -22,13 +22,13 @@
matrix:
application:
[
bluebell-playground,
eth-spout,
# bluebell-playground,
# eth-spout,
governance-api,
governance-snapshot,
multisig,
scilla-server,
zillion,
# scilla-server,
# zillion,
]
include:
- application: bluebell-playground
Expand Down
118 changes: 118 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# CLAUDE.md

Check failure on line 1 in CLAUDE.md

View workflow job for this annotation

GitHub Actions / Trunk Check

prettier

Incorrect formatting, autoformat by running 'trunk fmt'

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Repository Overview

`zilliqa-developer` is a Bazel-based monorepo containing SDKs, documentation, and products for the Zilliqa blockchain ecosystem. The build system is Bazel (via Bazelisk), with pnpm workspaces managing JS packages.

## Build System

The primary build tool is **Bazelisk** (Bazel wrapper). Most targets are built, tested, and run via Bazel:

```sh
bazelisk build [target] # Build a target
bazelisk run [target] # Run an executable target
bazelisk test [target] # Test a target
bazelisk query "//..." # List all targets
bazelisk query "//zilliqa/..." # List targets in a subfolder
bazelisk query "deps(//zilliqa/js/util:pkg)" # Find target dependencies
```

Useful flags: `--verbose_failures`, `--test_output=all`, `--sandbox_debug`

Set `DISABLE_WORKSPACE_STATUS=1` (or `--workspace_status_command=echo`) to skip git queries and avoid key/password prompts on every build.

## JS SDK (zilliqa/js)

The JS SDK packages live in `zilliqa/js/` and are managed as a pnpm workspace. Packages: `account`, `blockchain`, `contract`, `core`, `crypto`, `proto`, `subscriptions`, `typings`, `util`, `zilliqa` — all published as `@zilliqa-js/*`.

```sh
# Install dependencies
cd zilliqa/js && pnpm i

# Build all packages
pnpm -r build

# Run tests (via Bazel)
bazelisk test //zilliqa/js/...

# Run tests via Jest (from repo root)
npx jest
```

Jest config is at `jest.config.js` — tests match `zilliqa/js/**/test/?(*.)+(spec|test).(ts|js)`.

Each package builds three distribution formats (cjs, esm, umd) via `tsc` and `rollup`.

## Linting & Formatting

Uses [trunk.io](https://trunk.io) to manage multiple linters (eslint, prettier, black, flake8, gofmt, rustfmt, shellcheck, etc.):

```sh
trunk check # Check code style
trunk fmt # Auto-format where possible
```

Trunk is enforced by CI. Several directories are excluded from linting (see `.trunk/trunk.yaml`), including `products/governance-api`, `products/governance-snapshot`, `products/zillion`, `products/multisig`, and others.

## Products

Each product under `products/` is largely self-contained. Common setup patterns:

| Product | Stack | Dev command |
|---|---|---|
| `devex` | React (CRA) | `yarn start` (port 3000) |
| `neo-savant` | Vue 2 + Vite | `yarn dev` |
| `governance-snapshot` | Vue 2 | `yarn serve` (NODE_OPTIONS=--openssl-legacy-provider) |
| `governance-api` | Node.js/Express + Sequelize + PostgreSQL | `npm start` (ts-node) |
| `zillion` | React | `yarn` then configure `public/config.js` |
| `pdt` | Rust | `cargo run` |
| `faucet-service` | Go | `make deps && make build` |
| `eth-spout` | Rust | Configured via environment variables |
| `laksaj` | Java (Maven via Bazel) | Bazel build |
| `isolated-server` | Docker | `docker build` / `docker run` |
| `bridge` | Solidity smart contracts | pnpm workspace |
| `devex-apollo` | Node.js + Apollo + MongoDB | docker-compose |

## Architecture

### JS SDK Architecture

The `@zilliqa-js/zilliqa` package is the main entry point, re-exporting from these sub-packages:
- `@zilliqa-js/core` — HTTP/WebSocket provider, JSON-RPC

Check notice on line 83 in CLAUDE.md

View workflow job for this annotation

GitHub Actions / Trunk Check

markdownlint(MD032)

[new] Lists should be surrounded by blank lines
- `@zilliqa-js/account` — wallet, account management
- `@zilliqa-js/blockchain` — Blockchain API queries
- `@zilliqa-js/contract` — Scilla contract deployment and interaction
- `@zilliqa-js/crypto` — key generation, signing (schnorr), address formats
- `@zilliqa-js/util` — BN.js utilities, unit conversion, validation
- `@zilliqa-js/subscriptions` — WebSocket event subscriptions
- `@zilliqa-js/proto` — protobuf definitions

### Governance System

Two related products:
- `governance-api` — Express REST API backend (TypeScript, Sequelize ORM, PostgreSQL). Entry: `index.ts` → `lib/server.ts`. Uses IPFS (Pinata) for proposal storage.

Check notice on line 95 in CLAUDE.md

View workflow job for this annotation

GitHub Actions / Trunk Check

markdownlint(MD032)

[new] Lists should be surrounded by blank lines
- `governance-snapshot` — Vue 2 SPA frontend. Connects to `governance-api` and integrates with `@snapshot-labs` libraries.

### Devex (Block Explorer)

React SPA (`products/devex`) using Apollo Client for GraphQL queries against `devex-apollo` (Node.js + MongoDB backend that crawls Zilliqa chain data).

### Deployment

Products are deployed via the `z` CLI tool (Zilliqa internal DevOps tool). See each product's README for `z.yaml` configuration and staging/production deployment instructions.

## Contracts

- `contracts/audited/` — production-deployed contracts
- `contracts/experimental/` — contracts under development, including `ERC20ProxyForZRC2` (pnpm workspace package)
- `contracts/gaming_contracts/`, `contracts/reward_control/` — domain-specific contracts

## Key Configuration Files

- `WORKSPACE` / `BUILD` — Bazel workspace and build rules
- `pnpm-workspace.yaml` — pnpm workspace package list
- `tsconfig.base.json` — shared TypeScript base config
- `.trunk/trunk.yaml` — linter configuration and ignore rules
- `jest.config.js` — root Jest config for JS SDK tests
22 changes: 22 additions & 0 deletions products/.env.governance.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copy this file to .env and fill in the required values.
# docker compose reads .env automatically.

# ── Required ─────────────────────────────────────────────────────────────────

# PostgreSQL password (any non-empty string works for a local setup)
POSTGRES_PASSWORD=changeme

# ── Optional overrides ────────────────────────────────────────────────────────

# Database name and user (defaults shown)
# POSTGRES_DB=snapshot
# POSTGRES_USER=postgres

# IPFS gateway URL as seen from the user's browser.
# Change this if you run the stack on a remote server.
# VUE_APP_IPFS_NODE=http://localhost:8080

# Use Pinata instead of the local IPFS node.
# Set IPFS_API_URL= (empty) in docker-compose.yml and supply credentials here.
# PINATA_API_KEY=
# PINATA_SECRET_API_KEY=
Loading
Loading