add highload wallet
This commit is contained in:
1 parent
0b309c5eb4
commit
b8a5cf4965
8 files changed
+101
-5
No files matched your search
@@ -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})")
|
||||
|
||||
@@ -11,3 +11,5 @@ from app.core.models.content.user_content import UserContent, UserAction
|
||||
from app.core.models._config import ServiceConfigValue, ServiceConfig
|
||||
from app.core.models.asset import Asset
|
||||
from app.core.models.my_network import KnownNode, KnownNodeIncident, RemoteContentIndex
|
||||
from app.core.models.promo import PromoAction
|
||||
from app.core.models.tasks import BlockchainTask
|
||||
@@ -0,0 +1,16 @@
|
||||
from .base import AlchemyBase
|
||||
from sqlalchemy import Column, BigInteger, Integer, String, ForeignKey, DateTime, JSON, Boolean
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class PromoAction:
|
||||
__tablename__ = 'promo_actions'
|
||||
|
||||
id = Column(Integer, autoincrement=True, primary_key=True)
|
||||
user_id = Column(String(512), nullable=False)
|
||||
user_internal_id = Column(Integer, ForeignKey('users.id'), nullable=True)
|
||||
|
||||
action_type = Column(String(64), nullable=False) # Type of action, e.g., 'referral', 'discount'
|
||||
action_ref = Column(String(512), nullable=False) # Reference to the action, e.g., promo code
|
||||
|
||||
created = Column(DateTime, nullable=False, default=datetime.now)
|
||||
@@ -0,0 +1,24 @@
|
||||
from .base import AlchemyBase
|
||||
from sqlalchemy import Column, BigInteger, Integer, String, ForeignKey, DateTime, JSON, Boolean
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class BlockchainTask:
|
||||
__tablename__ = 'blockchain_tasks'
|
||||
|
||||
id = Column(Integer, autoincrement=True, primary_key=True)
|
||||
|
||||
destination = Column(String(1024), nullable=False)
|
||||
payload = Column(String(1024), nullable=False)
|
||||
|
||||
epoch = Column(Integer, nullable=True)
|
||||
seqno = Column(Integer, nullable=True)
|
||||
|
||||
created = Column(DateTime, nullable=False, default=datetime.now)
|
||||
updated = Column(DateTime, nullable=False, default=datetime.now)
|
||||
|
||||
meta = Column(JSON, nullable=False, default={})
|
||||
status = Column(String(256), nullable=False)
|
||||
|
||||
transaction_hash = Column(String(1024), nullable=True)
|
||||
transaction_lt = Column(String(1024), nullable=True)
|
||||
@@ -68,7 +68,7 @@ file_handler.setLevel(logging.DEBUG)
|
||||
file_handler.setFormatter(logging.Formatter(FORMAT_STRING))
|
||||
logger.addHandler(file_handler)
|
||||
|
||||
if os.getenv('APP_ENABLE_STDOUT_LOGS', '0') == '1':
|
||||
if int(os.getenv('APP_ENABLE_STDOUT_LOGS', '0')) == 1:
|
||||
stdout_handler = logging.StreamHandler()
|
||||
stdout_handler.setLevel(logging.DEBUG)
|
||||
stdout_handler.setFormatter(logging.Formatter(FORMAT_STRING))
|
||||
|
||||
Reference in new issue
Block a user