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 11, 2019
1 parent 7a3d44d commit 54e685d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
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
5 changes: 4 additions & 1 deletion web3/net.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from web3.module import (
Module,
)

from web3.utils.decorators import (
deprecated_in_v5,
)

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

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

Expand Down
20 changes: 20 additions & 0 deletions web3/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,23 @@ def wrapper(*args, **kwargs):
return to_wrap(*args, **kwargs)
return wrapper
return decorator


def deprecated_in_v5():
'''
Decorate a function to be deprecated in v5
@deprecated_for_v5()
def toAscii(arg):
...
'''
def decorator(to_wrap):
@functools.wraps(to_wrap)
def wrapper(*args, **kwargs):
warnings.warn(
"%s to be deprecated in v5" % (to_wrap.__name__),
category=DeprecationWarning,
stacklevel=2)
return to_wrap(*args, **kwargs)
return wrapper
return decorator

0 comments on commit 54e685d

Please sign in to comment.