|
12 | 12 | set -euo pipefail |
13 | 13 |
|
14 | 14 | echo "=========== Building dependencies ===========" |
15 | | -pushd ../../../ |
| 15 | + |
| 16 | +# This command also compiles the contracts if latest version is used |
16 | 17 | pnpm turbo build --filter @pythnetwork/pyth-evm-contract |
17 | | -popd |
18 | 18 |
|
19 | | -echo "=========== Compiling ===========" |
| 19 | +echo "=========== Deploying the contracts ===========" |
20 | 20 |
|
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 |
24 | | -fi |
| 21 | +version="$1" |
| 22 | +shift |
25 | 23 |
|
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 |
| 24 | +if [ "$version" = "latest" ]; then |
| 25 | + echo "Deploying latest version" |
| 26 | + stdoutputdir="../target_chains/ethereum/contracts/build/contracts" |
| 27 | +else |
| 28 | + # make sure version has format of vX.Y.Z |
| 29 | + if [[ ! "$version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 30 | + echo "Version must be in format vX.Y.Z" |
| 31 | + echo "Usage: $0 <version> <network_a> <network_b> ..." |
| 32 | + exit 1 |
| 33 | + fi |
29 | 34 |
|
30 | | -echo "Deploying the contracts..." |
| 35 | + echo "Deploying version $version" |
| 36 | + tmpdir=$(mktemp -d) |
| 37 | + wget https://github.com/pyth-network/pyth-crosschain/releases/download/pyth-evm-contract-$version/contracts-stdoutput.zip -O $tmpdir/contracts-stdoutput.zip |
| 38 | + unzip -q -o $tmpdir/contracts-stdoutput.zip -d $tmpdir |
| 39 | + stdoutputdir="$tmpdir" |
| 40 | +fi |
31 | 41 |
|
32 | | -pushd ../../../contract_manager/ |
| 42 | +pnpm --filter=@pythnetwork/contract-manager exec ts-node scripts/deploy_evm_pricefeed_contracts.ts --std-output-dir $stdoutputdir --private-key $PK --chain "$@" |
33 | 43 |
|
34 | | -pnpm exec ts-node scripts/deploy_evm_pricefeed_contracts.ts --std-output-dir ../target_chains/ethereum/contracts/build/contracts --private-key $PK --chain "$@" |
| 44 | +echo "=========== Cleaning up ===========" |
| 45 | +rm -rf $tmpdir |
| 46 | + |
| 47 | +if [ "$version" != "latest" ]; then |
| 48 | + 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" |
| 49 | +fi |
0 commit comments