-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
235 lines (197 loc) Β· 8.01 KB
/
Makefile
File metadata and controls
235 lines (197 loc) Β· 8.01 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# Aptos Token Scaffold - Makefile
# Provides convenient commands for development workflow
.PHONY: help install compile test deploy initialize interact monitor upgrade clean setup-dev
# Default target
help: ## Show this help message
@echo "π Aptos Token Scaffold Commands"
@echo "================================="
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
# Installation and Setup
install: ## Install Aptos CLI (macOS only)
@echo "π¦ Installing Aptos CLI..."
@if command -v brew >/dev/null 2>&1; then \
brew update && brew install aptos; \
else \
echo "β Homebrew not found. Please install manually."; \
echo "See: https://aptos.dev/tools/install-cli/"; \
fi
setup-dev: ## Setup development environment
@echo "π§ Setting up development environment..."
@chmod +x scripts/*.sh
@if [ ! -f .aptos/config.yaml ]; then \
echo "βοΈ Initializing Aptos CLI..."; \
aptos init --network testnet; \
fi
@echo "β
Development environment ready!"
# Development Commands
compile: ## Compile the Move contract
@echo "π¨ Compiling contract..."
@aptos move compile
test: ## Run all tests
@echo "π§ͺ Running tests..."
@aptos move test
test-coverage: ## Run tests with coverage report
@echo "π Running tests with coverage..."
@aptos move test --coverage
# Deployment Commands
deploy: compile test ## Deploy contract to testnet
@echo "π Deploying to testnet..."
@./scripts/deploy.sh testnet
deploy-mainnet: compile test ## Deploy contract to mainnet (use with caution!)
@echo "β οΈ Deploying to MAINNET..."
@read -p "Are you sure? This will deploy to mainnet! (y/N): " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
./scripts/deploy.sh mainnet; \
else \
echo "Deployment cancelled."; \
fi
# Token Operations
initialize: ## Initialize the deployed token
@echo "π― Initializing token..."
@./scripts/initialize.sh
interact: ## Open interactive CLI for token operations
@echo "π Starting interactive mode..."
@./scripts/interact.sh help
# Token-specific commands
balance: ## Check admin token balance
@./scripts/interact.sh balance
transfer: ## Transfer tokens (interactive)
@echo "π€ Token Transfer"
@echo "Usage: make transfer TO=<address> AMOUNT=<amount>"
@if [ -z "$(TO)" ] || [ -z "$(AMOUNT)" ]; then \
echo "β Please specify TO and AMOUNT"; \
echo "Example: make transfer TO=0x123...abc AMOUNT=1000"; \
else \
./scripts/interact.sh transfer $(TO) $(AMOUNT); \
fi
mint: ## Mint new tokens (interactive)
@echo "π Token Minting"
@echo "Usage: make mint TO=<address> AMOUNT=<amount>"
@if [ -z "$(TO)" ] || [ -z "$(AMOUNT)" ]; then \
echo "β Please specify TO and AMOUNT"; \
echo "Example: make mint TO=0x123...abc AMOUNT=1000"; \
else \
./scripts/interact.sh mint $(TO) $(AMOUNT); \
fi
info: ## Show token information
@./scripts/interact.sh info
supply: ## Show token supply information
@./scripts/interact.sh supply
# Monitoring and Maintenance
monitor: ## Start token monitoring dashboard
@echo "π Starting monitoring dashboard..."
@./scripts/monitor.sh
upgrade: compile test ## Upgrade the deployed contract
@echo "π Starting upgrade process..."
@./scripts/upgrade.sh
upgrade-force: compile ## Force upgrade without tests (dangerous!)
@echo "β οΈ Force upgrading contract..."
@./scripts/upgrade.sh --force
# Development Utilities
clean: ## Clean build artifacts
@echo "π§Ή Cleaning build artifacts..."
@rm -rf build/
@rm -rf .aptos/config.yaml.bak
@echo "β
Clean completed!"
check: ## Check code without compiling
@echo "π Checking code..."
@aptos move check
format: ## Format Move code (if formatter available)
@echo "π Formatting code..."
@if command -v move-fmt >/dev/null 2>&1; then \
find sources tests -name "*.move" -exec move-fmt {} \; ; \
else \
echo "βΉοΈ move-fmt not available. Install for automatic formatting."; \
fi
lint: ## Run linting checks
@echo "π Running linting checks..."
@aptos move check
@echo "β
Linting completed!"
# Documentation
docs: ## Generate documentation
@echo "π Generating documentation..."
@aptos move document --output-dir docs/generated/
@echo "π Documentation generated in docs/generated/"
# Security
security-check: ## Run basic security checks
@echo "π Running security checks..."
@echo "Checking for common patterns..."
@grep -r "unwrap\|panic\|abort" sources/ || echo "β
No unsafe patterns found"
@echo "Checking for TODO/FIXME comments..."
@grep -r "TODO\|FIXME\|XXX" sources/ || echo "β
No pending tasks found"
@echo "Security check completed. Consider professional audit for production!"
# Git hooks setup
setup-hooks: ## Setup git hooks for development
@echo "π Setting up git hooks..."
@mkdir -p .git/hooks
@echo '#!/bin/bash\nmake test' > .git/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
@echo "β
Git hooks setup completed!"
# Network operations
fund-account: ## Fund account with testnet tokens
@echo "π° Funding account with testnet tokens..."
@aptos account fund-with-faucet --account default
check-balance: ## Check APT balance
@echo "π° Checking APT balance..."
@aptos account list --query balance
# Backup operations
backup: ## Create backup of current contract state
@echo "πΎ Creating backup..."
@mkdir -p backups/manual_$(shell date +%Y%m%d_%H%M%S)
@cp -r sources tests Move.toml backups/manual_$(shell date +%Y%m%d_%H%M%S)/
@echo "β
Backup created!"
# All-in-one commands
dev-setup: install setup-dev fund-account ## Complete development setup
@echo "π Development environment fully configured!"
quick-deploy: compile test deploy initialize ## Quick deployment pipeline
@echo "π Quick deployment completed!"
full-test: clean compile test test-coverage security-check ## Full test suite
@echo "β
Full test suite completed!"
# Project customization helpers
customize: ## Interactive project customization
@echo "π¨ Project Customization Helper"
@echo "=============================="
@echo "This will help you customize the scaffold for your project."
@echo ""
@read -p "Enter your project name (snake_case): " project_name; \
read -p "Enter your wallet address: " wallet_addr; \
read -p "Enter your name: " author_name; \
read -p "Enter your email: " author_email; \
echo ""; \
echo "Customizing project..."; \
sed -i.bak "s/fungible_token/$$project_name/g" Move.toml; \
sed -i.bak "s/0xdffbb0f2a817c9e3ed7ec6670b24f4a4abc588b694082fd2be6e3fc0ea0ad894/$$wallet_addr/g" Move.toml; \
sed -i.bak "s/Therock Ani <[email protected]>/$$author_name <$$author_email>/g" Move.toml; \
echo "β
Basic customization completed!"; \
echo "Next steps:"; \
echo "1. Update module names in sources/ and tests/"; \
echo "2. Update function IDs in scripts/"; \
echo "3. Run 'make compile' to verify changes";
# Quick reference
commands: help ## Alias for help
# Development workflow examples
.PHONY: workflow-dev workflow-deploy workflow-test
workflow-dev: ## Example development workflow
@echo "π Development Workflow Example:"
@echo "1. make setup-dev # Setup environment"
@echo "2. make customize # Customize project"
@echo "3. make compile # Compile contract"
@echo "4. make test # Run tests"
@echo "5. make deploy # Deploy to testnet"
@echo "6. make initialize # Initialize token"
@echo "7. make monitor # Monitor contract"
workflow-deploy: ## Example deployment workflow
@echo "π Deployment Workflow Example:"
@echo "1. make full-test # Complete testing"
@echo "2. make backup # Backup current state"
@echo "3. make deploy # Deploy contract"
@echo "4. make initialize # Initialize token"
@echo "5. make security-check # Security validation"
@echo "6. make monitor # Start monitoring"
workflow-test: ## Example testing workflow
@echo "π§ͺ Testing Workflow Example:"
@echo "1. make compile # Compile first"
@echo "2. make test # Basic tests"
@echo "3. make test-coverage # Coverage report"
@echo "4. make security-check # Security checks"
@echo "5. make lint # Code quality"