From b8251a456b47104a6f7bf6eade3790dd4ccd65b2 Mon Sep 17 00:00:00 2001 From: user Date: Fri, 8 Mar 2024 23:45:04 +0300 Subject: [PATCH] dev@locazia: fix Tonhub tonhub --- app/api/routes/_blockchain.py | 4 ++-- app/core/_blockchain/ton/connect.py | 8 ++++++++ locale/en/LC_MESSAGES/sanic_telegram_bot.po | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/api/routes/_blockchain.py b/app/api/routes/_blockchain.py index c1f3d47..09e240c 100644 --- a/app/api/routes/_blockchain.py +++ b/app/api/routes/_blockchain.py @@ -6,7 +6,7 @@ from sanic import response from tonsdk.boc import begin_cell, begin_dict from tonsdk.utils import Address -from app.core._blockchain.ton.connect import TonConnect, TON_CONNECT_WALLETS_LIST +from app.core._blockchain.ton.connect import TonConnect, wallet_obj_by_name from app.core._blockchain.ton.platform import platform from app.core._config import PROJECT_HOST from app.core.logger import make_log @@ -144,7 +144,7 @@ async def s_api_v1_blockchain_send_new_content_message(request): reply_markup=get_inline_keyboard([ [{ 'text': request.ctx.user.translated('gotoWallet_button'), - 'url': next(x['universal_url'] for x in TON_CONNECT_WALLETS_LIST if x['app_name'] == ton_connection.wallet_key.split('==')[0]) + 'url': wallet_obj_by_name(ton_connection.wallet_key.split('==')[0])['universal_url'] }], [{ 'text': request.ctx.user.translated('home_button'), diff --git a/app/core/_blockchain/ton/connect.py b/app/core/_blockchain/ton/connect.py index 7c0fca7..e7c3021 100644 --- a/app/core/_blockchain/ton/connect.py +++ b/app/core/_blockchain/ton/connect.py @@ -48,6 +48,14 @@ TON_CONNECT_WALLETS_LIST = [ ] +def wallet_obj_by_name(wallet_name: str) -> dict: + wallet_name = wallet_name.lower() + for wallet in TON_CONNECT_WALLETS_LIST: + if wallet["app_name"].lower() == wallet_name: + return wallet + raise StopIteration(f"Wallet {wallet_name} not found") + + def unpack_wallet_info(wallet_info) -> dict: return { 'provider': wallet_info.provider, diff --git a/locale/en/LC_MESSAGES/sanic_telegram_bot.po b/locale/en/LC_MESSAGES/sanic_telegram_bot.po index b4340c0..c11056b 100644 --- a/locale/en/LC_MESSAGES/sanic_telegram_bot.po +++ b/locale/en/LC_MESSAGES/sanic_telegram_bot.po @@ -38,7 +38,7 @@ msgstr "🔌 Disconnect wallet" #: app/bot/routers/home.py:35 app/client_bot/routers/home.py:35 msgid "connectWalletsList_menu" msgstr "" -"/ Welcome to MY [🔴]\n" +"/ Welcome to MY [🔴]\n" "\n" "Please select the wallet you want to connect to the bot:"