dev@locazia: make wallet buttons
This commit is contained in:
parent
d7ebc26bce
commit
04c3441b42
|
|
@ -9,6 +9,8 @@ from app.bot.routers.tonconnect import router as tonconnect_router
|
|||
from app.core._utils.tg_process_template import tg_process_template
|
||||
from app.core._keyboards import get_inline_keyboard
|
||||
from app.core.logger import logger
|
||||
from app.core.models.wallet_connection import WalletConnection
|
||||
from app.core.models._blockchain.ton.connect import TonConnect, unpack_wallet_info
|
||||
from app.core._config import WEB_APP_URLS
|
||||
|
||||
main_router = Router()
|
||||
|
|
@ -19,6 +21,35 @@ async def t_home_menu(__msg, **extra):
|
|||
if extra.get('state'):
|
||||
await extra['state'].clear()
|
||||
|
||||
if not db_session.query(WalletConnection).filter(
|
||||
WalletConnection.user_id == user.id,
|
||||
WalletConnection.invalidated == False
|
||||
).first():
|
||||
ton_connect, ton_connection = TonConnect.by_user(db_session, user, callback_fn=())
|
||||
await ton_connect.restore_connection()
|
||||
wallets = ton_connect._sdk_client.get_wallets()
|
||||
message_text = user.translated("connectWalletsList_menu")
|
||||
return await tg_process_template(
|
||||
chat_wrap, message_text,
|
||||
keyboard=get_inline_keyboard([
|
||||
[
|
||||
{
|
||||
'text': f"{wallets[i]['name']}",
|
||||
'url': f"initTonconnect_{wallets[i]['app_name']}"
|
||||
} if i < len(wallets) else None,
|
||||
{
|
||||
'text': f"{wallets[i + 1]['name']}",
|
||||
'url': f"initTonconnect_{wallets[i + 1]['app_name']}"
|
||||
} if i + 1 < len(wallets) else None,
|
||||
{
|
||||
'text': f"{wallets[i + 2]['name']}",
|
||||
'url': f"initTonconnect_{wallets[i + 2]['app_name']}"
|
||||
} if i + 2 < len(wallets) else None,
|
||||
]
|
||||
for i in range(0, len(wallets), 3)
|
||||
])
|
||||
)
|
||||
|
||||
return await tg_process_template(
|
||||
chat_wrap, user.translated('home_menu'), message_id=__msg.message.message_id if isinstance(__msg, types.CallbackQuery) else None,
|
||||
keyboard=get_inline_keyboard([
|
||||
|
|
|
|||
|
|
@ -64,6 +64,4 @@ Use /dev_tonconnect <code>{wallet_app_name}</code> for connect to wallet."""
|
|||
keyboard=get_inline_keyboard(keyboard) if keyboard else None
|
||||
)
|
||||
|
||||
# async def t_tonconnect_wallets_list()
|
||||
|
||||
router.message.register(t_tonconnect_dev_menu, Command('dev_tonconnect'))
|
||||
|
|
|
|||
Loading…
Reference in New Issue