From fcc64a5b961e949cb2a0fadaefd61b0fa79062c1 Mon Sep 17 00:00:00 2001 From: mario4tier Date: Sun, 18 Aug 2024 20:43:00 -0400 Subject: [PATCH] Fix 'sui client faucet' commands --- CHANGELOG.md | 1 + scripts/common/__sui-exec.sh | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ec50927..131be028 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Suibase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - New VSCode extension https://marketplace.visualstudio.com/items?itemName=suibase.suibase ### Fixed +- "lsui/dsui/tsui client faucet" commands now work. - More robust handling of backend (suibase-daemon) - Reduce localnet storage need (delete full_node_db on regen). diff --git a/scripts/common/__sui-exec.sh b/scripts/common/__sui-exec.sh index a4dd0d0a..e5acdc08 100755 --- a/scripts/common/__sui-exec.sh +++ b/scripts/common/__sui-exec.sh @@ -147,6 +147,8 @@ sui_exec() { # does not specify path (and default to current dir). local _OPT_DEFAULT_PATH="" local _OPT_DEFAULT_INSTALLDIR="" + local _OPT_URL_PARAM="" + if [[ $SUI_SUBCOMMAND == "client" ]]; then case $1 in publish | verify-source | verify-bytecode-meter | upgrade) @@ -158,6 +160,20 @@ sui_exec() { _OPT_DEFAULT_INSTALLDIR="--install-dir $USER_CWD" fi ;; + faucet) + if ! has_param "" "--url" "$@"; then + if [ "$WORKDIR" = "localnet" ]; then + if [ "${CFG_sui_faucet_enabled:?}" != "true" ]; then + error_exit "suibase faucet not enabled for localnet. Check suibase.yaml config." + fi + _OPT_URL_PARAM="--url http://${CFG_sui_faucet_host_ip:?}:${CFG_sui_faucet_port:?}/gas" + elif [ "$WORKDIR" = "devnet" ] || [ "$WORKDIR" = "testnet" ]; then + _OPT_URL_PARAM="--url https://faucet.${WORKDIR}.sui.io/gas" + else + error_exit "faucet command not applicable to $WORKDIR" + fi + fi + ;; *) ;; # Do nothing esac fi @@ -166,7 +182,7 @@ sui_exec() { update_CANONICAL_ARGS_var "$@" # shellcheck disable=SC2086,SC2068 - $SUI_BIN "$SUI_SUBCOMMAND" --client.config "$CLIENT_CONFIG" ${CANONICAL_ARGS[@]} $_OPT_DEFAULT_INSTALLDIR $_OPT_DEFAULT_PATH + $SUI_BIN "$SUI_SUBCOMMAND" --client.config "$CLIENT_CONFIG" ${CANONICAL_ARGS[@]} $_OPT_DEFAULT_INSTALLDIR $_OPT_URL_PARAM $_OPT_DEFAULT_PATH if [ "$WORKDIR" = "localnet" ]; then # Print a friendly warning if localnet sui process found not running.