Skip to content

Commit

Permalink
update requirements.txt and update gen_current_permissions to use the…
Browse files Browse the repository at this point in the history
… new class in bal_tools.
  • Loading branch information
Tritium-VLK committed Jul 31, 2024
1 parent fecd6df commit 1d453d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 46 deletions.
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].2alpha1
git+https://github.com/BalancerMaxis/[email protected].2
requests
pandas
web3
Expand Down
49 changes: 4 additions & 45 deletions generate_current_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,16 @@
import os
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")
DRPC_KEY = os.getenv("DRPC_KEY")


DRPC_NAME_OVERRIDES = {
"mainnet": "ethereum",
"zkevm": "polygon-zkevm",
}


class W3_RPC:
def __init__(self, chain, DRPC_KEY):
drpc_chain = DRPC_NAME_OVERRIDES.get(chain, chain)
self.w3 = Web3(
Web3.HTTPProvider(
f"https://lb.drpc.org/ogrpc?network={drpc_chain}&dkey={DRPC_KEY}"
)
)

def __getattr__(self, name):
return getattr(self.w3, name)


class W3_RPC_BY_CHAIN:
def __init__(self, DRPC_KEY):
self.DRPC_KEY = DRPC_KEY
self.w3_by_chain = {}
for chain in AddrBook.chain_ids_by_name.keys():
self.w3_by_chain[chain] = W3_RPC(chain, DRPC_KEY)

def __getitem__(self, chain):
return self.w3_by_chain[chain]

def __setitem__(self, chain, value):
self.w3_by_chain[chain] = value

def __delitem__(self, chain):
del self.w3_by_chain[chain]


def build_chain_permissions_list(chain_name):
a = AddrBook(chain_name)
results = {}
action_ids_list = (
f"{GITHUB_DEPLOYMENTS_RAW}/action-ids/{chain_name}/action-ids.json"
)
w3 = W3_RPC(chain_name, os.getenv("DRPC_KEY"))
action_ids_list = f"{GITHUB_DEPLOYMENTS_RAW}/action-ids/{chain_name}/action-ids.json"
w3 = Web3Rpc(chain_name, DRPC_KEY)

try:
authorizer_address = a.search_unique("20210418-authorizer/Authorizer").address
Expand All @@ -77,9 +38,7 @@ def build_chain_permissions_list(chain_name):
if numMembers > 0:
memberAddressList = []
for i in range(0, numMembers, 1):
caller = str(
authorizer.functions.getRoleMember(action_id, i).call()
)
caller = str(authorizer.functions.getRoleMember(action_id, i).call())
memberAddressList.append(caller)

results[action_id] = memberAddressList
Expand Down

0 comments on commit 1d453d7

Please sign in to comment.