Skip to content
Open
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
59 changes: 45 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
include .env
# Load environment variables from .env file if it exists
ifneq (,$(wildcard .env))
include .env
export
endif

# Default target: show help
.DEFAULT_GOAL := help

##
# Solidity Setup / Testing
# -----------------------------------------------------------------------------
# Solidity Setup / Testing / DevOps
# -----------------------------------------------------------------------------
##

.PHONY: help
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: install-foundry
install-foundry:
install-foundry: ## Install Foundry toolchain (forge, cast, anvil)
@echo "[+] Installing Foundry..."
curl -L https://foundry.paradigm.xyz | bash
~/.foundry/bin/foundryup
@echo "[!] Please verify your PATH or restart your shell to use 'forge'."

.PHONY: deps
deps: clean-lib checkout-op-commit
deps: clean-lib checkout-op-commit ## Clean and re-install all Solidity dependencies
@echo "[+] Installing standard dependencies..."
forge install --no-git github.com/foundry-rs/forge-std \
github.com/OpenZeppelin/openzeppelin-contracts@v4.9.3 \
github.com/OpenZeppelin/openzeppelin-contracts-upgradeable@v4.7.3 \
Expand All @@ -18,29 +34,44 @@ deps: clean-lib checkout-op-commit
github.com/safe-global/safe-smart-account@v1.4.1-3

.PHONY: test
test:
test: ## Run tests (Warning: --ffi enabled, check dependencies!)
@echo "[!] Running tests with FFI enabled. Ensure you trust all dependencies."
forge test --ffi -vvv

.PHONY: snapshot
snapshot: ## Generate a gas snapshot for contract methods
forge snapshot --ffi

.PHONY: fmt
fmt: ## Format Solidity code
forge fmt

.PHONY: clean-lib
clean-lib:
clean-lib: ## Remove the lib directory
@echo "[+] Cleaning lib directory..."
rm -rf lib

.PHONY: checkout-op-commit
checkout-op-commit:
[ -n "$(OP_COMMIT)" ] || (echo "OP_COMMIT must be set in .env" && exit 1)
rm -rf lib/optimism
mkdir -p lib/optimism
cd lib/optimism; \
checkout-op-commit: ## Sparse checkout specific Optimism commit defined in .env
@echo "[+] Checking out Optimism commit: $(OP_COMMIT)"
@[ -n "$(OP_COMMIT)" ] || (echo "Error: OP_COMMIT must be set in .env" && exit 1)
@rm -rf lib/optimism
@mkdir -p lib/optimism
@cd lib/optimism; \
git init; \
git remote add origin https://github.com/ethereum-optimism/optimism.git; \
git fetch --depth=1 origin $(OP_COMMIT); \
git reset --hard FETCH_HEAD

.PHONY: bindings
bindings:
bindings: ## Generate Go bindings from Solidity ABIs
@echo "[+] Installing abigen (v1.15.8)..."
go install github.com/ethereum/go-ethereum/cmd/abigen@v1.15.8
@echo "[+] Building contracts..."
forge build
@echo "[+] Generating Go bindings..."
mkdir -p bindings
abigen --abi out/BalanceTracker.sol/BalanceTracker.abi.json --pkg bindings --type BalanceTracker --out bindings/balance_tracker.go
abigen --abi out/FeeDisburser.sol/FeeDisburser.abi.json --pkg bindings --type FeeDisburser --out bindings/fee_disburser.go
cd bindings && go mod tidy
@echo "[+] Tidying Go modules..."
cd bindings && go mod tidy