Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/arkiv/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
27 changes: 1 addition & 26 deletions src/arkiv/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 7 additions & 1 deletion src/arkiv/module_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down
2 changes: 1 addition & 1 deletion src/arkiv/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
6 changes: 3 additions & 3 deletions src/arkiv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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))

Expand Down
Loading