def setup_name( self, name: str, address: Optional[ChecksumAddress] = None, transact: Optional["TxParams"] = None ) -> HexBytes: """ Set up the address for reverse lookup, aka "caller ID". After successful setup, the method :meth:`~ens.main.ENS.name` will return `name` when supplied with `address`. :param str name: ENS name that address will point to :param str address: to set up, in checksum format :param dict transact: the transaction configuration, like in :meth:`~web3.eth.send_transaction` :raises AddressMismatch: if the name does not already point to the address :raises InvalidName: if `name` has invalid syntax :raises UnauthorizedError: if ``'from'`` in `transact` does not own `name` :raises UnownedName: if no one owns `name` """ if not transact: transact = {} transact = deepcopy(transact) if not name: self._assert_control(address, 'the reverse record') return self._setup_reverse(None, address, transact=transact) else: resolved = self.address(name) if is_none_or_zero_address(address): address = resolved elif resolved and address != resolved and resolved != EMPTY_ADDR_HEX: raise AddressMismatch( f"Could not set address {address!r} to point to name, " f"because the name resolves to {resolved!r}. " "To change the name for an existing address, call " "setup_address() first." ) if is_none_or_zero_address(address): address = self.owner(name) if is_none_or_zero_address(address): raise UnownedName("claim subdomain using setup_address() first") if is_binary_address(address): address = to_checksum_address(address) if not is_checksum_address(address): raise ValueError("You must supply the address in checksum format") self._assert_control(address, name) if not resolved: self.setup_address(name, address, transact=transact) return self._setup_reverse(name, address, transact=transact)
def setup_name(self, name, address=None, transact={}): ''' Set up the address for reverse lookup, aka "caller ID". After successful setup, the method :meth:`~ens.main.ENS.name` will return `name` when supplied with `address`. :param str name: ENS name that address will point to :param str address: to set up, in checksum format :param dict transact: the transaction configuration, like in :meth:`~web3.eth.sendTransaction` :raises AddressMismatch: if the name does not already point to the address :raises InvalidName: if `name` has invalid syntax :raises UnauthorizedError: if ``'from'`` in `transact` does not own `name` :raises UnownedName: if no one owns `name` ''' if not name: self._assert_control(address, 'the reverse record') return self._setup_reverse(None, address, transact=transact) else: resolved = self.address(name) if not address: address = resolved elif resolved and address != resolved: raise AddressMismatch( "Could not set address %r to point to name, because the name resolves to %r. " "To change the name for an existing address, call setup_address() first." % (address, resolved)) if not address: address = self.owner(name) if not address: raise UnownedName( "claim subdomain using setup_address() first") if is_binary_address(address): address = to_checksum_address(address) if not is_checksum_address(address): raise ValueError( "You must supply the address in checksum format") self._assert_control(address, name) if not resolved: self.setup_address(name, address, transact=transact) return self._setup_reverse(name, address, transact=transact)