From 862683b36ec3c946740421153d385b1493c116e0 Mon Sep 17 00:00:00 2001 From: user Date: Thu, 13 Mar 2025 16:33:37 +0300 Subject: [PATCH] add topup highload before deploy --- app/core/background/ton_service.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/core/background/ton_service.py b/app/core/background/ton_service.py index e0d5049..65f0be8 100644 --- a/app/core/background/ton_service.py +++ b/app/core/background/ton_service.py @@ -88,6 +88,22 @@ async def main_fn(memory): ) make_log("TON", f"Highload wallet address: {highload_wallet.address.to_string(1, 1, 1)}", level="info") highload_state = await toncenter.get_account(highload_wallet.address.to_string(1, 1, 1)) + if int(highload_state.get('balance', '0')) / 1e9 < 0.05: + make_log("TON", "Highload wallet balance is less than 0.05, send topup transaction..", level="info") + await toncenter.send_boc( + service_wallet.create_transfer_message( + [{ + 'address': highload_wallet.address.to_string(1, 1, 1), + 'amount': int(0.08 * 10 ** 9), + 'send_mode': 1, + 'payload': begin_cell().store_uint(0, 32).end_cell() + }], sw_seqno_value + )['message'].to_boc(False) + ) + await send_status("ton_daemon", "working: topup highload wallet") + await asyncio.sleep(15) + return await main_fn(memory) + if not highload_state.get('code'): make_log("TON", "Highload wallet contract is not deployed, send deploy transaction..", level="info") created_at_ts = int(datetime.utcnow().timestamp()) - 60 @@ -97,6 +113,7 @@ async def main_fn(memory): 1, HighloadQueryId.from_seqno(0), created_at_ts, send_mode=1, payload="hello world", need_deploy=True )['message'].to_boc(False) ) + await send_status("ton_daemon", "working: deploying highload wallet") await asyncio.sleep(15) return await main_fn(memory)