diff --git a/bittensor_cli/src/bittensor/extrinsics/registration.py b/bittensor_cli/src/bittensor/extrinsics/registration.py index c10929301..d082f58c6 100644 --- a/bittensor_cli/src/bittensor/extrinsics/registration.py +++ b/bittensor_cli/src/bittensor/extrinsics/registration.py @@ -33,6 +33,7 @@ confirm_action, console, print_error, + print_success, format_error_message, millify, get_human_readable, @@ -587,8 +588,8 @@ async def get_neuron_for_pubkey_and_subnet(): subtensor, netuid=netuid, hotkey_ss58=get_hotkey_pub_ss58(wallet) ) if is_registered: - print_error( - f":white_heavy_check_mark: [dark_sea_green3]Already registered on netuid:{netuid}[/dark_sea_green3]" + print_success( + f"[dark_sea_green3]Already registered on netuid:{netuid}[/dark_sea_green3]" ) return True @@ -630,8 +631,8 @@ async def get_neuron_for_pubkey_and_subnet(): # https://github.com/opentensor/subtensor/blob/development/pallets/subtensor/src/errors.rs if "HotKeyAlreadyRegisteredInSubNet" in err_msg: - console.print( - f":white_heavy_check_mark: [dark_sea_green3]Already Registered on " + print_success( + f"[dark_sea_green3]Already Registered on " f"[bold]subnet:{netuid}[/bold][/dark_sea_green3]" ) return True @@ -647,8 +648,8 @@ async def get_neuron_for_pubkey_and_subnet(): hotkey_ss58=get_hotkey_pub_ss58(wallet), ) if is_registered: - console.print( - ":white_heavy_check_mark: [dark_sea_green3]Registered[/dark_sea_green3]" + print_success( + "[dark_sea_green3]Registered[/dark_sea_green3]" ) return True else: @@ -738,8 +739,8 @@ async def burned_register_extrinsic( era_ = {"period": era} if not neuron.is_null: + print_success("[dark_sea_green3]Already Registered[/dark_sea_green3]:") console.print( - ":white_heavy_check_mark: [dark_sea_green3]Already Registered[/dark_sea_green3]:\n" 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" @@ -798,9 +799,7 @@ async def burned_register_extrinsic( ) if len(netuids_for_hotkey) > 0: - console.print( - f":white_heavy_check_mark: [green]Registered on netuid {netuid} with UID {my_uid}[/green]" - ) + print_success(f"Registered on netuid {netuid} with UID {my_uid}") return True, f"Registered on {netuid} with UID {my_uid}", ext_id else: # neuron not found, try again diff --git a/bittensor_cli/src/bittensor/extrinsics/root.py b/bittensor_cli/src/bittensor/extrinsics/root.py index 2c346a47d..1bcdccf6b 100644 --- a/bittensor_cli/src/bittensor/extrinsics/root.py +++ b/bittensor_cli/src/bittensor/extrinsics/root.py @@ -32,6 +32,7 @@ confirm_action, console, print_error, + print_success, u16_normalized_float, print_verbose, format_error_message, @@ -343,9 +344,7 @@ async def root_register_extrinsic( subtensor, netuid=0, hotkey_ss58=get_hotkey_pub_ss58(wallet) ) if is_registered: - console.print( - ":white_heavy_check_mark: [green]Already registered on root network.[/green]" - ) + print_success("Already registered on root network.") return True, "Already registered on root network", None with console.status(":satellite: Registering to root network...", spinner="earth"): @@ -377,9 +376,7 @@ async def root_register_extrinsic( params=[0, get_hotkey_pub_ss58(wallet)], ) if uid is not None: - console.print( - f":white_heavy_check_mark: [green]Registered with UID {uid}[/green]" - ) + print_success(f"Registered with UID {uid}") return True, f"Registered with UID {uid}", ext_id else: # neuron not found, try again @@ -540,7 +537,7 @@ async def _do_set_weights(): return True if success is True: - console.print(":white_heavy_check_mark: [green]Finalized[/green]") + print_success("Finalized") return True else: fmt_err = format_error_message(error_message) diff --git a/bittensor_cli/src/bittensor/extrinsics/serving.py b/bittensor_cli/src/bittensor/extrinsics/serving.py index 14945d46c..3ace41062 100644 --- a/bittensor_cli/src/bittensor/extrinsics/serving.py +++ b/bittensor_cli/src/bittensor/extrinsics/serving.py @@ -11,6 +11,7 @@ confirm_action, console, print_error, + print_success, format_error_message, unlock_key, print_extrinsic_id, @@ -112,8 +113,8 @@ async def reset_axon_extrinsic( # We only wait here if we expect finalization. if not wait_for_finalization and not wait_for_inclusion: - console.print( - ":white_heavy_check_mark: [dark_sea_green3]Axon reset successfully[/dark_sea_green3]" + print_success( + "[dark_sea_green3]Axon reset successfully[/dark_sea_green3]" ) return True, "Not waiting for finalization or inclusion.", None @@ -125,8 +126,8 @@ async def reset_axon_extrinsic( else: ext_id = await response.get_extrinsic_identifier() await print_extrinsic_id(response) - console.print( - ":white_heavy_check_mark: [dark_sea_green3]Axon reset successfully[/dark_sea_green3]" + print_success( + "[dark_sea_green3]Axon reset successfully[/dark_sea_green3]" ) return True, "Axon reset successfully", ext_id @@ -230,8 +231,8 @@ async def set_axon_extrinsic( # We only wait here if we expect finalization. if not wait_for_finalization and not wait_for_inclusion: - console.print( - f":white_heavy_check_mark: [dark_sea_green3]Axon set successfully to {ip}:{port}[/dark_sea_green3]" + print_success( + f"[dark_sea_green3]Axon set successfully to {ip}:{port}[/dark_sea_green3]" ) return True, "Not waiting for finalization or inclusion.", None @@ -243,8 +244,8 @@ async def set_axon_extrinsic( else: ext_id = await response.get_extrinsic_identifier() await print_extrinsic_id(response) - console.print( - f":white_heavy_check_mark: [dark_sea_green3]Axon set successfully to {ip}:{port}[/dark_sea_green3]" + print_success( + f"[dark_sea_green3]Axon set successfully to {ip}:{port}[/dark_sea_green3]" ) return True, f"Axon set successfully to {ip}:{port}", ext_id diff --git a/bittensor_cli/src/bittensor/extrinsics/transfer.py b/bittensor_cli/src/bittensor/extrinsics/transfer.py index 5de403466..fb714bfd2 100644 --- a/bittensor_cli/src/bittensor/extrinsics/transfer.py +++ b/bittensor_cli/src/bittensor/extrinsics/transfer.py @@ -12,6 +12,7 @@ confirm_action, console, print_error, + print_success, print_verbose, is_valid_bittensor_address_or_public_key, print_error, @@ -219,11 +220,10 @@ async def do_transfer() -> tuple[bool, str, str, Optional[AsyncExtrinsicReceipt] success, block_hash, err_msg, ext_receipt = await do_transfer() if success: - console.print(":white_heavy_check_mark: [green]Finalized[/green]") - console.print(f"[green]Block Hash: {block_hash}[/green]") + print_success(f"Finalized. Block Hash: {block_hash}") else: - console.print(f":cross_mark: [red]Failed[/red]: {err_msg}") + print_error(f"Failed: {err_msg}") if success: with console.status(":satellite: Checking Balance...", spinner="aesthetic"): diff --git a/bittensor_cli/src/bittensor/utils.py b/bittensor_cli/src/bittensor/utils.py index a5c1896d3..d63759271 100644 --- a/bittensor_cli/src/bittensor/utils.py +++ b/bittensor_cli/src/bittensor/utils.py @@ -156,6 +156,17 @@ def print_error(message: str, status=None): print_console(error_message, "red", err_console) +def print_success(message: str, status=None): + """Print success messages while temporarily pausing the status spinner.""" + success_message = f":white_heavy_check_mark: {message}" + if status: + status.stop() + print_console(success_message, "green", console) + status.start() + else: + print_console(success_message, "green", console) + + RAO_PER_TAO = 1e9 U16_MAX = 65535 U64_MAX = 18446744073709551615 diff --git a/bittensor_cli/src/commands/crowd/contribute.py b/bittensor_cli/src/commands/crowd/contribute.py index 933e794a6..0e0097a95 100644 --- a/bittensor_cli/src/commands/crowd/contribute.py +++ b/bittensor_cli/src/commands/crowd/contribute.py @@ -16,6 +16,7 @@ json_console, print_error, print_extrinsic_id, + print_success, unlock_key, ) from bittensor_cli.src.commands.crowd.view import show_crowdloan_details @@ -89,7 +90,7 @@ async def contribute_to_crowdloan( if json_output: json_console.print(json.dumps({"success": False, "error": error_msg})) else: - print_error(f"[red]{error_msg}[/red]") + print_error(error_msg) return False, error_msg is_valid, error_message = validate_for_contribution( @@ -99,7 +100,7 @@ async def contribute_to_crowdloan( if json_output: json_console.print(json.dumps({"success": False, "error": error_message})) else: - print_error(f"[red]{error_message}[/red]") + print_error(error_message) return False, error_message contributor_address = proxy or wallet.coldkeypub.ss58_address @@ -136,7 +137,7 @@ async def contribute_to_crowdloan( if json_output: json_console.print(json.dumps({"success": False, "error": error_msg})) else: - print_error(f"[red]{error_msg}[/red]") + print_error(error_msg) return False, "Contribution below minimum requirement." if contribution_amount > user_balance: @@ -144,7 +145,7 @@ async def contribute_to_crowdloan( if json_output: json_console.print(json.dumps({"success": False, "error": error_msg})) else: - print_error(f"[red]{error_msg}[/red]") + print_error(error_msg) return False, "Insufficient balance." # Auto-adjustment @@ -245,7 +246,7 @@ async def contribute_to_crowdloan( json.dumps({"success": False, "error": unlock_status.message}) ) else: - print_error(f"[red]{unlock_status.message}[/red]") + print_error(unlock_status.message) return False, unlock_status.message with console.status(f"\n:satellite: Contributing to crowdloan #{crowdloan_id}..."): @@ -272,7 +273,7 @@ async def contribute_to_crowdloan( ) ) else: - print_error(f"[red]Failed to contribute: {error_message}[/red]") + print_error(f"Failed to contribute: {error_message}") return False, error_message or "Failed to contribute." new_balance, new_contribution, updated_crowdloan = await asyncio.gather( @@ -398,7 +399,7 @@ async def withdraw_from_crowdloan( if json_output: json_console.print(json.dumps({"success": False, "error": error_msg})) else: - print_error(f"[red]{error_msg}[/red]") + print_error(error_msg) return False, error_msg if crowdloan.finalized: @@ -406,7 +407,7 @@ async def withdraw_from_crowdloan( if json_output: json_console.print(json.dumps({"success": False, "error": error_msg})) else: - print_error(f"[red]{error_msg}[/red]") + print_error(error_msg) return False, "Cannot withdraw from finalized crowdloan." contributor_address = proxy or wallet.coldkeypub.ss58_address @@ -424,7 +425,7 @@ async def withdraw_from_crowdloan( if json_output: json_console.print(json.dumps({"success": False, "error": error_msg})) else: - print_error(f"[red]{error_msg}[/red]") + print_error(error_msg) return False, "No contribution to withdraw." is_creator = wallet.coldkeypub.ss58_address == crowdloan.creator @@ -435,7 +436,7 @@ async def withdraw_from_crowdloan( if json_output: json_console.print(json.dumps({"success": False, "error": error_msg})) else: - print_error(f"[red]{error_msg}[/red]") + print_error(error_msg) return False, "Creator cannot withdraw deposit amount." remaining_contribution = crowdloan.deposit else: @@ -534,7 +535,7 @@ async def withdraw_from_crowdloan( json.dumps({"success": False, "error": unlock_status.message}) ) else: - print_error(f"[red]{unlock_status.message}[/red]") + print_error(unlock_status.message) return False, unlock_status.message with console.status(f"\n:satellite: Withdrawing from crowdloan #{crowdloan_id}..."): @@ -561,9 +562,7 @@ async def withdraw_from_crowdloan( ) ) else: - print_error( - f"[red]Failed to withdraw: {error_message or 'Unknown error'}[/red]" - ) + print_error(f"Failed to withdraw: {error_message or 'Unknown error'}") return False, error_message or "Failed to withdraw from crowdloan." new_balance, updated_contribution, updated_crowdloan = await asyncio.gather( @@ -602,9 +601,7 @@ async def withdraw_from_crowdloan( } json_console.print(json.dumps(output_dict)) else: - console.print( - f"\n✅ [green]Successfully withdrew from crowdloan #{crowdloan_id}![/green]\n" - ) + print_success(f"Successfully withdrew from crowdloan #{crowdloan_id}!\n") console.print( f"Amount Withdrawn: [{COLORS.S.AMOUNT}]{withdrawable}[/{COLORS.S.AMOUNT}]\n" diff --git a/bittensor_cli/src/commands/crowd/create.py b/bittensor_cli/src/commands/crowd/create.py index ff64e41a0..f14d4aae3 100644 --- a/bittensor_cli/src/commands/crowd/create.py +++ b/bittensor_cli/src/commands/crowd/create.py @@ -18,6 +18,7 @@ console, json_console, print_error, + print_success, is_valid_ss58_address, unlock_key, print_extrinsic_id, @@ -186,11 +187,11 @@ async def create_crowdloan( if cap <= deposit: if prompt: print_error( - f"[red]Cap must be greater than the deposit ({deposit.tao:,.4f} TAO).[/red]" + f"Cap must be greater than the deposit ({deposit.tao:,.4f} TAO)." ) cap_value = None continue - print_error("[red]Cap must be greater than the initial deposit.[/red]") + print_error("Cap must be greater than the initial deposit.") return False, "Cap must be greater than the initial deposit." break @@ -204,12 +205,12 @@ async def create_crowdloan( if duration_value < min_duration or duration_value > max_duration: if prompt: print_error( - f"[red]Duration must be between {min_duration} and " - f"{max_duration} blocks.[/red]" + f"Duration must be between {min_duration} and " + f"{max_duration} blocks." ) duration_value = None continue - print_error("[red]Crowdloan duration is outside the allowed range.[/red]") + print_error("Crowdloan duration is outside the allowed range.") return False, "Crowdloan duration is outside the allowed range." duration = duration_value break @@ -227,7 +228,7 @@ async def create_crowdloan( if not 0 <= emissions_share <= 100: print_error( - f"[red]Emissions share must be between 0 and 100, got {emissions_share}[/red]" + f"Emissions share must be between 0 and 100, got {emissions_share}" ) return False, "Invalid emissions share percentage." @@ -255,9 +256,7 @@ async def create_crowdloan( if target_address: target_address = target_address.strip() if not is_valid_ss58_address(target_address): - print_error( - f"[red]Invalid target SS58 address provided: {target_address}[/red]" - ) + print_error(f"Invalid target SS58 address provided: {target_address}") return False, "Invalid target SS58 address provided." elif prompt: target_input = Prompt.ask( @@ -266,9 +265,7 @@ async def create_crowdloan( target_address = target_input.strip() or None if not is_valid_ss58_address(target_address): - print_error( - f"[red]Invalid target SS58 address provided: {target_address}[/red]" - ) + print_error(f"Invalid target SS58 address provided: {target_address}") return False, "Invalid target SS58 address provided." call_to_attach = None @@ -278,8 +275,8 @@ async def create_crowdloan( ) if deposit > creator_balance: print_error( - f"[red]Insufficient balance to cover the deposit. " - f"Available: {creator_balance}, required: {deposit}[/red]" + f"Insufficient balance to cover the deposit. " + f"Available: {creator_balance}, required: {deposit}" ) return False, "Insufficient balance to cover the deposit." @@ -383,7 +380,7 @@ async def create_crowdloan( ) ) else: - print_error(f"[red]{error_message or 'Failed to create crowdloan.'}[/red]") + print_error(f"{error_message or 'Failed to create crowdloan.'}") return False, error_message or "Failed to create crowdloan." if json_output: @@ -414,8 +411,8 @@ async def create_crowdloan( else: if crowdloan_type == "subnet": message = "Subnet lease crowdloan created successfully." + print_success(message) console.print( - f"\n:white_check_mark: [green]{message}[/green]\n" f" Type: [magenta]Subnet Leasing[/magenta]\n" f" Emissions Share: [cyan]{emissions_share}%[/cyan]\n" f" Deposit: [{COLORS.P.TAO}]{deposit}[/{COLORS.P.TAO}]\n" @@ -429,8 +426,8 @@ async def create_crowdloan( console.print(" Lease: [green]Perpetual[/green]") else: message = "Fundraising crowdloan created successfully." + print_success(message) console.print( - f"\n:white_check_mark: [green]{message}[/green]\n" f" Type: [cyan]General Fundraising[/cyan]\n" f" Deposit: [{COLORS.P.TAO}]{deposit}[/{COLORS.P.TAO}]\n" f" Min contribution: [{COLORS.P.TAO}]{min_contribution}[/{COLORS.P.TAO}]\n" @@ -489,7 +486,7 @@ async def finalize_crowdloan( if json_output: json_console.print(json.dumps({"success": False, "error": error_msg})) else: - print_error(f"[red]{error_msg}[/red]") + print_error(error_msg) return False, error_msg if wallet.coldkeypub.ss58_address != crowdloan.creator: @@ -499,7 +496,7 @@ async def finalize_crowdloan( if json_output: json_console.print(json.dumps({"success": False, "error": error_msg})) else: - print_error(f"[red]{error_msg}[/red]") + print_error(error_msg) return False, "Only the creator can finalize a crowdloan." if crowdloan.finalized: @@ -507,7 +504,7 @@ async def finalize_crowdloan( if json_output: json_console.print(json.dumps({"success": False, "error": error_msg})) else: - print_error(f"[red]{error_msg}[/red]") + print_error(error_msg) return False, "Crowdloan is already finalized." if crowdloan.raised < crowdloan.cap: @@ -520,9 +517,9 @@ async def finalize_crowdloan( json_console.print(json.dumps({"success": False, "error": error_msg})) else: print_error( - f"[red]Crowdloan #{crowdloan_id} has not reached its cap.\n" + f"Crowdloan #{crowdloan_id} has not reached its cap.\n" f"Raised: {crowdloan.raised}, Cap: {crowdloan.cap}\n" - f"Still needed: {still_needed.tao}[/red]" + f"Still needed: {still_needed.tao}" ) return False, "Crowdloan has not reached its cap." diff --git a/bittensor_cli/src/commands/proxy.py b/bittensor_cli/src/commands/proxy.py index 9f3c403d0..8852fedf1 100644 --- a/bittensor_cli/src/commands/proxy.py +++ b/bittensor_cli/src/commands/proxy.py @@ -13,6 +13,7 @@ json_console, console, print_error, + print_success, unlock_key, ProxyAddressBook, is_valid_ss58_address_prompt, @@ -95,7 +96,7 @@ async def submit_proxy( ) else: await print_extrinsic_id(receipt) - console.print(":white_check_mark:[green]Success![/green]") + print_success("Success!") else: if json_output: json_console.print_json( @@ -627,7 +628,7 @@ async def execute_announced( ) inner_call.process() except StateDiscardedError: - err_console.print( + print_error( "The state has already been discarded for this block " "(you are likely not using an archive node endpoint)" ) @@ -645,8 +646,8 @@ async def execute_announced( ) inner_call.process() except Exception as e: - err_console.print( - f":cross_mark:[red]Failure[/red]Unable to regenerate the call data using the latest runtime: {e}\n" + print_error( + f"Failure: Unable to regenerate the call data using the latest runtime: {e}\n" "You should rerun this command on an archive node endpoint." ) if json_output: @@ -687,7 +688,7 @@ async def execute_announced( } ) else: - console.print(":white_check_mark:[green]Success![/green]") + print_success("Success!") await print_extrinsic_id(receipt) else: if json_output: diff --git a/bittensor_cli/src/commands/stake/add.py b/bittensor_cli/src/commands/stake/add.py index 18c6578eb..275049be4 100644 --- a/bittensor_cli/src/commands/stake/add.py +++ b/bittensor_cli/src/commands/stake/add.py @@ -20,6 +20,7 @@ get_hotkey_wallets_for_wallet, is_valid_ss58_address, print_error, + print_success, print_verbose, unlock_key, json_console, @@ -192,9 +193,8 @@ async def safe_stake_extrinsic( block_hash=block_hash, ), ) - console.print( - f":white_heavy_check_mark: [dark_sea_green3]Finalized. " - f"Stake added to netuid: {netuid_}[/dark_sea_green3]" + print_success( + f"[dark_sea_green3]Finalized. Stake added to netuid: {netuid_}[/dark_sea_green3]" ) console.print( f"Balance:\n [blue]{current_balance}[/blue] :arrow_right: " @@ -287,8 +287,7 @@ async def stake_extrinsic( block_hash=new_block_hash, ), ) - console.print( - f":white_heavy_check_mark: " + print_success( f"[dark_sea_green3]Finalized. Stake added to netuid: {netuid_i}[/dark_sea_green3]" ) console.print( diff --git a/bittensor_cli/src/commands/stake/auto_staking.py b/bittensor_cli/src/commands/stake/auto_staking.py index 9fb10847a..3d7888321 100644 --- a/bittensor_cli/src/commands/stake/auto_staking.py +++ b/bittensor_cli/src/commands/stake/auto_staking.py @@ -11,6 +11,7 @@ confirm_action, console, json_console, + print_success, get_subnet_name, is_valid_ss58_address, print_error, @@ -296,8 +297,8 @@ async def set_auto_stake_destination( if success: await print_extrinsic_id(ext_receipt) - console.print( - f":white_heavy_check_mark: [dark_sea_green3]Auto-stake destination set for netuid {netuid}[/dark_sea_green3]" + print_success( + f"[dark_sea_green3]Auto-stake destination set for netuid {netuid}[/dark_sea_green3]" ) return True diff --git a/bittensor_cli/src/commands/stake/children_hotkeys.py b/bittensor_cli/src/commands/stake/children_hotkeys.py index d4fb17998..69d4083e4 100644 --- a/bittensor_cli/src/commands/stake/children_hotkeys.py +++ b/bittensor_cli/src/commands/stake/children_hotkeys.py @@ -16,6 +16,7 @@ print_error, float_to_u16, float_to_u64, + print_success, u16_to_float, u64_to_float, is_valid_ss58_address, @@ -145,7 +146,7 @@ async def set_children_extrinsic( await print_extrinsic_id(ext_receipt) modifier = "included" if wait_for_finalization: - console.print(":white_heavy_check_mark: [green]Finalized[/green]") + print_success("Finalized") modifier = "finalized" return True, f"{operation} successfully {modifier}.", ext_id else: @@ -236,7 +237,7 @@ async def set_childkey_take_extrinsic( modifier = "included" if wait_for_finalization: modifier = "finalized" - console.print(":white_heavy_check_mark: [green]Finalized[/green]") + print_success("Finalized") return True, f"Successfully {modifier} childkey take", ext_id else: print_error(f"Failed: {error_message}") @@ -569,11 +570,9 @@ async def set_children( f"Your childkey request has been submitted. It will be completed around block {completion_block}. " f"The current block is {current_block}" ) - console.print( - ":white_heavy_check_mark: [green]Set children hotkeys.[/green]" - ) + print_success("Set children hotkeys.") else: - console.print(f"Unable to set children hotkeys. {message}") + print_error(f"Unable to set children hotkeys. {message}") else: # set children on all subnets that parent is registered on netuids = await subtensor.get_all_subnet_netuids() @@ -606,9 +605,7 @@ async def set_children( f"Your childkey request for netuid {netuid_} has been submitted. It will be completed around " f"block {completion_block}. The current block is {current_block}." ) - console.print( - ":white_heavy_check_mark: [green]Sent set children request for all subnets.[/green]" - ) + print_success("Sent set children request for all subnets.") if json_output: json_console.print(json.dumps(successes)) @@ -784,7 +781,7 @@ async def set_chk_take_subnet( ) # Result if success_: - console.print(":white_heavy_check_mark: [green]Set childkey take.[/green]") + print_success("Set childkey take.") console.print( f"The childkey take for {get_hotkey_pub_ss58(wallet)} is now set to {take * 100:.2f}%." ) @@ -864,7 +861,5 @@ async def set_chk_take_subnet( wait_for_finalization=False, ) output_list.append((netuid_, result, ext_id)) - console.print( - f":white_heavy_check_mark: [green]Sent childkey take of {take * 100:.2f}% to all subnets.[/green]" - ) + print_success(f"Sent childkey take of {take * 100:.2f}% to all subnets.") return output_list diff --git a/bittensor_cli/src/commands/stake/claim.py b/bittensor_cli/src/commands/stake/claim.py index d07f4715b..2f225f135 100644 --- a/bittensor_cli/src/commands/stake/claim.py +++ b/bittensor_cli/src/commands/stake/claim.py @@ -15,6 +15,7 @@ confirm_action, console, print_error, + print_success, unlock_key, print_extrinsic_id, json_console, @@ -209,7 +210,7 @@ async def set_claim_type( if success: ext_id = await ext_receipt.get_extrinsic_identifier() msg = "Successfully changed claim type" - console.print(f":white_heavy_check_mark: [green]{msg}[/green]") + print_success(msg) await print_extrinsic_id(ext_receipt) if json_output: json_console.print( diff --git a/bittensor_cli/src/commands/stake/move.py b/bittensor_cli/src/commands/stake/move.py index c106ddfbc..f28d689f2 100644 --- a/bittensor_cli/src/commands/stake/move.py +++ b/bittensor_cli/src/commands/stake/move.py @@ -19,6 +19,7 @@ print_error, group_subnets, get_subnet_name, + print_success, unlock_key, get_hotkey_pub_ss58, print_extrinsic_id, @@ -722,12 +723,10 @@ async def move_stake( return False, "" await print_extrinsic_id(response) if not prompt: - console.print(":white_heavy_check_mark: [green]Sent[/green]") + print_success("Sent") return True, ext_id else: - console.print( - ":white_heavy_check_mark: [dark_sea_green3]Stake moved.[/dark_sea_green3]" - ) + print_success("[dark_sea_green3]Stake moved.[/dark_sea_green3]") block_hash = await subtensor.substrate.get_chain_head() ( new_origin_stake_balance, @@ -945,7 +944,7 @@ async def transfer_stake( await print_extrinsic_id(response) ext_id = await response.get_extrinsic_identifier() if not prompt: - console.print(":white_heavy_check_mark: [green]Sent[/green]") + print_success("Sent") return True, ext_id else: # Get and display new stake balances @@ -1184,7 +1183,7 @@ async def swap_stake( return False, "" await print_extrinsic_id(response) if not prompt: - console.print(":white_heavy_check_mark: [green]Sent[/green]") + print_success("Sent") return True, await response.get_extrinsic_identifier() else: # Get and display new stake balances diff --git a/bittensor_cli/src/commands/stake/remove.py b/bittensor_cli/src/commands/stake/remove.py index 1cc7116a5..eb930a60e 100644 --- a/bittensor_cli/src/commands/stake/remove.py +++ b/bittensor_cli/src/commands/stake/remove.py @@ -18,6 +18,7 @@ from bittensor_cli.src.bittensor.utils import ( confirm_action, console, + print_success, print_verbose, print_error, get_hotkey_wallets_for_wallet, @@ -671,7 +672,7 @@ async def _unstake_extrinsic( ), ) - console.print(":white_heavy_check_mark: [green]Finalized[/green]") + print_success("Finalized") console.print( f"Balance:\n [blue]{current_balance}[/blue] :arrow_right: [{COLOR_PALETTE.S.AMOUNT}]{new_balance}" ) @@ -785,7 +786,7 @@ async def _safe_unstake_extrinsic( ), ) - console.print(":white_heavy_check_mark: [green]Finalized[/green]") + print_success("Finalized") console.print( f"Balance:\n [blue]{current_balance}[/blue] :arrow_right: [{COLOR_PALETTE.S.AMOUNT}]{new_balance}" ) diff --git a/bittensor_cli/src/commands/subnets/mechanisms.py b/bittensor_cli/src/commands/subnets/mechanisms.py index 2400be707..195820c56 100644 --- a/bittensor_cli/src/commands/subnets/mechanisms.py +++ b/bittensor_cli/src/commands/subnets/mechanisms.py @@ -16,6 +16,7 @@ json_console, U16_MAX, print_extrinsic_id, + print_success, ) if TYPE_CHECKING: @@ -294,7 +295,7 @@ async def set_emission_split( return False if normalized_weights == existing_split: - message = ":white_heavy_check_mark: [dark_sea_green3]Emission split unchanged.[/dark_sea_green3]" + message = "[dark_sea_green3]Emission split unchanged.[/dark_sea_green3]" if json_output: json_console.print_json( data={ @@ -306,7 +307,7 @@ async def set_emission_split( } ) else: - console.print(message) + print_success(message) return True if not json_output: @@ -462,8 +463,7 @@ async def set_mechanism_count( if success: await print_extrinsic_id(ext_receipt) - console.print( - ":white_heavy_check_mark: " + print_success( f"[dark_sea_green3]Mechanism count set to {mechanism_count} for subnet {netuid}[/dark_sea_green3]" ) else: @@ -506,8 +506,7 @@ async def set_mechanism_emission( if success: await print_extrinsic_id(ext_receipt) - console.print( - ":white_heavy_check_mark: " + print_success( f"[dark_sea_green3]Emission split updated for subnet {netuid}[/dark_sea_green3]" ) else: diff --git a/bittensor_cli/src/commands/subnets/subnets.py b/bittensor_cli/src/commands/subnets/subnets.py index ad0404b4f..610606ba3 100644 --- a/bittensor_cli/src/commands/subnets/subnets.py +++ b/bittensor_cli/src/commands/subnets/subnets.py @@ -30,6 +30,7 @@ confirm_action, console, create_and_populate_table, + print_success, print_verbose, print_error, get_metadata_table, @@ -297,8 +298,8 @@ async def _find_event_attributes_in_extrinsic_receipt( "" ) else: - console.print( - f":white_heavy_check_mark: [dark_sea_green3]Registered subnetwork with netuid: {attributes[0]}" + print_success( + f"[dark_sea_green3]Registered subnetwork with netuid: {attributes[0]}" ) return True, int(attributes[0]), ext_id @@ -2626,9 +2627,7 @@ async def set_identity( return False, None ext_id = await ext_receipt.get_extrinsic_identifier() await print_extrinsic_id(ext_receipt) - console.print( - ":white_heavy_check_mark: [dark_sea_green3]Successfully set subnet identity\n" - ) + print_success("[dark_sea_green3]Successfully set subnet identity\n") subnet = await subtensor.subnet(netuid) identity = subnet.subnet_identity if subnet else None @@ -2811,9 +2810,7 @@ async def start_subnet( if success: await print_extrinsic_id(response) - console.print( - f":white_heavy_check_mark: [green]Successfully started subnet {netuid}'s emission schedule.[/green]" - ) + print_success(f"Successfully started subnet {netuid}'s emission schedule.") return True else: if "FirstEmissionBlockNumberAlreadySet" in error_msg: @@ -2895,7 +2892,7 @@ async def set_symbol( } ) else: - console.print(f":white_heavy_check_mark:[dark_sea_green3] {message}\n") + print_success(f"[dark_sea_green3] {message}\n") return True else: if json_output: diff --git a/bittensor_cli/src/commands/sudo.py b/bittensor_cli/src/commands/sudo.py index b039ea4f2..ec6d1461c 100644 --- a/bittensor_cli/src/commands/sudo.py +++ b/bittensor_cli/src/commands/sudo.py @@ -23,6 +23,7 @@ confirm_action, console, print_error, + print_success, print_verbose, normalize_hyperparameters, unlock_key, @@ -410,15 +411,13 @@ async def set_hyperparameter_extrinsic( ext_id = await ext_receipt.get_extrinsic_identifier() await print_extrinsic_id(ext_receipt) if arbitrary_extrinsic: - console.print( - f":white_heavy_check_mark: " + print_success( f"[dark_sea_green3]Hyperparameter {parameter} values changed to {call_params}[/dark_sea_green3]" ) return True, "", ext_id # Successful registration, final check for membership else: - console.print( - f":white_heavy_check_mark: " + print_success( f"[dark_sea_green3]Hyperparameter {parameter} changed to {value}[/dark_sea_green3]" ) return True, "", ext_id @@ -641,7 +640,7 @@ async def vote_senate_extrinsic( vote_data.ayes.count(hotkey_ss58) > 0 or vote_data.nays.count(hotkey_ss58) > 0 ): - console.print(":white_heavy_check_mark: [green]Vote cast.[/green]") + print_success("Vote cast.") return True else: # hotkey not found in ayes/nays @@ -729,9 +728,7 @@ async def set_take_extrinsic( print_error(err) ext_id = None else: - console.print( - ":white_heavy_check_mark: [dark_sea_green_3]Success[/dark_sea_green_3]" - ) + print_success("Success") ext_id = await ext_receipt.get_extrinsic_identifier() await print_extrinsic_id(ext_receipt) return success, ext_id @@ -1293,7 +1290,5 @@ async def trim( ) else: await print_extrinsic_id(ext_receipt) - console.print( - f":white_heavy_check_mark: [dark_sea_green3]{msg}[/dark_sea_green3]" - ) + print_success(f"[dark_sea_green3]{msg}[/dark_sea_green3]") return True diff --git a/bittensor_cli/src/commands/wallets.py b/bittensor_cli/src/commands/wallets.py index 96c812be5..216d7bf10 100644 --- a/bittensor_cli/src/commands/wallets.py +++ b/bittensor_cli/src/commands/wallets.py @@ -37,7 +37,6 @@ confirm_action, console, convert_blocks_to_time, - err_console, json_console, print_error, print_verbose, @@ -137,9 +136,7 @@ async def associate_hotkey( ) if not success: - console.print( - f"[red]:cross_mark: Failed to associate hotkey: {err_msg}[/red]" - ) + print_error(f"Failed to associate hotkey: {err_msg}") return False console.print( diff --git a/bittensor_cli/src/commands/weights.py b/bittensor_cli/src/commands/weights.py index a12f5b659..3fa0135c3 100644 --- a/bittensor_cli/src/commands/weights.py +++ b/bittensor_cli/src/commands/weights.py @@ -12,6 +12,7 @@ from bittensor_cli.src.bittensor.utils import ( confirm_action, print_error, + print_success, console, format_error_message, json_console, @@ -181,9 +182,7 @@ async def _commit_reveal( reveal_time = (current_time + timedelta(seconds=interval)).isoformat() cli_retry_cmd = f"--netuid {self.netuid} --uids {weight_uids} --weights {self.weights} --reveal-using-salt {self.salt}" # Print params to screen and notify user this is a blocking operation - console.print( - ":white_heavy_check_mark: [green]Weights hash committed to chain[/green]" - ) + print_success("Weights hash committed to chain") console.print( f":alarm_clock: [dark_orange3]Weights hash will be revealed at {reveal_time}[/dark_orange3]" ) @@ -227,9 +226,7 @@ async def reveal(self, weight_uids, weight_vals) -> tuple[bool, str, Optional[st if not self.wait_for_finalization and not self.wait_for_inclusion: return True, "Not waiting for finalization or inclusion.", ext_id - console.print( - ":white_heavy_check_mark: [green]Weights hash revealed on chain[/green]" - ) + print_success("Weights hash revealed on chain") return ( True, "Successfully revealed previously committed weights hash.", @@ -284,7 +281,7 @@ async def _do_set_weights() -> tuple[bool, str, Optional[str]]: return True, "Not waiting for finalization or inclusion.", None if success: - console.print(":white_heavy_check_mark: [green]Finalized[/green]") + print_success("Finalized") # bittensor.logging.success(prefix="Set weights", suffix="Finalized: " + str(success)) return True, "Successfully set weights and finalized.", ext_id else: