forked from MystenLabs/sui-colors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.sh
executable file
·76 lines (56 loc) · 2.15 KB
/
publish.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# check dependencies are available.
for i in jq curl sui; do
if ! command -V ${i} 2>/dev/null; then
echo "${i} is not installed"
exit 1
fi
done
NETWORK=http://localhost:9000
APPID=0
if [ $# -ne 0 ]; then
if [ $1 = "devnet" ]; then
NETWORK="https://fullnode.devnet.sui.io:443"
fi
if [ $1 = "testnet" ]; then
# NETWORK="http://dfw-exp-val-00.experiments.sui.io:9000"
NETWORK="https://fullnode.testnet.sui.io:443"
fi
if [ $1 = "mainnet" ]; then
NETWORK="https://fullnode.mainnet.sui.io:443"
fi
fi
echo "- Admin Address is: ${ADMIN_ADDRESS}"
import_address=$(sui keytool import "$ADMIN_PHRASE" ed25519)
switch_res=$(sui client switch --address ${ADMIN_ADDRESS})
ACTIVE_ADMIN_ADDRESS=$(sui client active-address)
echo "Admin address used for publishing: ${ACTIVE_ADMIN_ADDRESS}"
ACTIVE_NETWORK=$(sui client active-env)
echo "Environment used is: ${ACTIVE_NETWORK}"
publish_res=$(sui client publish --gas-budget 2000000000 --json ./pixel_board)
echo ${publish_res} >.publish.res.json
# Check if the command succeeded (exit status 0)
if [[ "$publish_res" =~ "error" ]]; then
# If yes, print the error message and exit the script
echo "Error during move contract publishing. Details : $publish_res"
exit 1
fi
PACKAGE_ID=$(echo "${publish_res}" | jq -r '.effects.created[] | select(.owner == "Immutable").reference.objectId')
newObjs=$(echo "$publish_res" | jq -r '.objectChanges[] | select(.type == "created")')
BOARD_ID=$(echo "$newObjs" | jq -r 'select (.objectType | contains("::pixel_board::board")).objectId')
PIXEL_ID=$(echo "$newObjs" | jq -r 'select (.objectType | contains("::pixel_board::pixel")).objectId')
PUBLISHER_ID=$(echo "$newObjs" | jq -r 'select (.objectType | contains("package::Publisher")).objectId')
UPGRADE_CAP_ID=$(echo "$newObjs" | jq -r 'select (.objectType | contains("package::UpgradeCap")).objectId')
suffix=""
if [ $# -eq 0 ]; then
suffix=".localnet"
fi
cat >.env<<-ENV
FULLNODE=$NETWORK
ADMIN_PHRASE=$ADMIN_PHRASE
PACKAGE_ID=$PACKAGE_ID
UPGRADE_CAP_ID=$UPGRADE_CAP_ID
ADMIN_ADDRESS=$ACTIVE_ADMIN_ADDRESS
ACTIVE_NETWORK=$ACTIVE_NETWORK
ENV
echo "Weather Oracle Contracts Deployment finished!"