Example #1
0
def normalize_address(ens, address):
    if address:
        if is_ens_name(address):
            validate_name_has_address(ens, address)
        else:
            validate_address(address)
    return address
Example #2
0
def normalize_address(ens: ENS, address: ChecksumAddress) -> ChecksumAddress:
    if address:
        if is_ens_name(address):
            validate_name_has_address(ens, address)
        else:
            validate_address(address)
    return address
Example #3
0
def normalize_address(ens, address):
    if address:
        if is_ens_name(address):
            validate_name_has_address(ens, address)
        else:
            validate_address(address)
    return address
Example #4
0
def abi_ens_resolver(w3, type_str, val):
    if type_str == 'address' and is_ens_name(val):
        if w3 is None:
            raise InvalidAddress("Could not look up name %r because no web3"
                                 " connection available" % (val))
        elif w3.ens is None:
            raise InvalidAddress("Could not look up name %r because ENS is"
                                 " set to None" % (val))
        elif int(w3.net.version) != 1 and not isinstance(w3.ens, StaticENS):
            raise InvalidAddress("Could not look up name %r because web3 is"
                                 " not connected to mainnet" % (val))
        else:
            return type_str, validate_name_has_address(w3.ens, val)
    else:
        return type_str, val
Example #5
0
def abi_ens_resolver(w3: "Web3", type_str: TypeStr,
                     val: Any) -> Tuple[TypeStr, Any]:
    if type_str == 'address' and is_ens_name(val):
        if w3 is None:
            raise InvalidAddress(
                f"Could not look up name {val!r} because no web3"
                " connection available")
        elif w3.ens is None:
            raise InvalidAddress(
                f"Could not look up name {val!r} because ENS is"
                " set to None")
        elif int(w3.net.version) != 1 and not isinstance(w3.ens, StaticENS):
            raise InvalidAddress(
                f"Could not look up name {val!r} because web3 is"
                " not connected to mainnet")
        else:
            return type_str, validate_name_has_address(w3.ens, val)
    else:
        return type_str, val
Example #6
0
def abi_ens_resolver(w3, abi_type, val):
    if abi_type == 'address' and is_ens_name(val):
        if w3 is None:
            raise InvalidAddress(
                "Could not look up name %r because no web3"
                " connection available" % (val)
            )
        elif w3.ens is None:
            raise InvalidAddress(
                "Could not look up name %r because ENS is"
                " set to None" % (val)
            )
        elif int(w3.net.version) is not 1 and not isinstance(w3.ens, StaticENS):
            raise InvalidAddress(
                "Could not look up name %r because web3 is"
                " not connected to mainnet" % (val)
            )
        else:
            return (abi_type, validate_name_has_address(w3.ens, val))
    else:
        return (abi_type, val)