forked from Haroldwonder/SwiftRemit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
172 lines (151 loc) · 4.84 KB
/
Makefile
File metadata and controls
172 lines (151 loc) · 4.84 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
.PHONY: build test clean deploy install optimize check fmt
# Default target
all: build test
# Install dependencies
install:
@echo "Installing dependencies..."
rustup target add wasm32-unknown-unknown
cargo install --locked soroban-cli --features opt || true
@echo "✅ Dependencies installed"
# Build the contract
build:
@echo "Building contract..."
cargo build --target wasm32-unknown-unknown --release
@echo "✅ Build complete"
# Optimize the WASM binary
optimize: build
@echo "Optimizing contract..."
soroban contract optimize --wasm target/wasm32-unknown-unknown/release/swiftremit.wasm
@echo "✅ Optimization complete"
# Run tests
test:
@echo "Running tests..."
cargo test
@echo "✅ Tests passed"
# Run tests with output
test-verbose:
@echo "Running tests with verbose output..."
cargo test -- --nocapture
@echo "✅ Tests passed"
# Check code without building
check:
@echo "Checking code..."
cargo check --target wasm32-unknown-unknown
@echo "✅ Check complete"
# Format code
fmt:
@echo "Formatting code..."
cargo fmt
@echo "✅ Code formatted"
# Lint code
lint:
@echo "Linting code..."
cargo clippy --target wasm32-unknown-unknown -- -D warnings
@echo "✅ Lint complete"
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
cargo clean
rm -f *.wasm *.optimized.wasm
@echo "✅ Clean complete"
# Setup testnet network
setup-testnet:
@echo "Setting up testnet..."
soroban network add --global testnet \
--rpc-url https://soroban-testnet.stellar.org:443 \
--network-passphrase "Test SDF Network ; September 2015" || true
@echo "✅ Testnet configured"
# Create deployer identity
create-identity:
@echo "Creating deployer identity..."
soroban keys generate --global deployer --network testnet || true
@echo "Deployer address: $$(soroban keys address deployer)"
@echo "✅ Identity created"
# Fund deployer account
fund-deployer:
@echo "Funding deployer account..."
soroban keys fund deployer --network testnet
@echo "✅ Account funded"
# Deploy contract to testnet
deploy: optimize
@echo "Deploying contract to testnet..."
@CONTRACT_ID=$$(soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/swiftremit.optimized.wasm \
--source deployer \
--network testnet); \
echo "Contract deployed at: $$CONTRACT_ID"; \
echo "$$CONTRACT_ID" > .contract-id
@echo "✅ Deployment complete"
# Initialize contract (requires CONTRACT_ID, USDC_TOKEN, FEE_BPS env vars)
initialize:
@if [ -z "$(CONTRACT_ID)" ]; then \
echo "❌ CONTRACT_ID not set"; \
exit 1; \
fi
@if [ -z "$(USDC_TOKEN)" ]; then \
echo "❌ USDC_TOKEN not set"; \
exit 1; \
fi
@echo "Initializing contract..."
soroban contract invoke \
--id $(CONTRACT_ID) \
--source deployer \
--network testnet \
-- \
initialize \
--admin $$(soroban keys address deployer) \
--usdc_token $(USDC_TOKEN) \
--fee_bps $(or $(FEE_BPS),250)
@echo "✅ Contract initialized"
# Full deployment flow
deploy-full: setup-testnet create-identity fund-deployer deploy
@echo "✅ Full deployment complete"
@echo "Contract ID saved to .contract-id"
# Watch for file changes and rebuild
watch:
@echo "Watching for changes..."
cargo watch -x 'build --target wasm32-unknown-unknown --release'
# Generate documentation
docs:
@echo "Generating documentation..."
cargo doc --no-deps --open
@echo "✅ Documentation generated"
# Run security audit
audit:
@echo "Running security audit..."
cargo audit
@echo "✅ Audit complete"
# Show contract size
size: optimize
@echo "Contract size:"
@ls -lh target/wasm32-unknown-unknown/release/swiftremit.optimized.wasm | awk '{print $$5}'
# Help
help:
@echo "SwiftRemit Makefile Commands:"
@echo ""
@echo "Development:"
@echo " make install - Install dependencies"
@echo " make build - Build the contract"
@echo " make optimize - Optimize the WASM binary"
@echo " make test - Run tests"
@echo " make test-verbose - Run tests with output"
@echo " make check - Check code without building"
@echo " make fmt - Format code"
@echo " make lint - Lint code"
@echo " make clean - Clean build artifacts"
@echo " make watch - Watch for changes and rebuild"
@echo " make docs - Generate documentation"
@echo " make audit - Run security audit"
@echo " make size - Show contract size"
@echo ""
@echo "Deployment:"
@echo " make setup-testnet - Configure testnet"
@echo " make create-identity - Create deployer identity"
@echo " make fund-deployer - Fund deployer account"
@echo " make deploy - Deploy contract to testnet"
@echo " make initialize - Initialize contract (requires CONTRACT_ID, USDC_TOKEN)"
@echo " make deploy-full - Full deployment flow"
@echo ""
@echo "Example:"
@echo " make deploy-full"
@echo " make initialize CONTRACT_ID=CXXX... USDC_TOKEN=CYYY... FEE_BPS=250"