diff --git a/web3/eth.py b/web3/eth.py index 195fdd056b..29cec0ca5c 100644 --- a/web3/eth.py +++ b/web3/eth.py @@ -24,6 +24,7 @@ ) from web3.utils.decorators import ( deprecated_for, + deprecated_in_v5, ) from web3.utils.empty import ( empty, @@ -374,6 +375,7 @@ def contract(self, def setContractFactory(self, contractFactory): self.defaultContractFactory = contractFactory + @deprecated_in_v5 def getCompilers(self): return self.web3.manager.request_blocking("eth_getCompilers", []) diff --git a/web3/net.py b/web3/net.py index dddca64179..b5f681a026 100644 --- a/web3/net.py +++ b/web3/net.py @@ -1,6 +1,9 @@ from web3.module import ( Module, ) +from web3.utils.decorators import ( + deprecated_in_v5, +) class Net(Module): @@ -13,6 +16,7 @@ def peerCount(self): return self.web3.manager.request_blocking("net_peerCount", []) @property + @deprecated_in_v5 def chainId(self): return None diff --git a/web3/utils/decorators.py b/web3/utils/decorators.py index 2764fbd43c..2b6dd91abb 100644 --- a/web3/utils/decorators.py +++ b/web3/utils/decorators.py @@ -57,3 +57,19 @@ def wrapper(*args, **kwargs): return to_wrap(*args, **kwargs) return wrapper return decorator + + +def deprecated_in_v5(f): + ''' + Decorate a function to be deprecated in v5 + + @deprecated_for_v5 + def toAscii(arg): + ... + ''' + def decorator(to_wrap): + warnings.warn( + "%s to be deprecated in v5, according to EIP 1474" % (f.__name__), + category=DeprecationWarning, + stacklevel=2) + return decorator diff --git a/web3/utils/module_testing/eth_module.py b/web3/utils/module_testing/eth_module.py index e0d144eecd..1af838c501 100644 --- a/web3/utils/module_testing/eth_module.py +++ b/web3/utils/module_testing/eth_module.py @@ -588,8 +588,8 @@ def test_eth_getUncleByBlockNumberAndIndex(self, web3): pass def test_eth_getCompilers(self, web3): - # TODO: do we want to test this? - pass + with pytest.warns(DeprecationWarning): + web3.eth.getCompilers() def test_eth_compileSolidity(self, web3): # TODO: do we want to test this? diff --git a/web3/utils/module_testing/net_module.py b/web3/utils/module_testing/net_module.py index 3ce095a8e8..71f7573ecb 100644 --- a/web3/utils/module_testing/net_module.py +++ b/web3/utils/module_testing/net_module.py @@ -1,3 +1,5 @@ +import pytest + from eth_utils import ( is_boolean, is_integer, @@ -21,3 +23,7 @@ def test_net_peerCount(self, web3): peer_count = web3.net.peerCount assert is_integer(peer_count) + + def test_net_chainId(self, web3): + with pytest.warns(DeprecationWarning): + web3.net.chainId