From eb15f10b0da6313698415b90e8402bb7ed12d5e7 Mon Sep 17 00:00:00 2001 From: 0xAustrian Date: Thu, 12 Sep 2024 12:55:16 -0300 Subject: [PATCH] chore: add .sh script, update readme --- script/README.md | 43 ++++++++++++++++++++--- script/strategies/deployStrategy.sh | 54 +++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 5 deletions(-) create mode 100755 script/strategies/deployStrategy.sh diff --git a/script/README.md b/script/README.md index f6e77cb97..d42da55d4 100644 --- a/script/README.md +++ b/script/README.md @@ -1,6 +1,6 @@ -# Deployment scripts +# Strategy deployment scripts -This folder contains the scripts neccessary to deploy strategies and Allo contracts to the blockchain. +This folder contains the scripts neccessary to deploy strategies to the blockchain. # Usage @@ -9,9 +9,42 @@ This folder contains the scripts neccessary to deploy strategies and Allo contra 3. Fill the necessary environment variables in `.env` file. You can use `.env.example` as a template. 4. Run the deployment script with: ``` -forge script script/${SCRIPT_FILENAME}.sol:${SCRIPT_CONTRACT_NAME} --fork-url ${RPC_URL} --private-key ${PRIVATE_KEY} --broadcast +script/strategies/deployStrategy.sh ${CHAIN_NAME} ${STRATEGY_NAME} ``` For example: ``` -forge script script/strategies/DeployDirectAllocation.sol:DeployDirectAllocation --fork-url https://eth-sepolia.public.blastapi.io --private-key 0x0000 --broadcast -``` \ No newline at end of file +script/strategies/deployStrategy.sh sepolia DeployDirectAllocation +``` + +# Supported networks + +- fuji +- sepolia +- celo-testnet +- arbitrum-sepolia +- optimism-sepolia +- optimism-mainnet +- celo-mainnet +- arbitrum-mainnet +- base +- polygon +- mainnet +- avalanche +- scroll +- ftmTestnet +- fantom +- filecoin-mainnet +- filecoin-calibration +- sei-devnet +- sei-mainnet +- lukso-testnet +- lukso-mainnet +- zkSyncTestnet +- zkSyncMainnet + +# Deployment to zkSync + +1. Install [foundry-zksync](https://github.com/matter-labs/foundry-zksync) +2. Deploy as usual + +For actions other than deployments, such as running tests or compiling contracts, run `forge` commands using `--zksync`. \ No newline at end of file diff --git a/script/strategies/deployStrategy.sh b/script/strategies/deployStrategy.sh new file mode 100755 index 000000000..77b8d7fd1 --- /dev/null +++ b/script/strategies/deployStrategy.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Function to dynamically map chains to variables +# Relevant issue that would deprecate this script if solved: https://github.com/foundry-rs/foundry/issues/7726 +# TODO: add networks +deploy() { + chain=$1 + strategy=$2 + case "$chain" in + "sepolia") + RPC_URL="$SEPOLIA_RPC_URL" + API_KEY="$ETHERSCAN_API_KEY" + ;; + "mainnet") + RPC_URL="$MAINNET_RPC_URL" + API_KEY="$ETHERSCAN_API_KEY" + ;; + *) + echo "Error: Unknown chain '$chain'" + exit 1 + ;; + esac + + # Check if required variables are set + if [ -z "$RPC_URL" ] || [ -z "$API_KEY" ] || [ -z "$DEPLOYER_PRIVATE_KEY" ]; then + echo "Error: Missing environment variables." + exit 1 + fi + + # Deploy script with resolved variables + if [ "$chain" == "zkSyncMainnet" ] || [ "$chain" == "zkSyncTestnet" ]; then + forge script script/strategies/"$strategy".sol --zksync --rpc-url "$RPC_URL" --broadcast --private-key "$DEPLOYER_PRIVATE_KEY" --verify --etherscan-api-key "$API_KEY" + else + forge script script/strategies/"$strategy".sol --rpc-url "$RPC_URL" --broadcast --private-key "$DEPLOYER_PRIVATE_KEY" --verify --etherscan-api-key "$API_KEY" + fi +} + +# Ensure the chain argument is provided +if [ -z "$1" ]; then + echo " not provided. Usage: script/strategies/deployStrategy.sh " + exit 1 +fi + +# Ensure the strategy argument is provided +if [ -z "$2" ]; then + echo " not provided. Usage: script/strategies/deployStrategy.sh " + exit 1 +fi + +# Source the environment variables from the .env file +source .env + +# Call the deploy function with the provided chain argument +deploy "$1" "$2" \ No newline at end of file