-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
193 lines (152 loc) · 8.07 KB
/
Copy pathMakefile
File metadata and controls
193 lines (152 loc) · 8.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# ============================================================
# DEX Dashboard — Makefile
# Automation for smart contracts (Foundry) + frontend (Next.js)
# ============================================================
.PHONY: help install install-contracts install-frontend
.PHONY: build build-contracts build-frontend
.PHONY: test test-contracts test-frontend
.PHONY: anvil deploy-anvil deploy-sepolia update-addresses
.PHONY: dev dev-frontend prod prod-frontend
.PHONY: clean clean-contracts clean-frontend
.PHONY: fmt coverage generate-abi docs
# ─── Help ──────────────────────────────────────────────────────
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
# ─── Installation ──────────────────────────────────────────────
install: ## Install all dependencies (forge + npm)
@echo "📦 Installing Foundry dependencies..."
cd contracts && forge install --no-git
@echo "📦 Installing frontend dependencies..."
@npm install
@echo "✅ All dependencies installed."
install-contracts: ## Install only Foundry dependencies
@echo "📦 Installing Foundry dependencies..."
cd contracts && forge install --no-git
@echo "✅ Foundry dependencies installed."
install-frontend: ## Install only frontend dependencies
@echo "📦 Installing frontend dependencies..."
@npm install
@echo "✅ Frontend dependencies installed."
# ─── Build ─────────────────────────────────────────────────────
build: ## Build contracts + frontend
@echo "🔨 Building contracts..."
cd contracts && forge build
@echo "🔨 Building frontend..."
@npm run build
@echo "✅ Build complete."
build-contracts: ## Build only contracts
@echo "🔨 Building contracts..."
cd contracts && forge build
@echo "✅ Contracts built."
build-frontend: ## Build only frontend
@echo "🔨 Building frontend..."
@npm run build
@echo "✅ Frontend built."
# ─── Testing ───────────────────────────────────────────────────
test: ## Run all tests (contracts + frontend)
@echo "🧪 Running contract tests..."
cd contracts && forge test -vvv
@echo "🧪 Running frontend tests..."
@npm test
@echo "✅ All tests passed."
test-contracts: ## Run only Foundry tests
@echo "🧪 Running contract tests..."
cd contracts && forge test -vvv
@echo "✅ Contract tests passed."
test-frontend: ## Run only frontend tests
@echo "🧪 Running frontend tests..."
@npm test
@echo "✅ Frontend tests passed."
# ─── Local Node ────────────────────────────────────────────────
anvil: ## Start local Anvil node (port 8545)
@echo "🔥 Starting Anvil node on http://127.0.0.1:8545..."
cd contracts && anvil
# ─── Load Sepolia config from contracts/.env ──────────────────
# This makes SEPOLIA_RPC_URL and ETHERSCAN_API_KEY available as
# Make variables for the deploy-sepolia target.
# If you don't have a .env file yet, copy the template:
# cp contracts/.env.example contracts/.env
-include contracts/.env
# ─── Deployment ────────────────────────────────────────────────
deploy-anvil: build-contracts ## Deploy contracts to Anvil + auto-update frontend addresses
@echo "🚀 Deploying contracts to Anvil..."
@echo ""
@echo "🔥 Network: Anvil (http://127.0.0.1:8545)"
@echo "💡 Default Anvil key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
@echo ""
cd contracts && forge script script/Deploy.s.sol:Deploy \
--rpc-url http://127.0.0.1:8545 \
--broadcast \
-vvv \
--interactives 1 && \
cd .. && $(MAKE) update-addresses CHAIN_ID=31337
deploy-sepolia: build-contracts ## Deploy contracts to Sepolia + auto-update frontend addresses
@echo "🚀 Deploying contracts to Sepolia..."
@echo ""
@echo "⛓️ Using SEPOLIA_RPC_URL from contracts/.env"
@echo "🔑 Using ETHERSCAN_API_KEY from contracts/.env"
@echo ""
cd contracts && forge script script/Deploy.s.sol:Deploy \
--rpc-url $(SEPOLIA_RPC_URL) \
--broadcast \
-vvv \
--verify \
--etherscan-api-key $(ETHERSCAN_API_KEY) \
--interactives 1 && \
cd .. && $(MAKE) update-addresses CHAIN_ID=11155111
# ─── Address Auto-Capture ─────────────────────────────────────
update-addresses: ## Extract deployed addresses from broadcast JSON and update constants.ts
@echo "📝 Updating frontend contract addresses..."
@./scripts/update-addresses.sh $(CHAIN_ID)
@echo "✅ Addresses updated! Run 'make dev-frontend' to start the app."
# ─── Frontend Development ──────────────────────────────────────
dev: install-frontend dev-frontend ## Install deps + start dev server
dev-frontend: ## Start frontend dev server (localhost:3000)
@echo "🚀 Starting frontend dev server..."
cd frontend && npm run dev
# ─── Production ────────────────────────────────────────────────
prod: build-frontend prod-frontend ## Build + serve production
prod-frontend: ## Serve production build (localhost:3000)
@echo "🚀 Starting production server..."
cd frontend && npm run start
# ─── Coverage ──────────────────────────────────────────────────
coverage: ## Generate Foundry coverage report
@echo "📊 Generating coverage report..."
cd contracts && forge coverage --report lcov
@echo "✅ Coverage report generated."
# ─── Clean ─────────────────────────────────────────────────────
clean: ## Clean all build artifacts and dependencies
@echo "🧹 Cleaning..."
cd contracts && forge clean 2>/dev/null || true
rm -rf frontend/.next
rm -rf frontend/node_modules
rm -rf node_modules
@echo "✅ Clean complete."
clean-contracts: ## Clean only contract artifacts
@echo "🧹 Cleaning contract artifacts..."
cd contracts && forge clean
@echo "✅ Contract artifacts cleaned."
clean-frontend: ## Clean only frontend artifacts
@echo "🧹 Cleaning frontend artifacts..."
rm -rf frontend/.next
rm -rf frontend/node_modules
@echo "✅ Frontend artifacts cleaned."
# ─── Code Quality ──────────────────────────────────────────────
fmt: ## Format all code (Solidity + TypeScript)
@echo "💅 Formatting Solidity..."
cd contracts && forge fmt
@echo "💅 Formatting frontend..."
@npm run lint -- --fix 2>/dev/null || true
@echo "✅ Formatting complete."
# ─── ABI Code Generation ───────────────────────────────────────
generate-abi: ## Generate type-safe wagmi hooks from contract ABIs
@echo "🏗️ Generating wagmi CLI types..."
cd frontend && npx wagmi generate
@echo "✅ ABI types generated in frontend/src/lib/generated.ts"
# ─── Documentation ─────────────────────────────────────────────
docs: ## Serve documentation locally on port 3001
@echo "📖 Serving docs at http://127.0.0.1:3001..."
@cd docs && python3 -m http.server 3001 2>/dev/null || \
python -m http.server 3001 2>/dev/null || \
echo "⚠️ Python not found. Open docs/index.html directly in a browser."