From b1118b7030c8732bd5e9a73e85a002868d463da0 Mon Sep 17 00:00:00 2001 From: Janet Liang <56005637+janet-harmony@users.noreply.github.com> Date: Thu, 21 May 2020 05:02:27 -0700 Subject: [PATCH] [refactor] Move blockchain interaction methods out of rpc lib (#4) --- pyhmy/__init__.py | 11 ----------- pyhmy/{rpc => }/account.py | 16 ++++++++-------- pyhmy/{rpc => }/blockchain.py | 6 +++--- pyhmy/{rpc => }/staking.py | 3 +-- pyhmy/{rpc => }/transaction.py | 2 +- pyhmy/util.py | 2 +- tests/{rpc-pyhmy => sdk-pyhmy}/conftest.py | 0 tests/{rpc-pyhmy => sdk-pyhmy}/test_account.py | 0 .../{rpc-pyhmy => sdk-pyhmy}/test_blockchain.py | 0 tests/{rpc-pyhmy => sdk-pyhmy}/test_staking.py | 0 .../{rpc-pyhmy => sdk-pyhmy}/test_transaction.py | 0 11 files changed, 14 insertions(+), 26 deletions(-) rename pyhmy/{rpc => }/account.py (98%) rename pyhmy/{rpc => }/blockchain.py (99%) rename pyhmy/{rpc => }/staking.py (99%) rename pyhmy/{rpc => }/transaction.py (99%) rename tests/{rpc-pyhmy => sdk-pyhmy}/conftest.py (100%) rename tests/{rpc-pyhmy => sdk-pyhmy}/test_account.py (100%) rename tests/{rpc-pyhmy => sdk-pyhmy}/test_blockchain.py (100%) rename tests/{rpc-pyhmy => sdk-pyhmy}/test_staking.py (100%) rename tests/{rpc-pyhmy => sdk-pyhmy}/test_transaction.py (100%) diff --git a/pyhmy/__init__.py b/pyhmy/__init__.py index b548f78..5aefb14 100644 --- a/pyhmy/__init__.py +++ b/pyhmy/__init__.py @@ -3,13 +3,6 @@ import warnings from ._version import __version__ -from .rpc import ( - account, - blockchain, - staking, - transaction -) - from .util import ( Typgpy, get_gopath, @@ -18,10 +11,6 @@ from .util import ( json_load ) -from .logging import ( - ControlledLogger -) - if sys.version_info.major < 3: warnings.simplefilter("always", DeprecationWarning) warnings.warn( diff --git a/pyhmy/rpc/account.py b/pyhmy/account.py similarity index 98% rename from pyhmy/rpc/account.py rename to pyhmy/account.py index bfe3295..294660e 100644 --- a/pyhmy/rpc/account.py +++ b/pyhmy/account.py @@ -1,17 +1,17 @@ -from .request import ( +from .rpc.request import ( rpc_request ) -from .blockchain import ( - get_sharding_structure -) - -from .exceptions import ( +from .rpc.exceptions import ( RPCError, InvalidRPCReplyError, - JSONDecodeError, RequestsError, - RequestsTimeoutError + RequestsTimeoutError, + JSONDecodeError +) + +from .blockchain import ( + get_sharding_structure ) _default_endpoint = 'http://localhost:9500' diff --git a/pyhmy/rpc/blockchain.py b/pyhmy/blockchain.py similarity index 99% rename from pyhmy/rpc/blockchain.py rename to pyhmy/blockchain.py index ce35d95..318eaa1 100644 --- a/pyhmy/rpc/blockchain.py +++ b/pyhmy/blockchain.py @@ -1,9 +1,9 @@ -from .request import ( +from .rpc.request import ( rpc_request ) -from .exceptions import ( - InvalidRPCReplyError +from .rpc.exceptions import ( + InvalidRPCReplyError, ) _default_endpoint = 'http://localhost:9500' diff --git a/pyhmy/rpc/staking.py b/pyhmy/staking.py similarity index 99% rename from pyhmy/rpc/staking.py rename to pyhmy/staking.py index 8d1c224..026580c 100644 --- a/pyhmy/rpc/staking.py +++ b/pyhmy/staking.py @@ -1,8 +1,7 @@ -from .request import ( +from .rpc.request import ( rpc_request ) - _default_endpoint = 'http://localhost:9500' _default_timeout = 30 diff --git a/pyhmy/rpc/transaction.py b/pyhmy/transaction.py similarity index 99% rename from pyhmy/rpc/transaction.py rename to pyhmy/transaction.py index da2b047..e897764 100644 --- a/pyhmy/rpc/transaction.py +++ b/pyhmy/transaction.py @@ -1,4 +1,4 @@ -from .request import ( +from .rpc.request import ( rpc_request ) diff --git a/pyhmy/util.py b/pyhmy/util.py index c0762d1..41beb92 100644 --- a/pyhmy/util.py +++ b/pyhmy/util.py @@ -6,7 +6,7 @@ import datetime import requests -from .rpc.blockchain import ( +from .blockchain import ( get_latest_header ) diff --git a/tests/rpc-pyhmy/conftest.py b/tests/sdk-pyhmy/conftest.py similarity index 100% rename from tests/rpc-pyhmy/conftest.py rename to tests/sdk-pyhmy/conftest.py diff --git a/tests/rpc-pyhmy/test_account.py b/tests/sdk-pyhmy/test_account.py similarity index 100% rename from tests/rpc-pyhmy/test_account.py rename to tests/sdk-pyhmy/test_account.py diff --git a/tests/rpc-pyhmy/test_blockchain.py b/tests/sdk-pyhmy/test_blockchain.py similarity index 100% rename from tests/rpc-pyhmy/test_blockchain.py rename to tests/sdk-pyhmy/test_blockchain.py diff --git a/tests/rpc-pyhmy/test_staking.py b/tests/sdk-pyhmy/test_staking.py similarity index 100% rename from tests/rpc-pyhmy/test_staking.py rename to tests/sdk-pyhmy/test_staking.py diff --git a/tests/rpc-pyhmy/test_transaction.py b/tests/sdk-pyhmy/test_transaction.py similarity index 100% rename from tests/rpc-pyhmy/test_transaction.py rename to tests/sdk-pyhmy/test_transaction.py