diff --git a/HACKING.md b/HACKING.md index 7c702ea6..053d8ee2 100644 --- a/HACKING.md +++ b/HACKING.md @@ -9,6 +9,8 @@ work on CosmJS, i.e. modify it. It is not intended for users of CosmJS. - Node.js 12+, Docker and yarn - `sha256sum`, which you [can get on macOS as well](https://unix.stackexchange.com/questions/426837/no-sha256sum-in-macos) +- `gsed`, which you + [can get on macOS as well](https://formulae.brew.sh/formula/gnu-sed) ## Checking out code diff --git a/scripts/simapp/generate_template.sh b/scripts/simapp/generate_template.sh index aed23d74..0ef73908 100755 --- a/scripts/simapp/generate_template.sh +++ b/scripts/simapp/generate_template.sh @@ -2,6 +2,8 @@ set -o errexit -o nounset -o pipefail command -v shellcheck >/dev/null && shellcheck "$0" +gnused="$(command -v gsed || echo sed)" + SCRIPT_DIR="$(realpath "$(dirname "$0")")" # shellcheck source=./env # shellcheck disable=SC1091 @@ -53,7 +55,7 @@ function inline_jq() { inline_jq "template/.simapp/config/genesis.json" -S # Custom settings in config.toml - sed -i "" \ + "$gnused" -i \ -e 's/^cors_allowed_origins =.*$/cors_allowed_origins = ["*"]/' \ -e 's/^timeout_propose =.*$/timeout_propose = "300ms"/' \ -e 's/^timeout_propose_delta =.*$/timeout_propose_delta = "100ms"/' \ @@ -65,7 +67,7 @@ function inline_jq() { "template/.simapp/config/config.toml" # Custom settings app.toml - sed -i "" \ + "$gnused" -i \ -e 's/^enable =.*$/enable = true/' \ -e 's/^enabled-unsafe-cors =.*$/enabled-unsafe-cors = true/' \ "template/.simapp/config/app.toml" diff --git a/scripts/simapp/generate_template_slow.sh b/scripts/simapp/generate_template_slow.sh index 72f9cf42..d28227f3 100755 --- a/scripts/simapp/generate_template_slow.sh +++ b/scripts/simapp/generate_template_slow.sh @@ -2,6 +2,8 @@ set -o errexit -o nounset -o pipefail command -v shellcheck >/dev/null && shellcheck "$0" +gnused="$(command -v gsed || echo sed)" + SCRIPT_DIR="$(realpath "$(dirname "$0")")" # Create template for slow simapp @@ -12,7 +14,7 @@ SCRIPT_DIR="$(realpath "$(dirname "$0")")" chmod +x "$SCRIPT_DIR/template_slow/run_simd.sh" # Slow settings in config.toml - sed -i "" \ + "$gnused" -i \ -e 's/^timeout_broadcast_tx_commit =.*$/timeout_broadcast_tx_commit = "1s"/' \ -e 's/^timeout_commit =.*$/timeout_commit = "10s"/' \ "template_slow/.simapp/config/config.toml" diff --git a/scripts/simapp/setup.sh b/scripts/simapp/setup.sh index 1fd82742..18741399 100644 --- a/scripts/simapp/setup.sh +++ b/scripts/simapp/setup.sh @@ -2,6 +2,8 @@ set -o errexit -o nounset command -v shellcheck >/dev/null && shellcheck "$0" +gnused="$(command -v gsed || echo sed)" + PASSWORD=${PASSWORD:-1234567890} CHAIN_ID=${CHAIN_ID:-simd-testing} MONIKER=${MONIKER:-simd-moniker} @@ -15,7 +17,7 @@ START_BALANCE="10000000$STAKE,1000000000$FEE" echo "Creating genesis ..." simd init --chain-id "$CHAIN_ID" "$MONIKER" -sed -i "s/\"stake\"/\"$STAKE\"/" "$HOME"/.simapp/config/genesis.json # staking/governance token is hardcoded in config, change this +"$gnused" -i "s/\"stake\"/\"$STAKE\"/" "$HOME"/.simapp/config/genesis.json # staking/governance token is hardcoded in config, change this echo "Setting up validator ..." if ! simd keys show validator 2>/dev/null; then diff --git a/scripts/simapp/template/setup.sh b/scripts/simapp/template/setup.sh index 1fd82742..18741399 100755 --- a/scripts/simapp/template/setup.sh +++ b/scripts/simapp/template/setup.sh @@ -2,6 +2,8 @@ set -o errexit -o nounset command -v shellcheck >/dev/null && shellcheck "$0" +gnused="$(command -v gsed || echo sed)" + PASSWORD=${PASSWORD:-1234567890} CHAIN_ID=${CHAIN_ID:-simd-testing} MONIKER=${MONIKER:-simd-moniker} @@ -15,7 +17,7 @@ START_BALANCE="10000000$STAKE,1000000000$FEE" echo "Creating genesis ..." simd init --chain-id "$CHAIN_ID" "$MONIKER" -sed -i "s/\"stake\"/\"$STAKE\"/" "$HOME"/.simapp/config/genesis.json # staking/governance token is hardcoded in config, change this +"$gnused" -i "s/\"stake\"/\"$STAKE\"/" "$HOME"/.simapp/config/genesis.json # staking/governance token is hardcoded in config, change this echo "Setting up validator ..." if ! simd keys show validator 2>/dev/null; then diff --git a/scripts/simapp/template_slow/setup.sh b/scripts/simapp/template_slow/setup.sh index 1fd82742..18741399 100755 --- a/scripts/simapp/template_slow/setup.sh +++ b/scripts/simapp/template_slow/setup.sh @@ -2,6 +2,8 @@ set -o errexit -o nounset command -v shellcheck >/dev/null && shellcheck "$0" +gnused="$(command -v gsed || echo sed)" + PASSWORD=${PASSWORD:-1234567890} CHAIN_ID=${CHAIN_ID:-simd-testing} MONIKER=${MONIKER:-simd-moniker} @@ -15,7 +17,7 @@ START_BALANCE="10000000$STAKE,1000000000$FEE" echo "Creating genesis ..." simd init --chain-id "$CHAIN_ID" "$MONIKER" -sed -i "s/\"stake\"/\"$STAKE\"/" "$HOME"/.simapp/config/genesis.json # staking/governance token is hardcoded in config, change this +"$gnused" -i "s/\"stake\"/\"$STAKE\"/" "$HOME"/.simapp/config/genesis.json # staking/governance token is hardcoded in config, change this echo "Setting up validator ..." if ! simd keys show validator 2>/dev/null; then diff --git a/scripts/tendermint/start.sh b/scripts/tendermint/start.sh index e5d3b65b..20c4b3d2 100755 --- a/scripts/tendermint/start.sh +++ b/scripts/tendermint/start.sh @@ -2,6 +2,8 @@ set -o errexit -o nounset -o pipefail command -v shellcheck >/dev/null && shellcheck "$0" +gnused="$(command -v gsed || echo sed)" + # Tendermint settings must be specified # Choose version from https://hub.docker.com/r/tendermint/tendermint/tags/ for SETTING in "TENDERMINT_VERSION" "TENDERMINT_PORT" "TENDERMINT_NAME"; do @@ -24,7 +26,7 @@ docker run --rm \ # make sure we allow cors origins, only possible by modifying the config file # https://github.com/tendermint/tendermint/issues/3216 -sed -ie 's/^cors_allowed_origins =.*$/cors_allowed_origins = ["*"]/' "${TMP_DIR}/config/config.toml" +"$gnused" -i -e 's/^cors_allowed_origins =.*$/cors_allowed_origins = ["*"]/' "${TMP_DIR}/config/config.toml" # must enable tx index for search and subscribe docker run --rm \ diff --git a/scripts/wasmd/generate_template.sh b/scripts/wasmd/generate_template.sh index a3888f7f..8d08e13c 100755 --- a/scripts/wasmd/generate_template.sh +++ b/scripts/wasmd/generate_template.sh @@ -2,6 +2,8 @@ set -o errexit -o nounset -o pipefail command -v shellcheck >/dev/null && shellcheck "$0" +gnused="$(command -v gsed || echo sed)" + SCRIPT_DIR="$(realpath "$(dirname "$0")")" # shellcheck source=./env # shellcheck disable=SC1091 @@ -47,7 +49,7 @@ function inline_jq() { inline_jq "template/.wasmd/config/genesis.json" -S # Custom settings in config.toml - sed -i "" \ + "$gnused" -i \ -e 's/^cors_allowed_origins =.*$/cors_allowed_origins = ["*"]/' \ -e 's/^timeout_propose =.*$/timeout_propose = "300ms"/' \ -e 's/^timeout_propose_delta =.*$/timeout_propose_delta = "100ms"/' \ @@ -59,7 +61,7 @@ function inline_jq() { "template/.wasmd/config/config.toml" # Custom settings app.toml - sed -i "" \ + "$gnused" -i \ -e 's/^enable =.*$/enable = true/' \ -e 's/^enabled-unsafe-cors =.*$/enabled-unsafe-cors = true/' \ "template/.wasmd/config/app.toml"