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
9 changes: 6 additions & 3 deletions bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4067,7 +4067,8 @@ def stake_swap(
"""
self.verbosity_handler(quiet, verbose, json_output)
console.print(
"[dim]This command moves stake from one subnet to another subnet while keeping the same coldkey-hotkey pair.[/dim]"
"[dim]This command moves stake from one subnet to another subnet while keeping "
"the same coldkey-hotkey pair.[/dim]"
)

wallet = self.wallet_ask(
Expand Down Expand Up @@ -4222,7 +4223,8 @@ def stake_set_children(
proportions = list_prompt(
proportions,
float,
"Enter comma-separated proportions equal to the number of children (sum not exceeding a total of 1.0)",
"Enter comma-separated proportions equal to the number of children "
"(sum not exceeding a total of 1.0)",
)

if len(proportions) != len(children):
Expand Down Expand Up @@ -4340,7 +4342,8 @@ def stake_childkey_take(
None,
"--take",
"-t",
help="Use to set the take value for your child hotkey. When not used, the command will fetch the current take value.",
help="Use to set the take value for your child hotkey. When not used, the command will fetch the current "
"take value.",
prompt=False,
),
wait_for_inclusion: bool = Options.wait_for_inclusion,
Expand Down
8 changes: 6 additions & 2 deletions bittensor_cli/src/bittensor/chain_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,9 @@ def tao_to_alpha_with_slippage(
self, tao: Balance
) -> tuple[Balance, Balance, float]:
"""
Returns an estimate of how much Alpha would a staker receive if they stake their tao using the current pool state.
Returns an estimate of how much Alpha would a staker receive if they stake their tao using the current pool
state.

Args:
tao: Amount of TAO to stake.
Returns:
Expand Down Expand Up @@ -792,7 +794,9 @@ def alpha_to_tao_with_slippage(
self, alpha: Balance
) -> tuple[Balance, Balance, float]:
"""
Returns an estimate of how much TAO would a staker receive if they unstake their alpha using the current pool state.
Returns an estimate of how much TAO would a staker receive if they unstake their alpha using the current pool
state.

Args:
alpha: Amount of Alpha to stake.
Returns:
Expand Down
28 changes: 16 additions & 12 deletions bittensor_cli/src/bittensor/extrinsics/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,11 @@ async def get_neuron_for_pubkey_and_subnet():
if prompt:
if not Confirm.ask(
f"Continue Registration?\n"
f" hotkey [{COLOR_PALETTE['GENERAL']['HOTKEY']}]({wallet.hotkey_str})[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]:\t[{COLOR_PALETTE['GENERAL']['HOTKEY']}]{wallet.hotkey.ss58_address}[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]\n"
f" coldkey [{COLOR_PALETTE['GENERAL']['COLDKEY']}]({wallet.name})[/{COLOR_PALETTE['GENERAL']['COLDKEY']}]:\t[{COLOR_PALETTE['GENERAL']['COLDKEY']}]{wallet.coldkeypub.ss58_address}[/{COLOR_PALETTE['GENERAL']['COLDKEY']}]\n"
f" network:\t\t[{COLOR_PALETTE['GENERAL']['LINKS']}]{subtensor.network}[/{COLOR_PALETTE['GENERAL']['LINKS']}]\n"
f" hotkey [{COLOR_PALETTE.G.HK}]({wallet.hotkey_str})[/{COLOR_PALETTE.G.HK}]:"
f"\t[{COLOR_PALETTE.G.HK}]{wallet.hotkey.ss58_address}[/{COLOR_PALETTE.G.HK}]\n"
f" coldkey [{COLOR_PALETTE.G.CK}]({wallet.name})[/{COLOR_PALETTE.G.CK}]:"
f"\t[{COLOR_PALETTE.G.CK}]{wallet.coldkeypub.ss58_address}[/{COLOR_PALETTE.G.CK}]\n"
f" network:\t\t[{COLOR_PALETTE.G.LINKS}]{subtensor.network}[/{COLOR_PALETTE.G.LINKS}]\n"
):
return False

Expand Down Expand Up @@ -611,7 +613,6 @@ async def get_neuron_for_pubkey_and_subnet():
if not wait_for_finalization and not wait_for_inclusion:
success, err_msg = True, ""
else:
await response.process_events()
success = await response.is_success
if not success:
success, err_msg = (
Expand Down Expand Up @@ -689,6 +690,7 @@ async def burned_register_extrinsic(
`False` if the extrinsic fails to enter the block within the timeout.
:param wait_for_finalization: If set, waits for the extrinsic to be finalized on the chain before returning `True`,
or returns `False` if the extrinsic fails to be finalized within the timeout.
:param era: the period (in blocks) for which the transaction should remain valid.
:param prompt: If `True`, the call waits for confirmation from the user before proceeding.

:return: Flag is `True` if extrinsic was finalized or included in the block. If we did not wait for
Expand Down Expand Up @@ -735,10 +737,10 @@ async def burned_register_extrinsic(
if not neuron.is_null:
console.print(
":white_heavy_check_mark: [dark_sea_green3]Already Registered[/dark_sea_green3]:\n"
f"uid: [{COLOR_PALETTE['GENERAL']['NETUID_EXTRA']}]{neuron.uid}[/{COLOR_PALETTE['GENERAL']['NETUID_EXTRA']}]\n"
f"netuid: [{COLOR_PALETTE['GENERAL']['NETUID']}]{neuron.netuid}[/{COLOR_PALETTE['GENERAL']['NETUID']}]\n"
f"hotkey: [{COLOR_PALETTE['GENERAL']['HOTKEY']}]{neuron.hotkey}[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]\n"
f"coldkey: [{COLOR_PALETTE['GENERAL']['COLDKEY']}]{neuron.coldkey}[/{COLOR_PALETTE['GENERAL']['COLDKEY']}]"
f"uid: [{COLOR_PALETTE.G.NETUID_EXTRA}]{neuron.uid}[/{COLOR_PALETTE.G.NETUID_EXTRA}]\n"
f"netuid: [{COLOR_PALETTE.G.NETUID}]{neuron.netuid}[/{COLOR_PALETTE.G.NETUID}]\n"
f"hotkey: [{COLOR_PALETTE.G.HK}]{neuron.hotkey}[/{COLOR_PALETTE.G.HK}]\n"
f"coldkey: [{COLOR_PALETTE.G.CK}]{neuron.coldkey}[/{COLOR_PALETTE.G.CK}]"
)
return True

Expand Down Expand Up @@ -781,7 +783,8 @@ async def burned_register_extrinsic(

console.print(
"Balance:\n"
f" [blue]{old_balance}[/blue] :arrow_right: [{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]{new_balance}[/{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]"
f" [blue]{old_balance}[/blue] :arrow_right: "
f"[{COLOR_PALETTE.S.STAKE_AMOUNT}]{new_balance}[/{COLOR_PALETTE.S.STAKE_AMOUNT}]"
)

if len(netuids_for_hotkey) > 0:
Expand Down Expand Up @@ -914,7 +917,6 @@ async def run_faucet_extrinsic(
)

# process if registration successful, try again if pow is still valid
await response.process_events()
if not await response.is_success:
err_console.print(
f":cross_mark: [red]Failed[/red]: "
Expand Down Expand Up @@ -1757,7 +1759,8 @@ async def swap_hotkey_extrinsic(
)
if not len(netuids_registered) > 0:
err_console.print(
f"Destination hotkey [dark_orange]{new_wallet.hotkey.ss58_address}[/dark_orange] is not registered. Please register and try again"
f"Destination hotkey [dark_orange]{new_wallet.hotkey.ss58_address}[/dark_orange] is not registered. "
f"Please register and try again"
)
return False

Expand All @@ -1774,7 +1777,8 @@ async def swap_hotkey_extrinsic(
):
return False
print_verbose(
f"Swapping {wallet.name}'s hotkey ({wallet.hotkey.ss58_address}) with {new_wallet.name}s hotkey ({new_wallet.hotkey.ss58_address})"
f"Swapping {wallet.name}'s hotkey ({wallet.hotkey.ss58_address}) with "
f"{new_wallet.name}s hotkey ({new_wallet.hotkey.ss58_address})"
)
with console.status(":satellite: Swapping hotkeys...", spinner="aesthetic"):
call = await subtensor.substrate.compose_call(
Expand Down
1 change: 0 additions & 1 deletion bittensor_cli/src/bittensor/extrinsics/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ async def _do_set_weights():
if not wait_for_finalization and not wait_for_inclusion:
return True, "Not waiting for finalization or inclusion."

await response.process_events()
if await response.is_success:
return True, "Successfully set weights."
else:
Expand Down
5 changes: 3 additions & 2 deletions bittensor_cli/src/bittensor/extrinsics/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async def transfer_extrinsic(
:param wallet: Bittensor wallet object to make transfer from.
:param destination: Destination public key address (ss58_address or ed25519) of recipient.
:param amount: Amount to stake as Bittensor balance.
:param era: Length (in blocks) for which the transaction should be valid.
:param transfer_all: Whether to transfer all funds from this wallet to the destination address.
:param wait_for_inclusion: If set, waits for the extrinsic to enter a block before returning `True`,
or returns `False` if the extrinsic fails to enter the block within the timeout.
Expand Down Expand Up @@ -97,7 +98,6 @@ async def do_transfer() -> tuple[bool, str, str]:
return True, "", ""

# Otherwise continue with finalization.
await response.process_events()
if await response.is_success:
block_hash_ = response.block_hash
return True, block_hash_, ""
Expand Down Expand Up @@ -156,7 +156,8 @@ async def do_transfer() -> tuple[bool, str, str]:
if not Confirm.ask(
"Do you want to transfer:[bold white]\n"
f" amount: [bright_cyan]{amount}[/bright_cyan]\n"
f" from: [light_goldenrod2]{wallet.name}[/light_goldenrod2] : [bright_magenta]{wallet.coldkey.ss58_address}\n[/bright_magenta]"
f" from: [light_goldenrod2]{wallet.name}[/light_goldenrod2] : "
f"[bright_magenta]{wallet.coldkey.ss58_address}\n[/bright_magenta]"
f" to: [bright_magenta]{destination}[/bright_magenta]\n for fee: [bright_cyan]{fee}[/bright_cyan]"
):
return False
Expand Down
8 changes: 4 additions & 4 deletions bittensor_cli/src/bittensor/subtensor_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,7 @@ async def sign_and_send_extrinsic(
:param wallet: the wallet whose coldkey will be used to sign the extrinsic
:param wait_for_inclusion: whether to wait until the extrinsic call is included on the chain
:param wait_for_finalization: whether to wait until the extrinsic call is finalized on the chain
:param era: The length (in blocks) for which a transaction should be valid.

:return: (success, error message)
"""
Expand All @@ -1075,7 +1076,6 @@ async def sign_and_send_extrinsic(
# We only wait here if we expect finalization.
if not wait_for_finalization and not wait_for_inclusion:
return True, ""
await response.process_events()
if await response.is_success:
return True, ""
else:
Expand Down Expand Up @@ -1372,11 +1372,11 @@ async def get_stake_for_coldkeys(
This function is useful for analyzing the stake distribution and delegation patterns of multiple
accounts simultaneously, offering a broader perspective on network participation and investment strategies.
"""
BATCH_SIZE = 60
batch_size = 60

tasks = []
for i in range(0, len(coldkey_ss58_list), BATCH_SIZE):
ss58_chunk = coldkey_ss58_list[i : i + BATCH_SIZE]
for i in range(0, len(coldkey_ss58_list), batch_size):
ss58_chunk = coldkey_ss58_list[i : i + batch_size]
tasks.append(
self.query_runtime_api(
runtime_api="StakeInfoRuntimeApi",
Expand Down
4 changes: 3 additions & 1 deletion bittensor_cli/src/bittensor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,7 @@ def get_effective_network(config, network: Optional[list[str]]) -> str:
the configuration, and the default.
"""
if network:
network_ = ""
for item in network:
if item.startswith("ws"):
network_ = item
Expand Down Expand Up @@ -1309,7 +1310,8 @@ def print_linux_dependency_message():
"\tAdd this into the file and save: [green]deb http://archive.ubuntu.com/ubuntu jammy main universe[/green]"
)
console.print(
"\tUpdate the repository and install the webkit dependency: [green]sudo apt update && sudo apt install libwebkit2gtk-4.0-dev[/green]"
"\tUpdate the repository and install the webkit dependency: [green]sudo apt update && sudo apt install "
"libwebkit2gtk-4.0-dev[/green]"
)
console.print("\nFedora / CentOS / AlmaLinux:")
console.print("[green]sudo dnf install gtk3-devel webkit2gtk3-devel[/green]\n\n")
Expand Down
1 change: 0 additions & 1 deletion bittensor_cli/src/commands/stake/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,6 @@ async def _unstake_all_extrinsic(
wait_for_inclusion=True,
wait_for_finalization=False,
)
await response.process_events()

if not await response.is_success:
err_out(
Expand Down
1 change: 0 additions & 1 deletion bittensor_cli/src/commands/subnets/subnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ async def _find_event_attributes_in_extrinsic_receipt(
if not wait_for_finalization and not wait_for_inclusion:
return True

await response.process_events()
if not await response.is_success:
err_console.print(
f":cross_mark: [red]Failed[/red]: {format_error_message(await response.error_message)}"
Expand Down
3 changes: 0 additions & 3 deletions bittensor_cli/src/commands/weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ async def _do_set_weights():
if not self.wait_for_finalization and not self.wait_for_inclusion:
return True, "Not waiting for finalization or inclusion."

await response.process_events()
if await response.is_success:
return True, "Successfully set weights."
else:
Expand Down Expand Up @@ -316,7 +315,6 @@ async def reveal_weights_extrinsic(
success, error_message = True, ""

else:
await response.process_events()
if await response.is_success:
success, error_message = True, ""
else:
Expand Down Expand Up @@ -354,7 +352,6 @@ async def do_commit_weights(self, commit_hash):
if not self.wait_for_finalization and not self.wait_for_inclusion:
return True, None

await response.process_events()
if await response.is_success:
return True, None
else:
Expand Down
1 change: 0 additions & 1 deletion tests/e2e_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,5 +297,4 @@ async def call_add_proposal(
wait_for_finalization=True,
)

await response.process_events()
return await response.is_success
Loading