Skip to content

Commit 95a4af5

Browse files
committed
Think this is it
1 parent edfac73 commit 95a4af5

File tree

2 files changed

+31
-27
lines changed

2 files changed

+31
-27
lines changed

bittensor_cli/src/bittensor/extrinsics/registration.py

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
print_verbose,
3939
print_error,
4040
unlock_key,
41-
hex_to_bytes,
41+
hex_to_bytes, get_hotkey_pub_ss58,
4242
)
4343

4444
if typing.TYPE_CHECKING:
@@ -490,7 +490,7 @@ async def register_extrinsic(
490490

491491
async def get_neuron_for_pubkey_and_subnet():
492492
uid = await subtensor.query(
493-
"SubtensorModule", "Uids", [netuid, wallet.hotkey.ss58_address]
493+
"SubtensorModule", "Uids", [netuid, get_hotkey_pub_ss58(wallet)]
494494
)
495495
if uid is None:
496496
return NeuronInfo.get_null_neuron()
@@ -525,7 +525,7 @@ async def get_neuron_for_pubkey_and_subnet():
525525
if not Confirm.ask(
526526
f"Continue Registration?\n"
527527
f" hotkey [{COLOR_PALETTE.G.HK}]({wallet.hotkey_str})[/{COLOR_PALETTE.G.HK}]:"
528-
f"\t[{COLOR_PALETTE.G.HK}]{wallet.hotkey.ss58_address}[/{COLOR_PALETTE.G.HK}]\n"
528+
f"\t[{COLOR_PALETTE.G.HK}]{get_hotkey_pub_ss58(wallet)}[/{COLOR_PALETTE.G.HK}]\n"
529529
f" coldkey [{COLOR_PALETTE.G.CK}]({wallet.name})[/{COLOR_PALETTE.G.CK}]:"
530530
f"\t[{COLOR_PALETTE.G.CK}]{wallet.coldkeypub.ss58_address}[/{COLOR_PALETTE.G.CK}]\n"
531531
f" network:\t\t[{COLOR_PALETTE.G.LINKS}]{subtensor.network}[/{COLOR_PALETTE.G.LINKS}]\n"
@@ -577,7 +577,7 @@ async def get_neuron_for_pubkey_and_subnet():
577577
if not pow_result:
578578
# might be registered already on this subnet
579579
is_registered = await is_hotkey_registered(
580-
subtensor, netuid=netuid, hotkey_ss58=wallet.hotkey.ss58_address
580+
subtensor, netuid=netuid, hotkey_ss58=get_hotkey_pub_ss58(wallet)
581581
)
582582
if is_registered:
583583
err_console.print(
@@ -598,7 +598,7 @@ async def get_neuron_for_pubkey_and_subnet():
598598
"block_number": pow_result.block_number,
599599
"nonce": pow_result.nonce,
600600
"work": [int(byte_) for byte_ in pow_result.seal],
601-
"hotkey": wallet.hotkey.ss58_address,
601+
"hotkey": get_hotkey_pub_ss58(wallet),
602602
"coldkey": wallet.coldkeypub.ss58_address,
603603
},
604604
)
@@ -639,7 +639,7 @@ async def get_neuron_for_pubkey_and_subnet():
639639
is_registered = await is_hotkey_registered(
640640
subtensor,
641641
netuid=netuid,
642-
hotkey_ss58=wallet.hotkey.ss58_address,
642+
hotkey_ss58=get_hotkey_pub_ss58(wallet),
643643
)
644644
if is_registered:
645645
console.print(
@@ -704,7 +704,7 @@ async def burned_register_extrinsic(
704704
spinner="aesthetic",
705705
) as status:
706706
my_uid = await subtensor.query(
707-
"SubtensorModule", "Uids", [netuid, wallet.hotkey.ss58_address]
707+
"SubtensorModule", "Uids", [netuid, get_hotkey_pub_ss58(wallet)]
708708
)
709709
block_hash = await subtensor.substrate.get_chain_head()
710710

@@ -751,7 +751,7 @@ async def burned_register_extrinsic(
751751
call_function="burned_register",
752752
call_params={
753753
"netuid": netuid,
754-
"hotkey": wallet.hotkey.ss58_address,
754+
"hotkey": get_hotkey_pub_ss58(wallet),
755755
},
756756
)
757757
success, err_msg = await subtensor.sign_and_send_extrinsic(
@@ -773,10 +773,10 @@ async def burned_register_extrinsic(
773773
reuse_block=False,
774774
),
775775
subtensor.get_netuids_for_hotkey(
776-
wallet.hotkey.ss58_address, block_hash=block_hash
776+
get_hotkey_pub_ss58(wallet), block_hash=block_hash
777777
),
778778
subtensor.query(
779-
"SubtensorModule", "Uids", [netuid, wallet.hotkey.ss58_address]
779+
"SubtensorModule", "Uids", [netuid, get_hotkey_pub_ss58(wallet)]
780780
),
781781
)
782782

@@ -1146,7 +1146,7 @@ async def _block_solver(
11461146

11471147
timeout = 0.15 if cuda else 0.15
11481148
while netuid == -1 or not await is_hotkey_registered(
1149-
subtensor, netuid, wallet.hotkey.ss58_address
1149+
subtensor, netuid, get_hotkey_pub_ss58(wallet)
11501150
):
11511151
# Wait until a solver finds a solution
11521152
try:
@@ -1755,37 +1755,39 @@ async def swap_hotkey_extrinsic(
17551755
:return: Success
17561756
"""
17571757
block_hash = await subtensor.substrate.get_chain_head()
1758+
hk_ss58 = get_hotkey_pub_ss58(wallet)
17581759
netuids_registered = await subtensor.get_netuids_for_hotkey(
1759-
wallet.hotkey.ss58_address, block_hash=block_hash
1760+
hk_ss58, block_hash=block_hash
17601761
)
17611762
netuids_registered_new_hotkey = await subtensor.get_netuids_for_hotkey(
1762-
new_wallet.hotkey.ss58_address, block_hash=block_hash
1763+
hk_ss58, block_hash=block_hash
17631764
)
17641765

17651766
if netuid is not None and netuid not in netuids_registered:
17661767
err_console.print(
1767-
f":cross_mark: [red]Failed[/red]: Original hotkey {wallet.hotkey.ss58_address} is not registered on subnet {netuid}"
1768+
f":cross_mark: [red]Failed[/red]: Original hotkey {hk_ss58} is not registered on subnet {netuid}"
17681769
)
17691770
return False
17701771

17711772
elif not len(netuids_registered) > 0:
17721773
err_console.print(
1773-
f"Original hotkey [dark_orange]{wallet.hotkey.ss58_address}[/dark_orange] is not registered on any subnet. "
1774+
f"Original hotkey [dark_orange]{hk_ss58}[/dark_orange] is not registered on any subnet. "
17741775
f"Please register and try again"
17751776
)
17761777
return False
17771778

1779+
new_hk_ss58 = get_hotkey_pub_ss58(new_wallet)
17781780
if netuid is not None:
17791781
if netuid in netuids_registered_new_hotkey:
17801782
err_console.print(
1781-
f":cross_mark: [red]Failed[/red]: New hotkey {new_wallet.hotkey.ss58_address} "
1783+
f":cross_mark: [red]Failed[/red]: New hotkey {new_hk_ss58} "
17821784
f"is already registered on subnet {netuid}"
17831785
)
17841786
return False
17851787
else:
17861788
if len(netuids_registered_new_hotkey) > 0:
17871789
err_console.print(
1788-
f":cross_mark: [red]Failed[/red]: New hotkey {new_wallet.hotkey.ss58_address} "
1790+
f":cross_mark: [red]Failed[/red]: New hotkey {new_hk_ss58} "
17891791
f"is already registered on subnet(s) {netuids_registered_new_hotkey}"
17901792
)
17911793
return False
@@ -1798,28 +1800,28 @@ async def swap_hotkey_extrinsic(
17981800
if netuid is not None:
17991801
confirm_message = (
18001802
f"Do you want to swap [dark_orange]{wallet.name}[/dark_orange] hotkey \n\t"
1801-
f"[dark_orange]{wallet.hotkey.ss58_address} ({wallet.hotkey_str})[/dark_orange] with hotkey \n\t"
1802-
f"[dark_orange]{new_wallet.hotkey.ss58_address} ({new_wallet.hotkey_str})[/dark_orange] on subnet {netuid}\n"
1803+
f"[dark_orange]{hk_ss58} ({wallet.hotkey_str})[/dark_orange] with hotkey \n\t"
1804+
f"[dark_orange]{new_hk_ss58} ({new_wallet.hotkey_str})[/dark_orange] on subnet {netuid}\n"
18031805
"This operation will cost [bold cyan]1 TAO (recycled)[/bold cyan]"
18041806
)
18051807
else:
18061808
confirm_message = (
18071809
f"Do you want to swap [dark_orange]{wallet.name}[/dark_orange] hotkey \n\t"
1808-
f"[dark_orange]{wallet.hotkey.ss58_address} ({wallet.hotkey_str})[/dark_orange] with hotkey \n\t"
1809-
f"[dark_orange]{new_wallet.hotkey.ss58_address} ({new_wallet.hotkey_str})[/dark_orange] on all subnets\n"
1810+
f"[dark_orange]{hk_ss58} ({wallet.hotkey_str})[/dark_orange] with hotkey \n\t"
1811+
f"[dark_orange]{new_hk_ss58} ({new_wallet.hotkey_str})[/dark_orange] on all subnets\n"
18101812
"This operation will cost [bold cyan]1 TAO (recycled)[/bold cyan]"
18111813
)
18121814

18131815
if not Confirm.ask(confirm_message):
18141816
return False
18151817
print_verbose(
1816-
f"Swapping {wallet.name}'s hotkey ({wallet.hotkey.ss58_address} - {wallet.hotkey_str}) with "
1817-
f"{new_wallet.name}'s hotkey ({new_wallet.hotkey.ss58_address} - {new_wallet.hotkey_str})"
1818+
f"Swapping {wallet.name}'s hotkey ({hk_ss58} - {wallet.hotkey_str}) with "
1819+
f"{new_wallet.name}'s hotkey ({new_hk_ss58} - {new_wallet.hotkey_str})"
18181820
)
18191821
with console.status(":satellite: Swapping hotkeys...", spinner="aesthetic"):
18201822
call_params = {
1821-
"hotkey": wallet.hotkey.ss58_address,
1822-
"new_hotkey": new_wallet.hotkey.ss58_address,
1823+
"hotkey": hk_ss58,
1824+
"new_hotkey": new_hk_ss58,
18231825
"netuid": netuid,
18241826
}
18251827

@@ -1832,7 +1834,8 @@ async def swap_hotkey_extrinsic(
18321834

18331835
if success:
18341836
console.print(
1835-
f"Hotkey {wallet.hotkey.ss58_address} ({wallet.hotkey_str}) swapped for new hotkey: {new_wallet.hotkey.ss58_address} ({new_wallet.hotkey_str})"
1837+
f"Hotkey {hk_ss58} ({wallet.hotkey_str}) swapped for new hotkey: "
1838+
f"{new_hk_ss58} ({new_wallet.hotkey_str})"
18361839
)
18371840
return True
18381841
else:

bittensor_cli/src/bittensor/extrinsics/root.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
u16_normalized_float,
3737
print_verbose,
3838
format_error_message,
39-
unlock_key, get_hotkey_pub_ss58,
39+
unlock_key,
40+
get_hotkey_pub_ss58,
4041
)
4142

4243
if TYPE_CHECKING:

0 commit comments

Comments
 (0)