diff --git a/python/wax/_private/api/api_caller.py b/python/wax/_private/api/api_caller.py index a1a448025aad5a758da5348329aa86f1d60abebb..b37541da07cbeb9abda5be394bb098fed05aac02 100644 --- a/python/wax/_private/api/api_caller.py +++ b/python/wax/_private/api/api_caller.py @@ -4,9 +4,7 @@ import atexit from functools import partial from typing import TYPE_CHECKING, Any, ClassVar -from beekeepy import Settings from beekeepy.handle.remote import AbstractAsyncHandle, AsyncBatchHandle, RemoteHandleSettings -from wax.helpy._handles.hived.common_helpers import HiveHandleCommonHelpers from wax.interfaces import ApiCollectionT if TYPE_CHECKING: @@ -23,13 +21,13 @@ def api_collection_factory(api_collection: ApiCollectionT, owner: AsyncSendable) return api_collection -class WaxApiCaller(AbstractAsyncHandle[RemoteHandleSettings, ApiCollectionT], HiveHandleCommonHelpers): # type: ignore[type-var] +class WaxApiCaller(AbstractAsyncHandle[RemoteHandleSettings, ApiCollectionT]): # type: ignore[type-var] _INSTANCES: ClassVar[set[WaxApiCaller[Any]]] = set() def __init__(self, api_collection: ApiCollectionT, endpoint_url: HttpUrl) -> None: self._api_collection = api_collection # assigned here because `_constuct_api` method # is called in the constructor of the parent class - settings = Settings() + settings = RemoteHandleSettings() settings.http_endpoint = endpoint_url super().__init__(settings=settings) self._INSTANCES.add(self) @@ -57,7 +55,7 @@ class WaxApiCaller(AbstractAsyncHandle[RemoteHandleSettings, ApiCollectionT], Hi return api_collection_factory(self._api_collection, self) def _target_service(self) -> str: - return self._hived_target_service_name() + return "wax_api_caller" def _cleanup_instances() -> None: diff --git a/python/wax/_private/base_api.py b/python/wax/_private/base_api.py index 60beae3e3f95338c3d8c69ad1cbb9f61ff9e47c9..d85ea0227e70b49f19c629117879799291b8da2e 100644 --- a/python/wax/_private/base_api.py +++ b/python/wax/_private/base_api.py @@ -48,7 +48,7 @@ from wax.cpp_python_bridge import ( # type: ignore[attr-defined] validate_operation, validate_proto_operation, ) -from wax.interfaces import ChainConfig, IWaxBaseInterface, JsonTransaction, ProtoTransaction, TTimestamp +from wax.interfaces import ChainConfig, IWaxBaseInterface, TTimestamp from wax.models.asset import ( AssetFactory, AssetName, @@ -64,6 +64,7 @@ if TYPE_CHECKING: from wax.interfaces import ITransaction from wax.models.basic import AccountName, ChainId, PublicKey, SigDigest, Signature from wax.models.operations import Operation + from wax.transaction_type_aliases import JsonTransaction, ProtoTransaction class WaxBaseApi(IWaxBaseInterface): diff --git a/python/wax/_private/transaction.py b/python/wax/_private/transaction.py index 616d3d813bb8cd2089b3547c686f9eb6c5643abe..937fed1951793cbc2bab05c65c9709fbf6c6183c 100644 --- a/python/wax/_private/transaction.py +++ b/python/wax/_private/transaction.py @@ -34,13 +34,13 @@ from wax.cpp_python_bridge import ( # type: ignore[attr-defined] tx_to_json, tx_validate, ) -from wax.interfaces import ITransaction, JsonTransaction, ProtoTransaction -from wax.proto.transaction import transaction as proto_transaction +from wax.interfaces import ITransaction +from wax.transaction_type_aliases import JsonTransaction, ProtoTransaction, proto_transaction if TYPE_CHECKING: from datetime import timedelta - from beekeepy import AsyncUnlockedWallet + from beekeepy._interface.abc import AsyncUnlockedWallet from wax import IWaxBaseInterface from wax.models.basic import AccountName, Hex, PublicKey, SigDigest, Signature, TransactionId from wax.models.operations import WaxMetaOperation diff --git a/python/wax/interfaces.py b/python/wax/interfaces.py index ffc273837374ee31b344aa3c04e65aebe7e170cc..8795132b1e58ae21c3e5c526d924b5a22193090c 100644 --- a/python/wax/interfaces.py +++ b/python/wax/interfaces.py @@ -8,12 +8,11 @@ from typing import TYPE_CHECKING, Any, Generic, TypeAlias from typing_extensions import Self, TypeVar from wax.api.collection import WaxApiCollection -from wax.proto.transaction import transaction as proto_transaction if TYPE_CHECKING: from decimal import Decimal - from beekeepy import AsyncUnlockedWallet + from beekeepy._interface.abc import AsyncUnlockedWallet from beekeepy.interfaces import HttpUrl from wax.models.asset import ( AssetFactory, @@ -26,12 +25,8 @@ if TYPE_CHECKING: from wax.models.basic import AccountName, ChainId, Hex, PublicKey, SigDigest, Signature, TransactionId from wax.models.key_data import IBrainKeyData, IPrivateKeyData from wax.models.operations import Operation, WaxMetaOperation + from wax.transaction_type_aliases import JsonTransaction, ProtoTransaction - -ProtoTransaction: TypeAlias = proto_transaction -"""Type alias for a transaction in proto format.""" -JsonTransaction: TypeAlias = str -"""Type alias for a transaction in JSON format, which is used in Hive API calls.""" TTimestamp: TypeAlias = datetime | timedelta """TTimestamp is a type alias for a timestamp that can be either a datetime object or a timedelta object.""" diff --git a/python/wax/transaction_type_aliases.py b/python/wax/transaction_type_aliases.py new file mode 100644 index 0000000000000000000000000000000000000000..653af9ab977d64237e5c473530912f0edabd3de2 --- /dev/null +++ b/python/wax/transaction_type_aliases.py @@ -0,0 +1,16 @@ +from __future__ import annotations + +from typing import TypeAlias + +from wax.proto.transaction import transaction as proto_transaction + +ProtoTransaction: TypeAlias = proto_transaction +"""Type alias for a transaction in proto format.""" +JsonTransaction: TypeAlias = str +"""Type alias for a transaction in JSON format, which is used in Hive API calls.""" + +__all__ = [ + "JsonTransaction", + "proto_transaction", + "ProtoTransaction", +] diff --git a/python/wax/wax_factory.py b/python/wax/wax_factory.py index 82efe7e7aab183980a553fc35b35711a5da25d18..0befadf698b988c1ddec97aa8dc0d346091c6ec4 100644 --- a/python/wax/wax_factory.py +++ b/python/wax/wax_factory.py @@ -2,16 +2,16 @@ from __future__ import annotations from typing import TYPE_CHECKING -from wax._private.base_api import WaxBaseApi -from wax._private.chain_api import HiveChainApi -from wax.wax_options import WaxChainOptions, WaxOptions - if TYPE_CHECKING: from wax.interfaces import IHiveChainInterface, IWaxBaseInterface + from wax.wax_options import WaxChainOptions, WaxOptions def create_wax_foundation(options: WaxOptions | None = None) -> IWaxBaseInterface: """Factory function to provide wax base interface functionality.""" + from wax._private.base_api import WaxBaseApi + from wax.wax_options import WaxOptions + chain_id = options.chain_id if options is not None else WaxOptions().chain_id return WaxBaseApi(chain_id, _private=True) @@ -19,6 +19,9 @@ def create_wax_foundation(options: WaxOptions | None = None) -> IWaxBaseInterfac def create_hive_chain(options: WaxChainOptions | None = None) -> IHiveChainInterface: """Factory function to provide hive chain interface functionality.""" + from wax._private.chain_api import HiveChainApi + from wax.wax_options import WaxChainOptions + options = options if options is not None else WaxChainOptions() chain_id = options.chain_id endpoint_url = options.endpoint_url