Skip to content

Commit

Permalink
Merge pull request #184 from WadeBarnes/master
Browse files Browse the repository at this point in the history
Add generate genesis files command.
  • Loading branch information
WadeBarnes authored Oct 27, 2021
2 parents 0f4d14e + 6c5b62d commit 25a64cc
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ backup/
*_BuildConfig.json
tmp/

# External scripts
genesis_from_files.py

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
62 changes: 62 additions & 0 deletions manage
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,25 @@ usage () {
$0 generateDid [seed]
- Optional [seed]; if one is not provided a random one will be generated using openssl.
generateGenesisFiles - Generates pool and domain genesis files from data input via csv files.
$0 generategenesisfiles <trustees_csv_file> <stewards_csv_file>
This is a convenience command wrapped around the Steward Tools script for generating genesis files found here;
https://github.com/sovrin-foundation/steward-tools/tree/master/create_genesis
The script is downloaded and hosted in a running container which has the required packages installed.
Examples of the csv files can be downloaded from here;
https://docs.google.com/spreadsheets/d/1LDduIeZp7pansd9deXeVSqGgdf0VdAHNMc7xYli3QAY/edit#gid=0
Download each sheet separately in csv format and fill them out with the data specific to your network.
The input csv files must be placed into the ./tmp/ folder.
The resulting output 'pool_transactions_genesis' and 'domain_transactions_genesis' files will be placed
in the ./tmp/ folder.
Example:
$0 generategenesisfiles "./tmp/CANdy Beta Genesis File Node info - Trustees.csv" "./tmp/CANdy Beta Genesis File Node info - Stewards.csv"
indy-cli - Run Indy-Cli commands in a Indy-Cli container environment.
$0 indy-cli -h
Expand Down Expand Up @@ -459,6 +478,44 @@ function generateDid() {
runCliCommand python cli-scripts/generate_did.py --seed ${seed}
}

function generateGenesisFiles() {
trustee_csv="${1}"
steward_csv="${2}"
genesis_from_files_filename="genesis_from_files.py"
genesis_from_files_url="https://raw.githubusercontent.com/sovrin-foundation/steward-tools/master/create_genesis/genesis_from_files.py"

if [ -z "${trustee_csv}" ] || [ -z "${steward_csv}" ]; then
echoYellow "You must supply both the trustee and steward csv files."
exit 1
fi

if [[ "${trustee_csv}" != ./tmp/* ]]; then
trustee_csv="./tmp/${trustee_csv}"
fi

if [ ! -f "${trustee_csv}" ]; then
echoYellow "${trustee_csv} not found, please make sure you placed ${trustee_csv} in the ./tmp folder."
exit 1
fi

if [[ "${steward_csv}" != ./tmp/* ]]; then
steward_csv="./tmp/${steward_csv}"
fi

if [ ! -f "${steward_csv}" ]; then
echoYellow "${steward_csv} not found, please make sure you placed ${steward_csv} in the ./tmp folder."
exit 1
fi

echo "Downloading the latest version of ${genesis_from_files_filename} from ${genesis_from_files_url} ..."
curl -s -L -o ./cli-scripts/${genesis_from_files_filename} ${genesis_from_files_url}

# Escape spaces in path ...
trustee_csv_esc=$(echo ${trustee_csv##*/} | sed 's/ /\\ /g')
steward_csv_esc=$(echo ${steward_csv##*/} | sed 's/ /\\ /g')
runCliCommand cli-scripts/${genesis_from_files_filename} --pool /tmp/pool_transactions --domain /tmp/domain_transactions --trustees /tmp/${trustee_csv_esc} --stewards /tmp/${steward_csv_esc}
}

function backup() {
(
_msg=$@
Expand Down Expand Up @@ -741,6 +798,11 @@ case "${COMMAND}" in
generatedid)
generateDid $@
;;
generategenesisfiles)
trustee_csv="${1}"
steward_csv="${2}"
generateGenesisFiles "${trustee_csv}" "${steward_csv}"
;;

backup)
backup "$@"
Expand Down

0 comments on commit 25a64cc

Please sign in to comment.