Skip to content

Commit

Permalink
feat(makefile): create genesis template with DRS from make file (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
omritoptix authored Dec 9, 2024
1 parent c5ed499 commit 7877e6d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,18 @@ release:
release --clean --skip=validate

.PHONY: release-dry-run release

# Default DRS_VERSION if not set
DRS_VERSION ?= default-drs

.PHONY: generate-genesis
generate-genesis:
@if [ -z "$(env)" ]; then \
echo "Error: 'env' parameter is required. Use 'make generate-genesis env=mainnet' or 'make generate-genesis env=testnet'"; \
exit 1; \
fi
@if [ "$(env)" != "mainnet" ] && [ "$(env)" != "testnet" ]; then \
echo "Error: 'env' must be either 'mainnet' or 'testnet'"; \
exit 1; \
fi
@./scripts/generate-genesis-template.sh $(env) $(DRS_VERSION)
File renamed without changes.
File renamed without changes.
14 changes: 8 additions & 6 deletions scripts/generate-genesis-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
set -x

# Get environment parameter
if [ $# -eq 0 ]; then
echo "Error: Environment parameter (mainnet/testnet) is required"
if [ $# -lt 2 ]; then
echo "Error: Both Environment (mainnet/testnet) and DRS parameters are required"
exit 1
fi

ENVIRONMENT=$1
DRS=$2

if [ "$ENVIRONMENT" != "mainnet" ] && [ "$ENVIRONMENT" != "testnet" ]; then
echo "Error: Environment must be either 'mainnet' or 'testnet'"
exit 1
Expand Down Expand Up @@ -77,11 +79,11 @@ update_params() {
return 1
fi

# Create templates directory if it doesn't exist
mkdir -p ./genesis-templates
# Create templates directory with DRS subdirectory if it doesn't exist
mkdir -p "./genesis-templates/DRS/${DRS}"

# Copy the modified genesis file to the template location
cp "$TEMP_GENESIS" "./genesis-templates/genesis-${ENVIRONMENT}.json"
# Copy the modified genesis file to the DRS-specific template location
cp "$TEMP_GENESIS" "./genesis-templates/DRS/${DRS}/genesis-${ENVIRONMENT}.json"

# Cleanup temp directory
rm -rf "$TEMP_DIR"
Expand Down

0 comments on commit 7877e6d

Please sign in to comment.