def set_registry(self, address: Address) -> None: """ Sets the current registry used in ``web3.pm`` functions that read/write to an on-chain registry. This method accepts checksummed/canonical addresses or ENS names. Addresses must point to an on-chain instance of an ERC1319 registry implementation. To use an ENS domain as the address, make sure a valid ENS instance set as ``web3.ens``. * Parameters: * ``address``: Address of on-chain Registry. """ if is_canonical_address(address) or is_checksum_address(address): self.registry = SimpleRegistry(address, self.web3) elif is_ens_name(address): self._validate_set_ens() addr_lookup = self.web3.ens.address(address) if not addr_lookup: raise NameNotFound( "No address found after ENS lookup for name: {0}.".format( address)) self.registry = SimpleRegistry(addr_lookup, self.web3) else: raise PMError( "Expected a canonical/checksummed address or ENS name for the address, " "instead received {0}.".format(type(address)))
def set_registry(self, address: Address) -> None: """ Sets the current registry used in ``web3.pm`` functions that read/write to an on-chain registry. This method accepts checksummed/canonical addresses or ENS names. Addresses must point to an instance of the Vyper Reference Registry implementation. If you want to use a different registry implementation with ``web3.pm``, manually set the ``web3.pm.registry`` attribute to any subclass of ``ERCRegistry``. To use an ENS domain as the address, make sure a valid ENS instance set as ``web3.ens``. * Parameters: * ``address``: Address of on-chain Vyper Reference Registry. """ if is_canonical_address(address) or is_checksum_address(address): canonical_address = to_canonical_address(address) self.registry = VyperReferenceRegistry(canonical_address, self.web3) elif is_ens_name(address): self._validate_set_ens() addr_lookup = self.web3.ens.address(address) if not addr_lookup: raise NameNotFound( "No address found after ENS lookup for name: {0}.".format( address)) self.registry = VyperReferenceRegistry( to_canonical_address(addr_lookup), self.web3) else: raise PMError( "Expected a canonical/checksummed address or ENS name for the address, " "instead received {0}.".format(type(address)))
def validate_name_has_address(ens, name): addr = ens.address(name, guess_tld=False) if addr: return addr else: raise NameNotFound("Could not find address for name %r" % name)
def validate_name_has_address(ens: ENS, name: str) -> ChecksumAddress: addr = ens.address(name) if addr: return addr else: raise NameNotFound("Could not find address for name %r" % name)