2022-10-13 18:21:26 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-10-17 05:10:05 -07:00
|
|
|
set -eo pipefail
|
2022-10-13 18:21:26 -07:00
|
|
|
|
2022-10-17 05:10:05 -07:00
|
|
|
function usage() {
|
|
|
|
cat <<EOF >&2
|
|
|
|
Usage:
|
2022-10-13 18:23:23 -07:00
|
|
|
|
2022-10-17 05:10:05 -07:00
|
|
|
$(basename "$0") <devnet|testnet|mainnet> -- Deploy the contracts
|
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
}
|
2022-10-13 18:21:26 -07:00
|
|
|
|
2023-09-29 08:11:43 -07:00
|
|
|
# cd to script directory so that we can run this script from anywhere
|
|
|
|
cd "$(dirname "$0")"
|
2022-10-17 05:10:05 -07:00
|
|
|
NETWORK=$1 || usage
|
|
|
|
|
|
|
|
if [ "$NETWORK" = mainnet ]; then
|
|
|
|
GUARDIAN_ADDR=0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5
|
|
|
|
|
|
|
|
elif [ "$NETWORK" = testnet ]; then
|
|
|
|
GUARDIAN_ADDR=0x13947Bd48b18E53fdAeEe77F3473391aC727C638
|
|
|
|
|
|
|
|
elif [ "$NETWORK" = devnet ]; then
|
|
|
|
DOTENV=$(dirname $0)/../.env
|
|
|
|
[[ -f "$DOTENV" ]] && . "$DOTENV"
|
|
|
|
|
|
|
|
GUARDIAN_ADDR="${INIT_SIGNERS_CSV:-0xbeFA429d57cD18b7F8A4d91A2da9AB4AF05d0FBe}"
|
|
|
|
|
|
|
|
worm aptos faucet
|
|
|
|
else
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
2023-09-29 08:11:43 -07:00
|
|
|
NAMED_ADDRS="wormhole=$WORMHOLE_ADDR,deployer=$DEPLOYER_ADDR,token_bridge=$TOKEN_BRIDGE_ADDR"
|
|
|
|
NAMED_ADDRS="$(./named_addresses $NETWORK)"
|
2022-10-17 05:10:05 -07:00
|
|
|
|
2023-09-29 08:11:43 -07:00
|
|
|
echo "Addresses: $NAMED_ADDRS"
|
2022-10-13 18:21:26 -07:00
|
|
|
|
2023-09-29 08:11:43 -07:00
|
|
|
# NOTE: this always succeeds, even if the deployer contact is already deployed
|
2023-01-11 07:30:13 -08:00
|
|
|
echo "[1/6] Deploying deployer contract for creating resource accounts..."
|
2022-10-17 05:10:05 -07:00
|
|
|
worm aptos deploy --network "$NETWORK" ../deployer --named-addresses "$NAMED_ADDRS"
|
2022-10-13 18:21:26 -07:00
|
|
|
|
2023-09-29 08:11:43 -07:00
|
|
|
echo "[2/6] Deploying wormhole contract..."
|
2022-10-17 05:10:05 -07:00
|
|
|
worm aptos deploy-resource wormhole --network "$NETWORK" ../wormhole --named-addresses "$NAMED_ADDRS"
|
2022-10-13 18:21:26 -07:00
|
|
|
|
2023-01-11 07:30:13 -08:00
|
|
|
echo "[3/6] Initialising wormhole with guardian(s) $GUARDIAN_ADDR..."
|
|
|
|
worm aptos init-wormhole --network "$NETWORK" -g $GUARDIAN_ADDR
|
2022-10-13 18:21:26 -07:00
|
|
|
|
2023-09-29 08:11:43 -07:00
|
|
|
echo "[4/6] Deploying token bridge contract..."
|
2022-10-17 05:10:05 -07:00
|
|
|
worm aptos deploy-resource token_bridge --network "$NETWORK" ../token_bridge --named-addresses "$NAMED_ADDRS"
|
2023-01-11 07:30:13 -08:00
|
|
|
|
|
|
|
echo "[5/6] Initialising token bridge..."
|
|
|
|
worm aptos init-token-bridge --network "$NETWORK"
|
|
|
|
|
2023-09-29 08:11:43 -07:00
|
|
|
echo "[6/6] Deploying (& initialising) NFT bridge contract..."
|
2023-01-11 07:30:13 -08:00
|
|
|
worm aptos deploy-resource nft_bridge --network "$NETWORK" ../nft_bridge --named-addresses "$NAMED_ADDRS"
|
2022-10-13 18:21:26 -07:00
|
|
|
|
2022-10-17 05:10:05 -07:00
|
|
|
if [ "$NETWORK" = devnet ]; then
|
|
|
|
echo "[+1] Deploying example contract..."
|
|
|
|
worm aptos deploy --network "$NETWORK" ../examples/core_messages --named-addresses "$NAMED_ADDRS"
|
|
|
|
fi
|
2022-10-13 18:23:23 -07:00
|
|
|
|
|
|
|
echo "Deployments successful."
|