Skip to content

Commit fe23160

Browse files
committed
Progress
1 parent b8993fd commit fe23160

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

bittensor_cli/src/bittensor/subtensor_interface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,12 +1131,12 @@ async def get_stake_for_coldkey_and_hotkey_on_netuid(
11311131
coldkey_ss58: str,
11321132
netuid: int,
11331133
block_hash: Optional[str] = None,
1134-
) -> Optional["Balance"]:
1134+
) -> "Balance":
11351135
"""Returns the stake under a coldkey - hotkey - netuid pairing"""
11361136
_result = await self.substrate.query(
11371137
"SubtensorModule", "Alpha", [hotkey_ss58, coldkey_ss58, netuid], block_hash
11381138
)
11391139
if _result is None:
1140-
return None
1140+
return Balance(0).set_unit(netuid)
11411141
else:
11421142
return Balance.from_rao(_result).set_unit(int(netuid))

bittensor_cli/src/commands/stake/stake.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,31 +1213,34 @@ async def stake_add_new(
12131213
wallet.coldkeypub.ss58_address
12141214
].set_unit(0)
12151215
remaining_wallet_balance = current_wallet_balance
1216-
max_slippage = 0
1216+
max_slippage = 0.0
12171217

1218-
all_dynamic_info = await asyncio.gather(
1219-
*[subtensor.get_subnet_dynamic_info(x) for x in netuids]
1218+
all_dynamic_info, initial_stake_balances = await asyncio.gather(
1219+
asyncio.gather(*[subtensor.get_subnet_dynamic_info(x) for x in netuids]),
1220+
asyncio.gather(
1221+
*[
1222+
subtensor.get_stake_for_coldkey_and_hotkey_on_netuid(
1223+
coldkey_ss58=wallet.coldkeypub.ss58_address,
1224+
hotkey_ss58=staking_address_ss58,
1225+
netuid=x,
1226+
)
1227+
for x in netuids
1228+
]
1229+
),
12201230
)
12211231

1222-
for netuid, dynamic_info in zip(netuids, all_dynamic_info):
1232+
for netuid, dynamic_info, current_stake_balance in zip(
1233+
netuids, all_dynamic_info, initial_stake_balances
1234+
):
12231235
# Check that the subnet exists.
12241236
if not dynamic_info:
12251237
err_console.print(f"Subnet with netuid: {netuid} does not exist.")
12261238
continue
12271239

1228-
# Get old staking balance.
1229-
# TODO gather this
1230-
current_stake_balance: Balance = (
1231-
subtensor.get_stake_for_coldkey_and_hotkey_on_netuid( # TODO add/await
1232-
coldkey_ss58=wallet.coldkeypub.ss58_address,
1233-
hotkey_ss58=staking_address_ss58,
1234-
netuid=netuid,
1235-
).set_unit(netuid)
1236-
)
12371240
current_stake_balances.append(current_stake_balance)
12381241

12391242
# Get the amount.
1240-
amount_to_stake_as_balance = None
1243+
amount_to_stake_as_balance = Balance(0)
12411244
if amount:
12421245
amount_to_stake_as_balance = Balance.from_tao(amount)
12431246
elif stake_all:
@@ -1306,7 +1309,7 @@ async def stake_add_new(
13061309
style="light_goldenrod2",
13071310
)
13081311
table.add_column(
1309-
f"Recieved ({Balance.get_unit(netuid)})",
1312+
f"Received ({Balance.get_unit(netuid)})",
13101313
justify="center",
13111314
style="light_slate_blue",
13121315
)

0 commit comments

Comments
 (0)