Skip to content

Commit f40e8b5

Browse files
committed
More commands.
1 parent 68e5afc commit f40e8b5

File tree

6 files changed

+36
-35
lines changed

6 files changed

+36
-35
lines changed

bittensor_cli/src/bittensor/extrinsics/root.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
u16_normalized_float,
3737
print_verbose,
3838
format_error_message,
39-
unlock_key,
39+
unlock_key, get_hotkey_pub_ss58,
4040
)
4141

4242
if TYPE_CHECKING:
@@ -310,7 +310,7 @@ async def root_register_extrinsic(
310310

311311
print_verbose(f"Checking if hotkey ({wallet.hotkey_str}) is registered on root")
312312
is_registered = await is_hotkey_registered(
313-
subtensor, netuid=0, hotkey_ss58=wallet.hotkey.ss58_address
313+
subtensor, netuid=0, hotkey_ss58=get_hotkey_pub_ss58(wallet)
314314
)
315315
if is_registered:
316316
console.print(
@@ -322,7 +322,7 @@ async def root_register_extrinsic(
322322
call = await subtensor.substrate.compose_call(
323323
call_module="SubtensorModule",
324324
call_function="root_register",
325-
call_params={"hotkey": wallet.hotkey.ss58_address},
325+
call_params={"hotkey": get_hotkey_pub_ss58(wallet)},
326326
)
327327
success, err_msg = await subtensor.sign_and_send_extrinsic(
328328
call,
@@ -341,7 +341,7 @@ async def root_register_extrinsic(
341341
uid = await subtensor.query(
342342
module="SubtensorModule",
343343
storage_function="Uids",
344-
params=[0, wallet.hotkey.ss58_address],
344+
params=[0, get_hotkey_pub_ss58(wallet)],
345345
)
346346
if uid is not None:
347347
console.print(
@@ -391,7 +391,7 @@ async def _do_set_weights():
391391
"weights": weight_vals,
392392
"netuid": 0,
393393
"version_key": version_key,
394-
"hotkey": wallet.hotkey.ss58_address,
394+
"hotkey": get_hotkey_pub_ss58(wallet),
395395
},
396396
)
397397
# Period dictates how long the extrinsic will stay as part of waiting pool
@@ -415,7 +415,7 @@ async def _do_set_weights():
415415
return False, await response.error_message
416416

417417
my_uid = await subtensor.query(
418-
"SubtensorModule", "Uids", [0, wallet.hotkey.ss58_address]
418+
"SubtensorModule", "Uids", [0, get_hotkey_pub_ss58(wallet)]
419419
)
420420

421421
if my_uid is None:

bittensor_cli/src/commands/stake/add.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
print_error,
2020
print_verbose,
2121
unlock_key,
22-
json_console,
22+
json_console, get_hotkey_pub_ss58,
2323
)
2424
from bittensor_wallet import Wallet
2525

@@ -552,7 +552,7 @@ def _get_hotkeys_to_stake_to(
552552
# Stake to all hotkeys except excluded ones
553553
all_hotkeys_: list[Wallet] = get_hotkey_wallets_for_wallet(wallet=wallet)
554554
return [
555-
(wallet.hotkey_str, wallet.hotkey.ss58_address)
555+
(wallet.hotkey_str, get_hotkey_pub_ss58(wallet))
556556
for wallet in all_hotkeys_
557557
if wallet.hotkey_str not in (exclude_hotkeys or [])
558558
]
@@ -572,7 +572,7 @@ def _get_hotkeys_to_stake_to(
572572
name=wallet.name,
573573
hotkey=hotkey_ss58_or_hotkey_name,
574574
)
575-
hotkeys.append((wallet_.hotkey_str, wallet_.hotkey.ss58_address))
575+
hotkeys.append((wallet_.hotkey_str, get_hotkey_pub_ss58(wallet_)))
576576

577577
return hotkeys
578578

@@ -581,7 +581,7 @@ def _get_hotkeys_to_stake_to(
581581
f"Staking to hotkey: ({wallet.hotkey_str}) in wallet: ({wallet.name})"
582582
)
583583
assert wallet.hotkey is not None
584-
return [(None, wallet.hotkey.ss58_address)]
584+
return [(None, get_hotkey_pub_ss58(wallet))]
585585

586586

587587
def _define_stake_table(

bittensor_cli/src/commands/stake/children_hotkeys.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
is_valid_ss58_address,
2121
format_error_message,
2222
unlock_key,
23-
json_console,
23+
json_console, get_hotkey_pub_ss58,
2424
)
2525

2626

@@ -464,24 +464,24 @@ async def _render_table(
464464
netuid_children_tuples = []
465465
for netuid_ in netuids:
466466
success, children, err_mg = await subtensor.get_children(
467-
wallet.hotkey.ss58_address, netuid_
467+
get_hotkey_pub_ss58(wallet), netuid_
468468
)
469469
if children:
470470
netuid_children_tuples.append((netuid_, children))
471471
if not success:
472472
err_console.print(
473473
f"Failed to get children from subtensor {netuid_}: {err_mg}"
474474
)
475-
await _render_table(wallet.hotkey.ss58_address, netuid_children_tuples)
475+
await _render_table(get_hotkey_pub_ss58(wallet), netuid_children_tuples)
476476
else:
477477
success, children, err_mg = await subtensor.get_children(
478-
wallet.hotkey.ss58_address, netuid
478+
get_hotkey_pub_ss58(wallet), netuid
479479
)
480480
if not success:
481481
err_console.print(f"Failed to get children from subtensor: {err_mg}")
482482
if children:
483483
netuid_children_tuples = [(netuid, children)]
484-
await _render_table(wallet.hotkey.ss58_address, netuid_children_tuples)
484+
await _render_table(get_hotkey_pub_ss58(wallet), netuid_children_tuples)
485485

486486
return children
487487

@@ -500,12 +500,12 @@ async def set_children(
500500
"""Set children hotkeys."""
501501
# Validate children SS58 addresses
502502
# TODO check to see if this should be allowed to be specified by user instead of pulling from wallet
503-
hotkey = wallet.hotkey.ss58_address
503+
hotkey = get_hotkey_pub_ss58(wallet)
504504
for child in children:
505505
if not is_valid_ss58_address(child):
506506
err_console.print(f":cross_mark:[red] Invalid SS58 address: {child}[/red]")
507507
return
508-
if child == wallet.hotkey.ss58_address:
508+
if child == hotkey:
509509
err_console.print(":cross_mark:[red] Cannot set yourself as a child.[/red]")
510510
return
511511

@@ -608,7 +608,7 @@ async def revoke_children(
608608
subtensor=subtensor,
609609
wallet=wallet,
610610
netuid=netuid,
611-
hotkey=wallet.hotkey.ss58_address,
611+
hotkey=get_hotkey_pub_ss58(wallet),
612612
children_with_proportions=[],
613613
prompt=prompt,
614614
wait_for_inclusion=wait_for_inclusion,
@@ -647,7 +647,7 @@ async def revoke_children(
647647
subtensor=subtensor,
648648
wallet=wallet,
649649
netuid=netuid,
650-
hotkey=wallet.hotkey.ss58_address,
650+
hotkey=get_hotkey_pub_ss58(wallet),
651651
children_with_proportions=[],
652652
prompt=prompt,
653653
wait_for_inclusion=True,
@@ -746,7 +746,7 @@ async def set_chk_take_subnet(subnet: int, chk_take: float) -> bool:
746746
subtensor=subtensor,
747747
wallet=wallet,
748748
netuid=subnet,
749-
hotkey=wallet.hotkey.ss58_address,
749+
hotkey=get_hotkey_pub_ss58(wallet),
750750
take=chk_take,
751751
prompt=prompt,
752752
wait_for_inclusion=wait_for_inclusion,
@@ -756,7 +756,7 @@ async def set_chk_take_subnet(subnet: int, chk_take: float) -> bool:
756756
if success:
757757
console.print(":white_heavy_check_mark: [green]Set childkey take.[/green]")
758758
console.print(
759-
f"The childkey take for {wallet.hotkey.ss58_address} is now set to {take * 100:.2f}%."
759+
f"The childkey take for {get_hotkey_pub_ss58(wallet)} is now set to {take * 100:.2f}%."
760760
)
761761
return True
762762
else:
@@ -766,9 +766,10 @@ async def set_chk_take_subnet(subnet: int, chk_take: float) -> bool:
766766
return False
767767

768768
# Print childkey take for other user and return (dont offer to change take rate)
769-
if not hotkey or hotkey == wallet.hotkey.ss58_address:
770-
hotkey = wallet.hotkey.ss58_address
771-
if hotkey != wallet.hotkey.ss58_address or not take:
769+
wallet_hk = get_hotkey_pub_ss58(wallet)
770+
if not hotkey or hotkey == wallet_hk:
771+
hotkey = wallet_hk
772+
if hotkey != wallet_hk or not take:
772773
# display childkey take for other users
773774
if netuid:
774775
await display_chk_take(hotkey, netuid)
@@ -826,7 +827,7 @@ async def set_chk_take_subnet(subnet: int, chk_take: float) -> bool:
826827
subtensor=subtensor,
827828
wallet=wallet,
828829
netuid=netuid_,
829-
hotkey=wallet.hotkey.ss58_address,
830+
hotkey=wallet_hk,
830831
take=take,
831832
prompt=prompt,
832833
wait_for_inclusion=True,

bittensor_cli/src/commands/stake/remove.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
format_error_message,
2222
group_subnets,
2323
unlock_key,
24-
json_console,
24+
json_console, get_hotkey_pub_ss58,
2525
)
2626

2727
if TYPE_CHECKING:
@@ -407,7 +407,7 @@ async def unstake_all(
407407
old_identities=old_identities,
408408
)
409409
elif not hotkey_ss58_address:
410-
hotkeys = [(wallet.hotkey_str, wallet.hotkey.ss58_address, None)]
410+
hotkeys = [(wallet.hotkey_str, get_hotkey_pub_ss58(wallet), None)]
411411
else:
412412
hotkeys = [(None, hotkey_ss58_address, None)]
413413

@@ -1198,7 +1198,7 @@ def _get_hotkeys_to_unstake(
11981198
print_verbose("Unstaking from all hotkeys")
11991199
all_hotkeys_ = get_hotkey_wallets_for_wallet(wallet=wallet)
12001200
wallet_hotkeys = [
1201-
(wallet.hotkey_str, wallet.hotkey.ss58_address, None)
1201+
(wallet.hotkey_str, get_hotkey_pub_ss58(wallet), None)
12021202
for wallet in all_hotkeys_
12031203
if wallet.hotkey_str not in exclude_hotkeys
12041204
]
@@ -1230,15 +1230,15 @@ def _get_hotkeys_to_unstake(
12301230
path=wallet.path,
12311231
hotkey=hotkey_identifier,
12321232
)
1233-
result.append((wallet_.hotkey_str, wallet_.hotkey.ss58_address, None))
1233+
result.append((wallet_.hotkey_str, get_hotkey_pub_ss58(wallet_), None))
12341234
return result
12351235

12361236
# Only cli.config.wallet.hotkey is specified
12371237
print_verbose(
12381238
f"Unstaking from wallet: ({wallet.name}) from hotkey: ({wallet.hotkey_str})"
12391239
)
12401240
assert wallet.hotkey is not None
1241-
return [(wallet.hotkey_str, wallet.hotkey.ss58_address, None)]
1241+
return [(wallet.hotkey_str, get_hotkey_pub_ss58(wallet), None)]
12421242

12431243

12441244
def _create_unstake_table(

bittensor_cli/src/commands/subnets/subnets.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
get_subnet_name,
3636
unlock_key,
3737
blocks_to_duration,
38-
json_console,
38+
json_console, get_hotkey_pub_ss58,
3939
)
4040

4141
if TYPE_CHECKING:
@@ -114,7 +114,7 @@ async def _find_event_attributes_in_extrinsic_receipt(
114114
return False, None
115115

116116
call_params = {
117-
"hotkey": wallet.hotkey.ss58_address,
117+
"hotkey": get_hotkey_pub_ss58(wallet),
118118
"mechid": 1,
119119
}
120120
call_function = "register_network"
@@ -1654,7 +1654,7 @@ async def register(
16541654
str(netuid),
16551655
f"{Balance.get_unit(netuid)}",
16561656
f"τ {current_recycle.tao:.4f}",
1657-
f"{wallet.hotkey.ss58_address}",
1657+
f"{get_hotkey_pub_ss58(wallet)}",
16581658
f"{wallet.coldkeypub.ss58_address}",
16591659
)
16601660
console.print(table)

bittensor_cli/src/commands/weights.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
err_console,
1515
console,
1616
format_error_message,
17-
json_console,
17+
json_console, get_hotkey_pub_ss58,
1818
)
1919
from bittensor_cli.src.bittensor.extrinsics.root import (
2020
convert_weights_and_uids_for_emit,
@@ -128,7 +128,7 @@ async def commit_weights(
128128

129129
# Generate the hash of the weights
130130
commit_hash = generate_weight_hash(
131-
address=self.wallet.hotkey.ss58_address,
131+
address=get_hotkey_pub_ss58(self.wallet),
132132
netuid=self.netuid,
133133
uids=uids,
134134
values=weights,

0 commit comments

Comments
 (0)