Skip to content

Commit

Permalink
governance for mainnet
Browse files Browse the repository at this point in the history
Adding all governance related scripts to the mainnet folder:

- 21a_genDRepKeys.sh
- 21b_regDRepCert.sh
- 21c_checkDRepOnChain.sh
- 21d_retDRepCert.sh
- 22a_genVoteDelegCert.sh
- 22b_regVoteDelegCert.sh
- 23a_genComColdKeys.sh
- 23b_genComHotKeys.sh
- 23c_regComAuthCert.sh
- 23d_checkComOnChain.sh
- 23e_retComColdKeys.sh
- 24a_genVote.sh
- 24b_regVote.sh
- 24c_queryVote.sh
- 25a_genAction.sh
- 25b_regAction.sh
- cardano-signer v1.18.0

detailed release change will follow
  • Loading branch information
gitmachtl committed Sep 1, 2024
1 parent 9511773 commit af96907
Show file tree
Hide file tree
Showing 22 changed files with 9,892 additions and 66 deletions.
505 changes: 471 additions & 34 deletions cardano/mainnet/00_common.sh

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions cardano/mainnet/01_queryAddress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,6 @@ elif [[ ${typeOfAddr} == ${addrTypeStake} ]]; then #Staking Address

esac

# jq -r . <<< ${rewardsJSON}

rewardsEntryCnt=$(jq -r 'length' <<< ${rewardsJSON})

if [[ ${rewardsEntryCnt} == 0 ]]; then echo -e "\e[35mStaking Address is not on the chain, register it first !\e[0m\n"; exit 1;
Expand Down Expand Up @@ -336,6 +334,9 @@ elif [[ ${typeOfAddr} == ${addrTypeStake} ]]; then #Staking Address
"scriptHash") drepDelegationID=$(${bech32_bin} "drep_script" <<< "${drepDelegationHASH##*-}" 2> /dev/null)
echo -e " \t\e[0mVoting-Power of Staking Address is delegated to DRep-Script-ID(HASH): \e[32m${drepDelegationID}\e[0m (\e[94m${drepDelegationHASH##*-}\e[0m)\n";
;;
"null") #not delegated
echo -e " \t\e[0mVoting-Power of Staking Address is not delegated to a DRep !\e[0m\n";
;;
*) #unknown type
echo -e " \t\e[0mVoting-Power of Staking Address is delegated to DRep-HASH: \e[32m${drepDelegationHASH}\e[0m\n";
;;
Expand Down
49 changes: 24 additions & 25 deletions cardano/mainnet/01_workOffline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ case ${action} in
"online") #onlinemode
#get the normal parameters
protocolParametersJSON=$(${cardanocli} ${cliEra} query protocol-parameters )
#get the previous actions ids for the various action types and the constitution state
prevActionIDsJSON=$(${cardanocli} ${cliEra} query gov-state 2> /dev/null | jq -r ".nextRatifyState.nextEnactState.prevGovActionIds" 2> /dev/null)
if [[ ${prevActionIDsJSON} == "" ]]; then prevActionIDsJSON='{}'; fi
constitutionParametersJSON=$(${cardanocli} ${cliEra} query constitution 2> /dev/null | jq -r "." 2> /dev/null)
if [[ ${constitutionParametersJSON} == "" ]]; then constitutionParametersJSON='{}'; fi

#Governance Stuff
governanceParametersJSON=$(${cardanocli} ${cliEra} query gov-state 2> /dev/null | jq -r '{ committee : (.committee), constitution : (.constitution), prevActionIDs : (.nextRatifyState.nextEnactState.prevGovActionIds) }' 2> /dev/null)
if [[ "${governanceParametersJSON}" == "" ]]; then governanceParametersJSON="{}"; fi

#merge them together
protocolParametersJSON=$( jq --sort-keys ".constitution += ${constitutionParametersJSON} | .prevActionIDs += ${prevActionIDsJSON}" <<< ${protocolParametersJSON})
protocolParametersJSON=$( jq --sort-keys ". += ${governanceParametersJSON}" <<< ${protocolParametersJSON})
;;

"light") #lightmode
Expand Down Expand Up @@ -188,13 +188,13 @@ case ${action} in
"online") #onlinemode
#get the normal parameters
protocolParametersJSON=$(${cardanocli} ${cliEra} query protocol-parameters )
#get the previous actions ids for the various action types and the constitution state
prevActionIDsJSON=$(${cardanocli} ${cliEra} query gov-state 2> /dev/null | jq -r ".nextRatifyState.nextEnactState.prevGovActionIds" 2> /dev/null)
if [[ ${prevActionIDsJSON} == "" ]]; then prevActionIDsJSON='{}'; fi
constitutionParametersJSON=$(${cardanocli} ${cliEra} query constitution 2> /dev/null | jq -r "." 2> /dev/null)
if [[ ${constitutionParametersJSON} == "" ]]; then constitutionParametersJSON='{}'; fi

#Governance Stuff
governanceParametersJSON=$(${cardanocli} ${cliEra} query gov-state 2> /dev/null | jq -r '{ committee : (.committee), constitution : (.constitution), prevActionIDs : (.nextRatifyState.nextEnactState.prevGovActionIds) }' 2> /dev/null)
if [[ "${governanceParametersJSON}" == "" ]]; then governanceParametersJSON="{}"; fi

#merge them together
protocolParametersJSON=$( jq --sort-keys ".constitution += ${constitutionParametersJSON} | .prevActionIDs += ${prevActionIDsJSON}" <<< ${protocolParametersJSON})
protocolParametersJSON=$( jq --sort-keys ". += ${governanceParametersJSON}" <<< ${protocolParametersJSON})
;;

"light") #lightmode
Expand Down Expand Up @@ -545,30 +545,29 @@ if [[ "${action}" == "add-drep" ]]; then

drepID=$(cat ${drepName}.id) #we already checked that the file is present, so load the id from it

#do a short check if its a valid bech string
tmp=$(${bech32_bin} <<< ${drepID} 2> /dev/null)
#calculate the drep hash, and also do a bech validity check
drepHASH=$(${bech32_bin} 2> /dev/null <<< "${drepID}")
if [ $? -ne 0 ]; then echo -e "\e[35mERROR - The content of '${drepName}.id' is not a valid DRep-Bech-ID.\e[0m\n"; exit 1; fi;

echo -e "\e[0mChecking current Status about the DRep-ID:\e[32m ${drepID}\e[0m\n"

#Get state data for the drepID. When in online mode of course from the node and the chain, in light mode via koios
case ${workMode} in

"online") showProcessAnimation "Query DRep-ID Info: " &
drepStateJSON=$(${cardanocli} ${cliEra} query drep-state --drep-key-hash ${drepID} --include-stake 2> /dev/stdout )
if [ $? -ne 0 ]; then stopProcessAnimation; echo -e "\e[35mERROR - ${drepStateJSON}\e[0m\n"; exit $?; else stopProcessAnimation; fi;
drepStateJSON=$(jq -r ".[0] // []" <<< "${drepStateJSON}") #get rid of the outer array. if null, make an empty array
;;

# "light") showProcessAnimation "Query DRep-ID-Info-LightMode: " &
# drepStateJSON=$(queryLight_drepInfo "${drepID}")
# if [ $? -ne 0 ]; then stopProcessAnimation; echo -e "\e[35mERROR - ${drepStateJSON}\e[0m\n"; exit $?; else stopProcessAnimation; fi;
# ;;
"online") showProcessAnimation "Query DRep-ID Info: " &
drepStateJSON=$(${cardanocli} ${cliEra} query drep-state --drep-key-hash ${drepHASH} --drep-script-hash ${drepHASH} --include-stake 2> /dev/stdout )
if [ $? -ne 0 ]; then stopProcessAnimation; echo -e "\e[35mERROR - ${drepStateJSON}\e[0m\n"; exit $?; else stopProcessAnimation; fi;
drepStateJSON=$(jq -r ".[0] // []" <<< "${drepStateJSON}") #get rid of the outer array
;;

"light") showProcessAnimation "Query DRep-ID-Info-LightMode: " &
drepStateJSON=$(queryLight_drepInfo "${drepID}")
if [ $? -ne 0 ]; then stopProcessAnimation; echo -e "\e[35mERROR - ${drepStateJSON}\e[0m\n"; exit $?; else stopProcessAnimation; fi;
drepStateJSON=$(jq -r ".[0] // []" <<< "${drepStateJSON}") #get rid of the outer array
;;
esac

# { read drepEntryCnt; read drepDepositAmount; read drepAnchorURL; read drepAnchorHASH; } <<< $(jq -r 'length, .[1].deposit, .[1].anchor.url // "empty", .[1].anchor.dataHash // "no hash"' <<< ${drepStateJSON})

{ read drepEntryCnt;
read drepDepositAmount;
read drepAnchorURL;
Expand Down
3 changes: 3 additions & 0 deletions cardano/mainnet/03c_checkStakingAddrOnChain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ if [[ ${typeOfAddr} == ${addrTypeStake} ]]; then #Staking Address
"scriptHash") drepDelegationID=$(${bech32_bin} "drep_script" <<< "${drepDelegationHASH##*-}" 2> /dev/null)
echo -e "\e[0mVoting-Power of Staking Address is delegated to DRep-Script-ID(HASH): \e[32m${drepDelegationID}\e[0m (\e[94m${drepDelegationHASH##*-}\e[0m)\n";
;;
"null") #not delegated
echo -e "\e[0mVoting-Power of Staking Address is not delegated to a DRep !\e[0m\n";
;;
*) drepDelegationID="" #unknown type
echo -e "\e[0mVoting-Power of Staking Address is delegated to DRep-HASH: \e[32m${drepDelegationHASH}\e[0m\n";
;;
Expand Down
Loading

0 comments on commit af96907

Please sign in to comment.