Skip to content

Commit 3cb9908

Browse files
committed
Merge remote-tracking branch 'origin/fix/thewhaleking/add-all-easy-imports' into fix/thewhaleking/add-all-easy-imports
2 parents 0bb6682 + a41aad7 commit 3cb9908

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

bittensor/core/async_subtensor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ def _get_substrate(
303303
return RetryAsyncSubstrate(
304304
url=self.chain_endpoint,
305305
fallback_chains=fallback_chains,
306+
ss58_format=SS58_FORMAT,
307+
type_registry=TYPE_REGISTRY,
306308
retry_forever=retry_forever,
309+
use_remote_preset=True,
310+
chain_name="Bittensor",
307311
_mock=_mock,
308312
)
309313
return AsyncSubstrateInterface(

bittensor/core/subtensor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ def _get_substrate(
185185
if fallback_chains or retry_forever:
186186
return RetrySyncSubstrate(
187187
url=self.chain_endpoint,
188+
ss58_format=SS58_FORMAT,
189+
type_registry=TYPE_REGISTRY,
190+
use_remote_preset=True,
191+
chain_name="Bittensor",
188192
fallback_chains=fallback_chains,
189193
retry_forever=retry_forever,
190194
_mock=_mock,

bittensor/core/subtensor_api/__init__.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class SubtensorApi:
2222
"""Subtensor API class.
2323
2424
Arguments:
25-
network: The network to connect to. Defaults to `None` -> `finney`.
25+
network: The network to connect to. Defaults to `None` -> "finney".
2626
config: Bittensor configuration object. Defaults to `None`.
2727
legacy_methods: If `True`, all methods from the Subtensor class will be added to the root level of this class.
2828
fallback_chains (list): List of fallback chains to use if no network is specified. Defaults to `None`.
@@ -144,15 +144,31 @@ def __repr__(self):
144144
return self.__str__()
145145

146146
def __enter__(self):
147+
if self.is_async:
148+
raise NotImplementedError(
149+
"Async version of SubtensorApi cannot be used with sync context manager."
150+
)
147151
return self
148152

149153
def __exit__(self, exc_type, exc_val, exc_tb):
154+
if self.is_async:
155+
raise NotImplementedError(
156+
"Async version of SubtensorApi cannot be used with sync context manager."
157+
)
150158
self.close()
151159

152160
async def __aenter__(self):
161+
if not self.is_async:
162+
raise NotImplementedError(
163+
"Sync version of SubtensorApi cannot be used with async context manager."
164+
)
153165
return await self._subtensor.__aenter__()
154166

155167
async def __aexit__(self, exc_type, exc_val, exc_tb):
168+
if not self.is_async:
169+
raise NotImplementedError(
170+
"Sync version of SubtensorApi cannot be used with async context manager."
171+
)
156172
await self.substrate.close()
157173

158174
@classmethod

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies = [
3636
"uvicorn",
3737
"bittensor-drand>=0.5.0",
3838
"bittensor-wallet>=3.0.8",
39-
"async-substrate-interface>=1.1.0"
39+
"async-substrate-interface>=1.2.0"
4040
]
4141

4242
[project.optional-dependencies]

0 commit comments

Comments
 (0)