Skip to content

Commit

Permalink
Merge pull request #166 from BalancerMaxis/fix/sort_inv_dict
Browse files Browse the repository at this point in the history
fix: sort reverse dict by keys
  • Loading branch information
Tritium-VLK authored Dec 15, 2023
2 parents 35918b1 + ea8aa8d commit db58b8e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions gen_addresses.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import os
from bal_addresses import AddrBook
import requests
import json

from bal_addresses import AddrBook


def reverse_dict(d):
d = dict(d)
inv_map = {v: k for k, v in d.items()}
inv_map = dict(sorted({v: k for k, v in d.items()}.items()))
return inv_map


def write_addressbooks(chainlist=AddrBook.chain_ids_by_name.keys()):
for chain in chainlist:
print(f"Writing addressbooks for {chain}")
Expand All @@ -18,10 +19,12 @@ def write_addressbooks(chainlist=AddrBook.chain_ids_by_name.keys()):
with open(f"outputs/{chain}_reverse.json", "w") as f:
json.dump(reverse_dict(flatbook), f, indent=3)


def main():
chains = AddrBook.chain_ids_by_name.keys()
print(f"Generating new addressbook jsons for {chains}")
write_addressbooks(chains)


if __name__ == "__main__":
main()

0 comments on commit db58b8e

Please sign in to comment.