Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation warning to jsonrpc endpoints dropped in EIP 1474 #1271

Merged
merged 1 commit into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions web3/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
)
from web3.utils.decorators import (
deprecated_for,
deprecated_in_v5,
)
from web3.utils.empty import (
empty,
Expand Down Expand Up @@ -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", [])

Expand Down
4 changes: 4 additions & 0 deletions web3/net.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from web3.module import (
Module,
)
from web3.utils.decorators import (
deprecated_in_v5,
)


class Net(Module):
Expand All @@ -13,6 +16,7 @@ def peerCount(self):
return self.web3.manager.request_blocking("net_peerCount", [])

@property
@deprecated_in_v5
def chainId(self):
return None

Expand Down
16 changes: 16 additions & 0 deletions web3/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions web3/utils/module_testing/eth_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
6 changes: 6 additions & 0 deletions web3/utils/module_testing/net_module.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from eth_utils import (
is_boolean,
is_integer,
Expand All @@ -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