from httpx import AsyncClient from app.core._config import PROJECT_HOST from app.core.logger import make_log from app.core._secrets import hot_privkey, hot_seed from tonsdk.utils import sign_message from base58 import b58encode from json import dumps from app.core._crypto.signer import Signer async def send_status(service: str, status: str): make_log("send_status", f"Sending status (service={service}, status={status})", level='debug') try: message = { 'service': service, 'status': status, } message_bytes = dumps(message).encode() signer = Signer(hot_seed) message_signature = signer.sign(message_bytes) async with AsyncClient() as client: res = await client.post( f"{PROJECT_HOST}/api/system.sendStatus", json={ 'message': b58encode(message_bytes).decode(), 'signature': message_signature, } ) if res.status_code != 200: make_log("send_status", f"Error (service={service}, status={status}, response={res.text})", level='error') except BaseException as e: make_log("send_status", f"Error: {e}", level='error')