set -e AVAILIABLE_NETWORKS=(anvil-localnet sepolia-testnet hoodi-testnet) NETWORK="${AVAILIABLE_NETWORKS[0]}" START=1 END=12 VERIFY_NEEDED="--verify" usage() { echo "Correct deployer script usage:" echo -e "\t-s, --start - from which contract deployment should start." echo -e "\t-e, --end - last contract deployment to be done." echo -e "\t-n, --network - network name to be deployed on." echo -e "\t-b, --blockscout - should try to use blockscout as verifier." echo -e "\nAvailable network names: ${AVAILIABLE_NETWORKS[@]}" echo -e "\nContract enumeration:" echo "0) Reserve" echo "1) Authority" echo "2) Fatso" echo "3) Stinky" echo "4) Ghost" echo "5) Staking" echo "6) Treasury" echo "7) BondDepository" echo "8) StakingDistributor" echo "9) BondingCalculator" echo "10) AfterPartyFirst" echo "11) AfterPartySecond" echo "12) AfterPartyThird" exit 1 } while [[ $# -gt 0 ]]; do case "${1}" in -s|--start) START="$2" shift shift ;; -e|--end) END="$2" shift shift ;; -n|--network) NETWORK="$2" shift shift ;; -b|--blockscout) VERIFY_NEEDED+=" --verifier blockscout" shift ;; -h|--help) usage ;; *) echo -e "\nERROR: Unknown option provided\n" usage ;; esac done if [ "$NETWORK" == "anvil-localnet" ]; then VERIFY_NEEDED="" fi found=false for i in "${AVAILIABLE_NETWORKS[@]}" do if [ "$i" == "$NETWORK" ] ; then found=true fi done if [ $found == false ] ; then echo "ERROR: '${NETWORK}' is incorrect network for deployment, valid networks are:" for i in "${AVAILIABLE_NETWORKS[@]}" do echo -e "\t${i}" done exit fi for i in $(seq $START $END); do if [ "0" == "$i" ]; then CONTRACT="Reserve" elif [ "1" == "$i" ] ; then CONTRACT="Authority" elif [ "2" == "$i" ]; then CONTRACT="Fatso" elif [ "3" == "$i" ]; then CONTRACT="Stinky" elif [ "4" == "$i" ]; then CONTRACT="Ghost" elif [ "5" == "$i" ]; then CONTRACT="Staking" elif [ "6" == "$i" ]; then CONTRACT="Treasury" elif [ "7" == "$i" ]; then CONTRACT="BondDepository" elif [ "8" == "$i" ]; then CONTRACT="StakingDistributor" elif [ "9" == "$i" ]; then CONTRACT="BondingCalculator" elif [ "10" == "$i" ]; then CONTRACT="AfterPartyFirst" elif [ "11" == "$i" ]; then CONTRACT="AfterPartySecond" elif [ "12" == "$i" ]; then CONTRACT="AfterPartyThird" else echo "No contract found for index $i" exit fi forge script script/${CONTRACT}.s.sol:Ghost${CONTRACT}Script --rpc-url $NETWORK if [ "$NETWORK" == "anvil-localnet" ]; then answer="y" else read -p "Do you want to broadcast '${CONTRACT}' to ${NETWORK} (y/N)? " answer fi if [ "$answer" != "${answer#[Yy]}" ] ; then forge script script/${CONTRACT}.s.sol:Ghost${CONTRACT}Script \ --rpc-url $NETWORK \ --broadcast \ ${VERIFY_NEEDED} \ -vvv else exit fi done