From 15c4100380c2a729e30fb26fdc8719e69d83d139 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Mon, 9 Dec 2024 16:05:15 +0200 Subject: [PATCH] fix: check whether the service has transacted first Otherwise, the `tx_submitter` will not be available in the db for the current period, and either way it would not make sense to update the transaction information for a past period's decision. --- .../valory/skills/decision_maker_abci/behaviours/reedem.py | 3 ++- packages/valory/skills/decision_maker_abci/states/base.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py index 5c35f84f..e6019516 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py @@ -978,7 +978,8 @@ def async_act(self) -> Generator: # tx settlement multiplexer assures transitions from Post transaction to Redeem round # only if the transaction was successful if ( - self.synchronized_data.tx_submitter + self.synchronized_data.did_transact + and self.synchronized_data.tx_submitter == BetPlacementRound.auto_round_id() ): self.update_bet_transaction_information() diff --git a/packages/valory/skills/decision_maker_abci/states/base.py b/packages/valory/skills/decision_maker_abci/states/base.py index 33bdc463..76dd9a67 100644 --- a/packages/valory/skills/decision_maker_abci/states/base.py +++ b/packages/valory/skills/decision_maker_abci/states/base.py @@ -178,6 +178,11 @@ def is_profitable(self) -> bool: """Get whether the current vote is profitable or not.""" return bool(self.db.get_strict("is_profitable")) + @property + def did_transact(self) -> bool: + """Get whether the service performed any transactions in the current period.""" + return bool(self.db.get("tx_submitter", None)) + @property def tx_submitter(self) -> str: """Get the round that submitted a tx to transaction_settlement_abci."""