Skip to content

Latest commit

 

History

History
342 lines (233 loc) · 11.9 KB

CONTRIBUTING.md

File metadata and controls

342 lines (233 loc) · 11.9 KB

Contributing to Scavenger

Thank you for your interest in contributing to Scavenger — a Rust/Soroban smart contract system with a React/TypeScript frontend built on the Stellar blockchain. This document is the single authoritative reference for code style, the PR workflow, testing expectations, commit conventions, community standards, and environment setup.


Table of Contents

  1. Getting Started / Setup
  2. Pre-commit Hooks
  3. Code Style Guidelines
  4. Pull Request Process
  5. Testing Requirements
  6. Commit Message Conventions
  7. Code of Conduct

Getting Started / Setup

Prerequisites

Smart Contract (Rust / Soroban)

  • Rust toolchain — stable channel. Install via rustup:
    rustup toolchain install stable
    rustup default stable

    No pinned version is currently specified in rust-toolchain.toml; the stable channel is the expected toolchain.

  • Soroban CLI — install the latest release:
    cargo install --locked soroban-cli

Frontend (React / TypeScript)

  • Node.js — LTS version recommended. Download from nodejs.org or use a version manager such as nvm.
  • pnpm — enable via Corepack, which ships with Node.js:
    corepack enable

pnpm-only policy: This repository uses pnpm exclusively. Install and run Node.js dependencies and scripts from the repository root. Do not use npm install or npm ci, and do not commit package-lock.json files.

Clone and Install

# 1. Fork the repository on GitHub, then clone your fork
git clone https://github.com/<your-username>/Scavenger.git
cd Scavenger

# 2. Install Smart Contract dependencies
cargo build

# 3. Install Node.js dependencies (all workspaces)
pnpm install

Pre-commit Hooks

This repository uses pre-commit to enforce formatting and linting automatically before every commit. The hooks cover the languages used in the project: Rust and TypeScript/JavaScript.

Setup

# 1. Install pre-commit itself
pip install pre-commit

# 2. Install the hooks into your local clone
pre-commit install

rustfmt must be available for the cargo-fmt hook:

rustup component add rustfmt

prettier and eslint are resolved via pnpm exec — ensure you have run pnpm install first.

gitleaks must be installed separately (see gitleaks releases).

What gets checked

Hook Languages What it does
cargo-fmt Rust (.rs) Runs cargo fmt --all and blocks commits that aren't formatted
prettier TS, JS, JSON, CSS, MD Reformats files to the project's Prettier config
eslint TS, JS Runs ESLint with --fix; blocks commits with unfixable lint errors
gitleaks All tracked files Scans staged changes for secrets using .gitleaks.toml config
terraform_fmt / terraform_validate Terraform Formats and validates Terraform configs
trailing-whitespace / end-of-file-fixer All Generic file hygiene

Running manually

# Run all hooks against all files
pre-commit run --all-files

# Run a specific hook
pre-commit run cargo-fmt --all-files
pre-commit run prettier --all-files

Code Style Guidelines

Consistent style keeps the codebase readable and review cycles short. Run all formatters and linters before pushing.

Rust (Smart Contract)

  • Formatting — run cargo fmt before every commit:
    cargo fmt
  • Linting — run cargo clippy and resolve all warnings before submitting:
    cargo clippy -- -D warnings
    PRs with outstanding Clippy warnings will not be merged.
  • Naming conventions — use snake_case for functions, variables, structs, and module names.
  • Function length — keep functions focused on a single responsibility. Avoid functions exceeding 50 lines where practical; extract helpers when a function grows beyond that threshold.

TypeScript / React (Frontend)

  • Formatting — prettier must pass with no diff:
    pnpm exec prettier --check .
  • Linting — eslint must pass with no errors or warnings:
    pnpm exec eslint .
  • Naming conventions — use PascalCase for React components and TypeScript types/interfaces; use camelCase for variables and functions. These conventions are enforced by CI lint checks and regression tests (see __tests__/cleanup/).
  • Script naming — use kebab-case for all shell script filenames (e.g. build-wasm.sh, not build_wasm.sh). Enforced by __tests__/cleanup/scripts.test.ts.
  • Function design — keep functions focused on a single responsibility. Avoid large multi-purpose functions; prefer small, composable units.

Pull Request Process

1. Fork and Branch

Fork the repository on GitHub and create a dedicated branch for your change before opening a PR. Never commit directly to main.

git checkout -b feature/my-new-feature

2. Branch Naming Convention

Use one of the following prefixes followed by a short kebab-case description:

Prefix When to use
feature/<short-description> New functionality
fix/<short-description> Bug fixes
docs/<short-description> Documentation-only changes

Examples: feature/add-token-transfer, fix/null-pointer-crash, docs/update-setup-guide

3. PR Description

Every PR must include a description that covers:

  • What changed — a clear summary of the modifications made.
  • Why it changed — the motivation or problem being solved.
  • Related issues — reference any relevant GitHub issue numbers (e.g., Closes #42).

The repository provides a PR template (.github/PULL_REQUEST_TEMPLATE.md) that pre-fills this structure when you open a PR on GitHub. Fill in every section; do not delete sections you leave blank — use the checkboxes to show what applies.

4. Target the Correct Base Branch

Ensure your PR targets the correct base branch (typically main). Check the repository's branch strategy before opening your PR and update the base if needed.

5. Review and Approval

  • At least one maintainer approval is required before a PR can be merged.
  • All CI checks must pass — do not merge a PR with failing checks.
  • The PR Title Convention Check CI job (pr-title-check.yml) validates that the PR title follows the Conventional Commits format. The title is used as the squash-merge commit message, so it must pass before the PR can be merged.

6. Keep PRs Focused

Address one concern per PR. Large, multi-purpose PRs are harder to review and more likely to introduce regressions. If your change spans multiple concerns, split it into separate PRs.


Testing Requirements

Smart Contract Tests

  • All Smart Contract changes must include or update unit tests using the Soroban test framework.
  • Run the full Smart Contract test suite with:
    cargo test

Frontend Tests

  • All Frontend changes must include or update unit tests.
  • Run the frontend test suite with:
    pnpm test

Coverage and New Public API

  • PRs must not reduce overall test coverage for the modified modules.
  • If a PR introduces a new public function or component, at least one test covering the primary behavior must be included.

Commit Message Conventions

This project follows the Conventional Commits v1.0.0 specification.

Commit message template

A .gitmessage file at the repository root pre-fills the subject and footer format. Configure it once in your local clone:

git config commit.template .gitmessage

After that, running git commit (without -m) will open your editor with the template, prompting for type, scope, summary, body, and issue reference.

Format

<type>(<scope>): <short summary>

<body>

Closes #<issue-number>

Types

Type When to use
feat A new feature
fix A bug fix
docs Documentation changes only
chore Build process, tooling, or dependency updates
refactor Code restructuring without behavior change
test Adding or updating tests
style Formatting, whitespace, or style-only changes

Scopes

Scope Area of the codebase
contract Rust / Soroban smart contract code
frontend React / TypeScript frontend
scripts Build scripts, CI configuration, tooling
docs Documentation files

Summary Rules

  • Written in the imperative mood (e.g., "add feature", not "added feature" or "adds feature").
  • Lowercase — do not capitalize the first letter.
  • 72 characters or fewer — keep it concise.

Body

  • Separate the body from the subject line with a blank line.
  • Use the body to explain the motivation for the change and any context a reviewer needs.

Closing Issues

If a commit or PR closes a GitHub issue, include the following in the commit body or PR description:

Closes #<issue-number>

Examples

feat(contract): add token transfer function

Implements the transfer entrypoint as specified in the token interface.
Validates sender balance before executing the transfer.

Closes #17
fix(frontend): resolve null pointer on wallet disconnect

The wallet context was not guarded against undefined on disconnect,
causing a crash in the header component.

Closes #23

Code of Conduct

Our Pledge

This project is committed to providing a welcoming and inclusive environment for everyone. We welcome contributors regardless of experience level, background, or identity.

We follow the Contributor Covenant as our Code of Conduct. All contributors and maintainers are expected to uphold these standards in all project spaces — including GitHub issues, pull requests, discussions, and any other communication channels.

Reporting Violations

If you experience or witness behavior that violates the Code of Conduct, please report it by emailing:

[conduct@example.com]

Replace this placeholder with the actual contact email before publishing.

All reports will be reviewed promptly and handled with discretion.

Enforcement

Violations of the Code of Conduct may result in temporary or permanent exclusion from the project, at the discretion of the maintainers.

Summary of Expected Behavior

  • Be respectful and considerate in all interactions.
  • Welcome newcomers and those with different levels of experience.
  • Accept constructive feedback gracefully.
  • Focus on what is best for the community and the project.

For the full text of the Contributor Covenant, visit https://www.contributor-covenant.org/version/2/1/code_of_conduct/.