|
@@ -1,34 +1,54 @@
|
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
|
#
|
|
#
|
|
|
# This script deploys changes to given networks. Usage:
|
|
# This script deploys changes to given networks. Usage:
|
|
|
-# $ ./deploy.sh <network_a> <network_a> <...>
|
|
|
|
|
-# Network names are defined in `truffle-config.js`.
|
|
|
|
|
|
|
+# $ ./deploy.sh <version:vX.Y.Z|latest> <network_a> <network_a> <...>
|
|
|
|
|
+#
|
|
|
|
|
+# You need to set the PK environment variable to your private key.
|
|
|
#
|
|
#
|
|
|
# Example: Deploying to some testnet networks
|
|
# Example: Deploying to some testnet networks
|
|
|
-# $ ./deploy.sh bnb_testnet fantom_testnet mumbai
|
|
|
|
|
|
|
+# $ ./deploy.sh latest bnb_testnet fantom_testnet mumbai
|
|
|
#
|
|
#
|
|
|
# Example: Deploying to some mainnet networks
|
|
# Example: Deploying to some mainnet networks
|
|
|
-# $ ./deploy.sh ethereum bnb avalanche
|
|
|
|
|
|
|
+# $ ./deploy.sh v1.4.5 ethereum bnb avalanche
|
|
|
set -euo pipefail
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
-echo "=========== Building dependencies ==========="
|
|
|
|
|
-pushd ../../../
|
|
|
|
|
-pnpm turbo build --filter @pythnetwork/pyth-evm-contract
|
|
|
|
|
-popd
|
|
|
|
|
|
|
+echo "=========== Preparing contracts ==========="
|
|
|
|
|
+
|
|
|
|
|
+PK=$PK
|
|
|
|
|
+
|
|
|
|
|
+version="$1"
|
|
|
|
|
+shift
|
|
|
|
|
|
|
|
-echo "=========== Compiling ==========="
|
|
|
|
|
|
|
+if [ "$version" = "latest" ]; then
|
|
|
|
|
+ echo "Deploying latest version"
|
|
|
|
|
+ stdoutputdir="../target_chains/ethereum/contracts/build/contracts"
|
|
|
|
|
+else
|
|
|
|
|
+ # make sure version has format of vX.Y.Z
|
|
|
|
|
+ if [[ ! "$version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
|
|
|
+ echo "Version must be in format vX.Y.Z"
|
|
|
|
|
+ echo "Usage: $0 <version> <network_a> <network_b> ..."
|
|
|
|
|
+ exit 1
|
|
|
|
|
+ fi
|
|
|
|
|
|
|
|
-if [[ -e contracts/pyth/PythUpgradable_merged.sol ]]; then
|
|
|
|
|
- echo "Flattened contract PythUpgradable_merged.sol exists. Removing before compiling."
|
|
|
|
|
- rm contracts/pyth/PythUpgradable_merged.sol
|
|
|
|
|
|
|
+ echo "Deploying version $version"
|
|
|
|
|
+ tmpdir=$(mktemp -d)
|
|
|
|
|
+ wget https://github.com/pyth-network/pyth-crosschain/releases/download/pyth-evm-contract-$version/contracts-stdoutput.zip -O $tmpdir/contracts-stdoutput.zip
|
|
|
|
|
+ unzip -q -o $tmpdir/contracts-stdoutput.zip -d $tmpdir
|
|
|
|
|
+ stdoutputdir="$tmpdir"
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
-echo "Building the contracts..."
|
|
|
|
|
-# Ensure that we deploy a fresh build with up-to-date dependencies.
|
|
|
|
|
-rm -rf build && pnpm exec truffle compile --all
|
|
|
|
|
|
|
+echo "=========== Building dependencies ==========="
|
|
|
|
|
+
|
|
|
|
|
+# This command also compiles the contracts if latest version is used
|
|
|
|
|
+pnpm turbo build --filter @pythnetwork/pyth-evm-contract
|
|
|
|
|
|
|
|
-echo "Deploying the contracts..."
|
|
|
|
|
|
|
+echo "=========== Deploying the contracts ==========="
|
|
|
|
|
|
|
|
-pushd ../../../contract_manager/
|
|
|
|
|
|
|
+pnpm --filter=@pythnetwork/contract-manager exec ts-node scripts/deploy_evm_pricefeed_contracts.ts --std-output-dir $stdoutputdir --private-key $PK --chain "$@"
|
|
|
|
|
|
|
|
-pnpm exec ts-node scripts/deploy_evm_pricefeed_contracts.ts --std-output-dir ../target_chains/ethereum/contracts/build/contracts --private-key $PK --chain "$@"
|
|
|
|
|
|
|
+echo "=========== Cleaning up ==========="
|
|
|
|
|
+rm -rf $tmpdir
|
|
|
|
|
+
|
|
|
|
|
+if [ "$version" != "latest" ]; then
|
|
|
|
|
+ echo "Verify the contracts by using the std-input artifacts of the contracts in https://github.com/pyth-network/pyth-crosschain/releases/tag/pyth-evm-contract-$version"
|
|
|
|
|
+fi
|