From 9a5846e8c180c5dd3788071c816405b1d4b76de6 Mon Sep 17 00:00:00 2001 From: abel Date: Wed, 20 Sep 2023 13:15:17 -0300 Subject: [PATCH 1/2] (fix) Changed broadcaster logic to initialize timeout_height and sequence in the AsyncClient only if they have not been initialized yet --- pyinjective/core/broadcaster.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyinjective/core/broadcaster.py b/pyinjective/core/broadcaster.py index a84b38dd..a121ef22 100644 --- a/pyinjective/core/broadcaster.py +++ b/pyinjective/core/broadcaster.py @@ -146,8 +146,12 @@ def new_for_grantee_account_without_simulation( return instance async def broadcast(self, messages: List[any_pb2.Any]): - await self._client.sync_timeout_height() - await self._client.get_account(self._account_config.trading_injective_address) + # Only force initialization of timeout_height and account info (number and sequence) if they are not initialized + # Done this way to allow users to handle timeout_height and sequence re-synchronization in case of errors + if self._client.timeout_height == 1: + await self._client.sync_timeout_height() + if self._client.number == 0: + await self._client.get_account(self._account_config.trading_injective_address) messages_for_transaction = self._account_config.messages_prepared_for_transaction(messages=messages) From 24eda15a4a415b85c72402b2e0684ce110809cca Mon Sep 17 00:00:00 2001 From: abel Date: Wed, 20 Sep 2023 13:15:17 -0300 Subject: [PATCH 2/2] (fix) Changed broadcaster logic to initialize timeout_height and sequence in the AsyncClient only if they have not been initialized yet --- pyinjective/core/broadcaster.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyinjective/core/broadcaster.py b/pyinjective/core/broadcaster.py index a84b38dd..a121ef22 100644 --- a/pyinjective/core/broadcaster.py +++ b/pyinjective/core/broadcaster.py @@ -146,8 +146,12 @@ def new_for_grantee_account_without_simulation( return instance async def broadcast(self, messages: List[any_pb2.Any]): - await self._client.sync_timeout_height() - await self._client.get_account(self._account_config.trading_injective_address) + # Only force initialization of timeout_height and account info (number and sequence) if they are not initialized + # Done this way to allow users to handle timeout_height and sequence re-synchronization in case of errors + if self._client.timeout_height == 1: + await self._client.sync_timeout_height() + if self._client.number == 0: + await self._client.get_account(self._account_config.trading_injective_address) messages_for_transaction = self._account_config.messages_prepared_for_transaction(messages=messages)