@@ -796,19 +796,11 @@ async def _get_current_block_hash(
796796
797797 async def load_registry (self ):
798798 # TODO this needs to happen before init_runtime
799- metadata_rpc_result = await self .rpc_request (
800- "state_call" ,
801- ["Metadata_metadata_at_version" , self .metadata_version_hex ],
802- )
803- metadata_option_hex_str = metadata_rpc_result ["result" ]
804- metadata_option_bytes = bytes .fromhex (metadata_option_hex_str [2 :])
805- self .metadata_v15 = MetadataV15 .decode_from_metadata_option (
806- metadata_option_bytes
807- )
799+ self .metadata_v15 = await self ._load_registry_at_block (None )
808800 self .registry = PortableRegistry .from_metadata_v15 (self .metadata_v15 )
809801 self ._load_registry_type_map ()
810802
811- async def _load_registry_at_block (self , block_hash : str ) -> MetadataV15 :
803+ async def _load_registry_at_block (self , block_hash : Optional [ str ] ) -> MetadataV15 :
812804 # Should be called for any block that fails decoding.
813805 # Possibly the metadata was different.
814806 try :
@@ -830,9 +822,8 @@ async def _load_registry_at_block(self, block_hash: str) -> MetadataV15:
830822 raise e
831823 metadata_option_hex_str = metadata_rpc_result ["result" ]
832824 metadata_option_bytes = bytes .fromhex (metadata_option_hex_str [2 :])
833- old_metadata = MetadataV15 .decode_from_metadata_option (metadata_option_bytes )
834-
835- return old_metadata
825+ metadata = MetadataV15 .decode_from_metadata_option (metadata_option_bytes )
826+ return metadata
836827
837828 async def _wait_for_registry (self , _attempt : int = 1 , _retries : int = 3 ) -> None :
838829 async def _waiter ():
0 commit comments