Skip to content

Commit

Permalink
handling around predefined roles
Browse files Browse the repository at this point in the history
  • Loading branch information
Scitz0 committed Nov 4, 2024
1 parent 992b9a1 commit 8d7731f
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 73 deletions.
5 changes: 5 additions & 0 deletions scripts/cnode-helper-scripts/cntools.library
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,11 @@ getRewardInfoKoios() {
rewards_available["${stake_address}"]="${rewards_available}"
[[ -n ${delegated_pool} ]] && pool_delegations["${stake_address}"]="${delegated_pool}"
if [[ -n ${delegated_drep} ]]; then
if [[ ${delegated_drep} = always_abstain ]]; then
vote_delegations["${stake_address}"]="alwaysAbstain"; return
elif [[ ${delegated_drep} = always_no_confidence ]]; then
vote_delegations["${stake_address}"]="alwaysNoConfidence"; return
fi
# convert to cli format <type>-<hash>
vote_delegation_raw=$(bech32 <<< "${delegated_drep}")
if [[ ${vote_delegation_raw:0:2} = '22' ]]; then
Expand Down
162 changes: 89 additions & 73 deletions scripts/cnode-helper-scripts/cntools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1122,50 +1122,60 @@ function main {
if getWalletVoteDelegation ${wallet_name}; then
unset vote_delegation_hash
vote_delegation_type="${vote_delegation%-*}"
if [[ ${vote_delegation} = *-* ]]; then
vote_delegation_hash="${vote_delegation#*-}"
while IFS= read -r -d '' _wallet; do
getGovKeyInfo "$(basename ${_wallet})"
if [[ "${drep_hash}" = "${vote_delegation_hash}" ]]; then
walletName="$(basename ${_wallet})" && break
fi
done < <(find "${WALLET_FOLDER}" -mindepth 1 -maxdepth 1 -type d -print0 | sort -z)
fi
getDRepIds ${vote_delegation_type} ${vote_delegation_hash}
println "Delegation : CIP-105 => ${FG_LGRAY}${vote_delegation_type} ${drep_id}${NC}"
println " : CIP-129 => ${FG_LGRAY}${vote_delegation_type} ${drep_id_cip129}${NC}"
if [[ -n ${walletName} ]]; then
println " : Wallet => ${FG_GREEN}${walletName}${NC}"
fi
if [[ ${vote_delegation} = always* ]]; then
: # do nothing
elif getDRepStatus ${vote_delegation_type} ${vote_delegation_hash}; then
[[ $(getEpoch) -lt ${drep_expiry} ]] && expire_status="${FG_GREEN}active${NC}" || expire_status="${FG_RED}inactive${NC} (vote power does not count)"
println "DRep expiry : epoch ${FG_LBLUE}${drep_expiry}${NC} - ${expire_status}"
if [[ -n ${drep_anchor_url} ]]; then
println "DRep anchor url : ${FG_LGRAY}${drep_anchor_url}${NC}"
getDRepAnchor "${drep_anchor_url}" "${drep_anchor_hash}"
case $? in
0) println "DRep anchor data :\n${FG_LGRAY}"
jq -er "${drep_anchor_file}" 2>/dev/null || cat "${drep_anchor_file}"
println DEBUG "${NC}"
;;
1) println "DRep anchor data : ${FG_YELLOW}Invalid URL or currently not available${NC}" ;;
2) println "DRep anchor data :\n${FG_LGRAY}"
jq -er "${drep_anchor_file}" 2>/dev/null || cat "${drep_anchor_file}"
println "${NC}DRep anchor hash : ${FG_YELLOW}mismatch${NC}"
println " registered : ${FG_LGRAY}${drep_anchor_hash}${NC}"
println " actual : ${FG_LGRAY}${drep_anchor_real_hash}${NC}"
;;
esac
if [[ ${vote_delegation} = alwaysAbstain ]]; then
println "Delegation : ${FG_LGRAY}Always abstain${NC}"
else
println "Delegation : ${FG_LGRAY}Always no confidence${NC}"
fi
else
println "Status : ${FG_RED}Unable to get DRep status, retired?${NC}"
if [[ ${vote_delegation} = *-* ]]; then
vote_delegation_hash="${vote_delegation#*-}"
while IFS= read -r -d '' _wallet; do
getGovKeyInfo "$(basename ${_wallet})"
if [[ "${drep_hash}" = "${vote_delegation_hash}" ]]; then
walletName="$(basename ${_wallet})" && break
fi
done < <(find "${WALLET_FOLDER}" -mindepth 1 -maxdepth 1 -type d -print0 | sort -z)
fi
getDRepIds ${vote_delegation_type} ${vote_delegation_hash}
println "Delegation : CIP-105 => ${FG_LGRAY}${vote_delegation_type} ${drep_id}${NC}"
println " : CIP-129 => ${FG_LGRAY}${vote_delegation_type} ${drep_id_cip129}${NC}"
if [[ -n ${walletName} ]]; then
println " : Wallet => ${FG_GREEN}${walletName}${NC}"
fi
if getDRepStatus ${vote_delegation_type} ${vote_delegation_hash}; then
[[ $(getEpoch) -lt ${drep_expiry} ]] && expire_status="${FG_GREEN}active${NC}" || expire_status="${FG_RED}inactive${NC} (vote power does not count)"
println "DRep expiry : epoch ${FG_LBLUE}${drep_expiry}${NC} - ${expire_status}"
if [[ -n ${drep_anchor_url} ]]; then
println "DRep anchor url : ${FG_LGRAY}${drep_anchor_url}${NC}"
getDRepAnchor "${drep_anchor_url}" "${drep_anchor_hash}"
case $? in
0) println "DRep anchor data :\n${FG_LGRAY}"
jq -er "${drep_anchor_file}" 2>/dev/null || cat "${drep_anchor_file}"
println DEBUG "${NC}"
;;
1) println "DRep anchor data : ${FG_YELLOW}Invalid URL or currently not available${NC}" ;;
2) println "DRep anchor data :\n${FG_LGRAY}"
jq -er "${drep_anchor_file}" 2>/dev/null || cat "${drep_anchor_file}"
println "${NC}DRep anchor hash : ${FG_YELLOW}mismatch${NC}"
println " registered : ${FG_LGRAY}${drep_anchor_hash}${NC}"
println " actual : ${FG_LGRAY}${drep_anchor_real_hash}${NC}"
;;
esac
fi
else
println "Status : ${FG_RED}Unable to get DRep status, retired?${NC}"
fi
fi
getDRepVotePower ${vote_delegation_type} ${vote_delegation_hash}
println "Active Vote power : ${FG_LBLUE}$(formatLovelace ${vote_power:=0})${NC} ADA (${FG_LBLUE}${vote_power_pct:=0} %${NC})"
else
println "Delegation : ${FG_YELLOW}undelegated${NC} - please note that reward withdrawals will not work in the future until wallet is vote delegated"
if versionCheck "10.0" "${PROT_VERSION}"; then
println "Delegation : ${FG_YELLOW}undelegated${NC} - please note that reward withdrawals will not work until wallet is vote delegated"
else
println "Delegation : ${FG_YELLOW}undelegated${NC}"
fi
fi
fi
waitToProceed && continue
Expand Down Expand Up @@ -3871,45 +3881,51 @@ function main {
if getWalletVoteDelegation ${wallet_name}; then
unset vote_delegation_hash
vote_delegation_type="${vote_delegation%-*}"
if [[ ${vote_delegation} = *-* ]]; then
vote_delegation_hash="${vote_delegation#*-}"
while IFS= read -r -d '' _wallet; do
getGovKeyInfo "$(basename ${_wallet})"
if [[ ${drep_hash} = "${vote_delegation_hash}" ]]; then
walletName="$(basename ${_wallet})" && break
fi
done < <(find "${WALLET_FOLDER}" -mindepth 1 -maxdepth 1 -type d -print0 | sort -z)
fi
getDRepIds ${vote_delegation_type} ${vote_delegation_hash}
println "Delegation : CIP-105 => ${FG_LGRAY}${vote_delegation_type} ${drep_id}${NC}"
println " : CIP-129 => ${FG_LGRAY}${vote_delegation_type} ${drep_id_cip129}${NC}"
if [[ -n ${walletName} ]]; then
println " : Wallet => ${FG_GREEN}${walletName}${NC}"
fi
if [[ ${vote_delegation} = always* ]]; then
: # do nothing
elif getDRepStatus ${vote_delegation_type} ${vote_delegation_hash}; then
[[ ${current_epoch} -lt ${drep_expiry} ]] && expire_status="${FG_GREEN}active${NC}" || expire_status="${FG_RED}inactive${NC} (vote power does not count)"
println "DRep expiry : epoch ${FG_LBLUE}${drep_expiry}${NC} - ${expire_status}"
if [[ -n ${drep_anchor_url} ]]; then
println "DRep anchor url : ${FG_LGRAY}${drep_anchor_url}${NC}"
getDRepAnchor "${drep_anchor_url}" "${drep_anchor_hash}"
case $? in
0) println "DRep anchor data :\n${FG_LGRAY}"
jq -er "${drep_anchor_file}" 2>/dev/null || cat "${drep_anchor_file}"
println DEBUG "${NC}"
;;
1) println "DRep anchor data : ${FG_YELLOW}Invalid URL or currently not available${NC}" ;;
2) println "DRep anchor data :\n${FG_LGRAY}"
jq -er "${drep_anchor_file}" 2>/dev/null || cat "${drep_anchor_file}"
println "${NC}DRep anchor hash : ${FG_YELLOW}mismatch${NC}"
println " registered : ${FG_LGRAY}${drep_anchor_hash}${NC}"
println " actual : ${FG_LGRAY}${drep_anchor_real_hash}${NC}"
;;
esac
if [[ ${vote_delegation} = alwaysAbstain ]]; then
println "Delegation : ${FG_LGRAY}Always abstain${NC}"
else
println "Delegation : ${FG_LGRAY}Always no confidence${NC}"
fi
else
println "Status : ${FG_RED}Unable to get DRep status, retired?${NC}"
if [[ ${vote_delegation} = *-* ]]; then
vote_delegation_hash="${vote_delegation#*-}"
while IFS= read -r -d '' _wallet; do
getGovKeyInfo "$(basename ${_wallet})"
if [[ ${drep_hash} = "${vote_delegation_hash}" ]]; then
walletName="$(basename ${_wallet})" && break
fi
done < <(find "${WALLET_FOLDER}" -mindepth 1 -maxdepth 1 -type d -print0 | sort -z)
fi
getDRepIds ${vote_delegation_type} ${vote_delegation_hash}
println "Delegation : CIP-105 => ${FG_LGRAY}${vote_delegation_type} ${drep_id}${NC}"
println " : CIP-129 => ${FG_LGRAY}${vote_delegation_type} ${drep_id_cip129}${NC}"
if [[ -n ${walletName} ]]; then
println " : Wallet => ${FG_GREEN}${walletName}${NC}"
fi
if getDRepStatus ${vote_delegation_type} ${vote_delegation_hash}; then
[[ ${current_epoch} -lt ${drep_expiry} ]] && expire_status="${FG_GREEN}active${NC}" || expire_status="${FG_RED}inactive${NC} (vote power does not count)"
println "DRep expiry : epoch ${FG_LBLUE}${drep_expiry}${NC} - ${expire_status}"
if [[ -n ${drep_anchor_url} ]]; then
println "DRep anchor url : ${FG_LGRAY}${drep_anchor_url}${NC}"
getDRepAnchor "${drep_anchor_url}" "${drep_anchor_hash}"
case $? in
0) println "DRep anchor data :\n${FG_LGRAY}"
jq -er "${drep_anchor_file}" 2>/dev/null || cat "${drep_anchor_file}"
println DEBUG "${NC}"
;;
1) println "DRep anchor data : ${FG_YELLOW}Invalid URL or currently not available${NC}" ;;
2) println "DRep anchor data :\n${FG_LGRAY}"
jq -er "${drep_anchor_file}" 2>/dev/null || cat "${drep_anchor_file}"
println "${NC}DRep anchor hash : ${FG_YELLOW}mismatch${NC}"
println " registered : ${FG_LGRAY}${drep_anchor_hash}${NC}"
println " actual : ${FG_LGRAY}${drep_anchor_real_hash}${NC}"
;;
esac
fi
else
println "Status : ${FG_RED}Unable to get DRep status, retired?${NC}"
fi
fi
getDRepVotePower ${vote_delegation_type} ${vote_delegation_hash}
println "Active Vote power : ${FG_LBLUE}$(formatLovelace ${vote_power:=0})${NC} ADA (${FG_LBLUE}${vote_power_pct:=0} %${NC})"
Expand Down

0 comments on commit 8d7731f

Please sign in to comment.