Skip to content

Commit

Permalink
Updates from Shaks comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tritium committed Jul 27, 2023
1 parent 856ad01 commit 5a75aa6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 0.8.0
added andd dotmaps + permissions
Added extra Munch based explorable dotmaps + permissions
Restructured function returns to be more consistent.
# 0.6.0
Use new balancer deployments repo.
# 0.4.0
Expand Down
2 changes: 1 addition & 1 deletion bal_addresses/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .addresses import AddrBook, GITHUB_DEPLOYMENTS_RAW, GITHUB_DEPLOYMENTS_NICE, GITHUB_RAW_OUTPUTS, GITHUB_RAW_EXTRAS
from .permissions import BalPermissions
from .errors import Errors
from .errors import MultipleMatchesError, NoResultError
14 changes: 7 additions & 7 deletions bal_addresses/addresses.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from .errors import Errors
from .errors import MultipleMatchesError, NoResultError
from typing import Dict
from typing import Optional

Expand Down Expand Up @@ -141,16 +141,16 @@ def populate_multisigs(self) -> None:
self._multisigs = Munch.fromDict(msigs[self.chain])
else:
print(f"Warning: No multisigs for chain {self.chain}, multisigs must be added in extras/multisig.json")
self._multisigs = {}
self._multisigs = Munch



def search_unique(self, substr):
results = [s for s in self.flatbook.keys() if substr in s]
if len(results) > 1:
raise Errors.MultipleMatchesError(f"{substr} Multiple matches found: {results}")
raise MultipleMatchesError(f"{substr} Multiple matches found: {results}")
if len(results) < 1:
raise Errors.NoResultError(f"{substr}")
raise NoResultError(f"{substr}")
return Munch.fromDict({
"path": results[0],
"address": self.flatbook[results[0]]
Expand All @@ -159,9 +159,9 @@ def search_unique(self, substr):
def search_unique_deployment(self, substr):
results = [s for s in self.deployments_only.keys() if substr in s]
if len(results) > 1:
raise Errors.MultipleMatchesError(f"{substr} Multiple matches found: {results}")
raise MultipleMatchesError(f"{substr} Multiple matches found: {results}")
if len(results) < 1:
raise Errors.NoResultError(f"{substr}")
raise NoResultError(f"{substr}")
return Munch.fromDict({
"deployment": results[0],
"addresses_by_contract": self.deployments_only[results[0]]
Expand All @@ -183,7 +183,7 @@ def latest_contract(self, contract_name):
if contract_name in contractData.keys():
deployments.append(deployment)
if len(deployments) == 0:
raise Errors.NoResultError(contract_name)
raise NoResultError(contract_name)
deployments.sort(reverse=True)
address = self.deployments_only[deployments[0]][contract_name]
return Munch.fromDict({
Expand Down
10 changes: 4 additions & 6 deletions bal_addresses/errors.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

class Errors():
class MultipleMatchesError(Exception):
pass

class MultipleMatchesError(Exception):
pass

class NoResultError(Exception):
pass
class NoResultError(Exception):
pass
10 changes: 5 additions & 5 deletions bal_addresses/permissions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .errors import Errors
from .errors import NoResultError, MultipleMatchesError
import requests
from dotmap import DotMap
from bal_addresses import AddrBook, GITHUB_DEPLOYMENTS_RAW, GITHUB_RAW_OUTPUTS
Expand Down Expand Up @@ -53,9 +53,9 @@ def search_many_paths_by_unique_deployment(self, deployment_substr, fx_substr) -
def search_unique_path_by_unique_deployment(self, deployment_substr, fx_substr) -> dict[str, str]:
results = self.search_many_paths_by_unique_deployment(deployment_substr, fx_substr)
if len(results) > 1:
raise Errors.MultipleMatchesError(f"{fx_substr} Multiple matches found: {results}")
raise MultipleMatchesError(f"{fx_substr} Multiple matches found: {results}")
if len(results) < 1:
raise Errors.NoResultError(f"{fx_substr}")
raise NoResultError(f"{fx_substr}")
return results[0]

def needs_authorizer(self, contract, deployment) -> bool:
Expand All @@ -65,14 +65,14 @@ def allowed_addresses(self, action_id) -> list[str]:
try:
return self.active_permissions_by_action_id[action_id]
except KeyError:
raise Errors.NoResultError(f"{action_id} has no authorized callers")
raise NoResultError(f"{action_id} has no authorized callers")

def allowed_caller_names(self, action_id) -> list[str]:
a = AddrBook(self.chain)
try:
addresslist = self.active_permissions_by_action_id[action_id]
except KeyError:
raise Errors.NoResultError(f"{action_id} has no authorized callers")
raise NoResultError(f"{action_id} has no authorized callers")
names = [a.flatbook.get(item, 'undef') for item in addresslist]
return names

Expand Down

0 comments on commit 5a75aa6

Please sign in to comment.