File tree 4 files changed +29
-16
lines changed 4 files changed +29
-16
lines changed Original file line number Diff line number Diff line change 46
46
)
47
47
from ens .exceptions import (
48
48
AddressMismatch ,
49
+ ENSValueError ,
49
50
ResolverNotFound ,
50
51
UnauthorizedError ,
51
52
UnownedName ,
64
65
normalize_name ,
65
66
raw_name_to_hash ,
66
67
)
67
- from web3 .exceptions import (
68
- Web3ValueError ,
69
- )
70
68
71
69
if TYPE_CHECKING :
72
70
from web3 .contract .async_contract import ( # noqa: F401
@@ -207,7 +205,7 @@ async def setup_address(
207
205
elif is_binary_address (address ):
208
206
address = to_checksum_address (cast (str , address ))
209
207
elif not is_checksum_address (address ):
210
- raise Web3ValueError ("You must supply the address in checksum format" )
208
+ raise ENSValueError ("You must supply the address in checksum format" )
211
209
if await self .address (name ) == address :
212
210
return None
213
211
if address is None :
@@ -285,7 +283,7 @@ async def setup_name(
285
283
if is_binary_address (address ):
286
284
address = to_checksum_address (address )
287
285
if not is_checksum_address (address ):
288
- raise Web3ValueError ("You must supply the address in checksum format" )
286
+ raise ENSValueError ("You must supply the address in checksum format" )
289
287
await self ._assert_control (address , name )
290
288
if not resolved :
291
289
await self .setup_address (name , address , transact = transact )
Original file line number Diff line number Diff line change 30
30
HexBytes ,
31
31
)
32
32
33
- from web3 .exceptions import (
34
- Web3ValueError ,
35
- )
36
-
37
33
from . import (
38
34
abis ,
39
35
)
50
46
)
51
47
from .exceptions import (
52
48
AddressMismatch ,
49
+ ENSValueError ,
53
50
ResolverNotFound ,
54
51
UnauthorizedError ,
55
52
UnownedName ,
@@ -212,7 +209,7 @@ def setup_address(
212
209
elif is_binary_address (address ):
213
210
address = to_checksum_address (cast (str , address ))
214
211
elif not is_checksum_address (address ):
215
- raise Web3ValueError ("You must supply the address in checksum format" )
212
+ raise ENSValueError ("You must supply the address in checksum format" )
216
213
if self .address (name ) == address :
217
214
return None
218
215
if address is None :
@@ -288,7 +285,7 @@ def setup_name(
288
285
if is_binary_address (address ):
289
286
address = to_checksum_address (address )
290
287
if not is_checksum_address (address ):
291
- raise Web3ValueError ("You must supply the address in checksum format" )
288
+ raise ENSValueError ("You must supply the address in checksum format" )
292
289
self ._assert_control (address , name )
293
290
if not resolved :
294
291
self .setup_address (name , address , transact = transact )
Original file line number Diff line number Diff line change @@ -12,6 +12,24 @@ class ENSException(Exception):
12
12
pass
13
13
14
14
15
+ class ENSValueError (ENSException , ValueError ):
16
+ """
17
+ An ENS exception wrapper for `ValueError`, for better control over
18
+ exception handling.
19
+ """
20
+
21
+ pass
22
+
23
+
24
+ class ENSTypeError (ENSException , TypeError ):
25
+ """
26
+ An ENS exception wrapper for `TypeError`, for better control over
27
+ exception handling.
28
+ """
29
+
30
+ pass
31
+
32
+
15
33
class AddressMismatch (ENSException ):
16
34
"""
17
35
In order to set up reverse resolution correctly, the ENS name should first
Original file line number Diff line number Diff line change 35
35
HexBytes ,
36
36
)
37
37
38
- from web3 .exceptions import (
39
- Web3TypeError ,
40
- Web3ValueError ,
38
+ from ens .exceptions import (
39
+ ENSTypeError ,
40
+ ENSValueError ,
41
41
)
42
42
43
43
from .constants import (
@@ -204,7 +204,7 @@ def sha3_text(val: Union[str, bytes]) -> HexBytes:
204
204
def label_to_hash (label : str ) -> HexBytes :
205
205
label = normalize_name (label )
206
206
if "." in label :
207
- raise Web3ValueError (f"Cannot generate hash for label { label !r} with a '.'" )
207
+ raise ENSValueError (f"Cannot generate hash for label { label !r} with a '.'" )
208
208
return Web3 ().keccak (text = label )
209
209
210
210
@@ -269,7 +269,7 @@ def assert_signer_in_modifier_kwargs(modifier_kwargs: Any) -> ChecksumAddress:
269
269
270
270
_modifier_type , modifier_dict = dict (modifier_kwargs ).popitem ()
271
271
if "from" not in modifier_dict :
272
- raise Web3TypeError (ERR_MSG )
272
+ raise ENSTypeError (ERR_MSG )
273
273
274
274
return modifier_dict ["from" ]
275
275
You can’t perform that action at this time.
0 commit comments