Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions async_substrate_interface/async_substrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions async_substrate_interface/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down