Skip to content

Commit ce34259

Browse files
committed
Remove ENS check for mainnet
- ENS supports many chains now. We should remove the mainnet check.
1 parent 2bdb55e commit ce34259

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

tests/core/middleware/test_name_to_address_middleware.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
Web3,
88
)
99
from web3.exceptions import (
10-
InvalidAddress,
10+
NameNotFound,
1111
)
12-
from web3.middleware import ( # noqa: F401
13-
construct_fixture_middleware,
12+
from web3.middleware import (
1413
name_to_address_middleware,
1514
)
16-
from web3.middleware.names import async_name_to_address_middleware
15+
from web3.middleware.names import (
16+
async_name_to_address_middleware,
17+
)
1718
from web3.providers.eth_tester import (
1819
AsyncEthereumTesterProvider,
1920
EthereumTesterProvider,
@@ -49,24 +50,12 @@ def w3(_w3_setup, ens_mapped_address):
4950

5051

5152
def test_pass_name_resolver(w3, ens_mapped_address):
52-
return_chain_on_mainnet = construct_fixture_middleware(
53-
{
54-
"net_version": "1",
55-
}
56-
)
5753
known_account_balance = w3.eth.get_balance(ens_mapped_address)
58-
w3.middleware_onion.inject(return_chain_on_mainnet, layer=0)
5954
assert w3.eth.get_balance(NAME) == known_account_balance
6055

6156

6257
def test_fail_name_resolver(w3):
63-
return_chain_on_mainnet = construct_fixture_middleware(
64-
{
65-
"net_version": "2",
66-
}
67-
)
68-
w3.middleware_onion.inject(return_chain_on_mainnet, layer=0)
69-
with pytest.raises(InvalidAddress, match=r".*ethereum\.eth.*"):
58+
with pytest.raises(NameNotFound, match=r".*ethereum\.eth.*"):
7059
w3.eth.get_balance("ethereum.eth")
7160

7261

@@ -104,5 +93,5 @@ async def test_async_pass_name_resolver(async_w3, async_ens_mapped_address):
10493

10594
@pytest.mark.asyncio
10695
async def test_async_fail_name_resolver(async_w3):
107-
with pytest.raises(InvalidAddress, match=r".*ethereum\.eth.*"):
96+
with pytest.raises(NameNotFound, match=r".*ethereum\.eth.*"):
10897
await async_w3.eth.get_balance("ethereum.eth")

web3/_utils/normalizers.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,10 @@ def abi_ens_resolver(
218218
)
219219

220220
_ens = cast(ENS, w3.ens)
221-
net_version = int(w3.net.version) if hasattr(w3, "net") else None
222221
if _ens is None:
223222
raise InvalidAddress(
224223
f"Could not look up name {val!r} because ENS is" " set to None"
225224
)
226-
elif net_version != 1 and not isinstance(_ens, StaticENS):
227-
raise InvalidAddress(
228-
f"Could not look up name {val!r} because web3 is"
229-
" not connected to mainnet"
230-
)
231225
else:
232226
return type_str, validate_name_has_address(_ens, val)
233227
else:

0 commit comments

Comments
 (0)