Skip to content

Commit

Permalink
Merge pull request #36 from hyphacoop/sorted-coins
Browse files Browse the repository at this point in the history
Add jq patch to sort coins
  • Loading branch information
ASoTNetworks authored Nov 20, 2023
2 parents b58f67b + 0919824 commit c36dba3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]:hyphacoop/cosmos-genesis-tinkerer.git`
Expand Down
8 changes: 8 additions & 0 deletions cosmos_genesis_tinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c36dba3

Please sign in to comment.