From 043daf836306d5b70d55aaf29f44b3d950feceda Mon Sep 17 00:00:00 2001 From: Ethan Date: Wed, 10 Jun 2020 20:35:57 -0400 Subject: [PATCH] Refactor installation script --- .../scripts/install-testchain-outputs.sh | 4 +--- .../scripts/install-testchain-outputs.sh | 11 ++-------- .../{ => contracts}/deprecatedContracts.json | 0 .../scripts/install-testchain-outputs.sh | 4 +--- .../scripts/install-testchain-outputs.sh | 9 +------- .../dai/scripts/install-testchain-outputs.sh | 9 +------- scripts/install-testchain-outputs.sh | 22 ++++++++++++++----- 7 files changed, 23 insertions(+), 36 deletions(-) rename packages/dai-plugin-mcd/test/{ => contracts}/deprecatedContracts.json (100%) diff --git a/packages/dai-plugin-governance/scripts/install-testchain-outputs.sh b/packages/dai-plugin-governance/scripts/install-testchain-outputs.sh index d6b6216ed..38a825300 100755 --- a/packages/dai-plugin-governance/scripts/install-testchain-outputs.sh +++ b/packages/dai-plugin-governance/scripts/install-testchain-outputs.sh @@ -1,9 +1,7 @@ #!/usr/bin/env bash set -e -CWD=`dirname $0` -CONTRACTS=$CWD/../packages/dai-plugin-governance/contracts -SOURCE=${1:-$CWD/../node_modules/@makerdao/testchain} +CONTRACTS=$GOVERNANCE/contracts CHIEF=`jq ".MCD_ADM" "$SOURCE/out/addresses-mcd.json"` jq ".CHIEF=$CHIEF" $CONTRACTS/addresses/testnet.json > testnet.tmp && mv testnet.tmp $CONTRACTS/addresses/testnet.json diff --git a/packages/dai-plugin-mcd/scripts/install-testchain-outputs.sh b/packages/dai-plugin-mcd/scripts/install-testchain-outputs.sh index 07cf4b5a5..d01fe7aab 100755 --- a/packages/dai-plugin-mcd/scripts/install-testchain-outputs.sh +++ b/packages/dai-plugin-mcd/scripts/install-testchain-outputs.sh @@ -3,14 +3,7 @@ set -e # TODO take the source directory as a parameter -CWD=`dirname $0` -CONTRACTS=$CWD/../packages/dai-plugin-mcd/contracts -SOURCE=${1:-$CWD/../node_modules/@makerdao/testchain} - -function jq_inplace { - TMP=$(mktemp) - jq "$1" > $TMP && mv $TMP "$2" -} +CONTRACTS=$MCD/contracts for file in $SOURCE/out/mcd/*.abi; do cp $file $CONTRACTS/abis/$(basename $file .abi).json @@ -21,7 +14,7 @@ cp $SOURCE/out/addresses-mcd.json $PACKAGE_ADDRESSES # These contracts are no longer supported, but dummy addresses # must still be set to prevent errors when fetching event history -DEPRECATED_CONTRACTS=$CWD/../packages/dai-plugin-mcd/test/deprecatedContracts.json +DEPRECATED_CONTRACTS=$MCD/test/contracts/deprecatedContracts.json MIGRATION=$(cat $DEPRECATED_CONTRACTS | jq '.MIGRATION') MCD_JOIN_SAI=$(cat $DEPRECATED_CONTRACTS | jq '.MCD_JOIN_SAI') cat $PACKAGE_ADDRESSES | jq_inplace ".MIGRATION = $(echo $MIGRATION)" $PACKAGE_ADDRESSES diff --git a/packages/dai-plugin-mcd/test/deprecatedContracts.json b/packages/dai-plugin-mcd/test/contracts/deprecatedContracts.json similarity index 100% rename from packages/dai-plugin-mcd/test/deprecatedContracts.json rename to packages/dai-plugin-mcd/test/contracts/deprecatedContracts.json diff --git a/packages/dai-plugin-migrations/scripts/install-testchain-outputs.sh b/packages/dai-plugin-migrations/scripts/install-testchain-outputs.sh index 78e7f6dfe..a0b80b199 100755 --- a/packages/dai-plugin-migrations/scripts/install-testchain-outputs.sh +++ b/packages/dai-plugin-migrations/scripts/install-testchain-outputs.sh @@ -3,9 +3,7 @@ set -e # TODO take the source directory as a parameter -CWD=`dirname $0` -CONTRACTS=$CWD/../packages/dai-plugin-migrations/contracts -SOURCE=${1:-$CWD/../node_modules/@makerdao/testchain} +CONTRACTS=$MIGRATIONS/contracts # Relevant contracts from SCD: for CONTRACT in "SAI_TUB","SaiTub" "REDEEMER","Redeemer" "OLD_MKR","DSToken" "OLD_CHIEF","DSChief" "SAI_CAGEFREE","CageFree" "OLD_VOTE_PROXY_FACTORY","VoteProxyFactory" diff --git a/packages/dai-plugin-scd/scripts/install-testchain-outputs.sh b/packages/dai-plugin-scd/scripts/install-testchain-outputs.sh index 4acdf51fd..556d7b3b1 100755 --- a/packages/dai-plugin-scd/scripts/install-testchain-outputs.sh +++ b/packages/dai-plugin-scd/scripts/install-testchain-outputs.sh @@ -1,14 +1,7 @@ #!/usr/bin/env bash set -e -CWD=`dirname $0` -CONTRACTS=$CWD/../packages/dai-plugin-scd/contracts -SOURCE=${1:-$CWD/../node_modules/@makerdao/testchain} - -function jq_inplace { - TMP=$(mktemp) - jq "$1" > $TMP && mv $TMP "$2" -} +CONTRACTS=$SCD/contracts for file in $SOURCE/out/*.abi; do cp $file $CONTRACTS/abis/$(basename $file .abi).json diff --git a/packages/dai/scripts/install-testchain-outputs.sh b/packages/dai/scripts/install-testchain-outputs.sh index eef288e00..6cf7b0223 100755 --- a/packages/dai/scripts/install-testchain-outputs.sh +++ b/packages/dai/scripts/install-testchain-outputs.sh @@ -1,14 +1,7 @@ #!/usr/bin/env bash set -e -CWD=`dirname $0` -CONTRACTS=$CWD/../packages/dai/contracts -SOURCE=${1:-$CWD/../node_modules/@makerdao/testchain} - -function jq_inplace { - TMP=$(mktemp) - jq "$1" > $TMP && mv $TMP "$2" -} +CONTRACTS=$DAI/contracts for file in $SOURCE/out/*.abi; do cp $file $CONTRACTS/abis/$(basename $file .abi).json diff --git a/scripts/install-testchain-outputs.sh b/scripts/install-testchain-outputs.sh index 6e18dd90d..71c0f8f8c 100755 --- a/scripts/install-testchain-outputs.sh +++ b/scripts/install-testchain-outputs.sh @@ -2,9 +2,21 @@ set -e CWD=`dirname $0` +SOURCE=${1:-$CWD/../node_modules/@makerdao/testchain} -. $CWD/../packages/dai-plugin-mcd/scripts/install-testchain-outputs.sh -. $CWD/../packages/dai-plugin-scd/scripts/install-testchain-outputs.sh -. $CWD/../packages/dai/scripts/install-testchain-outputs.sh -. $CWD/../packages/dai-plugin-migrations/scripts/install-testchain-outputs.sh -. $CWD/../packages/dai-plugin-governance/scripts/install-testchain-outputs.sh \ No newline at end of file +function jq_inplace { + TMP=$(mktemp) + jq "$1" > $TMP && mv $TMP "$2" +} + +DAI=$CWD/../packages/dai +MCD=$CWD/../packages/dai-plugin-mcd +SCD=$CWD/../packages/dai-plugin-scd +MIGRATIONS=$CWD/../packages/dai-plugin-migrations +GOVERNANCE=$CWD/../packages/dai-plugin-governance + +. $MCD/scripts/install-testchain-outputs.sh +. $SCD/scripts/install-testchain-outputs.sh +. $DAI/scripts/install-testchain-outputs.sh +. $MIGRATIONS/scripts/install-testchain-outputs.sh +. $GOVERNANCE/scripts/install-testchain-outputs.sh \ No newline at end of file