|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +source .env |
| 4 | + |
| 5 | +if [ -z "$ALCHEMY_API_KEY" ] |
| 6 | +then |
| 7 | + echo "ALCHEMY_API_KEY is not set on the .env file, exiting..." |
| 8 | + exit -1 |
| 9 | +else |
| 10 | + export ALCHEMY_API_KEY=$ALCHEMY_API_KEY |
| 11 | +fi |
| 12 | + |
| 13 | + |
| 14 | +current_dir=$(pwd) |
| 15 | +CLONE_DIR="temp_dir" |
| 16 | + |
| 17 | +rm -rf $CLONE_DIR |
| 18 | +mkdir -p $CLONE_DIR |
| 19 | +cd $CLONE_DIR |
| 20 | + |
| 21 | +# The format is the following: |
| 22 | +# repoUrl = branchname&artifactsDirectory&projectType&contractsDirectory |
| 23 | + |
| 24 | +REPOS=$(cat <<EOF |
| 25 | +https://github.com/aragon/osx=develop&artifacts/src&hardhat&packages/contracts, |
| 26 | +https://github.com/aragon/admin-plugin=develop&artifacts/src&hardhat&packages/contracts, |
| 27 | +https://github.com/aragon/token-voting-plugin=develop&artifacts/src&hardhat&packages/contracts, |
| 28 | +https://github.com/aragon/multisig-plugin=develop&artifacts/src&hardhat&packages/contracts, |
| 29 | +https://github.com/aragon/staged-proposal-processor-plugin=init-project&out&forge& |
| 30 | +EOF |
| 31 | +) |
| 32 | + |
| 33 | +# Process each line |
| 34 | +while IFS=',' read -r line; do |
| 35 | + IFS='=' read -r repoUrl data <<< "$line" |
| 36 | + |
| 37 | + IFS='&' read -r branch artifactSource projectType contractsDirectory <<< "$data" |
| 38 | + |
| 39 | + REPO_NAME=$(basename $repoUrl .git) |
| 40 | + |
| 41 | + git clone -b ${branch} $repoUrl $REPO_NAME |
| 42 | + |
| 43 | + cd $REPO_NAME/$contractsDirectory |
| 44 | + |
| 45 | + yarn install |
| 46 | + |
| 47 | + yarn add -D @wagmi/cli |
| 48 | + |
| 49 | + if [ "$projectType" = "hardhat" ]; then |
| 50 | + cp $current_dir/wagmi.hardhat.config.ts wagmi.config.ts |
| 51 | + sed -i -e "s|REPLACE_ARTIFACTS_SOURCE|${artifactSource}|g" wagmi.config.ts |
| 52 | + npx hardhat compile |
| 53 | + |
| 54 | + elif [ "$projectType" = "forge" ]; then |
| 55 | + cp $current_dir/wagmi.foundry.config.ts wagmi.config.ts |
| 56 | + forge remappings |
| 57 | + forge compile |
| 58 | + |
| 59 | + else |
| 60 | + echo "either hardhat or forge project is required" |
| 61 | + exit 1 |
| 62 | + fi |
| 63 | + |
| 64 | + yarn wagmi generate |
| 65 | + |
| 66 | + mv generated/abis.ts $current_dir/src/abis/${REPO_NAME}-abis.ts |
| 67 | + |
| 68 | + cd $current_dir/$CLONE_DIR |
| 69 | + |
| 70 | +done <<< "$REPOS" |
0 commit comments