Skip to content

Commit 85bfd0a

Browse files
committed
Remove backwards-compatibility for ENS mainnet requirement, let NameNotFound raise.
1 parent aefb880 commit 85bfd0a

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

Diff for: tests/core/middleware/test_name_to_address_middleware.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
Web3,
88
)
99
from web3.exceptions import (
10-
InvalidAddress,
1110
NameNotFound,
1211
)
1312
from web3.middleware import (
@@ -95,7 +94,7 @@ def test_pass_name_resolver_send_transaction_dict_args(
9594

9695

9796
def test_fail_name_resolver(w3):
98-
with pytest.raises(InvalidAddress, match=r".*ethereum\.eth.*"):
97+
with pytest.raises(NameNotFound, match=r".*ethereum\.eth.*"):
9998
w3.eth.get_balance("ethereum.eth")
10099

101100

Diff for: web3/_utils/normalizers.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
text_if_str,
5050
)
5151
from web3._utils.ens import (
52-
StaticENS,
5352
async_validate_name_has_address,
5453
is_ens_name,
5554
validate_name_has_address,
@@ -60,7 +59,6 @@
6059
)
6160
from web3.exceptions import (
6261
InvalidAddress,
63-
NameNotFound,
6462
Web3ValueError,
6563
)
6664

@@ -224,15 +222,7 @@ def abi_ens_resolver(
224222
f"Could not look up name {val!r} because ENS is set to None"
225223
)
226224
else:
227-
try:
228-
return type_str, validate_name_has_address(_ens, val)
229-
except NameNotFound as e:
230-
# TODO: This try/except is to keep backwards compatibility when we
231-
# removed the mainnet requirement. Remove this in web3.py v7 and allow
232-
# NameNotFound to raise.
233-
if not isinstance(_ens, StaticENS):
234-
raise InvalidAddress(f"{e}")
235-
raise e
225+
return type_str, validate_name_has_address(_ens, val)
236226
else:
237227
return type_str, val
238228

0 commit comments

Comments
 (0)