Skip to content

Commit

Permalink
fix: sort reverse dict by keys
Browse files Browse the repository at this point in the history
  • Loading branch information
gosuto-inzasheru committed Dec 15, 2023
1 parent 1dac7f8 commit ea8aa8d
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 ea8aa8d

Please sign in to comment.