diff --git a/src/arkiv/client_base.py b/src/arkiv/client_base.py index 90c2a99..08cff68 100644 --- a/src/arkiv/client_base.py +++ b/src/arkiv/client_base.py @@ -6,6 +6,7 @@ from typing import TYPE_CHECKING, Any, Literal from eth_account.signers.local import LocalAccount +from web3.eth import AsyncEth, Eth from web3.providers.async_base import AsyncBaseProvider from web3.providers.base import BaseProvider @@ -34,7 +35,7 @@ class ArkivBase: ACCOUNT_NAME_DEFAULT = "default" # These will be set by the Web3/AsyncWeb3 parent class - eth: Any + eth: Eth | AsyncEth from_wei: Any def __init__(self) -> None: diff --git a/src/arkiv/contract.py b/src/arkiv/contract.py index 230fa11..cd8fdec 100644 --- a/src/arkiv/contract.py +++ b/src/arkiv/contract.py @@ -157,33 +157,8 @@ FUNCTIONS_ABI: dict[str, Method[Any]] = { - "get_storage_value": Method( - json_rpc_method=RPCEndpoint("golembase_getStorageValue"), - mungers=[default_root_munger], - ), - "get_entity_metadata": Method( - json_rpc_method=RPCEndpoint("golembase_getEntityMetaData"), - mungers=[default_root_munger], - ), - "get_entities_to_expire_at_block": Method( - json_rpc_method=RPCEndpoint("golembase_getEntitiesToExpireAtBlock"), - mungers=[default_root_munger], - ), "get_entity_count": Method( - json_rpc_method=RPCEndpoint("golembase_getEntityCount"), - mungers=[default_root_munger], - ), - "get_all_entity_keys": Method( - json_rpc_method=RPCEndpoint("golembase_getAllEntityKeys"), - mungers=[default_root_munger], - ), - "get_entities_of_owner": Method( - json_rpc_method=RPCEndpoint("golembase_getEntitiesOfOwner"), - mungers=[default_root_munger], - ), - "query_entities": Method( - # TODO figure out why endpoint has the prefix "golembase_" - json_rpc_method=RPCEndpoint("golembase_queryEntities"), + json_rpc_method=RPCEndpoint("arkiv_getEntityCount"), mungers=[default_root_munger], ), "query": Method( diff --git a/src/arkiv/module_base.py b/src/arkiv/module_base.py index ae3874f..b47854c 100644 --- a/src/arkiv/module_base.py +++ b/src/arkiv/module_base.py @@ -60,7 +60,13 @@ logger = logging.getLogger(__name__) # Generic type variable for the client (Arkiv or AsyncArkiv) -ClientT = TypeVar("ClientT") +if TYPE_CHECKING: + from arkiv.client import Arkiv, AsyncArkiv + + ClientT = TypeVar("ClientT", Arkiv, AsyncArkiv) +else: + # runtime: don't import arkiv.client (avoids circular import) + ClientT = TypeVar("ClientT") class ArkivModuleBase(Generic[ClientT]): diff --git a/src/arkiv/types.py b/src/arkiv/types.py index 8425c87..ba537b4 100644 --- a/src/arkiv/types.py +++ b/src/arkiv/types.py @@ -393,7 +393,7 @@ class TransactionReceipt: # Low level attributes for RLP encoding StringAttributesRlp = NewType("StringAttributesRlp", list[tuple[str, str]]) -NumericAttributesRlp = NewType("NumericAttributesRlp", list[tuple[str, int]]) +NumericAttributesRlp = NewType("NumericAttributesRlp", list[tuple[str, HexStr]]) # Low level attributes for entity decoding StringAttributes = NewType("StringAttributes", AttributeDict[str, str]) diff --git a/src/arkiv/utils.py b/src/arkiv/utils.py index 7f16f83..dc7c1e7 100644 --- a/src/arkiv/utils.py +++ b/src/arkiv/utils.py @@ -338,7 +338,7 @@ def to_rpc_query_options( } if options.at_block is not None: - rpc_query_options["atBlock"] = options.at_block + rpc_query_options["atBlock"] = Web3.to_hex(options.at_block) else: rpc_query_options["atBlock"] = None @@ -349,7 +349,7 @@ def to_rpc_query_options( effective_page_size = min(effective_page_size, options.max_results) if effective_page_size is not None: - rpc_query_options["resultsPerPage"] = effective_page_size + rpc_query_options["resultsPerPage"] = Web3.to_hex(effective_page_size) if options.cursor is not None: rpc_query_options["cursor"] = options.cursor @@ -819,7 +819,7 @@ def split_attributes( f"Numeric attributes must be non-negative but found '{value}' for key '{key}'" ) - numeric_attributes.append((key, value)) + numeric_attributes.append((key, Web3.to_hex(value))) else: string_attributes.append((key, value))