Skip to content

Commit

Permalink
Merge pull request #383 from BalancerMaxis/add_w3_rpc_class
Browse files Browse the repository at this point in the history
bal_addresses 0.9.9: bal_tools 0.1.2 + use new RPC class for permissions probing
  • Loading branch information
gosuto-inzasheru authored Aug 1, 2024
2 parents 47090c5 + 568e26c commit 5d22dda
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 42 deletions.
1 change: 1 addition & 0 deletions .github/workflows/generate_permissions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
env:
INFURA_KEY: ${{ secrets.INFURA_KEY }}
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
DRPC_KEY: ${{ secrets.DRPC_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion bal_addresses/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pathlib>=1.0
git+https://github.com/BalancerMaxis/[email protected].1
git+https://github.com/BalancerMaxis/[email protected].2
requests
pandas
web3
Expand Down
50 changes: 12 additions & 38 deletions generate_current_permissions.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,11 @@
import requests
import json
import os
from bal_addresses import AddrBook, GITHUB_DEPLOYMENTS_RAW
from bal_addresses import AddrBook, GITHUB_DEPLOYMENTS_RAW, NoResultError
from web3 import Web3
from bal_tools import Web3Rpc

INFURA_KEY = os.getenv("INFURA_KEY")
ALCHEMY_KEY = os.getenv("ALCHEMY_KEY")

w3_by_chain = {
"gnosis": Web3(Web3.HTTPProvider(f"https://rpc.gnosischain.com")),
"zkevm": Web3(
Web3.HTTPProvider(
f"https://polygonzkevm-mainnet.g.alchemy.com/v2/{ALCHEMY_KEY}"
)
),
"avalanche": Web3(Web3.HTTPProvider(f"https://api.avax.network/ext/bc/C/rpc")),
### Less reliable RPCs first to fail fast :)
# "linea": Web3(Web3.HTTPProvider(f"https://linea-mainnet.infura.io/v3/{INFURA_KEY}")),
"mainnet": Web3(
Web3.HTTPProvider(f"https://eth-mainnet.g.alchemy.com/v2/{ALCHEMY_KEY}")
),
"base": Web3(
Web3.HTTPProvider(f"https://base-mainnet.g.alchemy.com/v2/{ALCHEMY_KEY}")
),
"arbitrum": Web3(
Web3.HTTPProvider(f"https://arb-mainnet.g.alchemy.com/v2/{ALCHEMY_KEY}")
),
"optimism": Web3(
Web3.HTTPProvider(f"https://opt-mainnet.g.alchemy.com/v2/{ALCHEMY_KEY}")
),
"polygon": Web3(
Web3.HTTPProvider(f"https://polygon-mainnet.g.alchemy.com/v2/{ALCHEMY_KEY}")
),
"mode": Web3(Web3.HTTPProvider("https://mainnet.mode.network/")),
"fraxtal": Web3(Web3.HTTPProvider("https://rpc.frax.com")),
"sepolia": Web3(
Web3.HTTPProvider(f"https://eth-sepolia.g.alchemy.com/v2/{ALCHEMY_KEY}")
),
}
DRPC_KEY = os.getenv("DRPC_KEY")


def build_chain_permissions_list(chain_name):
Expand All @@ -46,9 +14,15 @@ def build_chain_permissions_list(chain_name):
action_ids_list = (
f"{GITHUB_DEPLOYMENTS_RAW}/action-ids/{chain_name}/action-ids.json"
)
w3 = w3_by_chain[chain_name]
w3 = Web3Rpc(chain_name, DRPC_KEY)

try:
authorizer_address = a.search_unique("20210418-authorizer/Authorizer").address
except NoResultError as e:
print(f"WARNING: Authorizer not found: {e}")
return results
authorizer = w3.eth.contract(
address=a.search_unique("20210418-authorizer/Authorizer").address,
address=authorizer_address,
abi=json.load(open("bal_addresses/abis/Authorizer.json")),
)
try:
Expand Down Expand Up @@ -82,7 +56,7 @@ def generate_chain_files(chain):


def main():
for chain in w3_by_chain:
for chain in AddrBook.chains.BALANCER_PRODUCTION_CHAINS:
print(f"\n\n\nGenerating Permissions Data for {chain.capitalize()}\n\n\n")
generate_chain_files(chain)

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from setuptools import setup, find_packages

VERSION = "0.9.8"
VERSION = "0.9.9"
DESCRIPTION = "Balancer Maxi Addressbook"
LONG_DESCRIPTION = "Balancer Maxi Addressbook and Balancer Permissions helper"

# Setting up
setup(
name="bal_addresses",
version=VERSION,
author="Tritium",
author="The Balancer Maxis",
author_email="<[email protected]>",
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
Expand All @@ -23,7 +23,7 @@
"web3",
"gql[requests]",
"requests",
"bal_tools @ git+https://github.com/BalancerMaxis/[email protected].1",
"bal_tools @ git+https://github.com/BalancerMaxis/[email protected].2",
],
keywords=["python", "first package"],
classifiers=[
Expand Down

0 comments on commit 5d22dda

Please sign in to comment.