Skip to content

Commit 7f5bed0

Browse files
igorsyligorsyl
authored andcommitted
fix feedback
2 parents 7a0c8e4 + c9930e7 commit 7f5bed0

File tree

12 files changed

+658
-211
lines changed

12 files changed

+658
-211
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## 9.0.1 /2025-02-13
4+
5+
## What's Changed
6+
* Fixes root tempo being 0 by @ibraheem-opentensor in https://github.com/opentensor/btcli/pull/312
7+
* Backmerge main to staging 900 by @ibraheem-opentensor in https://github.com/opentensor/btcli/pull/313
8+
* Fixes fmt err msg by @ibraheem-opentensor in https://github.com/opentensor/btcli/pull/314
9+
* Adds subnet identities set/get by @ibraheem-opentensor in https://github.com/opentensor/btcli/pull/316
10+
* Fix return type annotation for `alpha_to_tao_with_slippage` by @thewhaleking in https://github.com/opentensor/btcli/pull/311
11+
* Updates live view of btcli stake list
12+
13+
**Full Changelog**: https://github.com/opentensor/btcli/compare/v9.0.0...v9.0.1
14+
315
## 9.0.0 /2025-02-13
416

517
## What's Changed

bittensor_cli/cli.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ def __init__(self):
644644
self.config_app.command("set")(self.set_config)
645645
self.config_app.command("get")(self.get_config)
646646
self.config_app.command("clear")(self.del_config)
647-
self.config_app.command("metagraph", hidden=True)(self.metagraph_config)
647+
# self.config_app.command("metagraph", hidden=True)(self.metagraph_config)
648648

649649
# wallet commands
650650
self.wallet_app.command(
@@ -3209,11 +3209,22 @@ def stake_remove(
32093209
else:
32103210
print_error("Invalid hotkey ss58 address.")
32113211
raise typer.Exit()
3212-
else:
3213-
hotkey_or_ss58 = Prompt.ask(
3214-
"Enter the [blue]hotkey[/blue] name or [blue]ss58 address[/blue] to unstake all from",
3215-
default=self.config.get("wallet_hotkey") or defaults.wallet.hotkey,
3212+
elif all_hotkeys:
3213+
wallet = self.wallet_ask(
3214+
wallet_name,
3215+
wallet_path,
3216+
wallet_hotkey,
3217+
ask_for=[WO.NAME, WO.PATH],
32163218
)
3219+
else:
3220+
if not hotkey_ss58_address and not wallet_hotkey:
3221+
hotkey_or_ss58 = Prompt.ask(
3222+
"Enter the [blue]hotkey[/blue] name or [blue]ss58 address[/blue] to unstake all from [dim](or enter 'all' to unstake from all hotkeys)[/dim]",
3223+
default=self.config.get("wallet_hotkey") or defaults.wallet.hotkey,
3224+
)
3225+
else:
3226+
hotkey_or_ss58 = hotkey_ss58_address or wallet_hotkey
3227+
32173228
if is_valid_ss58_address(hotkey_or_ss58):
32183229
hotkey_ss58_address = hotkey_or_ss58
32193230
wallet = self.wallet_ask(
@@ -3222,6 +3233,14 @@ def stake_remove(
32223233
wallet_hotkey,
32233234
ask_for=[WO.NAME, WO.PATH],
32243235
)
3236+
elif hotkey_or_ss58 == "all":
3237+
all_hotkeys = True
3238+
wallet = self.wallet_ask(
3239+
wallet_name,
3240+
wallet_path,
3241+
wallet_hotkey,
3242+
ask_for=[WO.NAME, WO.PATH],
3243+
)
32253244
else:
32263245
wallet_hotkey = hotkey_or_ss58
32273246
wallet = self.wallet_ask(
@@ -3237,6 +3256,9 @@ def stake_remove(
32373256
subtensor=self.initialize_chain(network),
32383257
hotkey_ss58_address=hotkey_ss58_address,
32393258
unstake_all_alpha=unstake_all_alpha,
3259+
all_hotkeys=all_hotkeys,
3260+
include_hotkeys=include_hotkeys,
3261+
exclude_hotkeys=exclude_hotkeys,
32403262
prompt=prompt,
32413263
)
32423264
)

bittensor_cli/src/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Constants:
2020
subvortex_entrypoint = "ws://subvortex.info:9944"
2121
local_entrypoint = "ws://127.0.0.1:9944"
2222
rao_entrypoint = "wss://rao.chain.opentensor.ai:443"
23-
dev_entrypoint = "wss://dev.chain.opentensor.ai:443 "
23+
dev_entrypoint = "wss://dev.chain.opentensor.ai:443"
2424
local_entrypoint = "ws://127.0.0.1:9944"
2525
latent_lite_entrypoint = "wss://lite.sub.latent.to:443"
2626
network_map = {

bittensor_cli/src/bittensor/balances.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __str__(self):
7676
if self.unit == UNITS[0]:
7777
return f"{self.unit} {float(self.tao):,.4f}"
7878
else:
79-
return f"{float(self.tao):,.4f} {self.unit}\u200e"
79+
return f"\u200e{float(self.tao):,.4f} {self.unit}\u200e"
8080

8181
def __rich__(self):
8282
return "[green]{}[/green][green]{}[/green][green].[/green][dim green]{}[/dim green]".format(

bittensor_cli/src/bittensor/chain_data.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class SubnetHyperparameters(InfoBase):
156156
def _fix_decoded(
157157
cls, decoded: Union[dict, "SubnetHyperparameters"]
158158
) -> "SubnetHyperparameters":
159-
return SubnetHyperparameters(
159+
return cls(
160160
rho=decoded.get("rho"),
161161
kappa=decoded.get("kappa"),
162162
immunity_period=decoded.get("immunity_period"),
@@ -197,6 +197,7 @@ class StakeInfo(InfoBase):
197197
stake: Balance # Stake for the hotkey-coldkey pair
198198
locked: Balance # Stake which is locked.
199199
emission: Balance # Emission for the hotkey-coldkey pair
200+
tao_emission: Balance # TAO emission for the hotkey-coldkey pair
200201
drain: int
201202
is_registered: bool
202203

@@ -208,11 +209,20 @@ def _fix_decoded(cls, decoded: Any) -> "StakeInfo":
208209
stake = Balance.from_rao(decoded.get("stake")).set_unit(netuid)
209210
locked = Balance.from_rao(decoded.get("locked")).set_unit(netuid)
210211
emission = Balance.from_rao(decoded.get("emission")).set_unit(netuid)
212+
tao_emission = Balance.from_rao(decoded.get("tao_emission"))
211213
drain = int(decoded.get("drain"))
212214
is_registered = bool(decoded.get("is_registered"))
213215

214-
return StakeInfo(
215-
hotkey, coldkey, netuid, stake, locked, emission, drain, is_registered
216+
return cls(
217+
hotkey,
218+
coldkey,
219+
netuid,
220+
stake,
221+
locked,
222+
emission,
223+
tao_emission,
224+
drain,
225+
is_registered,
216226
)
217227

218228

@@ -293,7 +303,7 @@ def _fix_decoded(cls, decoded: Any) -> "NeuronInfo":
293303
axon_info = decoded.get("axon_info", {})
294304
coldkey = decode_account_id(decoded.get("coldkey"))
295305
hotkey = decode_account_id(decoded.get("hotkey"))
296-
return NeuronInfo(
306+
return cls(
297307
hotkey=hotkey,
298308
coldkey=coldkey,
299309
uid=decoded.get("uid"),
@@ -555,7 +565,7 @@ class SubnetInfo(InfoBase):
555565

556566
@classmethod
557567
def _fix_decoded(cls, decoded: "SubnetInfo") -> "SubnetInfo":
558-
return SubnetInfo(
568+
return cls(
559569
netuid=decoded.get("netuid"),
560570
rho=decoded.get("rho"),
561571
kappa=decoded.get("kappa"),
@@ -594,7 +604,7 @@ class SubnetIdentity(InfoBase):
594604

595605
@classmethod
596606
def _fix_decoded(cls, decoded: dict) -> "SubnetIdentity":
597-
return SubnetIdentity(
607+
return cls(
598608
subnet_name=bytes(decoded["subnet_name"]).decode(),
599609
github_repo=bytes(decoded["github_repo"]).decode(),
600610
subnet_contact=bytes(decoded["subnet_contact"]).decode(),
@@ -828,7 +838,7 @@ class SubnetState(InfoBase):
828838
@classmethod
829839
def _fix_decoded(cls, decoded: Any) -> "SubnetState":
830840
netuid = decoded.get("netuid")
831-
return SubnetState(
841+
return cls(
832842
netuid=netuid,
833843
hotkeys=[decode_account_id(val) for val in decoded.get("hotkeys")],
834844
coldkeys=[decode_account_id(val) for val in decoded.get("coldkeys")],

bittensor_cli/src/bittensor/subtensor_interface.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ async def get_total_stake_for_coldkey(
352352
*ss58_addresses,
353353
block_hash: Optional[str] = None,
354354
reuse_block: bool = False,
355-
) -> dict[str, Balance]:
355+
) -> dict[str, tuple[Balance, Balance]]:
356356
"""
357357
Returns the total stake held on a coldkey.
358358
@@ -370,7 +370,8 @@ async def get_total_stake_for_coldkey(
370370

371371
results = {}
372372
for ss58, stake_info_list in sub_stakes.items():
373-
all_staked_tao = 0
373+
total_tao_value = Balance(0)
374+
total_swapped_tao_value = Balance(0)
374375
for sub_stake in stake_info_list:
375376
if sub_stake.stake.rao == 0:
376377
continue
@@ -381,19 +382,20 @@ async def get_total_stake_for_coldkey(
381382
netuid
382383
)
383384

384-
tao_locked = pool.tao_in
385-
386-
issuance = pool.alpha_out if pool.is_dynamic else tao_locked
387-
tao_ownership = Balance(0)
385+
# Without slippage
386+
tao_value = pool.alpha_to_tao(alpha_value)
387+
total_tao_value += tao_value
388388

389-
if alpha_value.tao > 0.00009 and issuance.tao != 0:
390-
tao_ownership = Balance.from_tao(
391-
(alpha_value.tao / issuance.tao) * tao_locked.tao
389+
# With slippage
390+
if netuid == 0:
391+
swapped_tao_value = tao_value
392+
else:
393+
swapped_tao_value, _, _ = pool.alpha_to_tao_with_slippage(
394+
sub_stake.stake
392395
)
396+
total_swapped_tao_value += swapped_tao_value
393397

394-
all_staked_tao += tao_ownership.rao
395-
396-
results[ss58] = Balance.from_rao(all_staked_tao)
398+
results[ss58] = (total_tao_value, total_swapped_tao_value)
397399
return results
398400

399401
async def get_total_stake_for_hotkey(

bittensor_cli/src/commands/stake/children_hotkeys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ async def get_childkey_take(subtensor, hotkey: str, netuid: int) -> Optional[int
256256
params=[hotkey, netuid],
257257
)
258258
if childkey_take_:
259-
return int(childkey_take_.value)
259+
return int(childkey_take_)
260260

261261
except SubstrateRequestException as e:
262262
err_console.print(f"Error querying ChildKeys: {format_error_message(e)}")

0 commit comments

Comments
 (0)