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
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,14 @@ repos:
entry: scripts/lint-docs.sh
language: system
pass_filenames: false
- id: eslint
name: ESLint
entry: npx eslint
language: system
types: [typescript]
files: '\.(ts|tsx)$'
- id: prettier
name: Prettier
entry: npx prettier --check
language: system
files: '\.(ts|tsx)$'
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Hooks run on each commit and enforce:

- ABI snapshot hygiene (`abis/*.json` must change together with `COMEBACKHERE-contracts/contracts/*/src/`)
- Markdown linting
- TypeScript/TSX linting (ESLint)
- TypeScript/TSX formatting (Prettier)
- Trailing whitespace detection
- End-of-file fixing (ensure files end with a newline)
- JSON validation
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,19 @@ deploy-testnet:

abi-snapshot:
@$(MAKE) update-abi-snapshots

verify:
@./scripts/verify.sh

lint-docs:
@./scripts/lint-docs.sh

snapshot:
@$(MAKE) update-abi-snapshots

check-snapshot:
@$(MAKE) check-abi-snapshots

default: verify

.PHONY: default snapshot check-snapshot
24 changes: 24 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
snapshot:
@./scripts/generate_abi_metadata.sh abis

update-abi-snapshots: snapshot

abi-snapshot: snapshot

# Verify committed ABI snapshots match contract sources (no writes)
check-snapshot:
@./scripts/generate_abi_metadata.sh /tmp/comebackhere-abis-check
@diff -ru abis/ /tmp/comebackhere-abis-check/

check-abi-snapshots: check-snapshot

# Lint markdown documentation
lint-docs:
@./scripts/lint-docs.sh
Expand All @@ -17,5 +23,23 @@ lint-docs:
verify:
@./scripts/verify.sh

# Start local Docker environment
dev:
docker-compose up -d

# Run contract tests
test:
cargo test --manifest-path COMEBACKHERE-contracts/Cargo.toml

# Lint TypeScript, contracts, and documentation
lint:
@./scripts/lint-docs.sh && cargo clippy --manifest-path COMEBACKHERE-contracts/Cargo.toml -- -D warnings && (cd frontend && npx eslint src --ext ts,tsx --report-unused-disable-directives)

# Deploy to testnet
deploy-testnet:
@test -n "$$STELLAR_NETWORK" || (echo "ERROR: STELLAR_NETWORK is not set" && exit 1)
@test -n "$$DEPLOYER_SECRET" || (echo "ERROR: DEPLOYER_SECRET is not set" && exit 1)
@./scripts/deploy_testnet.sh

# Default target
default: verify
46 changes: 46 additions & 0 deletions scripts/check_make_just_parity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
# check_make_just_parity.sh — verify Makefile and justfile have equivalent targets
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

# Extract Makefile targets (targets that start at column 0 and end with :)
MAKE_TARGETS=$(grep -E '^[a-zA-Z0-9_-]+:' "$ROOT_DIR/Makefile" | sed 's/:.*//g' | sort)

# Extract justfile targets (lines with # at start of recipe)
JUST_TARGETS=$(grep -E '^[a-zA-Z0-9_-]+:' "$ROOT_DIR/justfile" | sed 's/:.*//g' | sort)

# Convert to arrays for comparison
mapfile -t MAKE_ARRAY <<<"$MAKE_TARGETS"
mapfile -t JUST_ARRAY <<<"$JUST_TARGETS"

# Compare targets
MISSING_IN_JUST=()
MISSING_IN_MAKE=()

for target in "${MAKE_ARRAY[@]}"; do
if ! grep -q "^$target:" "$ROOT_DIR/justfile"; then
MISSING_IN_JUST+=("$target")
fi
done

for target in "${JUST_ARRAY[@]}"; do
if ! grep -q "^$target:" "$ROOT_DIR/Makefile"; then
MISSING_IN_MAKE+=("$target")
fi
done

# Report results
if [[ ${#MISSING_IN_JUST[@]} -gt 0 ]] || [[ ${#MISSING_IN_MAKE[@]} -gt 0 ]]; then
echo "ERROR: Makefile and justfile targets are not in parity" >&2
if [[ ${#MISSING_IN_JUST[@]} -gt 0 ]]; then
echo "Missing in justfile: ${MISSING_IN_JUST[*]}" >&2
fi
if [[ ${#MISSING_IN_MAKE[@]} -gt 0 ]]; then
echo "Missing in Makefile: ${MISSING_IN_MAKE[*]}" >&2
fi
exit 1
fi

echo "Makefile and justfile targets are in parity."
exit 0
4 changes: 2 additions & 2 deletions scripts/coverage.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -e
#!/usr/bin/env bash
set -euo pipefail

# Generate coverage report for COMEBACKHERE contract tests.
# Outputs HTML report to coverage/ directory and prints terminal summary.
Expand Down
55 changes: 30 additions & 25 deletions scripts/deploy_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,39 @@ echo "Building COMEBACKHERE contracts for local standalone network via $SOROBAN_
# Build from the contracts repo (sibling directory)
(cd ../COMEBACKHERE-contracts && cargo build --target wasm32-unknown-unknown --release)

cat > abis/deployed.local.json <<JSON
{
"network": "$STELLAR_NETWORK",
"rpc_url": "$SOROBAN_RPC_URL",
"invoice_contract_id": "${INVOICE_CONTRACT_ID:-C...}",
"treasury_contract_id": "${TREASURY_CONTRACT_ID:-C...}",
"compliance_contract_id": "${COMPLIANCE_CONTRACT_ID:-C...}",
"generated_at": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
}
JSON

echo "Local contract deployment metadata written to abis/deployed.local.json"
echo "Replace placeholder IDs with actual deployed contract IDs before backend integration."

genenv() {
if [ -f .env.local ]; then
# shellcheck disable=SC1091
set -a
source .env.local
set +a
fi
}

genenv
# Deploy contracts and capture IDs
# These are placeholder deploy commands — actual deployment logic should be integrated here
INVOICE_WASM="../COMEBACKHERE-contracts/target/wasm32-unknown-unknown/release/invoice_contract.wasm"
TREASURY_WASM="../COMEBACKHERE-contracts/target/wasm32-unknown-unknown/release/treasury_contract.wasm"
COMPLIANCE_WASM="../COMEBACKHERE-contracts/target/wasm32-unknown-unknown/release/compliance_contract.wasm"

if [ ! -f "$INVOICE_WASM" ] || [ ! -f "$TREASURY_WASM" ] || [ ! -f "$COMPLIANCE_WASM" ]; then
echo "ERROR: Contract WASM binaries not found after build" >&2
exit 1
fi

echo "Deploying contracts to $STELLAR_NETWORK…"
# Uncomment and integrate actual soroban contract deploy commands:
# soroban contract deploy --wasm "$INVOICE_WASM" ... > /tmp/invoice_deploy.txt 2>&1
# soroban contract deploy --wasm "$TREASURY_WASM" ... > /tmp/treasury_deploy.txt 2>&1
# soroban contract deploy --wasm "$COMPLIANCE_WASM" ... > /tmp/compliance_deploy.txt 2>&1
#
# Parse output to extract contract IDs:
# INVOICE_CONTRACT_ID=$(grep -oP 'Contract ID: \K[C][A-Z0-9]*' /tmp/invoice_deploy.txt || echo "C...")
# TREASURY_CONTRACT_ID=$(grep -oP 'Contract ID: \K[C][A-Z0-9]*' /tmp/treasury_deploy.txt || echo "C...")
# COMPLIANCE_CONTRACT_ID=$(grep -oP 'Contract ID: \K[C][A-Z0-9]*' /tmp/compliance_deploy.txt || echo "C...")

if [ -f .env.local ]; then
# shellcheck disable=SC1091
set -a
source .env.local
set +a
fi

export STELLAR_NETWORK="${STELLAR_NETWORK:-standalone}"
export INVOICE_CONTRACT_ID="${INVOICE_CONTRACT_ID:-C...}"
export TREASURY_CONTRACT_ID="${TREASURY_CONTRACT_ID:-C...}"
export COMPLIANCE_CONTRACT_ID="${COMPLIANCE_CONTRACT_ID:-C...}"

scripts/export_deployed_addresses.sh
echo "Running deployment validation…"
"$ROOT_DIR/scripts/export_deployed_addresses.sh"
38 changes: 24 additions & 14 deletions scripts/deploy_testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,27 @@ echo "Building COMEBACKHERE contracts for $STELLAR_NETWORK via $SOROBAN_RPC_URL"
# Build from the contracts repo (sibling directory)
(cd ../COMEBACKHERE-contracts && cargo build --target wasm32-unknown-unknown --release)

cat > abis/deployed.testnet.json <<JSON
{
"network": "$STELLAR_NETWORK",
"rpc_url": "$SOROBAN_RPC_URL",
"invoice_contract_id": "${INVOICE_CONTRACT_ID:-C...}",
"treasury_contract_id": "${TREASURY_CONTRACT_ID:-C...}",
"compliance_contract_id": "${COMPLIANCE_CONTRACT_ID:-C...}",
"generated_at": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
}
JSON

echo "Contract deployment metadata written to abis/deployed.testnet.json"
echo "Replace placeholder IDs with soroban contract deploy output before backend integration."
# Deploy contracts and capture IDs
# These are placeholder deploy commands — actual deployment logic should be integrated here
INVOICE_WASM="../COMEBACKHERE-contracts/target/wasm32-unknown-unknown/release/invoice_contract.wasm"
TREASURY_WASM="../COMEBACKHERE-contracts/target/wasm32-unknown-unknown/release/treasury_contract.wasm"
COMPLIANCE_WASM="../COMEBACKHERE-contracts/target/wasm32-unknown-unknown/release/compliance_contract.wasm"

if [ ! -f "$INVOICE_WASM" ] || [ ! -f "$TREASURY_WASM" ] || [ ! -f "$COMPLIANCE_WASM" ]; then
echo "ERROR: Contract WASM binaries not found after build" >&2
exit 1
fi

echo "Deploying contracts to $STELLAR_NETWORK…"
# Uncomment and integrate actual soroban contract deploy commands:
# soroban contract deploy --wasm "$INVOICE_WASM" ... > /tmp/invoice_deploy.txt 2>&1
# soroban contract deploy --wasm "$TREASURY_WASM" ... > /tmp/treasury_deploy.txt 2>&1
# soroban contract deploy --wasm "$COMPLIANCE_WASM" ... > /tmp/compliance_deploy.txt 2>&1
#
# Parse output to extract contract IDs:
# INVOICE_CONTRACT_ID=$(grep -oP 'Contract ID: \K[C][A-Z0-9]*' /tmp/invoice_deploy.txt || echo "C...")
# TREASURY_CONTRACT_ID=$(grep -oP 'Contract ID: \K[C][A-Z0-9]*' /tmp/treasury_deploy.txt || echo "C...")
# COMPLIANCE_CONTRACT_ID=$(grep -oP 'Contract ID: \K[C][A-Z0-9]*' /tmp/compliance_deploy.txt || echo "C...")

if [ -f .env.testnet ]; then
# shellcheck disable=SC1091
Expand All @@ -41,4 +49,6 @@ export STELLAR_NETWORK="${STELLAR_NETWORK:-testnet}"
export INVOICE_CONTRACT_ID="${INVOICE_CONTRACT_ID:-C...}"
export TREASURY_CONTRACT_ID="${TREASURY_CONTRACT_ID:-C...}"
export COMPLIANCE_CONTRACT_ID="${COMPLIANCE_CONTRACT_ID:-C...}"
scripts/export_deployed_addresses.sh

echo "Running deployment validation…"
"$ROOT_DIR/scripts/export_deployed_addresses.sh"
11 changes: 4 additions & 7 deletions scripts/lint-docs.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/bin/bash
set -e

# Lint markdown documentation
# Enforces style rules: no trailing spaces, consistent heading levels, consistent list style
#!/usr/bin/env bash
set -euo pipefail

echo "Linting markdown documentation..."

npx markdownlint-cli2 "**/*.md" "#node_modules" || {
echo "✗ Markdown linting failed"
echo " Fix issues or run: npx markdownlint-cli2 --fix \"**/*.md\" \"#node_modules\""
echo "✗ Markdown linting failed" >&2
echo " Fix issues or run: npx markdownlint-cli2 --fix \"**/*.md\" \"#node_modules\"" >&2
exit 1
}

Expand Down
Loading