diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index 718c2f7ff..a73aa2e81 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -3658,7 +3658,6 @@ def get_auto_stake( self.initialize_chain(network), coldkey_ss58=coldkey_ss58, json_output=json_output, - verbose=verbose, ) ) diff --git a/bittensor_cli/src/commands/liquidity/liquidity.py b/bittensor_cli/src/commands/liquidity/liquidity.py index cc25ff1e9..47f0141f3 100644 --- a/bittensor_cli/src/commands/liquidity/liquidity.py +++ b/bittensor_cli/src/commands/liquidity/liquidity.py @@ -458,7 +458,7 @@ async def show_liquidity_list( wallet: "Wallet", netuid: int, json_output: bool = False, -): +) -> None: current_price_, (success, err_msg, positions) = await asyncio.gather( subtensor.subnet(netuid=netuid), get_liquidity_list(subtensor, wallet, netuid) ) @@ -467,10 +467,10 @@ async def show_liquidity_list( json_console.print( json.dumps({"success": success, "err_msg": err_msg, "positions": []}) ) - return False + return else: err_console.print(f"Error: {err_msg}") - return False + return liquidity_table = Table( Column("ID", justify="center"), Column("Liquidity", justify="center"), @@ -535,10 +535,10 @@ async def remove_liquidity( prompt: Optional[bool] = None, all_liquidity_ids: Optional[bool] = None, json_output: bool = False, -) -> tuple[bool, str]: +) -> None: """Remove liquidity position from provided subnet.""" if not await subtensor.subnet_exists(netuid=netuid): - return False, f"Subnet with netuid: {netuid} does not exist in {subtensor}." + return None if all_liquidity_ids: success, msg, positions = await get_liquidity_list(subtensor, wallet, netuid) @@ -549,7 +549,7 @@ async def remove_liquidity( ) else: return err_console.print(f"Error: {msg}") - return False, msg + return None else: position_ids = [p.id for p in positions] else: @@ -563,7 +563,7 @@ async def remove_liquidity( console.print(f"\tPosition id: {pos}") if not Confirm.ask("Would you like to continue?"): - return False, "User cancelled operation." + return None results = await asyncio.gather( *[ @@ -593,6 +593,7 @@ async def remove_liquidity( "extrinsic_identifier": await ext_receipt.get_extrinsic_identifier(), } json_console.print_json(data=json_table) + return None async def modify_liquidity( diff --git a/bittensor_cli/src/commands/liquidity/utils.py b/bittensor_cli/src/commands/liquidity/utils.py index 76f7ea8a7..f364a64e4 100644 --- a/bittensor_cli/src/commands/liquidity/utils.py +++ b/bittensor_cli/src/commands/liquidity/utils.py @@ -198,3 +198,5 @@ def prompt_position_id() -> int: return position_id except ValueError: console.print("[red]Please enter a valid number[/red].") + # will never return this, but fixes the type checker + return 0 diff --git a/bittensor_cli/src/commands/stake/add.py b/bittensor_cli/src/commands/stake/add.py index 9f3ffc0d0..5b980af08 100644 --- a/bittensor_cli/src/commands/stake/add.py +++ b/bittensor_cli/src/commands/stake/add.py @@ -1,5 +1,4 @@ import asyncio -import json from collections import defaultdict from functools import partial @@ -349,7 +348,7 @@ async def stake_extrinsic( f"[red]Not enough stake[/red]:[bold white]\n wallet balance:{remaining_wallet_balance} < " f"staking amount: {amount_to_stake}[/bold white]" ) - return False + return remaining_wallet_balance -= amount_to_stake # Calculate slippage @@ -432,9 +431,9 @@ async def stake_extrinsic( if prompt: if not Confirm.ask("Would you like to continue?"): - return False + return if not unlock_key(wallet).success: - return False + return if safe_staking: stake_coroutines = {} @@ -537,6 +536,8 @@ def _prompt_stake_amount( return Balance.from_tao(amount), False except ValueError: console.print("[red]Please enter a valid number or 'all'[/red]") + # will never return this, but fixes the type checker + return Balance(0), False def _get_hotkeys_to_stake_to( diff --git a/bittensor_cli/src/commands/stake/auto_staking.py b/bittensor_cli/src/commands/stake/auto_staking.py index d697df8d4..6e8bf3632 100644 --- a/bittensor_cli/src/commands/stake/auto_staking.py +++ b/bittensor_cli/src/commands/stake/auto_staking.py @@ -28,7 +28,6 @@ async def show_auto_stake_destinations( subtensor: "SubtensorInterface", coldkey_ss58: Optional[str] = None, json_output: bool = False, - verbose: bool = False, ) -> Optional[dict[int, dict[str, Optional[str]]]]: """Display auto-stake destinations for the supplied wallet.""" diff --git a/bittensor_cli/src/commands/stake/move.py b/bittensor_cli/src/commands/stake/move.py index 1443d611e..53587a577 100644 --- a/bittensor_cli/src/commands/stake/move.py +++ b/bittensor_cli/src/commands/stake/move.py @@ -201,6 +201,8 @@ def prompt_stake_amount( return Balance.from_tao(amount), False except ValueError: console.print("[red]Please enter a valid number or 'all'[/red]") + # can never return this, but fixes the type checker + return Balance(0), False async def stake_move_transfer_selection( @@ -818,14 +820,16 @@ async def swap_stake( wait_for_finalization (bool): If true, waits for the transaction to be finalized. Returns: - bool: True if the swap was successful, False otherwise. + (success, extrinsic_identifier): + success is True if the swap was successful, False otherwise. + extrinsic_identifier if the extrinsic was successfully included """ hotkey_ss58 = get_hotkey_pub_ss58(wallet) if interactive_selection: try: selection = await stake_swap_selection(subtensor, wallet) except ValueError: - return False + return False, "" origin_netuid = selection["origin_netuid"] amount = selection["amount"] destination_netuid = selection["destination_netuid"] diff --git a/bittensor_cli/src/commands/stake/remove.py b/bittensor_cli/src/commands/stake/remove.py index b4b6bbeb1..5c1033cb2 100644 --- a/bittensor_cli/src/commands/stake/remove.py +++ b/bittensor_cli/src/commands/stake/remove.py @@ -370,7 +370,7 @@ async def unstake_all( era: int = 3, prompt: bool = True, json_output: bool = False, -) -> bool: +) -> None: """Unstakes all stakes from all hotkeys in all subnets.""" include_hotkeys = include_hotkeys or [] exclude_hotkeys = exclude_hotkeys or [] @@ -419,7 +419,7 @@ async def unstake_all( if not stake_info: console.print("[red]No stakes found to unstake[/red]") - return False + return all_sn_dynamic_info = {info.netuid: info for info in all_sn_dynamic_info_} @@ -531,10 +531,10 @@ async def unstake_all( if prompt and not Confirm.ask( "\nDo you want to proceed with unstaking everything?" ): - return False + return if not unlock_key(wallet).success: - return False + return successes = {} with console.status("Unstaking all stakes...") as status: for hotkey_ss58 in hotkey_ss58s: @@ -553,7 +553,7 @@ async def unstake_all( "extrinsic_identifier": ext_id, } if json_output: - return json_console.print(json.dumps({"success": successes})) + json_console.print(json.dumps({"success": successes})) # Extrinsics diff --git a/bittensor_cli/src/commands/wallets.py b/bittensor_cli/src/commands/wallets.py index 63edd7ef3..4d74773c5 100644 --- a/bittensor_cli/src/commands/wallets.py +++ b/bittensor_cli/src/commands/wallets.py @@ -594,8 +594,8 @@ async def wallet_balance( subtensor.get_total_stake_for_coldkey(*coldkeys, block_hash=block_hash), ) - total_free_balance = sum(free_balances.values()) - total_staked_balance = sum(stake[0] for stake in staked_balances.values()) + total_free_balance: Balance = sum(free_balances.values()) + total_staked_balance: Balance = sum(stake[0] for stake in staked_balances.values()) balances = { name: (