Skip to content

Commit

Permalink
sui-explorer integration with CLI publish commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mario4tier committed Jul 21, 2024
1 parent 36c530a commit bf6d434
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 11 deletions.
36 changes: 32 additions & 4 deletions scripts/common/__publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,38 @@ publish_all() {
echo "Package ID also in [~/suibase/workdirs/$WORKDIR_NAME/published-data/$MOVE_TOML_PACKAGE_NAME/most-recent/package-id.json]"
echo "Created objects in [~/suibase/workdirs/$WORKDIR_NAME/published-data/$MOVE_TOML_PACKAGE_NAME/most-recent/created-objects.json]"
echo "Complete output in [~/suibase/workdirs/$WORKDIR_NAME/published-data/$_SUB_INSTALL_DIR/publish-output.json]"
echo "==================== Explorer Links ======================"
echo "Package [https://suiexplorer.com/object/$_ID_PACKAGE_FOR_LINK?network=$_WORKDIR_NAME_FOR_LINK]"
if [ -n "$SUI_PUBLISH_TXDIGEST" ]; then
echo "TxBlock [https://suiexplorer.com/txblock/$SUI_PUBLISH_TXDIGEST?network=$_WORKDIR_NAME_FOR_LINK]"

if [ "${CFG_sui_explorer_enabled:?}" = "true" ] && [ "${CFG_sui_explorer_host_ip:?}" != "~" ]; then
echo "==================== Explorer Links ======================"
# Build the URL using the yaml config. Example of config:
#
# sui_explorer_enabled: true
# sui_explorer_scheme: "http://"
# sui_explorer_host_ip: "localhost"
# sui_explorer_port_number: 44380
# sui_explorer_object_path: "/object/{ID}"
# sui_explorer_txn_path: "/txblock/{ID}"
#
local _URL_BASE
if [ -n "${CFG_sui_explorer_scheme}" ] && [ "${CFG_sui_explorer_scheme}" != "~" ]; then
_URL_BASE="${CFG_sui_explorer_scheme}${CFG_sui_explorer_host_ip:?}"
else
_URL_BASE="http://${CFG_sui_explorer_host_ip:?}"
fi

if [ -n "${CFG_sui_explorer_port_number}" ] && [ "${CFG_sui_explorer_port_number}" != "~" ]; then
_URL_BASE="${_URL_BASE}:${CFG_sui_explorer_port_number:?}"
fi

if [ -n "${CFG_sui_explorer_package_path:?}" ] && [ -n "$_ID_PACKAGE_FOR_LINK" ]; then
local _URL_PATH="${CFG_sui_explorer_package_path//\{ID\}/$_ID_PACKAGE_FOR_LINK}"
echo "Package [${_URL_BASE}${_URL_PATH}]"
fi

if [ -n "${CFG_sui_explorer_txn_path}" ] && [ -n "$SUI_PUBLISH_TXDIGEST" ]; then
local _URL_PATH="${CFG_sui_explorer_txn_path//\{ID\}/$SUI_PUBLISH_TXDIGEST}"
echo "TxBlock [${_URL_BASE}${_URL_PATH}]"
fi
fi

# Push new information to suibase-daemon.
Expand Down
1 change: 0 additions & 1 deletion scripts/common/__sui-faucet-process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ start_sui_faucet_process() {
if [ "$_HOST_IP" = "localhost" ]; then
_HOST_IP="127.0.0.1"
fi
echo "Starting sui-faucet process at http://$_HOST_IP:${CFG_sui_faucet_port:?}"
env SUI_CONFIG_DIR="$WORKDIRS/$WORKDIR/faucet" "$SUI_BIN_DIR/sui-faucet" \
--amount "${CFG_sui_faucet_coin_value:?}" \
--host-ip "$_HOST_IP" \
Expand Down
10 changes: 7 additions & 3 deletions scripts/defaults/cargobin/suibase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ dtp_api_port_number: 44398

suibase_api_port_number: 44399

sui_explorer_enabled: true
sui_explorer_host_ip: "suiscan.xyz"
sui_explorer_port_number: 443
sui_explorer_enabled: false
sui_explorer_scheme: ~
sui_explorer_host_ip: ~
sui_explorer_port_number: ~
sui_explorer_object_path: ~
sui_explorer_package_path: ~
sui_explorer_txn_path: ~

links:
- alias: "devnet"
Expand Down
6 changes: 5 additions & 1 deletion scripts/defaults/devnet/suibase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ dtp_api_port_number: 44398
suibase_api_port_number: 44399

sui_explorer_enabled: true
sui_explorer_scheme: "https://"
sui_explorer_host_ip: "suiscan.xyz"
sui_explorer_port_number: 443
sui_explorer_port_number: ~
sui_explorer_object_path: "/devnet/object/{ID}"
sui_explorer_package_path: "/devnet/object/{ID}/contracts"
sui_explorer_txn_path: "/devnet/tx/{ID}"

links:
- alias: "sui.io"
Expand Down
4 changes: 4 additions & 0 deletions scripts/defaults/localnet/suibase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ dtp_api_port_number: 44398
suibase_api_port_number: 44399

sui_explorer_enabled: true
sui_explorer_scheme: "http://"
sui_explorer_host_ip: "localhost"
sui_explorer_port_number: 44380
sui_explorer_object_path: "/object/{ID}"
sui_explorer_package_path: "/object/{ID}"
sui_explorer_txn_path: "/txblock/{ID}"

links:
- alias: "localnet"
Expand Down
6 changes: 5 additions & 1 deletion scripts/defaults/mainnet/suibase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ dtp_api_port_number: 44398
suibase_api_port_number: 44399

sui_explorer_enabled: true
sui_explorer_scheme: "https://"
sui_explorer_host_ip: "suiscan.xyz"
sui_explorer_port_number: 443
sui_explorer_port_number: ~
sui_explorer_object_path: "/mainnet/object/{ID}"
sui_explorer_package_path: "/mainnet/object/{ID}/contracts"
sui_explorer_txn_path: "/mainnet/tx/{ID}"

links:
- alias: "sui.io"
Expand Down
6 changes: 5 additions & 1 deletion scripts/defaults/testnet/suibase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ dtp_api_port_number: 44398
suibase_api_port_number: 44399

sui_explorer_enabled: true
sui_explorer_scheme: "https://"
sui_explorer_host_ip: "suiscan.xyz"
sui_explorer_port_number: 443
sui_explorer_port_number: ~
sui_explorer_object_path: "/testnet/object/{ID}"
sui_explorer_package_path: "/testnet/object/{ID}/contracts"
sui_explorer_txn_path: "/testnet/tx/{ID}"

links:
- alias: "sui.io"
Expand Down

0 comments on commit bf6d434

Please sign in to comment.