Skip to content

Commit c9930e7

Browse files
authored
Merge branch 'staging' into fix/igorsyl/version
2 parents 747efa1 + 72910f9 commit c9930e7

File tree

13 files changed

+659
-214
lines changed

13 files changed

+659
-214
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/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ def version_as_int(version):
3232
__new_signature_version__ = 360
3333
return __version_as_int__
3434

35-
__version__ = "9.0.0"
35+
__version__ = "9.0.1"
3636
__version_as_int__ = version_as_int(__version__)
3737

38-
39-
4038
__all__ = ["CLIManager", "__version__", "__version_as_int__"]

bittensor_cli/cli.py

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

650650
# wallet commands
651651
self.wallet_app.command(
@@ -3210,11 +3210,22 @@ def stake_remove(
32103210
else:
32113211
print_error("Invalid hotkey ss58 address.")
32123212
raise typer.Exit()
3213-
else:
3214-
hotkey_or_ss58 = Prompt.ask(
3215-
"Enter the [blue]hotkey[/blue] name or [blue]ss58 address[/blue] to unstake all from",
3216-
default=self.config.get("wallet_hotkey") or defaults.wallet.hotkey,
3213+
elif all_hotkeys:
3214+
wallet = self.wallet_ask(
3215+
wallet_name,
3216+
wallet_path,
3217+
wallet_hotkey,
3218+
ask_for=[WO.NAME, WO.PATH],
32173219
)
3220+
else:
3221+
if not hotkey_ss58_address and not wallet_hotkey:
3222+
hotkey_or_ss58 = Prompt.ask(
3223+
"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]",
3224+
default=self.config.get("wallet_hotkey") or defaults.wallet.hotkey,
3225+
)
3226+
else:
3227+
hotkey_or_ss58 = hotkey_ss58_address or wallet_hotkey
3228+
32183229
if is_valid_ss58_address(hotkey_or_ss58):
32193230
hotkey_ss58_address = hotkey_or_ss58
32203231
wallet = self.wallet_ask(
@@ -3223,6 +3234,14 @@ def stake_remove(
32233234
wallet_hotkey,
32243235
ask_for=[WO.NAME, WO.PATH],
32253236
)
3237+
elif hotkey_or_ss58 == "all":
3238+
all_hotkeys = True
3239+
wallet = self.wallet_ask(
3240+
wallet_name,
3241+
wallet_path,
3242+
wallet_hotkey,
3243+
ask_for=[WO.NAME, WO.PATH],
3244+
)
32263245
else:
32273246
wallet_hotkey = hotkey_or_ss58
32283247
wallet = self.wallet_ask(
@@ -3238,6 +3257,9 @@ def stake_remove(
32383257
subtensor=self.initialize_chain(network),
32393258
hotkey_ss58_address=hotkey_ss58_address,
32403259
unstake_all_alpha=unstake_all_alpha,
3260+
all_hotkeys=all_hotkeys,
3261+
include_hotkeys=include_hotkeys,
3262+
exclude_hotkeys=exclude_hotkeys,
32413263
prompt=prompt,
32423264
)
32433265
)

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)