Skip to content

Commit 885cc52

Browse files
authored
Merge pull request #60 from opentensor/feat/thewhaleking/warn-users-about-too-old-blocks
Warn users about too old blocks
2 parents 8f1c6c4 + 31f0844 commit 885cc52

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

async_substrate_interface/async_substrate.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -814,11 +814,23 @@ async def load_registry(self):
814814
async def _load_registry_at_block(self, block_hash: str) -> MetadataV15:
815815
# Should be called for any block that fails decoding.
816816
# Possibly the metadata was different.
817-
metadata_rpc_result = await self.rpc_request(
818-
"state_call",
819-
["Metadata_metadata_at_version", self.metadata_version_hex],
820-
block_hash=block_hash,
821-
)
817+
try:
818+
metadata_rpc_result = await self.rpc_request(
819+
"state_call",
820+
["Metadata_metadata_at_version", self.metadata_version_hex],
821+
block_hash=block_hash,
822+
)
823+
except SubstrateRequestException as e:
824+
if (
825+
"Client error: Execution failed: Other: Exported method Metadata_metadata_at_version is not found"
826+
in e.args
827+
):
828+
raise SubstrateRequestException(
829+
"You are attempting to call a block too old for this version of async-substrate-interface. Please"
830+
" instead use legacy py-substrate-interface for these very old blocks."
831+
)
832+
else:
833+
raise e
822834
metadata_option_hex_str = metadata_rpc_result["result"]
823835
metadata_option_bytes = bytes.fromhex(metadata_option_hex_str[2:])
824836
old_metadata = MetadataV15.decode_from_metadata_option(metadata_option_bytes)

0 commit comments

Comments
 (0)