Skip to content

Commit 7eca41f

Browse files
committed
Proxy announce execute improved
1 parent 6bd022c commit 7eca41f

File tree

1 file changed

+39
-29
lines changed

1 file changed

+39
-29
lines changed

bittensor_cli/cli.py

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8911,43 +8911,48 @@ def proxy_execute_announced(
89118911
else:
89128912
proxies = []
89138913
potential_matches = []
8914-
for row in proxies:
8915-
p_name, ss58_address, delay_, spawner, proxy_type, note = row
8916-
if proxy == ss58_address:
8917-
potential_matches.append(row)
8918-
if len(potential_matches) == 1:
8919-
delay = potential_matches[0][2]
8920-
elif len(potential_matches) > 1:
8921-
if not prompt:
8922-
err_console.print(
8923-
f":cross_mark:[red]Error: The proxy ss58 you provided: {proxy} matched the address book"
8924-
f" ambiguously (more than one match). To use this (rather than the address book name), you will "
8925-
f"have to use without {arg__('--no-prompt')}"
8926-
)
8927-
return
8928-
else:
8929-
console.print(
8930-
f"The proxy ss58 you provided matches the address book ambiguously. The results will be"
8931-
f"iterated, for you to select your intended proxy."
8932-
)
8933-
for row in potential_matches:
8934-
p_name, ss58_address, delay_, spawner, proxy_type, note = row
8914+
if not got_delay_from_config:
8915+
for row in proxies:
8916+
p_name, ss58_address, delay_, spawner, proxy_type, note = row
8917+
if proxy == ss58_address:
8918+
potential_matches.append(row)
8919+
if len(potential_matches) == 1:
8920+
delay = potential_matches[0][2]
8921+
got_delay_from_config = True
8922+
elif len(potential_matches) > 1:
8923+
if not prompt:
8924+
err_console.print(
8925+
f":cross_mark:[red]Error: The proxy ss58 you provided: {proxy} matched the address book"
8926+
f" ambiguously (more than one match). To use this (rather than the address book name), you will "
8927+
f"have to use without {arg__('--no-prompt')}"
8928+
)
8929+
return
8930+
else:
89358931
console.print(
8936-
f"Name: {p_name}\n"
8937-
f"Delay: {delay_}\n"
8938-
f"Spawner/Delegator: {spawner}\n"
8939-
f"Proxy Type: {proxy_type}\n"
8940-
f"Note: {note}\n"
8932+
f"The proxy ss58 you provided matches the address book ambiguously. The results will be"
8933+
f"iterated, for you to select your intended proxy."
89418934
)
8942-
if Confirm.ask("Is this the intended proxy?"):
8943-
delay = delay_
8944-
got_delay_from_config = True
8935+
for row in potential_matches:
8936+
p_name, ss58_address, delay_, spawner, proxy_type, note = row
8937+
console.print(
8938+
f"Name: {p_name}\n"
8939+
f"Delay: {delay_}\n"
8940+
f"Spawner/Delegator: {spawner}\n"
8941+
f"Proxy Type: {proxy_type}\n"
8942+
f"Note: {note}\n"
8943+
)
8944+
if Confirm.ask("Is this the intended proxy?"):
8945+
delay = delay_
8946+
got_delay_from_config = True
8947+
break
8948+
89458949
if not got_delay_from_config:
89468950
verbose_console.print(
89478951
f"Unable to retrieve proxy from address book: {proxy}"
89488952
)
89498953
call_hex = None
89508954
block = None
8955+
got_call_from_db = False
89518956
potential_call_matches = []
89528957
for row in announcements:
89538958
(
@@ -8963,6 +8968,7 @@ def proxy_execute_announced(
89638968
if len(potential_call_matches) == 1:
89648969
block = potential_call_matches[0][2]
89658970
call_hex = potential_call_matches[0][4]
8971+
got_call_from_db = True
89668972
elif len(potential_call_matches) > 1:
89678973
if not prompt:
89688974
err_console.print(
@@ -8993,6 +8999,10 @@ def proxy_execute_announced(
89938999
if Confirm.ask("Is this the intended call?"):
89949000
call_hex = call_hex_
89959001
block = block_
9002+
got_call_from_db = True
9003+
break
9004+
if not got_call_from_db:
9005+
console.print("Unable to retrieve call from DB. Proceeding without.")
89969006

89979007
return self._run_command(
89989008
proxy_commands.execute_announced(

0 commit comments

Comments
 (0)