diff --git a/ens/constants.py b/ens/constants.py index 78455f4e30..464a303fad 100644 --- a/ens/constants.py +++ b/ens/constants.py @@ -17,4 +17,4 @@ REVERSE_REGISTRAR_DOMAIN = 'addr.reverse' -ENS_MAINNET_ADDR = ChecksumAddress(HexAddress(HexStr('0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e'))) +ENS_PUBLIC_ADDR = ChecksumAddress(HexAddress(HexStr('0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e'))) diff --git a/ens/main.py b/ens/main.py index 1a8152e833..567d6a3137 100644 --- a/ens/main.py +++ b/ens/main.py @@ -24,7 +24,7 @@ from ens import abis from ens.constants import ( EMPTY_ADDR_HEX, - ENS_MAINNET_ADDR, + ENS_PUBLIC_ADDR, REVERSE_REGISTRAR_DOMAIN, ) from ens.exceptions import ( @@ -83,10 +83,11 @@ def __init__( :type provider: instance of `web3.providers.base.BaseProvider` :param hex-string addr: the address of the ENS registry on-chain. If not provided, ENS.py will default to the mainnet ENS registry address. + :raises UnknownNetwork: if network is unknown """ self.web3 = init_web3(provider) - ens_addr = addr if addr else ENS_MAINNET_ADDR + ens_addr = addr if addr else ENS_PUBLIC_ADDR self.ens = self.web3.eth.contract(abi=abis.ENS, address=ens_addr) self._resolverContract = self.web3.eth.contract(abi=abis.RESOLVER) diff --git a/ens/utils.py b/ens/utils.py index 08eb211b94..8f92aabf18 100644 --- a/ens/utils.py +++ b/ens/utils.py @@ -87,12 +87,20 @@ def init_web3(provider: 'BaseProvider'=cast('BaseProvider', default)) -> '_Web3' def customize_web3(w3: '_Web3') -> '_Web3': from web3.middleware import make_stalecheck_middleware + from web3.middleware import geth_poa_middleware w3.middleware_onion.remove('name_to_address') + w3.middleware_onion.add( make_stalecheck_middleware(ACCEPTABLE_STALE_HOURS * 3600), name='stalecheck', ) + + w3.middleware_onion.inject( + geth_poa_middleware, + layer=0, + ) + return w3 diff --git a/web3/middleware/stalecheck.py b/web3/middleware/stalecheck.py index b9117e2f70..38262500f6 100644 --- a/web3/middleware/stalecheck.py +++ b/web3/middleware/stalecheck.py @@ -22,6 +22,7 @@ SKIP_STALECHECK_FOR_METHODS = set([ 'eth_getBlockByNumber', + 'net_version', ])