-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMakefile
More file actions
100 lines (81 loc) · 2.99 KB
/
Makefile
File metadata and controls
100 lines (81 loc) · 2.99 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
# Makefile for PDP Contracts
# Variables
RPC_URL ?=
KEYSTORE ?=
PASSWORD ?=
# Generated files
LAYOUT=src/PDPVerifierLayout.sol
LAYOUT_JSON=src/PDPVerifierLayout.json
# Default target
.PHONY: default
default: build test
# All target including installation
.PHONY: all
all: install build test
# Install dependencies
.PHONY: install
install:
forge install
# Build target
.PHONY: build
build:
forge build --via-ir
# Test target
.PHONY: test
test:
forge test --via-ir -vv
# Deployment targets
.PHONY: deploy-calibnet
deploy-calibnet:
./tools/deploy-calibnet.sh
.PHONY: deploy-devnet
deploy-devnet:
./tools/deploy-devnet.sh
.PHONY: deploy-mainnet
deploy-mainnet:
./tools/deploy-mainnet.sh
# Extract just the ABI arrays into abi/ContractName.abi.json
.PHONY: extract-abis
extract-abis:
mkdir -p abi
@find out -type f -name '*.json' | while read file; do \
name=$$(basename "$${file%.*}"); \
jq '.abi' "$${file}" > "abi/$${name}.abi.json"; \
done
# Contract size check
.PHONY: contract-size-check
contract-size-check:
@echo "Checking contract sizes..."
bash tools/check-contract-size.sh
# Storage layout generation
$(LAYOUT): tools/generate_storage_layout.sh src/PDPVerifier.sol
bash tools/generate_storage_layout.sh src/PDPVerifier.sol:PDPVerifier | forge fmt -r - > $@
# Storage layout JSON (full metadata for upgrade safety checks)
$(LAYOUT_JSON): src/PDPVerifier.sol
forge inspect --json src/PDPVerifier.sol:PDPVerifier storageLayout | jq -S '. as $$root | def normalize_type($$id): ($$root.types[$$id]) as $$type | {label: $$type.label, encoding: $$type.encoding, numberOfBytes: $$type.numberOfBytes} + (if $$type.key then {key: normalize_type($$type.key)} else {} end) + (if $$type.value then {value: normalize_type($$type.value)} else {} end) + (if $$type.base then {base: normalize_type($$type.base)} else {} end) + (if $$type.members then {members: [$$type.members[] | {label, slot, offset, type: normalize_type(.type)}]} else {} end); [.storage[] | {label, slot, offset, type: normalize_type(.type)}]' > $@
# Main code generation target
.PHONY: gen
gen: check-tools $(LAYOUT) $(LAYOUT_JSON)
@echo "Code generation complete"
# Force regeneration - useful when things are broken
.PHONY: force-gen
force-gen: clean-gen gen
@echo "Force regeneration complete"
# Clean generated files only
.PHONY: clean-gen
clean-gen:
@echo "Removing generated files..."
@rm -f $(LAYOUT) $(LAYOUT_JSON)
@echo "Generated files removed"
# Check required tools
.PHONY: check-tools
check-tools:
@which jq >/dev/null 2>&1 || (echo "Error: jq is required but not installed" && exit 1)
@which forge >/dev/null 2>&1 || (echo "Error: forge is required but not installed" && exit 1)
# Storage layout validation
.PHONY: check-layout
check-layout: force-gen
@echo "Checking if layout files are up to date..."
@git diff --exit-code $(LAYOUT) $(LAYOUT_JSON) || (echo "Error: Layout files are stale. Please commit the generated changes." && exit 1)
@echo "Checking storage layout for destructive changes..."
@bash tools/check_storage_layout.sh