create-genesis.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. if [ -z "${NUM_GUARDIANS}" ]; then
  4. echo "Error: NUM_GUARDIANS is unset, cannot create wormchain genesis."
  5. exit 1
  6. fi
  7. pwd=$(pwd)
  8. genesis="$pwd/devnet/base/config/genesis.json"
  9. # TODO
  10. # create a sequence of the wormchain instances to include
  11. # loop through the sequence, reading the data from the instance's dir
  12. # add the genesis account to:
  13. # app_state.auth.accounts
  14. # app_state.bank.balances
  15. # add the gentx
  16. # add the guardian pubkey base64 to wormhole.guardianSetList[0].keys
  17. # add the validator obj to wormhole.guardianValidatorList
  18. # TEMP manually add the second validator info to genesis.json
  19. if [ $NUM_GUARDIANS -ge 2 ]; then
  20. echo "number of guardians is >= 2, adding second validator to genesis.json."
  21. # the validator info for wormchain-1
  22. guardianKey="iNfYsyqRBdIoEA5y3/4vrgcF0xw="
  23. validatorAddr="cBxHWxmj9o0/3r8JWRSH+s7y1jY="
  24. # add the validatorAddr to guardianSetList.keys.
  25. # use jq to add the object to the list in genesis.json. use cat and a sub-shell to send the output of jq to the json file.
  26. cat <<< $(jq --arg new "$guardianKey" '.app_state.wormhole.guardianSetList[0].keys += [$new]' ${genesis}) > ${genesis}
  27. # create a guardianValidator config object and add it to the guardianValidatorList.
  28. validatorConfig="{\"guardianKey\": \"$guardianKey\", \"validatorAddr\": \"$validatorAddr\"}"
  29. cat <<< $(jq --argjson new "$validatorConfig" '.app_state.wormhole.guardianValidatorList += [$new]' ${genesis}) > ${genesis}
  30. fi
  31. echo "done with genesis, exiting."