Skip to content

Commit 4514210

Browse files
committed
chore(target_chains/ethereum): use versioned artifacts for deployment
1 parent 3292f62 commit 4514210

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

target_chains/ethereum/contracts/deploy.sh

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,38 @@
1212
set -euo pipefail
1313

1414
echo "=========== Building dependencies ==========="
15-
pushd ../../../
15+
16+
# This command also compiles the contracts if latest version is used
1617
pnpm turbo build --filter @pythnetwork/pyth-evm-contract
17-
popd
1818

19-
echo "=========== Compiling ==========="
19+
echo "=========== Deploying the contracts ==========="
2020

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
2523

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
2934

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
3141

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 "$@"
3343

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

Comments
 (0)