From 6c3cb7cbfec52578a6a90a8c336e815263716356 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Wed, 28 Aug 2024 11:07:38 +0200 Subject: [PATCH] chore: fix fund before swap transaction --- operate/services/manage.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/operate/services/manage.py b/operate/services/manage.py index e6393e664..6ea44db92 100644 --- a/operate/services/manage.py +++ b/operate/services/manage.py @@ -476,6 +476,7 @@ def _deploy_service_onchain_from_safe( # pylint: disable=too-many-statements,to ) on_chain_hash = self._get_on_chain_hash(chain_config=chain_config) + current_agent_bond = staking_params["min_staking_deposit"] # TODO fixme, read from service registry token utility contract is_first_mint = ( self._get_on_chain_state(service=service, chain_id=chain_id) == OnChainState.NON_EXISTENT @@ -486,6 +487,7 @@ def _deploy_service_onchain_from_safe( # pylint: disable=too-many-statements,to and ( on_chain_hash != service.hash or current_agent_id != staking_params["agent_ids"][0] + or current_agent_bond != staking_params["min_staking_deposit"] ) ) current_staking_program = self._get_current_staking_program( @@ -845,6 +847,16 @@ def _terminate_service_on_chain_from_safe( # pylint: disable=too-many-locals if counter_current_safe_owners == counter_instances: self.logger.info("Swapping Safe owners") + + self.fund_service( + hash=hash, + rpc=ledger_config.rpc, + agent_topup=chain_data.user_params.fund_requirements.agent, + agent_fund_threshold=chain_data.user_params.fund_requirements.agent, + safe_topup=0, + safe_fund_treshold=0, + ) + sftxb.swap( # noqa: E800 service_id=chain_data.token, # noqa: E800 multisig=chain_data.multisig, # TODO this can be read from the registry