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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ poetry run pytest -v
```

### Changelogs
**0.10**
* Remove `aiocron` dependency. Use plain asyncio tasks to solve the timeout height synchronization

**0.9.3**
* Updated TIA/USDT-30NOV2023 market id in denoms_mainnet.ini file

**0.9.2**
* Added fix to the grpc import error in Mac with M1 and M2 chips

Expand Down
104 changes: 9 additions & 95 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 18 additions & 10 deletions pyinjective/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from decimal import Decimal
from typing import Coroutine, Dict, List, Optional, Tuple, Union

import aiocron
import grpc

from pyinjective.composer import Composer
Expand Down Expand Up @@ -108,13 +107,8 @@ def __init__(
)
self.stubExplorer = explorer_rpc_grpc.InjectiveExplorerRPCStub(self.explorer_channel)

# timeout height update routine
self.cron = aiocron.crontab(
"* * * * * */{}".format(DEFAULT_TIMEOUTHEIGHT_SYNC_INTERVAL),
func=self.sync_timeout_height,
args=(),
start=True,
)
self._timeout_height_sync_task = None
self._initialize_timeout_height_sync_task()

self._tokens_and_markets_initialization_lock = asyncio.Lock()
self._tokens: Optional[Dict[str, Token]] = None
Expand Down Expand Up @@ -163,11 +157,11 @@ async def get_tx(self, tx_hash):

async def close_exchange_channel(self):
await self.exchange_channel.close()
self.cron.stop()
self._cancel_timeout_height_sync_task()

async def close_chain_channel(self):
await self.chain_channel.close()
self.cron.stop()
self._cancel_timeout_height_sync_task()

async def sync_timeout_height(self):
try:
Expand Down Expand Up @@ -1009,3 +1003,17 @@ def _chain_cookie_metadata_requestor(self) -> Coroutine:
def _exchange_cookie_metadata_requestor(self) -> Coroutine:
request = exchange_meta_rpc_pb.VersionRequest()
return self.stubMeta.Version(request).initial_metadata()

def _initialize_timeout_height_sync_task(self):
self._cancel_timeout_height_sync_task()
self._timeout_height_sync_task = asyncio.create_task(self._timeout_height_sync_process())

async def _timeout_height_sync_process(self):
while True:
await self.sync_timeout_height()
await asyncio.sleep(DEFAULT_TIMEOUTHEIGHT_SYNC_INTERVAL)

def _cancel_timeout_height_sync_task(self):
if self._timeout_height_sync_task is not None:
self._timeout_height_sync_task.cancel()
self._timeout_height_sync_task = None
2 changes: 1 addition & 1 deletion pyinjective/denoms_mainnet.ini
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ min_display_price_tick_size = 0.0001
min_quantity_tick_size = 0.1
min_display_quantity_tick_size = 0.1

[0x4b7a550e1760cbd2c6ccb97562c56878083b92e32d07e9e3326945c6e60e6b60]
[0x64c3a57b693ede854b0a2794ed5c99546925d1fbe74d91a2e3286e4155a00dee]
description = 'Mainnet Derivative TIA/USDT-30NOV2023 PERP'
base = 0
quote = 6
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "injective-py"
version = "0.9.2"
version = "0.10dev"
description = "Injective Python SDK, with Exchange API Client"
authors = ["Injective Labs <contact@injectivelabs.org>"]
license = "Apache-2.0"
Expand All @@ -22,7 +22,6 @@ include = [

[tool.poetry.dependencies]
python = "^3.9"
aiocron = "*"
aiohttp = "*"
asyncio = "*"
bech32 = "*"
Expand Down