@@ -2002,11 +2002,12 @@ async def check_swap_status(
2002
2002
Args:
2003
2003
subtensor: Connection to the network
2004
2004
origin_ss58: The SS58 address of the original coldkey
2005
- block_number: Optional block number where the swap was scheduled
2005
+ expected_block_number: Optional block number where the swap was scheduled
2006
+
2006
2007
"""
2007
- scheduled_swaps = await subtensor .get_scheduled_coldkey_swap ()
2008
2008
2009
2009
if not origin_ss58 :
2010
+ scheduled_swaps = await subtensor .get_scheduled_coldkey_swap ()
2010
2011
if not scheduled_swaps :
2011
2012
console .print ("[yellow]No pending coldkey swaps found.[/yellow]" )
2012
2013
return
@@ -2035,11 +2036,20 @@ async def check_swap_status(
2035
2036
2036
2037
console .print (table )
2037
2038
console .print (
2038
- "\n [dim]Tip: Check specific swap details by providing the original coldkey SS58 address and the block number.[/dim]"
2039
+ "\n [dim]Tip: Check specific swap details by providing the original coldkey "
2040
+ "SS58 address and the block number.[/dim]"
2039
2041
)
2040
2042
return
2041
-
2042
- is_pending = origin_ss58 in scheduled_swaps
2043
+ chain_reported_completion_block , destination_address = await subtensor .query (
2044
+ "SubtensorModule" , "ColdkeySwapScheduled" , [origin_ss58 ]
2045
+ )
2046
+ if (
2047
+ chain_reported_completion_block != 0
2048
+ and destination_address != "5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM"
2049
+ ):
2050
+ is_pending = True
2051
+ else :
2052
+ is_pending = False
2043
2053
2044
2054
if not is_pending :
2045
2055
console .print (
@@ -2052,33 +2062,19 @@ async def check_swap_status(
2052
2062
)
2053
2063
2054
2064
if expected_block_number is None :
2055
- return
2056
-
2057
- swap_info = await find_coldkey_swap_extrinsic (
2058
- subtensor = subtensor ,
2059
- start_block = expected_block_number ,
2060
- end_block = expected_block_number ,
2061
- wallet_ss58 = origin_ss58 ,
2062
- )
2063
-
2064
- if not swap_info :
2065
- console .print (
2066
- f"[yellow]Warning: Could not find swap extrinsic at block { expected_block_number } [/yellow]"
2067
- )
2068
- return
2065
+ expected_block_number = chain_reported_completion_block
2069
2066
2070
2067
current_block = await subtensor .substrate .get_block_number ()
2071
- remaining_blocks = swap_info [ "execution_block" ] - current_block
2068
+ remaining_blocks = expected_block_number - current_block
2072
2069
2073
2070
if remaining_blocks <= 0 :
2074
2071
console .print ("[green]Swap period has completed![/green]" )
2075
2072
return
2076
2073
2077
2074
console .print (
2078
2075
"\n [green]Coldkey swap details:[/green]"
2079
- f"\n Scheduled at block: { swap_info ['block_num' ]} "
2080
2076
f"\n Original address: [{ COLORS .G .CK } ]{ origin_ss58 } [/{ COLORS .G .CK } ]"
2081
- f"\n Destination address: [{ COLORS .G .CK } ]{ swap_info [ 'dest_coldkey' ] } [/{ COLORS .G .CK } ]"
2082
- f"\n Completion block: { swap_info [ 'execution_block' ] } "
2077
+ f"\n Destination address: [{ COLORS .G .CK } ]{ destination_address } [/{ COLORS .G .CK } ]"
2078
+ f"\n Completion block: { chain_reported_completion_block } "
2083
2079
f"\n Time remaining: { blocks_to_duration (remaining_blocks )} "
2084
2080
)
0 commit comments