2626
2727from ens .constants import ENS_EXTENDED_RESOLVER_INTERFACE_ID , EMPTY_SHA3_BYTES
2828from ens .ens import _resolver_supports_interface , ENS
29- from ens .exceptions import ENSValidationError
29+ from ens .exceptions import ENSValidationError , ENSValueError
3030from ens .utils import address_to_reverse_domain , is_empty_name , is_none_or_zero_address , Web3
3131
3232# from ens.utils import normalize_name
3939def label_to_hash (label : str ) -> HexBytes :
4040 # label = normalize_name(label)
4141 if '.' in label :
42- raise ValueError (f"Cannot generate hash for label { label !r} with a '.'" )
42+ raise ENSValueError (f"Cannot generate hash for label { label !r} with a '.'" )
4343 return Web3 ().keccak (text = label )
4444
4545
4646def normal_name_to_hash (name : str ) -> HexBytes :
4747 """
48- This method will not normalize the name. 'normal' name here means the name
49- should already be normalized before calling this method .
48+ Hashes a pre-normalized name.
49+ The normalization of the name is a prerequisite and is not handled by this function .
5050
51- :param name: the name to hash - should already be normalized
52- :return: namehash the hash of the name
51+ :param str name: A normalized name string to be hashed.
52+ :return: namehash - the hash of the name
5353 :rtype: HexBytes
5454 """
5555 node = EMPTY_SHA3_BYTES
@@ -71,7 +71,7 @@ def raw_name_to_hash(name: str) -> HexBytes:
7171 behind the scenes. For advanced usage, it is a helpful utility.
7272
7373 This normalizes the name with `nameprep
74- <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md#name-syntax>`_
74+ <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md#name-syntax>`_ # blocklint: pragma # noqa: E501
7575 before hashing.
7676
7777 :param str name: ENS name to hash
@@ -85,7 +85,7 @@ def raw_name_to_hash(name: str) -> HexBytes:
8585
8686
8787def ens_encode_name (name : str ) -> bytes :
88- """
88+ r """
8989 Encode a name according to DNS standards specified in section 3.1
9090 of RFC1035 with the following validations:
9191
@@ -135,9 +135,7 @@ def name(self, address: ChecksumAddress) -> Optional[str]:
135135
136136 # To be absolutely certain of the name, via reverse resolution,
137137 # the address must match in the forward resolution
138- result = name if to_checksum_address (address ) == self .address (name ) else None
139-
140- return result
138+ return name if to_checksum_address (address ) == self .address (name ) else None
141139
142140 def resolver (self , name : str ) -> Optional ['Contract' ]:
143141 """
@@ -154,7 +152,7 @@ def resolver(self, name: str) -> Optional['Contract']:
154152 def namehash (name : str ) -> HexBytes :
155153 return raw_name_to_hash (name )
156154
157- def _resolve (self , name : str , fn_name : str = 'addr' ) -> Optional [Union [ChecksumAddress , str ]]:
155+ def _resolve (self , name : str , fn_name : str = 'addr' ) -> Optional [Union [ChecksumAddress , str ]]: # OK
158156 # normal_name = normalize_name(name)
159157 normal_name = name
160158 resolver , current_name = self ._get_resolver (normal_name , fn_name )
@@ -167,9 +165,9 @@ def _resolve(self, name: str, fn_name: str = 'addr') -> Optional[Union[ChecksumA
167165 if _resolver_supports_interface (resolver , ENS_EXTENDED_RESOLVER_INTERFACE_ID ):
168166 contract_func_with_args = (fn_name , [node ])
169167
170- calldata = resolver .encodeABI (* contract_func_with_args )
168+ calldata = resolver .encode_abi (* contract_func_with_args )
171169 contract_call_result = resolver .caller .resolve (
172- ens_encode_name (normal_name ), # TODO ens_encode_name
170+ ens_encode_name (normal_name ),
173171 calldata ,
174172 )
175173 result = self ._decode_ensip10_resolve_data (contract_call_result , resolver , fn_name )
0 commit comments