Skip to content

Commit

Permalink
fix: fund service safe instead of wallet safe and add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybayblade committed Apr 11, 2024
1 parent c3d82b5 commit af36a96
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions operate/services/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,12 @@ def fund_service(self, hash: str) -> None:
ledger_api = wallet.ledger_api(chain_type=service.ledger_config.chain)
agent_fund_requirement = service.chain_data.user_params.fund_requirements.agent

self.logger.info("Funding agents")
for key in service.keys:
agent_balance = ledger_api.get_balance(address=key.address)
self.logger.info(f"Agent {key.address} balance: {agent_balance}")
self.logger.info(f"Required balance: {agent_fund_requirement}")
if agent_balance < agent_fund_requirement:
self.logger.info("Funding agents")
to_transfer = agent_fund_requirement - agent_balance
self.logger.info(f"Transferring {to_transfer} units to {key.address}")
wallet.transfer(
Expand All @@ -374,14 +376,16 @@ def fund_service(self, hash: str) -> None:
chain_type=service.ledger_config.chain,
)

self.logger.info("Funding safe")
safe_balanace = ledger_api.get_balance(service.chain_data.multisig)
safe_fund_requirement = service.chain_data.user_params.fund_requirements.safe
safe_balanace = ledger_api.get_balance(wallet.safe)
self.logger.info(f"Safe {wallet.safe} balance: {safe_balanace}")
self.logger.info(f"Required balance: {safe_fund_requirement}")
if safe_balanace < safe_fund_requirement:
self.logger.info("Funding safe")
to_transfer = safe_fund_requirement - safe_balanace
self.logger.info(f"Transferring {to_transfer} units to {wallet.safe}")
wallet.transfer(
to=t.cast(str, wallet.safe),
to=t.cast(str, service.chain_data.multisig),
amount=to_transfer,
chain_type=service.ledger_config.chain,
)
Expand Down

0 comments on commit af36a96

Please sign in to comment.