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
5 changes: 4 additions & 1 deletion bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import curses
import os.path
import re
import ssl
import sys
from pathlib import Path
from typing import Coroutine, Optional
Expand Down Expand Up @@ -756,16 +757,18 @@ async def _run():
else:
result = await cmd
return result
except ConnectionRefusedError:
except (ConnectionRefusedError, ssl.SSLError):
err_console.print(
f"Unable to connect to the chain: {self.not_subtensor}"
)
asyncio.create_task(cmd).cancel()
raise typer.Exit()
except ConnectionClosed:
asyncio.create_task(cmd).cancel()
raise typer.Exit()
except SubstrateRequestException as e:
err_console.print(str(e))
asyncio.create_task(cmd).cancel()
raise typer.Exit()

if sys.version_info < (3, 10):
Expand Down
21 changes: 7 additions & 14 deletions bittensor_cli/src/bittensor/async_substrate_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,11 +845,7 @@ async def _get_current_block_hash(
async def load_registry(self):
metadata_rpc_result = await self.rpc_request(
"state_call",
[
"Metadata_metadata_at_version",
self.metadata_version_hex,
await self.get_chain_finalised_head(),
],
["Metadata_metadata_at_version", self.metadata_version_hex],
)
metadata_option_hex_str = metadata_rpc_result["result"]
metadata_option_bytes = bytes.fromhex(metadata_option_hex_str[2:])
Expand Down Expand Up @@ -897,6 +893,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 @@ -2193,20 +2190,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