Skip to content

Commit

Permalink
rework flatbook generation
Browse files Browse the repository at this point in the history
  • Loading branch information
BIP Bot committed Jul 28, 2023
1 parent a5f1388 commit 24fa62c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
16 changes: 3 additions & 13 deletions bal_addresses/addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class AddrBook:
def __init__(self, chain, jsonfile=False):
self.jsonfile = jsonfile
self.chain = chain
self.dotmap = self.build_dotmap()
deployments = requests.get(f"{GITHUB_RAW_OUTPUTS}/deployments.json").json()
try:
dold = deployments["old"][chain]
Expand All @@ -54,7 +53,7 @@ def __init__(self, chain, jsonfile=False):
dactive = {}
self.deployments_only = Munch.fromDict(dactive | dold)
try:
self.flatbook = requests.get(f"{GITHUB_RAW_OUTPUTS}/{chain}.json").json()
self.flatbook = self.generate_flatbook()
self.reversebook = requests.get(f"{GITHUB_RAW_OUTPUTS}/{chain}_reverse.json").json()
except Exception:
self.flatbook = {"zero/zero": ZERO_ADDRESS}
Expand Down Expand Up @@ -206,15 +205,6 @@ def checksum_address_dict(addresses):
print(k, v, "formatted incorrectly")
return checksummed

def build_dotmap(self):
if self.jsonfile:
with open(self.jsonfile, "r") as f:
fullbook = json.load(f)
else:
fullbook = self.fullbook
return (fullbook["active"].get(self.chain, {}) | fullbook["old"].get(self.chain, {}))
# Checksum one more time for good measure

def flatten_dict(self, d, parent_key='', sep='/'):
items = []
for k, v in d.items():
Expand All @@ -227,8 +217,8 @@ def flatten_dict(self, d, parent_key='', sep='/'):

def generate_flatbook(self):
print(f"Generating Addressbook for {self.chain}")
ab = dict(self.merge_deployments())
return self.flatten_dict(ab)
flatbook = {**self.extras, **self.deployments_only, "multisigs": self.multisigs}
return self.flatten_dict(flatbook)


# Version outside class to allow for recursion on the uninitialized class
Expand Down
4 changes: 0 additions & 4 deletions bal_addresses/transform-deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
import re
import json
from pathlib import Path
from pandas import DataFrame
import requests
from addresses import AddrBook

#monorepo = os.environ["MONOREPO_ROOT"]
deployments = os.environ["DEPLOYMENTS_REPO_ROOT_URL"]
#basepath = f"{monorepo}/pkg/deployments"
basepath = deployments

def main():
Expand Down

0 comments on commit 24fa62c

Please sign in to comment.