diff --git a/README.md b/README.md index e74c677..6922081 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Use this tool to test how the network reacts to a given scenario. The available ### Requirements +* `jq` * Python 3.10 1. Clone from github: `git clone git@github.com:hyphacoop/cosmos-genesis-tinkerer.git` diff --git a/cosmos_genesis_tinker.py b/cosmos_genesis_tinker.py index 1cc7732..f952fda 100755 --- a/cosmos_genesis_tinker.py +++ b/cosmos_genesis_tinker.py @@ -389,6 +389,14 @@ def replace_validator(self, old_validator: Validator, new_validator: Validator): self.preprocessing_file], check=True) + # Sort coins in bank balances + self.log_step("Sorting balances coins") + subprocess.run("jq '.app_state.bank.balances |= map(.coins |= sort_by(.denom))' " + \ + f"{self.preprocessing_file} > sorted.json", + check=True, shell=True) + subprocess.run(f"mv sorted.json {self.preprocessing_file}", + check=True, shell=True) + def load_file(self, path): """ Loads a genesis file from the given path