Skip to content

Commit ab4747f

Browse files
committed
Update all Testnet Scripts
- Updated all testnet scripts to be on the same codebase as the mainnet scripts - Updating cardano-signer to v1.24.0
1 parent 8f6ca66 commit ab4747f

19 files changed

Lines changed: 1489 additions & 354 deletions

cardano/testnet/00_common.sh

Lines changed: 86 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,16 @@ case "${network,,}" in
192192
_lightModeParametersURL="https://uptime.live/data/cardano/parms/mainnet-parameters.json" #Parameters-JSON-File with current informations about cardano-cli version, tip, era, protocol-parameters
193193
_guardrailScriptUTXO="dc06746a898fd230f164f47a3d749348b65655b8fb388ff275f54d62891653e2#0"
194194
_guardrailScriptSize=2132
195-
;;
195+
_ccMemberColdHashNames='{
196+
"scriptHash-349e55f83e9af24813e6cb368df6a80d38951b2a334dfcdf26815558": "CAC",
197+
"scriptHash-84aebcfd3e00d0f87af918fc4b5e00135f407e379893df7e7d392c6a": "ECC",
198+
"scriptHash-b6012034ba0a7e4afbbf2c7a1432f8824aee5299a48e38e41a952686": "CF",
199+
"scriptHash-ce8b37a72b178a37bbd3236daa7b2c158c9d3604e7aa667e6c6004b7": "Emurgo",
200+
"scriptHash-df0e83bde65416dade5b1f97e7f115cc1ff999550ad968850783fe50": "IOG",
201+
"scriptHash-e8165b3328027ee0d74b1f07298cb092fd99aa7697a1436f5997f625": "CJC",
202+
"scriptHash-f0dc2c00d92a45521267be2d5de1c485f6f9d14466d7e16062897cf7": "ICC"
203+
}'
204+
;;
196205

197206

198207
"preprod"|"pre-prod" )
@@ -207,6 +216,15 @@ case "${network,,}" in
207216
_adahandleAPI="https://preprod.api.handle.me" #Adahandle-API URLs -> autoresolve into ${adahandleAPI}
208217
_catalystAPI="https://api.testnet.projectcatalyst.io/api/v1" #Catalyst-API URLs -> autoresolve into ${catalystAPI}
209218
_lightModeParametersURL="https://uptime.live/data/cardano/parms/preprod-parameters.json" #Parameters-JSON-File with current informations about cardano-cli version, tip, era, protocol-parameters
219+
_ccMemberColdHashNames='{
220+
"scriptHash-5098dfd0deba725fadd692198fc33ee959fbe7e6edf1b5a695e06e61": "CAC",
221+
"scriptHash-5a71f17f4ce4c1c0be053575d717ade6ad8a1d5453d02a65ce40d4b1": "ECC",
222+
"scriptHash-6095e643ea6f1cccb6e463ec34349026b3a48621aac5d512655ab1bf": "CF",
223+
"scriptHash-94c0de47e7ae32e3f7234ada5cf976506b68e3bb88c54dc53b4ba984": "ICC"
224+
"scriptHash-94f51c795a6c11adb9c1e30f0b6def4230cbd0b8bc800098e2d2307b": "Emurgo",
225+
"scriptHash-a6a5e006fd4e8f51062dc431362369b2a43140abced8aa2ff2256d7b": "IOG",
226+
"scriptHash-2f4a6c6f098e20ee4bfd5b39942c164575f8ceb348e754df5d0ec04f": "CJC"
227+
}'
210228
;;
211229

212230

@@ -224,6 +242,7 @@ case "${network,,}" in
224242
_lightModeParametersURL="https://uptime.live/data/cardano/parms/preview-parameters.json" #Parameters-JSON-File with current informations about cardano-cli version, tip, era, protocol-parameters
225243
_guardrailScriptUTXO="f3f61635034140e6cec495a1c69ce85b22690e65ab9553ef408d524f58183649#0"
226244
_guardrailScriptSize=2132
245+
_ccMemberColdHashNames='{}'
227246
;;
228247

229248

@@ -239,6 +258,7 @@ case "${network,,}" in
239258
_adahandleAPI=
240259
_catalystAPI= #Catalyst-API URLs -> autoresolve into ${catalystAPI}
241260
_lightModeParametersURL= #Parameters-JSON-File with current informations about cardano-cli version, tip, era, protocol-parameters
261+
_ccMemberColdHashNames='{}'
242262
;;
243263

244264

@@ -256,6 +276,7 @@ case "${network,,}" in
256276
_lightModeParametersURL="https://uptime.live/data/cardano/parms/sanchonet-parameters.json" #Parameters-JSON-File with current informations about cardano-cli version, tip, era, protocol-parameters
257277
# _guardrailScriptUTXO="8b9163fa38914b45470a5426c27939cfb77628f0c54d08b0b61b9905c2cbfc2b#0"
258278
_guardrailScriptSize=2132
279+
_ccMemberColdHashNames='{}'
259280
;;
260281

261282

@@ -271,6 +292,7 @@ case "${network,,}" in
271292
_adahandleAPI=
272293
_catalystAPI= #Catalyst-API URLs -> autoresolve into ${catalystAPI}
273294
_lightModeParametersURL= #Parameters-JSON-File with current informations about cardano-cli version, tip, era, protocol-parameters
295+
_ccMemberColdHashNames='{}'
274296
;;
275297

276298
esac
@@ -289,6 +311,7 @@ catalystAPI=${catalystAPI:-"${_catalystAPI}"}
289311
lightModeParametersURL=${lightModeParametersURL:-"${_lightModeParametersURL}"}
290312
guardrailScriptUTXO=${guardrailScriptUTXO:-"${_guardrailScriptUTXO}"}
291313
guardrailScriptSize=${guardrailScriptSize:-"${_guardrailScriptSize}"}
314+
ccMemberColdHashNames=${ccMemberColdHashNames:-"${_ccMemberColdHashNames}"}
292315

293316

294317
#Check about the / at the end of the URLs
@@ -302,15 +325,15 @@ if [[ "${adahandleAPI: -1}" == "/" ]]; then adahandleAPI=${adahandleAPI%?}; fi #
302325
if [[ "${magicparam}" == "" || ${addrformat} == "" || ${byronToShelleyEpochs} == "" ]]; then majorError "The 'magicparam', 'addrformat' or 'byronToShelleyEpochs' is not set!\nOr maybe you have set the wrong parameter network=\"${network}\" ?\nList of preconfigured network-names: ${networknames}"; exit 1; fi
303326

304327
#Don't allow to overwrite the needed Versions, so we set it after the overwrite part
305-
minCliVersion="10.2.0" #minimum allowed cli version for this script-collection version
328+
minCliVersion="10.4.0" #minimum allowed cli version for this script-collection version
306329
maxCliVersion="99.99.9" #maximum allowed cli version, 99.99.9 = no limit so far
307330
minNodeVersion="10.1.4" #minimum allowed node version for this script-collection version
308331
maxNodeVersion="99.99.9" #maximum allowed node version, 99.99.9 = no limit so far
309-
minLedgerCardanoAppVersion=${ENV_MINLEDGERCARDANOAPPVERSION:-"7.1.1"} #minimum version for the cardano-app on the Ledger HW-Wallet
332+
minLedgerCardanoAppVersion=${ENV_MINLEDGERCARDANOAPPVERSION:-"7.1.4"} #minimum version for the cardano-app on the Ledger HW-Wallet
310333
minTrezorCardanoAppVersion="2.7.2" #minimum version for the firmware on the Trezor HW-Wallet
311334
minKeystoneCardanoAppVersion="1.7.7" #minimum version for the firmware on the Keystone HW-Wallet
312-
minHardwareCliVersion="1.15.0" #minimum version for the cardano-hw-cli
313-
minCardanoSignerVersion="1.20.1" #minimum version for the cardano-signer binary
335+
minHardwareCliVersion="1.17.0" #minimum version for the cardano-hw-cli
336+
minCardanoSignerVersion="1.24.0" #minimum version for the cardano-signer binary
314337
minCatalystToolboxVersion="0.5.0" #minimum version for the catalyst-toolbox binary
315338

316339
#Defaults - Variables and Constants
@@ -1250,12 +1273,12 @@ local protocolParam=${1}
12501273
IFS='+' read -ra asset_entry <<< "${2}" #split the tx-out string into address, lovelaces, assets (read it into asset_entry array)
12511274

12521275
#protocol version major
1253-
#7=babbage, 5+6=alonzo, 4=mary, 3=allegra, 2=shelley, 0+1=byron
1276+
#9+10=conway, 7+8=babbage, 5+6=alonzo, 4=mary, 3=allegra, 2=shelley, 0+1=byron
12541277
local protocolVersionMajor=$(jq -r ".protocolVersion.major | select (.!=null)" <<< ${protocolParam})
12551278

12561279

12571280
### switch the method of the minOutUTXO calculation depending on the current era, starting with protocolVersionMajor>=7 (babbage)
1258-
if [[ ${protocolVersionMajor} -ge 7 ]]; then #7=Babbage, 9+10=Conway ..., new since babbage: CIP-0055 -> minOutUTXO depends on the cbor bytes length
1281+
if [[ ${protocolVersionMajor} -ge 7 ]]; then #7+8=Babbage, 9+10=Conway ..., new since babbage: CIP-0055 -> minOutUTXO depends on the cbor bytes length
12591282

12601283
#chain constants for babbage
12611284
local constantOverhead=160 #constantOverhead=160 bytes set for babbage-era, 158 for mary/alonzo transactions in babbage era
@@ -1535,38 +1558,65 @@ queryLight_stakeAddressInfo() { #${1} = stakeaddress(bech) to query
15351558
if [ $? -ne 0 ]; then echo -e "Query via Koios-API (${koiosAPI}) failed, not a JSON response."; exit 1; fi; #reponse is not a json file
15361559

15371560
#check if the stakeAddress is registered, if not, return an empty array
1538-
if [[ $(jq -r ".[0].status" <<< "${responseJSON}" 2> /dev/null) != "registered" ]]; then
1539-
printf "[]"; #stakeAddress not registered on chain, return an empty array
1540-
else
1561+
if [[ $(jq -r ".[0].status" <<< "${responseJSON}" 2> /dev/null) != "registered" ]]; then printf "[]"; exit 0; fi #stakeAddress not registered on chain, return an empty array
15411562

1542-
local delegation; local rewardAccountBalance; local delegationDeposit; local voteDelegation; #define local variables so we can read it in one go with the next jq command
1543-
{ read delegation; read rewardAccountBalance; read delegationDeposit; read voteDelegation; } <<< $(jq -r ".[0].delegated_pool // \"null\", .[0].rewards_available // \"null\", .[0].deposit // \"null\", .[0].delegated_drep // \"null\"" <<< "${responseJSON}" 2> /dev/null)
1563+
#get the first values
1564+
local delegation; local rewardAccountBalance; local delegationDeposit; local voteDelegation; #define local variables so we can read it in one go with the next jq command
1565+
{ read delegation; read rewardAccountBalance; read delegationDeposit; read voteDelegation; } <<< $(jq -r ".[0].delegated_pool // \"null\", .[0].rewards_available // \"null\", .[0].deposit // \"null\", .[0].delegated_drep // \"null\"" <<< "${responseJSON}" 2> /dev/null)
15441566

1545-
#deposit value, always 2000000 lovelaces until conway
1546-
if [[ ${delegationDeposit} == null ]]; then delegationDeposit=2000000; fi
1567+
#Do another query to get all the proposals this stakeaddress is set as the deposit return address
1568+
errorcnt=0
1569+
error=-1
1570+
while [[ ${errorcnt} -lt 5 && ${error} -ne 0 ]]; do #try a maximum of 5 times to request the information via koios API
1571+
error=0
1572+
response=$(curl -sL -m 30 -X GET -w "---spo-scripts---%{http_code}" "${koiosAPI}/proposal_list?return_address=eq.${addr}&dropped_epoch=is.null&enacted_epoch=is.null&expired_epoch=is.null&select=proposal_tx_hash,proposal_index,deposit,return_address,dropped_epoch,enacted_epoch,expired_epoch" -H "${koiosAuthorizationHeader}" -H "Accept: application/json" 2> /dev/null)
1573+
if [ $? -ne 0 ]; then error=1; fi;
1574+
errorcnt=$(( ${errorcnt} + 1 ))
1575+
done
1576+
if [[ ${error} -ne 0 ]]; then echo -e "Query of the Koios-API via curl failed, tried 5 times."; exit 1; fi; #curl query failed
15471577

1548-
#convert from CIP129 to regular format if its a normal drep delegation
1549-
if [[ "${voteDelegation}" == "drep1"* ]]; then voteDelegation=$(convert_actionCIP1292Bech ${voteDelegation}); fi
1578+
#Split the response string into JSON content and the HTTP-ResponseCode
1579+
if [[ "${response}" =~ (.*)---spo-scripts---([0-9]*)* ]]; then
1580+
local responseJSON="${BASH_REMATCH[1]}"
1581+
local responseCode="${BASH_REMATCH[2]}"
1582+
else
1583+
echo -e "Query of the Koios-API via curl failed. Could not separate Content and ResponseCode."; exit 1; #curl query failed
1584+
fi
15501585

1551-
#convert bech-voteDelegation into keyHash-/scriptHAsh-voteDelegation
1552-
case "${voteDelegation}" in
1553-
"drep1"*) voteDelegation="keyHash-$(${bech32_bin} <<< ${voteDelegation})"
1554-
;;
1555-
"drep_script1"*) voteDelegation="scriptHash-$(${bech32_bin} <<< ${voteDelegation})"
1556-
;;
1557-
"drep_always_abstain") voteDelegation="alwaysAbstain"
1558-
;;
1559-
"drep_always_no_confidence")
1560-
voteDelegation="alwaysNoConfidence"
1561-
;;
1562-
*) voteDelegation="null"
1563-
;;
1564-
esac
1586+
#Check the responseCode
1587+
case ${responseCode} in
1588+
"200" ) ;; #all good, continue
1589+
* ) echo -e "HTTP Response code: ${responseCode}"; exit 1; #exit with a failure and the http response code
1590+
esac;
15651591

1566-
jsonRet="[ { \"address\": \"${addr}\", \"stakeDelegation\": \"${delegation}\", \"delegationDeposit\": ${delegationDeposit}, \"rewardAccountBalance\": ${rewardAccountBalance}, \"voteDelegation\": \"${voteDelegation}\" } ]" #compose a json like the cli output
1567-
#return the composed json
1568-
printf "${jsonRet}"
1569-
fi
1592+
#generate the govActionsDeposits
1593+
govActionDeposits=$(jq -r '(map ({ "\(.proposal_tx_hash)#\(.proposal_index)": .deposit }) | add) // {}' <<< ${responseJSON} 2> /dev/null)
1594+
if [ $? -ne 0 ]; then echo -e "Query via Koios-API (${koiosAPI}) failed, not a JSON response."; exit 1; fi; #reponse is not a json file
1595+
1596+
#deposit value, always 2000000 lovelaces until conway
1597+
if [[ ${delegationDeposit} == null ]]; then delegationDeposit=2000000; fi
1598+
1599+
#convert from CIP129 to regular format if its a normal drep delegation
1600+
if [[ "${voteDelegation}" == "drep1"* ]]; then voteDelegation=$(convert_actionCIP1292Bech ${voteDelegation}); fi
1601+
1602+
#convert bech-voteDelegation into keyHash-/scriptHAsh-voteDelegation
1603+
case "${voteDelegation}" in
1604+
"drep1"*) voteDelegation="keyHash-$(${bech32_bin} <<< ${voteDelegation})"
1605+
;;
1606+
"drep_script1"*) voteDelegation="scriptHash-$(${bech32_bin} <<< ${voteDelegation})"
1607+
;;
1608+
"drep_always_abstain") voteDelegation="alwaysAbstain"
1609+
;;
1610+
"drep_always_no_confidence")
1611+
voteDelegation="alwaysNoConfidence"
1612+
;;
1613+
*) voteDelegation="null"
1614+
;;
1615+
esac
1616+
1617+
jsonRet="[ { \"address\": \"${addr}\", \"stakeDelegation\": \"${delegation}\", \"stakeRegistrationDeposit\": ${delegationDeposit}, \"rewardAccountBalance\": ${rewardAccountBalance}, \"voteDelegation\": \"${voteDelegation}\", \"govActionDeposits\": ${govActionDeposits} } ]" #compose a json like the cli output
1618+
#return the composed json
1619+
printf "${jsonRet}"
15701620

15711621
unset jsonRet response responseCode responseJSON addr error errorcnt
15721622

@@ -1744,10 +1794,10 @@ queryLight_actionState() { #for filtering, ${1} = govActionUTXO, ${2} = govActio
17441794
error=0
17451795
case "${voterID}" in
17461796
"drep"*|"cc_hot"*|"pool"*) #a voterID was given, so do a filtering directly via koios on the given bech voterID
1747-
response=$(curl -sL -m 30 -X GET -w "---spo-scripts---%{http_code}" "${koiosAPI}/voter_proposal_list?_voter_id=${voterID}&dropped_epoch=is.null" -H "${koiosAuthorizationHeader}" -H "Accept: application/json" -H "Content-Type: application/json" 2> /dev/null)
1797+
response=$(curl -sL -m 30 -X GET -w "---spo-scripts---%{http_code}" "${koiosAPI}/voter_proposal_list?_voter_id=${voterID}&dropped_epoch=is.null&enacted_epoch=is.null&expired_epoch=is.null" -H "${koiosAuthorizationHeader}" -H "Accept: application/json" -H "Content-Type: application/json" 2> /dev/null)
17481798
;;
17491799
*) #no voterID was given, do a query for the complete proposal list
1750-
response=$(curl -sL -m 30 -X GET -w "---spo-scripts---%{http_code}" "${koiosAPI}/proposal_list?dropped_epoch=is.null" -H "${koiosAuthorizationHeader}" -H "Accept: application/json" -H "Content-Type: application/json" 2> /dev/null)
1800+
response=$(curl -sL -m 30 -X GET -w "---spo-scripts---%{http_code}" "${koiosAPI}/proposal_list?dropped_epoch=is.null&enacted_epoch=is.null&expired_epoch=is.null" -H "${koiosAuthorizationHeader}" -H "Accept: application/json" -H "Content-Type: application/json" 2> /dev/null)
17511801
;;
17521802
esac
17531803
if [ $? -ne 0 ]; then error=1; fi;

0 commit comments

Comments
 (0)