Skip to content

Commit

Permalink
Various fixes for reg status and sourcing of scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Scitz0 committed Apr 17, 2024
1 parent 92f7a95 commit 7dde0ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
18 changes: 10 additions & 8 deletions scripts/cnode-helper-scripts/cntools.library
Expand Up @@ -485,9 +485,9 @@ selectWallet() {
if [[ ${mode} = "reg" || ${mode} = "non-reg" ]]; then
if [[ ${CNTOOLS_MODE} = "LOCAL" ]]; then
if [[ ${mode} = "reg" ]]; then
isWalletRegistered ${dir} && continue
else
! isWalletRegistered ${dir} && continue
else
isWalletRegistered ${dir} && continue
fi
else
getRewardAddress ${dir}
Expand Down Expand Up @@ -564,10 +564,12 @@ selectWallet() {
if [[ ${mode} = "reg" || ${mode} = "non-reg" ]]; then
getRewardAddress ${wallet_dir}
if [[ -n ${reward_addr} ]]; then
if [[ ${mode} = "reg" ]]; then
if [[ ! -v reward_status[${reward_addr}] || ${reward_status[${reward_addr}]} != "registered" ]]; then continue; fi
else
[[ -v reward_status[${reward_addr}] && ${reward_status[${reward_addr}]} = "registered" ]] && continue
if [[ ${CNTOOLS_MODE} = "LIGHT" ]]; then
if [[ ${mode} = "reg" ]]; then
if [[ ! -v reward_status[${reward_addr}] || ${reward_status[${reward_addr}]} != "registered" ]]; then continue; fi
else
[[ -v reward_status[${reward_addr}] && ${reward_status[${reward_addr}]} = "registered" ]] && continue
fi
fi
fi
elif [[ ${mode} = "delegate" ]]; then
Expand Down Expand Up @@ -626,9 +628,9 @@ selectWallet() {
elif [[ ${mode} = "reward" ]]; then
println ERROR "\n${FG_YELLOW}WARN${NC}: No wallets available that have rewards to withdraw or signing keys to do so!"
elif [[ ${mode} = "reg" ]]; then
println ERROR "\n${FG_YELLOW}WARN${NC}: No wallets available that are unregistered!"
elif [[ ${mode} = "non-reg" ]]; then
println ERROR "\n${FG_YELLOW}WARN${NC}: No wallets available that are registered on chain!"
elif [[ ${mode} = "non-reg" ]]; then
println ERROR "\n${FG_YELLOW}WARN${NC}: No wallets available that are unregistered!"
else
println ERROR "\n${FG_YELLOW}WARN${NC}: No wallets available for selection! Required files:\n$(printf '%b\n' "$@")"
fi
Expand Down
15 changes: 7 additions & 8 deletions scripts/cnode-helper-scripts/cntools.sh
Expand Up @@ -119,23 +119,22 @@ if [[ ! -f "${PARENT}"/env ]]; then
myExit 1
fi

# Source env file in offline mode
! . "${PARENT}"/env offline && myExit 1
# Source env file in normal mode with node connection, else offline mode
if [[ ${CNTOOLS_MODE} = "LOCAL" ]]; then
. "${PARENT}"/env || myExit 1
else
. "${PARENT}"/env offline || myExit 1
fi

# Source cntools.library to populate defaults for CNTools
! . "${PARENT}"/cntools.library && myExit 1
. "${PARENT}"/cntools.library || myExit 1

# If light mode, test if koios is reachable, otherwise - unset KOIOS_API
if [[ ${CNTOOLS_MODE} = "LIGHT" ]]; then
test_koios
[[ -z ${KOIOS_API} ]] && myExit 1 "ERROR: Koios query test failed, unable to launch CNTools in light mode utilizing Koios query layer\n\n${launch_modes_info}"
fi

# Source env file in normal mode with node connection
if [[ ${CNTOOLS_MODE} = "LOCAL" ]]; then
. "${PARENT}"/env &>/dev/null
fi

[[ ${CNTOOLS_MODE} != "LIGHT" ]] && unset KOIOS_API

[[ ${PRINT_VERSION} = "true" ]] && myExit 0 "CNTools v${CNTOOLS_VERSION} (branch: $([[ -f "${PARENT}"/.env_branch ]] && cat "${PARENT}"/.env_branch || echo "master"))"
Expand Down

0 comments on commit 7dde0ad

Please sign in to comment.