Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Lookup unique address on all chains #448

Merged
merged 11 commits into from
Oct 23, 2024
1 change: 1 addition & 0 deletions bal_addresses/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .addresses import (
AddrBook,
get_address_all_chains,
GITHUB_DEPLOYMENTS_RAW,
GITHUB_DEPLOYMENTS_NICE,
GITHUB_RAW_OUTPUTS,
Expand Down
19 changes: 19 additions & 0 deletions bal_addresses/addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@
ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"


def get_address_all_chains(search_string: str) -> dict:
Tritium-VLK marked this conversation as resolved.
Show resolved Hide resolved
"""
Finds addresses for a unique name across all chains
returns a dict with chain as keys and a dict with "path" and "address"
Will throw MultipleMatchesError if the string is not unique on each and every chain
"""
result = {}
for chain in AddrBook.chain_ids_by_name.keys():
print(f"Processing {chain}")
addr_book = AddrBook(chain)
try:
info = addr_book.search_unique(search_string)
result[chain] = info
except NoResultError:
result[chain] = None
print("Not Found")
return result


class AddrBook:
chains = Munch.fromDict(
json.load(open("extras/chains.json"))
Expand Down