示例#1
0
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")
示例#2
0
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
示例#3
0
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