From a598a8f2e20d4a1e34de2e4a616a379d645522a1 Mon Sep 17 00:00:00 2001 From: "F. Eugene Aumson" Date: Thu, 8 Aug 2019 07:41:53 -0400 Subject: [PATCH] contract_wrappers.py: don't auto-import wrappers This was discovered while minimizing CircleCI steps to dianose a problem with running the Launch Kit Backend in CircleCI. These classes should be imported via the zero_ex.contract_wrappers.exchange and zero_ex.contract_wrappers.erc20_token modules, respectively. We permitted importing them from just zero_ex.contract_wrappers back when they were the only wrappers we had, but now that we have so many different contracts being wrapped, this is just another list to keep manually updated (which, obviously is error prone, since it slipped through the cracks already), so it's better to just not support this type of import. --- python-packages/contract_wrappers/src/index.rst | 10 +++++----- .../src/zero_ex/contract_wrappers/__init__.py | 6 ++---- .../contract_wrappers/test/test_erc20_wrapper.py | 3 ++- .../contract_wrappers/test/test_exchange_wrapper.py | 3 ++- .../sra_client/src/zero_ex/sra_client/__init__.py | 3 ++- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/python-packages/contract_wrappers/src/index.rst b/python-packages/contract_wrappers/src/index.rst index 4112445962..20e8a2f4f8 100644 --- a/python-packages/contract_wrappers/src/index.rst +++ b/python-packages/contract_wrappers/src/index.rst @@ -9,18 +9,18 @@ Python zero_ex.contract_wrappers :members: -zero_ex.contract_wrappers.Exchange +zero_ex.contract_wrappers.exchange ================================== -.. autoclass:: zero_ex.contract_wrappers.Exchange +.. automodule:: zero_ex.contract_wrappers.exchange :members: :special-members: -zero_ex.contract_wrappers.ERC20Token -==================================== +zero_ex.contract_wrappers.erc20_token +===================================== -.. autoclass:: zero_ex.contract_wrappers.ERC20Token +.. automodule:: zero_ex.contract_wrappers.erc20_token :members: :special-members: diff --git a/python-packages/contract_wrappers/src/zero_ex/contract_wrappers/__init__.py b/python-packages/contract_wrappers/src/zero_ex/contract_wrappers/__init__.py index 208187869a..243d685ee1 100644 --- a/python-packages/contract_wrappers/src/zero_ex/contract_wrappers/__init__.py +++ b/python-packages/contract_wrappers/src/zero_ex/contract_wrappers/__init__.py @@ -90,7 +90,7 @@ we need to tell the WETH token contract to let the 0x contracts transfer our balance: ->>> from zero_ex.contract_wrappers import ERC20Token +>>> from zero_ex.contract_wrappers.erc20_token import ERC20Token >>> zrx_token = ERC20Token( ... provider=ganache, ... contract_address=NETWORK_TO_ADDRESSES[NetworkId.GANACHE].zrx_token, @@ -161,7 +161,7 @@ fill. This example fills the order completely, but partial fills are possible too. ->>> from zero_ex.contract_wrappers import Exchange +>>> from zero_ex.contract_wrappers.exchange import Exchange >>> exchange = Exchange( ... provider=ganache, ... contract_address=NETWORK_TO_ADDRESSES[NetworkId.GANACHE].exchange, @@ -324,5 +324,3 @@ """ from .tx_params import TxParams -from .erc20_token import ERC20Token -from .exchange import Exchange diff --git a/python-packages/contract_wrappers/test/test_erc20_wrapper.py b/python-packages/contract_wrappers/test/test_erc20_wrapper.py index 7f3d42fb2b..da80356ed0 100644 --- a/python-packages/contract_wrappers/test/test_erc20_wrapper.py +++ b/python-packages/contract_wrappers/test/test_erc20_wrapper.py @@ -5,7 +5,8 @@ import pytest from zero_ex.contract_addresses import NETWORK_TO_ADDRESSES, NetworkId -from zero_ex.contract_wrappers import ERC20Token, TxParams +from zero_ex.contract_wrappers import TxParams +from zero_ex.contract_wrappers.erc20_token import ERC20Token MAX_ALLOWANCE = int("{:.0f}".format(Decimal(2) ** 256 - 1)) diff --git a/python-packages/contract_wrappers/test/test_exchange_wrapper.py b/python-packages/contract_wrappers/test/test_exchange_wrapper.py index 4f2b70a079..271525ba75 100644 --- a/python-packages/contract_wrappers/test/test_exchange_wrapper.py +++ b/python-packages/contract_wrappers/test/test_exchange_wrapper.py @@ -6,7 +6,8 @@ from eth_utils import remove_0x_prefix from zero_ex.contract_addresses import NETWORK_TO_ADDRESSES, NetworkId -from zero_ex.contract_wrappers import Exchange, TxParams +from zero_ex.contract_wrappers import TxParams +from zero_ex.contract_wrappers.exchange import Exchange from zero_ex.contract_wrappers.exchange.types import Order from zero_ex.json_schemas import assert_valid from zero_ex.order_utils import generate_order_hash_hex, sign_hash_to_bytes diff --git a/python-packages/sra_client/src/zero_ex/sra_client/__init__.py b/python-packages/sra_client/src/zero_ex/sra_client/__init__.py index a88b69cf6e..d439f0016c 100644 --- a/python-packages/sra_client/src/zero_ex/sra_client/__init__.py +++ b/python-packages/sra_client/src/zero_ex/sra_client/__init__.py @@ -315,7 +315,8 @@ Recall that in a previous example we selected a specific order from the order book. Now let's have the taker fill it: ->>> from zero_ex.contract_wrappers import Exchange, TxParams +>>> from zero_ex.contract_wrappers import TxParams +>>> from zero_ex.contract_wrappers.exchange import Exchange >>> from zero_ex.order_utils import Order >>> exchange = Exchange( ... provider=eth_node,