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

Remove audit warnings about eth-account #788

Merged
merged 1 commit into from
Apr 25, 2018
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
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