Skip to content

Commit

Permalink
Merge pull request #201 from balancer/fix_contract_list_gen
Browse files Browse the repository at this point in the history
fix: Update package version and handle chains with no deployments.
  • Loading branch information
Tritium-VLK committed May 24, 2024
2 parents 638630a + 509684a commit 4824e44
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 273 deletions.
25 changes: 19 additions & 6 deletions .github/python_actions/genContractLists.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import requests
import pandas as pd
import re
import os
from bal_addresses import AddrBook, GITHUB_DEPLOYMENTS_NICE

OUTPUT_PATH = "docs/reference/contracts/deployment-addresses"
Expand All @@ -19,8 +20,13 @@
SCANNERS_BY_CHAIN = AddrBook.chains["SCANNERS_BY_CHAIN"]

def address_directory(chain, status=None):
r = requests.get(f"https://raw.githubusercontent.com/balancer/balancer-deployments/master/addresses/{chain}.json")
r=r.json()
try:
r = requests.get(f"https://raw.githubusercontent.com/balancer/balancer-deployments/master/addresses/{chain}.json")
r.raise_for_status()
r=r.json()
except:
print (f"Error fetching deployments {chain} addresses, returning empty dict dict")
return {}
if isinstance(status, str):
return {k: v for k, v in r.items() if v['status'] == status}
else:
Expand Down Expand Up @@ -51,7 +57,6 @@ def genFullTable(r, chain):

def genPoolFactories(r, chain):
result = pd.DataFrame(columns=["Contract", "Address", "Deployment"])
print(f"Generating pools for {chain}")
for deployment, depdata in r.items():
if "-pool" not in deployment:
continue
Expand Down Expand Up @@ -126,6 +131,7 @@ def genFromContractList(r, chain, contractList):
return result

def genChainMd(chain):
print(f"Generating md for {chain}")
groupedContracts = []
for contracts in CONTRACTS_BY_HEADING.values():
groupedContracts += contracts
Expand Down Expand Up @@ -194,9 +200,16 @@ def genChainMd(chain):

def main():
for chain in SCANNERS_BY_CHAIN:
output=genChainMd(chain)
with open(f"{OUTPUT_PATH}/{chain}.md", "w") as f:
f.write(output)
if AddrBook(chain).deployments:
output=genChainMd(chain)
with open(f"{OUTPUT_PATH}/{chain}.md", "w") as f:
f.write(output)
else:
#Remove old files if they exist
try:
os.remove(f"{OUTPUT_PATH}/{chain}.md")
except:
pass

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion .github/python_actions/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
git+https://github.com/BalancerMaxis/bal_addresses@0.8.4
git+https://github.com/BalancerMaxis/bal_addresses@0.9.4
pandas>=1.5.3
tabulate>=0.9.0

2 changes: 1 addition & 1 deletion .github/workflows/update_contract_addresses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'

- name: Update Files
id: update
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_permissions_table.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'

- name: Update Files
id: update
Expand Down
69 changes: 0 additions & 69 deletions docs/reference/contracts/deployment-addresses/fantom.md

This file was deleted.

Loading

0 comments on commit 4824e44

Please sign in to comment.