diff --git a/async_substrate_interface/async_substrate.py b/async_substrate_interface/async_substrate.py index ea09a2f..9cad7e0 100644 --- a/async_substrate_interface/async_substrate.py +++ b/async_substrate_interface/async_substrate.py @@ -734,9 +734,13 @@ async def initialize(self): if not self._chain: chain = await self.rpc_request("system_chain", []) self._chain = chain.get("result") - await asyncio.gather( - self.load_registry(), self._first_initialize_runtime() + init_load = await asyncio.gather( + self.load_registry(), self._first_initialize_runtime(), + return_exceptions=True ) + for potential_exception in init_load: + if isinstance(potential_exception, Exception): + raise potential_exception self.initialized = True self._initializing = False @@ -1107,6 +1111,11 @@ async def get_runtime(block_hash, block_id) -> Runtime: if block_id and block_hash: raise ValueError("Cannot provide block_hash and block_id at the same time") + if not self.metadata_v15: + raise SubstrateRequestException( + "Metadata V15 was not loaded. This usually indicates that you did not correctly initialize" + " the AsyncSubstrateInterface class with `async with` or by calling `initialize()`" + ) if ( not (runtime := self.runtime_cache.retrieve(block_id, block_hash)) or runtime.metadata is None diff --git a/async_substrate_interface/types.py b/async_substrate_interface/types.py index 2c3e17c..5b7835c 100644 --- a/async_substrate_interface/types.py +++ b/async_substrate_interface/types.py @@ -343,6 +343,7 @@ class SubstrateMixin(ABC): _token_decimals = None _token_symbol = None _metadata = None + metadata_v15 = None _chain: str runtime_config: RuntimeConfigurationObject type_registry: Optional[dict]