def _str_to_addr(s: str) -> AddressLike: if s.startswith("0x"): return Address(bytes.fromhex(s[2:])) elif s.endswith(".eth"): return ENS(s) else: raise Exception("Could't convert string {s} to AddressLike")
def str_to_addr(s: str) -> AddressLike: if s.startswith("0x"): return Address(bytes.fromhex(s[2:])) elif s.endswith(".eth"): return ENS(s) else: # TODO: add exception pass
def _str_to_addr(s: Union[str, Address]) -> AddressLike: """Idempotent""" if isinstance(s, str): if s.startswith("0x"): return Address(bytes.fromhex(s[2:])) elif s.endswith(".eth"): return ENS(s) else: raise Exception(f"Couldn't convert string '{s}' to AddressLike") else: return s