Skip to content

Commit

Permalink
fix: check whether the service has transacted first
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Adamantios committed Dec 9, 2024
1 parent fd35046 commit 15c4100
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions packages/valory/skills/decision_maker_abci/states/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit 15c4100

Please sign in to comment.