File tree Expand file tree Collapse file tree 3 files changed +15
-12
lines changed Expand file tree Collapse file tree 3 files changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -1175,9 +1175,10 @@ async def get_last_commitment_bonds_reset_block(
11751175 )
11761176 return None
11771177 block = await get_last_bonds_reset (self , netuid , hotkey )
1178- if block is None :
1179- return None
1180- return await decode_block (block )
1178+ try :
1179+ return decode_block (block )
1180+ except TypeError :
1181+ return ""
11811182
11821183 async def get_all_commitments (
11831184 self ,
Original file line number Diff line number Diff line change 44from typing import Optional , Union , TYPE_CHECKING
55
66from scalecodec .base import RuntimeConfiguration , ScaleBytes
7+ from async_substrate_interface .types import ScaleObj
78from scalecodec .type_registry import load_type_registry_preset
89from scalecodec .utils .ss58 import ss58_encode
910
@@ -148,7 +149,7 @@ def decode_block(data: bytes) -> int:
148149 Returns:
149150 int: The decoded block.
150151 """
151- return int (data .value ) if isinstance (data , ScaleBytes ) else data
152+ return int (data .value ) if isinstance (data , ScaleObj ) else data
152153
153154
154155def decode_revealed_commitment (encoded_data ) -> tuple [int , str ]:
Original file line number Diff line number Diff line change @@ -327,14 +327,15 @@ async def get_last_bonds_reset(
327327 netuid : int ,
328328 hotkey : str ,
329329 block : Optional [int ] = None ,
330+ block_hash : Optional [str ] = None ,
331+ reuse_block : bool = False ,
330332) -> bytes :
331333 """Fetches the last bonds reset triggered at commitment from the blockchain for a given hotkey and netuid."""
332- async with subtensor .substrate :
333- block_hash = await subtensor .determine_block_hash (block )
334- block = subtensor .substrate .query (
335- module = "Commitments" ,
336- storage_function = "LastBondsReset" ,
337- params = [netuid , hotkey ],
338- block_hash = block_hash ,
339- )
334+ block_hash = await subtensor .determine_block_hash (block , block_hash , reuse_block )
335+ block = await subtensor .substrate .query (
336+ module = "Commitments" ,
337+ storage_function = "LastBondsReset" ,
338+ params = [netuid , hotkey ],
339+ block_hash = block_hash ,
340+ )
340341 return block
You can’t perform that action at this time.
0 commit comments