-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·45 lines (33 loc) · 1.36 KB
/
deploy.sh
File metadata and controls
executable file
·45 lines (33 loc) · 1.36 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/bash
set -e # Exit immediately if a command exits with non-zero status
# Define paths
CONTRACTS_DIR="."
ADDRESSES_JSON="./addresses.json"
# Step 1: Deploy contracts using Forge script
echo "Deploying contracts..."
cd "$CONTRACTS_DIR"
# Run the deployment script and capture the output
FORGE_OUT=$(mktemp)
forge script script/Deploy.s.sol:DeploymentScript --rpc-url $RPC_URL --private-key $DEPLOYER_PRIVATE_KEY --broadcast | tee "$FORGE_OUT"
# Step 2: Extract contract addresses from deployment output
echo "Extracting contract addresses..."
# Initialize JSON file
echo "{" > "$ADDRESSES_JSON"
# Process proxy contract addresses
grep "(Proxy):" "$FORGE_OUT" | while read -r line; do
CONTRACT_NAME=$(echo "$line" | cut -d':' -f1 | sed 's/(Proxy)//' | tr -d '[:space:]')
ADDRESS=$(echo "$line" | cut -d':' -f2 | tr -d '[:space:]')
echo " \"$CONTRACT_NAME\": \"$ADDRESS\"," >> "$ADDRESSES_JSON"
done
# Add EpochManager (no proxy)
grep "EpochManager:" "$FORGE_OUT" | while read -r line; do
ADDRESS=$(echo "$line" | cut -d':' -f2 | tr -d '[:space:]')
echo " \"EpochManager\": \"$ADDRESS\"" >> "$ADDRESSES_JSON"
done
# Fix the JSON file (remove trailing comma if needed)
# sed -i '$ s/,$//' "$ADDRESSES_JSON"
# Close the JSON object
echo "}" >> "$ADDRESSES_JSON"
# Clean up
rm -f "$FORGE_OUT"
echo "Deployment completed and addresses stored in $ADDRESSES_JSON"