Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jq patch to sort coins #36

Merged
merged 4 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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