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 048826f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 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
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(arg):
'''
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 048826f

Please sign in to comment.