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
21 changes: 15 additions & 6 deletions bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4909,12 +4909,21 @@ def stake_add(

# TODO: Ask amount for each subnet explicitly if more than one
if not stake_all and not amount:
free_balance = self._run_command(
wallets.wallet_balance(
wallet, self.initialize_chain(network), False, None
),
exit_early=False,
)
staker_ss58 = proxy or wallet.coldkeypub.ss58_address
if proxy:
free_balance = self._run_command(
wallets.wallet_balance(
None, self.initialize_chain(network), False, [staker_ss58]
),
exit_early=False,
)
else:
free_balance = self._run_command(
wallets.wallet_balance(
wallet, self.initialize_chain(network), False, None
),
exit_early=False,
)
logger.debug(f"Free balance: {free_balance}")
if free_balance == Balance.from_tao(0):
print_error("You dont have any balance to stake.")
Expand Down
5 changes: 3 additions & 2 deletions bittensor_cli/src/commands/stake/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async def safe_stake_extrinsic(
)
current_balance, next_nonce, call = await asyncio.gather(
subtensor.get_balance(coldkey_ss58),
subtensor.substrate.get_account_next_index(coldkey_ss58),
subtensor.substrate.get_account_next_index(signer_ss58),
subtensor.substrate.compose_call(
call_module="SubtensorModule",
call_function="add_stake_limit",
Expand Down Expand Up @@ -229,7 +229,7 @@ async def stake_extrinsic(
block_hash = await subtensor.substrate.get_chain_head()
current_balance, next_nonce, call = await asyncio.gather(
subtensor.get_balance(coldkey_ss58, block_hash=block_hash),
subtensor.substrate.get_account_next_index(coldkey_ss58),
subtensor.substrate.get_account_next_index(signer_ss58),
subtensor.substrate.compose_call(
call_module="SubtensorModule",
call_function="add_stake",
Expand Down Expand Up @@ -309,6 +309,7 @@ async def stake_extrinsic(
netuids if netuids is not None else await subtensor.get_all_subnet_netuids()
)
coldkey_ss58 = proxy or wallet.coldkeypub.ss58_address
signer_ss58 = wallet.coldkeypub.ss58_address

hotkeys_to_stake_to = _get_hotkeys_to_stake_to(
wallet=wallet,
Expand Down
8 changes: 2 additions & 6 deletions bittensor_cli/src/commands/stake/move.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,9 +864,7 @@ async def transfer_stake(
amount=amount_to_transfer.rao,
),
subtensor.get_extrinsic_fee(call, wallet.coldkeypub, proxy=proxy),
subtensor.substrate.get_account_next_index(
proxy or wallet.coldkeypub.ss58_address
),
subtensor.substrate.get_account_next_index(wallet.coldkeypub.ss58_address),
)

# Display stake movement details
Expand Down Expand Up @@ -1094,9 +1092,7 @@ async def swap_stake(
amount=amount_to_swap.rao,
),
subtensor.get_extrinsic_fee(call, wallet.coldkeypub, proxy=proxy),
subtensor.substrate.get_account_next_index(
proxy or wallet.coldkeypub.ss58_address
),
subtensor.substrate.get_account_next_index(wallet.coldkeypub.ss58_address),
)

# Display stake movement details
Expand Down
9 changes: 6 additions & 3 deletions bittensor_cli/src/commands/stake/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ async def _unstake_extrinsic(
f":cross_mark: [red]Failed[/red] to unstake {amount} on Netuid {netuid}"
)
coldkey_ss58 = proxy or wallet.coldkeypub.ss58_address
signer_ss58 = wallet.coldkeypub.ss58_address

if status:
status.update(
Expand All @@ -617,7 +618,7 @@ async def _unstake_extrinsic(

current_balance, next_nonce, call = await asyncio.gather(
subtensor.get_balance(coldkey_ss58),
subtensor.substrate.get_account_next_index(coldkey_ss58),
subtensor.substrate.get_account_next_index(signer_ss58),
subtensor.substrate.compose_call(
call_module="SubtensorModule",
call_function="remove_stake",
Expand Down Expand Up @@ -714,6 +715,7 @@ async def _safe_unstake_extrinsic(
f":cross_mark: [red]Failed[/red] to unstake {amount} on Netuid {netuid}"
)
coldkey_ss58 = proxy or wallet.coldkeypub.ss58_address
signer_ss58 = wallet.coldkeypub.ss58_address

if status:
status.update(
Expand All @@ -724,7 +726,7 @@ async def _safe_unstake_extrinsic(

current_balance, next_nonce, current_stake, call = await asyncio.gather(
subtensor.get_balance(coldkey_ss58, block_hash),
subtensor.substrate.get_account_next_index(coldkey_ss58),
subtensor.substrate.get_account_next_index(signer_ss58),
subtensor.get_stake(
hotkey_ss58=hotkey_ss58,
coldkey_ss58=coldkey_ss58,
Expand Down Expand Up @@ -836,6 +838,7 @@ async def _unstake_all_extrinsic(
f":cross_mark: [red]Failed[/red] to unstake all from {hotkey_name}"
)
coldkey_ss58 = proxy or wallet.coldkeypub.ss58_address
signer_ss58 = wallet.coldkeypub.ss58_address

if status:
status.update(
Expand Down Expand Up @@ -866,7 +869,7 @@ async def _unstake_all_extrinsic(
call_function=call_function,
call_params={"hotkey": hotkey_ss58},
),
subtensor.substrate.get_account_next_index(coldkey_ss58),
subtensor.substrate.get_account_next_index(signer_ss58),
)
try:
success_, err_msg, response = await subtensor.sign_and_send_extrinsic(
Expand Down