-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathstorage-report.sh
More file actions
45 lines (35 loc) · 1.28 KB
/
storage-report.sh
File metadata and controls
45 lines (35 loc) · 1.28 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
#!/bin/sh
# Default output directory
OUTPUT_DIR=${1:-docs/storage-report}
# Function to print messages
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') [INFO] $1"
}
# Function to print error messages
error() {
echo "$(date '+%Y-%m-%d %H:%M:%S') [ERROR] $1" >&2
}
log "Starting the storage report generation."
# Create the output directory if it doesn't exist
if ! mkdir -p "$OUTPUT_DIR"; then
error "Failed to create output directory: $OUTPUT_DIR"
exit 1
fi
log "Output directory is set to: $OUTPUT_DIR"
# Loop through Solidity files and generate storage report
# NOTE: Ignores `src/interfaces` & `src/libraries` since they "should" not contain storage logic.
for file in $(find src/ -name "*.sol" ! -path "*/interfaces/*" ! -path "*/libraries/*"); do
contract_name=$(basename "$file" .sol)
# Check if the file exists and is readable
if [ ! -r "$file" ]; then
error "Cannot read file: $file"
continue
fi
log "Processing contract: $contract_name"
# Run forge inspect and capture errors
if ! forge inspect "$contract_name" storage > "$OUTPUT_DIR/$contract_name.md"; then
error "Failed to generate storage report for contract: $contract_name"
else
log "Storage report generated for contract: $contract_name"
fi
done