diff --git a/README.md b/README.md index 33a46bc..63644eb 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,10 @@ To nullify inflation attacks, `CometWrapper` maintains internal accounting of al ### Testnets -| Network | Base Asset | CometWrapper Address | -| -------- | ---------- | ------------------------------------------ | -| Sepolia | USDC | 0xC3836072018B4D590488b851d574556f2EeB895a | +| Network | Base Asset | CometWrapper Address | +| ------------ | ------------- | ------------------------------------------ | +| Sepolia | USDC | 0xC3836072018B4D590488b851d574556f2EeB895a | +| Base Sepolia | USDC | 0x383eCD943E338357c0D81942933acA781C2E74cE | ## Usage diff --git a/script/DeployCometWrapper.s.sol b/script/DeployCometWrapper.s.sol index fe0161c..f1f03f6 100644 --- a/script/DeployCometWrapper.s.sol +++ b/script/DeployCometWrapper.s.sol @@ -18,6 +18,7 @@ import { CometWrapper, CometInterface, ICometRewards, CometHelpers, IERC20 } fro // PROXY_ADMIN_ADDRESS // TOKEN_NAME // TOKEN_SYMBOL +// CHAIN_ID // Optional but suggested ENV vars: // ETHERSCAN_KEY diff --git a/script/deploy.sh b/script/deploy.sh index ddb127b..6f105b7 100755 --- a/script/deploy.sh +++ b/script/deploy.sh @@ -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 \ No newline at end of file + 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 \ No newline at end of file