def content(self, name_domain): """ Returns the hash associated with an RNS domain. or 0x00 if hash is not set. :param name_domain: :return: """ eip137hash = namehash(name_domain) response = self.resolver_contract.functions.content(eip137hash).call() return response
def set_content(self, name_domain, hash, from_account): """ Sets the hash associated with an RNS domain. May only be called by the owner of that node in the RNS registry. :param name_domain: The domain to update. :param hash: The address to set. :param from_account: The spender address :return: """ eip137hash = namehash(name_domain) response = self.resolver_contract.functions.setContent(eip137hash, hash).transact({"from": from_account}) return response
def addr(self, name_domain=None) -> str: """ Returns the address associated with an RNS node. or 0x00 if address is not set. :param name_domain: The RNS' name domain to query. :return: rsk address """ if is_rns_address(name_domain): eip137hash = namehash(name_domain) resolved_address = self.resolver_contract.functions.addr(eip137hash).call() return resolved_address else: raise RnsError("Invalid RNS domain")
def has(self, name_domain, kind): """ Returns true if the specified node has the specified record type. :param name_domain: The RNS' name domain to query. :param kind: The record type name, as specified in RNSIP01. :return: True if this resolver has a record of the provided type on the provided node. """ eip137hash = namehash(name_domain) byte_str_kind = kind.encode() byte_str_hex_kind = binascii.hexlify(byte_str_kind) str_hex_kind = byte_str_hex_kind.decode("utf-8") response = self.resolver_contract.functions.has(eip137hash, str_hex_kind).call() return response
def chain_addr(self, name_domain: str, chain_id: int = RSK_CHAIN_ID) -> str: """ Returns the address associated with an RNS node for a specific chain id. or 0x00 if address is not set. :param chain_id: The RNS' chain id. Defaults to rsk chain id. :param name_domain: The RNS' name domain to query. :return: rsk address """ if is_rns_address(name_domain): eip137hash = namehash(name_domain) resolved_address = self.resolver_contract.functions.chainAddr( eip137hash, chain_id).call() return resolved_address else: raise RnsError("Invalid RNS domain")