Skip to content

Commit

Permalink
Add deprecation warning to jsonrpc endpoints dropped in EIP 1474
Browse files Browse the repository at this point in the history
  • Loading branch information
njgheorghita committed Mar 12, 2019
1 parent 7a3d44d commit bd75fa1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
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" % (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

0 comments on commit bd75fa1

Please sign in to comment.