Skip to content

Commit

Permalink
Merge pull request #788 from carver/stable-eth-account
Browse files Browse the repository at this point in the history
Remove audit warnings about eth-account
  • Loading branch information
carver authored Apr 25, 2018
2 parents 460ad33 + a0e4974 commit 87e32b1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 68 deletions.
13 changes: 1 addition & 12 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,7 @@ def _wait_for_transaction(web3, txn_hash, timeout=120):
@pytest.fixture()
def web3():
provider = EthereumTesterProvider()
w3 = Web3(provider)

# Delete this whole block after eth-account has passed security audit
try:
w3.eth.account
except AttributeError:
pass
else:
raise AssertionError("Unaudited features must be disabled by default")
w3.eth.enable_unaudited_features()

return w3
return Web3(provider)


@pytest.fixture(autouse=True)
Expand Down
41 changes: 0 additions & 41 deletions docs/web3.eth.account.rst
Original file line number Diff line number Diff line change
@@ -1,47 +1,6 @@
Working with Local Private Keys
==========================================

Not Acceptable for Production
---------------------------------

.. WARNING::
**Do not use** this module in production. It is still in beta. A security audit is pending.

Now is a great time to get familiar with the API, and test out writing
code that uses some of the great upcoming features.

By default, access to this module has been turned off in the stable version of Web3.py:

.. code-block:: python
>>> from web3.auto import w3
>>> w3.eth.account
...
AttributeError: This feature is disabled, pending security audit. ...
In order to access these features, you can either:

1. Turn it on inside web3 with:

.. code-block:: python
>>> from web3.auto import w3
>>> w3.eth.enable_unaudited_features()
>>> w3.eth.account
2. Load the beta version of :class:`eth_account.Account <eth_account.account.Account>`
directly, with:

.. code-block:: python
>>> from eth_account import Account
>>> account = Account()
.. testsetup::

from web3.auto import w3
w3.eth.enable_unaudited_features()

Local vs Hosted Nodes
---------------------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
install_requires=[
"cytoolz>=0.9.0,<1.0.0",
"eth-abi>=1.0.0,<2",
"eth-account==0.2.0-alpha.0",
"eth-account>=0.2.1,<0.3.0",
"eth-utils>=1.0.1,<2.0.0",
"hexbytes>=0.1.0,<1.0.0",
"lru-dict>=1.1.6,<2.0.0",
Expand Down
20 changes: 6 additions & 14 deletions web3/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
from web3.utils.blocks import (
select_method_for_block_identifier,
)
from web3.utils.decorators import (
deprecated_for,
)
from web3.utils.empty import (
empty,
)
Expand All @@ -48,27 +51,16 @@


class Eth(Module):
_account = None
account = Account()
defaultAccount = empty
defaultBlock = "latest"
defaultContractFactory = Contract
iban = Iban
gasPriceStrategy = None

@property
def account(self):
if self._account is not None:
return self._account
else:
raise AttributeError(
"This feature is disabled, pending security audit. "
"If you want to use unaudited code dealing with private keys, "
"despite the risks, you can run `w3.eth.enable_unaudited_features()` "
"and try again."
)

@deprecated_for("doing nothing at all")
def enable_unaudited_features(self):
self._account = Account()
pass

def namereg(self):
raise NotImplementedError()
Expand Down

0 comments on commit 87e32b1

Please sign in to comment.