Skip to content

Commit

Permalink
Update deployment script for immediate verification
Browse files Browse the repository at this point in the history
  • Loading branch information
pclaesen committed Sep 6, 2024
1 parent f3c80ed commit 50bad25
Showing 1 changed file with 48 additions and 25 deletions.
73 changes: 48 additions & 25 deletions script/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,58 @@ else
etherscan_args=""
fi

if [ -z "$COMET_ADDRESS" ]; then
echo "COMET_ADDRESS is not set"
exit 1
fi

if [ -z "$REWARDS_ADDRESS" ]; then
echo "REWARDS_ADDRESS is not set"
exit 1
fi

if [ -z "$PROXY_ADMIN_ADDRESS" ]; then
echo "PROXY_ADMIN_ADDRESS is not set"
exit 1
fi

if [ -z "$TOKEN_NAME" ]; then
echo "TOKEN_NAME is not set"
exit 1
fi

if [ -z "$TOKEN_SYMBOL" ]; then
echo "TOKEN_SYMBOL is not set"
exit 1
fi
# Check for required environment variables
required_vars=("COMET_ADDRESS" "REWARDS_ADDRESS" "PROXY_ADMIN_ADDRESS" "TOKEN_NAME" "TOKEN_SYMBOL" "CHAIN_ID")
for var in "${required_vars[@]}"; do
if [ -z "${!var}" ]; then
echo "$var is not set"
exit 1
fi
done

# Run the Forge script
forge script \
$rpc_args \
$wallet_args \
$etherscan_args \
--broadcast \
$@ \
script/DeployCometWrapper.s.sol:DeployCometWrapper
script/DeployCometWrapper.s.sol:DeployCometWrapper

# Check if verification is enabled
if [ -n "$ETHERSCAN_KEY" ]; then
# Extract the deployed contract address from the Forge output
deployed_address=$(grep -oP 'Contract Address: \K[0-9a-fA-F]{40}' forge-output.txt)

if [ -n "$deployed_address" ]; then
echo "Waiting for contract verification..."

# Loop until verification is successful or timeout occurs
timeout=300 # 5 minutes timeout
start_time=$(date +%s)

while true; do
verification_status=$(forge verify-contract $deployed_address DeployCometWrapper --chain-id $CHAIN_ID --etherscan-api-key $ETHERSCAN_KEY --watch)

if [[ $verification_status == *"Contract successfully verified"* ]]; then
echo "Contract successfully verified!"
break
fi

current_time=$(date +%s)
elapsed_time=$((current_time - start_time))

if [ $elapsed_time -ge $timeout ]; then
echo "Verification timed out after ${timeout} seconds."
exit 1
fi

sleep 10 # Wait for 10 seconds before checking again
done
else
echo "Failed to extract deployed contract address."
exit 1
fi
else
echo "Verification skipped (ETHERSCAN_KEY not set)."
fi

0 comments on commit 50bad25

Please sign in to comment.