Skip to content
Draft
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
4 changes: 2 additions & 2 deletions bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import warnings
from dataclasses import fields
from pathlib import Path
from typing import Coroutine, Optional, Union, Literal
from typing import Coroutine, Optional, Union

import numpy as np
import rich
Expand Down Expand Up @@ -93,7 +93,6 @@
subnets,
mechanisms as subnet_mechanisms,
)
from bittensor_cli.src.commands.wallets import SortByBalance
from bittensor_cli.version import __version__, __version_as_int__

try:
Expand Down Expand Up @@ -1343,6 +1342,7 @@ async def _run():
except Exception as e: # ensures we always exit cleanly
if not isinstance(e, (typer.Exit, RuntimeError)):
err_console.print(f"An unknown error has occurred: {e}")
traceback.print_exc()
if exception_occurred:
raise typer.Exit()

Expand Down
12 changes: 8 additions & 4 deletions bittensor_cli/src/bittensor/subtensor_interface.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import logging
import os
import time
from typing import Optional, Any, Union, TypedDict, Iterable
Expand Down Expand Up @@ -45,6 +46,8 @@
get_hotkey_pub_ss58,
)

logger = logging.getLogger("btcli")


class ParamWithTypes(TypedDict):
name: str # Name of the parameter.
Expand Down Expand Up @@ -113,6 +116,7 @@ def __init__(self, network, use_disk_cache: bool = False):
if (use_disk_cache or os.getenv("DISK_CACHE", "0") == "1")
else AsyncSubstrateInterface
)
logger.debug(f"Using substrate class {substrate_class.__name__}")
self.substrate = substrate_class(
url=self.chain_endpoint,
ss58_format=SS58_FORMAT,
Expand Down Expand Up @@ -438,11 +442,11 @@ async def get_total_stake_for_coldkey(

:return: {address: Balance objects}
"""
sub_stakes = await self.get_stake_for_coldkeys(
list(ss58_addresses), block_hash=block_hash
sub_stakes, dynamic_info = await asyncio.gather(
self.get_stake_for_coldkeys(list(ss58_addresses), block_hash=block_hash),
# Token pricing info
self.all_subnets(block_hash=block_hash),
)
# Token pricing info
dynamic_info = await self.all_subnets()

results = {}
for ss58, stake_info_list in sub_stakes.items():
Expand Down
6 changes: 4 additions & 2 deletions bittensor_cli/src/commands/wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ async def wallet_balance(
str(total_free_balance + total_staked_balance),
)
console.print(Padding(table, (0, 0, 0, 4)))
await subtensor.substrate.close()
if json_output:
output_balances = {
key: {
Expand Down Expand Up @@ -2175,7 +2174,10 @@ async def find_coldkey_swap_extrinsic(
):
console.print("Querying archive node for coldkey swap events...")
await subtensor.substrate.close()
subtensor = SubtensorInterface("archive")
subtensor.substrate.chain_endpoint = Constants.archive_entrypoint
subtensor.substrate.url = Constants.archive_entrypoint
subtensor.substrate.initialized = False
await subtensor.substrate.initialize()

block_hashes = await asyncio.gather(
*[
Expand Down