diff --git a/CHANGELOG.md b/CHANGELOG.md index c4b6d30..1cd948c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.0rc14 /2025-02-11 +* Improves the error-handling of initialisation of the object @thewhaleking in https://github.com/opentensor/async-substrate-interface/pull/39 +* Backmerge main to staging rc12 by @ibraheem-opentensor in https://github.com/opentensor/async-substrate-interface/pull/40 + ## 1.0.0rc13 /2025-02-10 * Improve logging by @roman-opentensor and @thewhaleking in https://github.com/opentensor/async-substrate-interface/pull/36 * Backmerge main to staging rc12 by @ibraheem-opentensor in https://github.com/opentensor/async-substrate-interface/pull/37 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] diff --git a/pyproject.toml b/pyproject.toml index ca35ba4..c68f144 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "async-substrate-interface" -version = "1.0.0rc13" +version = "1.0.0rc14" description = "Asyncio library for interacting with substrate. Mostly API-compatible with py-substrate-interface" readme = "README.md" license = { file = "LICENSE" }