add highload wallet

This commit is contained in:
user committed 2025-03-13 15:46:48 +03:00
1 parent 0b309c5eb4
commit b8a5cf4965
8 files changed
+101 -5

No files matched your search

+34 -2
View File
@@ -1,13 +1,19 @@
import asyncio
import os
from sqlalchemy import and_
from tonsdk.boc import begin_cell
from tonsdk.contract.wallet import Wallets
from tonsdk.utils import HighloadQueryId
from datetime import datetime, timedelta
from app.core._blockchain.ton.platform import platform
from app.core._blockchain.ton.toncenter import toncenter
from app.core.models.tasks import BlockchainTask
from app.core._config import MY_FUND_ADDRESS
from app.core._secrets import service_wallet
from app.core._utils.send_status import send_status
from app.core.storage import db_session
from app.core.logger import make_log
@@ -74,6 +80,25 @@ async def main_fn(memory):
await send_status("ton_daemon", "working: deploying platform")
await asyncio.sleep(15)
return await main_fn(memory)
highload_wallet = Wallets.ALL['hv3'](
private_key=service_wallet.private_key,
public_key=service_wallet.public_key,
wc=0
)
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 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
await toncenter.send_boc(
highload_wallet.create_transfer_message(
service_wallet.address.to_string(1, 1, 1),
1, HighloadQueryId.from_seqno(0), created_at_ts, send_mode=1, payload="hello world", need_deploy=True
)['message'].to_boc(False)
)
await asyncio.sleep(15)
return await main_fn(memory)
while True:
try:
@@ -81,8 +106,15 @@ async def main_fn(memory):
make_log("TON", f"Service running ({sw_seqno_value})", level="debug")
# with db_session() as session:
# for stored_content in session.query(StoredContent).filter(StoredContent.uploaded == False).all():
# pass
# next_task = session.query(BlockchainTask).filter(
# BlockchainTask.status == 'wait'
# ).first()
# if next_task:
# make_log("TON", f"Processing task {next_task.id}", level="info")
# next_task.status = 'processing'
# session.commit()
await asyncio.sleep(5)
await send_status("ton_daemon", f"working (seqno={sw_seqno_value})")