Skip to content

Commit 65b35a4

Browse files
committed
Fixes Subtensor.get_all_subnets_info()
1 parent f6f872c commit 65b35a4

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

bittensor/core/subtensor.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,17 +1407,18 @@ def get_all_subnets_info(self, block: Optional[int] = None) -> list[SubnetInfo]:
14071407
14081408
Gaining insights into the subnets' details assists in understanding the network's composition, the roles of different subnets, and their unique features.
14091409
"""
1410-
block_hash = None if block is None else self.substrate.get_block_hash(block)
1411-
1412-
json_body = self.substrate.rpc_request(
1413-
method="subnetInfo_getSubnetsInfo", # custom rpc method
1414-
params=[block_hash] if block_hash else [],
1410+
hex_bytes_result = self.query_runtime_api(
1411+
"SubnetInfoRuntimeApi", "get_subnets_info", params=[], block=block
14151412
)
1416-
1417-
if not (result := json_body.get("result", None)):
1413+
if not hex_bytes_result:
14181414
return []
1415+
else:
1416+
try:
1417+
bytes_result = bytes.fromhex(hex_bytes_result[2:])
1418+
except ValueError:
1419+
bytes_result = bytes.fromhex(hex_bytes_result)
14191420

1420-
return SubnetInfo.list_from_vec_u8(result)
1421+
return SubnetInfo.list_from_vec_u8(bytes_result)
14211422

14221423
# Metagraph uses this method
14231424
def bonds(

0 commit comments

Comments
 (0)