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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
"""
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