|
1 | 1 | #!/bin/bash
|
2 | 2 | #
|
3 | 3 | # This script deploys changes to given networks. Usage:
|
4 |
| -# $ ./deploy.sh <network_a> <network_a> <...> |
5 |
| -# Network names are defined in `truffle-config.js`. |
| 4 | +# $ ./deploy.sh <version:vX.Y.Z|latest> <network_a> <network_a> <...> |
| 5 | +# |
| 6 | +# You need to set the PK environment variable to your private key. |
6 | 7 | #
|
7 | 8 | # Example: Deploying to some testnet networks
|
8 |
| -# $ ./deploy.sh bnb_testnet fantom_testnet mumbai |
| 9 | +# $ ./deploy.sh latest bnb_testnet fantom_testnet mumbai |
9 | 10 | #
|
10 | 11 | # Example: Deploying to some mainnet networks
|
11 |
| -# $ ./deploy.sh ethereum bnb avalanche |
| 12 | +# $ ./deploy.sh v1.4.5 ethereum bnb avalanche |
12 | 13 | set -euo pipefail
|
13 | 14 |
|
14 |
| -echo "=========== Building dependencies ===========" |
15 |
| -pushd ../../../ |
16 |
| -pnpm turbo build --filter @pythnetwork/pyth-evm-contract |
17 |
| -popd |
| 15 | +echo "=========== Preparing contracts ===========" |
| 16 | + |
| 17 | +PK=$PK |
| 18 | + |
| 19 | +version="$1" |
| 20 | +shift |
18 | 21 |
|
19 |
| -echo "=========== Compiling ===========" |
| 22 | +if [ "$version" = "latest" ]; then |
| 23 | + echo "Deploying latest version" |
| 24 | + stdoutputdir="../target_chains/ethereum/contracts/build/contracts" |
| 25 | +else |
| 26 | + # make sure version has format of vX.Y.Z |
| 27 | + if [[ ! "$version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 28 | + echo "Version must be in format vX.Y.Z" |
| 29 | + echo "Usage: $0 <version> <network_a> <network_b> ..." |
| 30 | + exit 1 |
| 31 | + fi |
20 | 32 |
|
21 |
| -if [[ -e contracts/pyth/PythUpgradable_merged.sol ]]; then |
22 |
| - echo "Flattened contract PythUpgradable_merged.sol exists. Removing before compiling." |
23 |
| - rm contracts/pyth/PythUpgradable_merged.sol |
| 33 | + echo "Deploying version $version" |
| 34 | + tmpdir=$(mktemp -d) |
| 35 | + wget https://github.com/pyth-network/pyth-crosschain/releases/download/pyth-evm-contract-$version/contracts-stdoutput.zip -O $tmpdir/contracts-stdoutput.zip |
| 36 | + unzip -q -o $tmpdir/contracts-stdoutput.zip -d $tmpdir |
| 37 | + stdoutputdir="$tmpdir" |
24 | 38 | fi
|
25 | 39 |
|
26 |
| -echo "Building the contracts..." |
27 |
| -# Ensure that we deploy a fresh build with up-to-date dependencies. |
28 |
| -rm -rf build && pnpm exec truffle compile --all |
| 40 | +echo "=========== Building dependencies ===========" |
| 41 | + |
| 42 | +# This command also compiles the contracts if latest version is used |
| 43 | +pnpm turbo build --filter @pythnetwork/pyth-evm-contract |
29 | 44 |
|
30 |
| -echo "Deploying the contracts..." |
| 45 | +echo "=========== Deploying the contracts ===========" |
31 | 46 |
|
32 |
| -pushd ../../../contract_manager/ |
| 47 | +pnpm --filter=@pythnetwork/contract-manager exec ts-node scripts/deploy_evm_pricefeed_contracts.ts --std-output-dir $stdoutputdir --private-key $PK --chain "$@" |
33 | 48 |
|
34 |
| -pnpm exec ts-node scripts/deploy_evm_pricefeed_contracts.ts --std-output-dir ../target_chains/ethereum/contracts/build/contracts --private-key $PK --chain "$@" |
| 49 | +echo "=========== Cleaning up ===========" |
| 50 | +rm -rf $tmpdir |
| 51 | + |
| 52 | +if [ "$version" != "latest" ]; then |
| 53 | + 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" |
| 54 | +fi |
0 commit comments