Skip to content
Merged
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
2 changes: 2 additions & 0 deletions bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,10 +1135,12 @@ def wallet_overview(
),
sort_by: Optional[str] = typer.Option(
None,
"--sort-by", "--sort_by",
help="Sort the hotkeys by the specified column title. For example: name, uid, axon.",
),
sort_order: Optional[str] = typer.Option(
None,
"--sort-order", "--sort_order",
help="Sort the hotkeys in the specified order (ascending/asc or descending/desc/reverse).",
),
include_hotkeys: str = typer.Option(
Expand Down
27 changes: 13 additions & 14 deletions bittensor_cli/src/bittensor/async_substrate_interface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import json
import random
from collections import defaultdict
from dataclasses import dataclass
from hashlib import blake2b
Expand Down Expand Up @@ -897,6 +898,7 @@ async def init_runtime(

:returns: Runtime object
"""

async def get_runtime(block_hash, block_id) -> Runtime:
# Check if runtime state already set to current block
if (block_hash and block_hash == self.last_block_hash) or (
Expand Down Expand Up @@ -1693,9 +1695,10 @@ async def rpc_request(
"""
block_hash = await self._get_current_block_hash(block_hash, reuse_block_hash)
params = params or []
payload_id = f"{method}{random.randint(0, 7000)}"
payloads = [
self.make_payload(
"rpc_request",
payload_id,
method,
params + [block_hash] if block_hash else params,
)
Expand All @@ -1707,14 +1710,14 @@ async def rpc_request(
self.type_registry,
)
result = await self._make_rpc_request(payloads, runtime=runtime)
if "error" in result["rpc_request"][0]:
if "error" in result[payload_id][0]:
raise SubstrateRequestException(
result["rpc_request"][0]["error"]["message"]
)
if "result" in result["rpc_request"][0]:
return result["rpc_request"][0]
if "result" in result[payload_id][0]:
return result[payload_id][0]
else:
raise SubstrateRequestException(result["rpc_request"][0])
raise SubstrateRequestException(result[payload_id][0])

async def get_block_hash(self, block_id: int) -> str:
return (await self.rpc_request("chain_getBlockHash", [block_id]))["result"]
Expand Down Expand Up @@ -2193,20 +2196,16 @@ async def runtime_call(
params = {}

try:
runtime_call_def = self.runtime_config.type_registry["runtime_api"][
api
]["methods"][method]
runtime_call_def = self.runtime_config.type_registry["runtime_api"][api][
"methods"
][method]
runtime_api_types = self.runtime_config.type_registry["runtime_api"][
api
].get("types", {})
except KeyError:
raise ValueError(
f"Runtime API Call '{api}.{method}' not found in registry"
)
raise ValueError(f"Runtime API Call '{api}.{method}' not found in registry")

if isinstance(params, list) and len(params) != len(
runtime_call_def["params"]
):
if isinstance(params, list) and len(params) != len(runtime_call_def["params"]):
raise ValueError(
f"Number of parameter provided ({len(params)}) does not "
f"match definition {len(runtime_call_def['params'])}"
Expand Down