dev@locazia: add "confirm tx" message

This commit is contained in:
user 2024-03-08 22:58:48 +03:00
parent b80e070b4d
commit 836adaf7b2
6 changed files with 113 additions and 29 deletions

View File

@ -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
from app.core._blockchain.ton.connect import TonConnect, TON_CONNECT_WALLETS_LIST
from app.core._blockchain.ton.platform import platform
from app.core._config import PROJECT_HOST
from app.core.logger import make_log
@ -14,6 +14,8 @@ from app.core._utils.resolve_content import resolve_content
from app.core.content.utils import create_metadata_for_item
from app.core._crypto.content import create_encrypted_content
from app.core.models.node_storage import StoredContent
from app.core.models._telegram import Wrapped_CBotChat
from app.core._keyboards import get_inline_keyboard
def valid_royalty_params(royalty_params):
@ -137,6 +139,20 @@ async def s_api_v1_blockchain_send_new_content_message(request):
]
}))
await (Wrapped_CBotChat(request.app.memory._telegram_bot, chat_id=request.ctx.user.telegram_id)).send_message(
request.ctx.user.translated('p_tonconnectTransactionRequested'),
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['app_name'])
}],
[{
'text': request.ctx.user.translated('home_button'),
'callback_data': 'home'
}]
])
)
return response.json({"message": "Transaction requested"})
except BaseException as e:
make_log("Blockchain", f"Error while sending new content message: {e}" + '\n' + traceback.format_exc(), level='error')

View File

@ -13,6 +13,40 @@ from app.core.models.wallet_connection import WalletConnection
TON_CONNECT_MANIFEST_URI = os.getenv("TON_CONNECT_MANIFEST_URI")
TON_CONNECT_WALLETS_LIST = [
{
'about_url': 'https://wallet.tg/',
'app_name': 'telegram-wallet',
'bridge_url': 'https://bridge.tonapi.io/bridge',
'image': 'https://wallet.tg/images/logo-288.png',
'name': 'Wallet',
'universal_url': 'https://t.me/wallet?attach=wallet&startattach=tonconnect'
},
{
'about_url': 'https://tonkeeper.com',
'app_name': 'tonkeeper',
'bridge_url': 'https://bridge.tonapi.io/bridge',
'image': 'https://tonkeeper.com/assets/tonconnect-icon.png',
'name': 'Tonkeeper',
'universal_url': 'https://app.tonkeeper.com/ton-connect'},
{
'about_url': 'https://mytonwallet.io',
'app_name': 'mytonwallet',
'bridge_url': 'https://tonconnectbridge.mytonwallet.org/bridge/',
'image': 'https://mytonwallet.io/icon-256.png',
'name': 'MyTonWallet',
'universal_url': 'https://connect.mytonwallet.org'
},
{
'about_url': 'https://tonhub.com',
'app_name': 'tonhub',
'bridge_url': 'https://connect.tonhubapi.com/tonconnect',
'image': 'https://tonhub.com/tonconnect_logo.png',
'name': 'Tonhub',
'universal_url': 'https://tonhub.com/ton-connect'
}
]
def unpack_wallet_info(wallet_info) -> dict:
return {
@ -65,6 +99,9 @@ class TonConnect:
if wallet["app_name"] == app_name:
return await self._sdk_client.connect(wallet)
async def raw_new_connection(self, app_startup: dict):
return await self._sdk_client.connect(app_startup)
async def restore_connection(self):
return await self._sdk_client.restore_connection()

View File

@ -111,7 +111,8 @@ async def indexer_loop(platform_found: bool, seqno: int) -> [bool, int]:
).first()
encrypted_stored_content = session.query(StoredContent).filter(
StoredContent.hash == item_content_hash_str
StoredContent.hash == item_content_hash_str,
StoredContent.type.like("local%")
).first()
if encrypted_stored_content:
encrypted_stored_content_meta = encrypted_stored_content.meta

View File

@ -49,6 +49,13 @@ class StoredContent(AlchemyBase):
accept_type=self.meta.get('content_type', 'image/jpeg')
)
@property
def decrypt_possible(self) -> bool:
if self.encrypted is False:
return True
return bool(self.key_id or self.decrypted_content_id)
def json_format(self):
extra_fields = {}
if self.btfs_cid:

View File

@ -6,62 +6,85 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: 1\n"
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-29 01:26+0300\n"
"PO-Revision-Date: 2024-02-29 01:00+0\n"
"Last-Translator: oscux\n"
"Language: en\n"
"POT-Creation-Date: 2024-03-08 22:45+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: app/bot/routers/home.py:16
#: app/bot/routers/home.py:16 app/bot/routers/home.py:15
#: app/client_bot/routers/home.py:15
msgid "home_menu"
msgstr "Hi, <b>{name}</b>!"
"\n\n"
"Here you can upload your content to the blockchain and manage it."
"\n\n"
"You logged in with wallet: <code>{wallet_address}</code>"
msgstr ""
"Hi, <b>{name}</b>!\n"
"\n"
"Here you can upload your content to the blockchain and manage it.\n"
"\n"
"You logged as <code>{wallet_address}</code>"
#: app/bot/routers/home.py:20
#: app/bot/routers/home.py:20 app/client_bot/routers/home.py:20
msgid "ownedContent_button"
msgstr "📊 My content"
#: app/bot/routers/home.py:24
#: app/bot/routers/home.py:24 app/client_bot/routers/home.py:24
msgid "disconnectWallet_button"
msgstr "🔌 Disconnect wallet"
#: app/bot/routers/home.py:35
#: app/bot/routers/home.py:35 app/client_bot/routers/home.py:35
msgid "connectWalletsList_menu"
msgstr "<b>> To work, you need to connect your wallet</b>"
"\n\n"
"Please select the wallet you want to connect:"
msgstr ""
"/ Welcome to MY [🔴]\n"
"\n"
"Please select the wallet you want to connect to the bot:"
#: app/bot/routers/index.py:23
#: app/bot/routers/index.py:23 app/bot/routers/index.py:22
#: app/client_bot/routers/index.py:18
msgid "error_unknownCommand"
msgstr "Unknown command, please try again or press /start"
#: app/bot/routers/content.py:16
#: app/bot/routers/content.py:16 app/bot/routers/content.py:12
msgid "ownedContent_menu"
msgstr "📊 <b>My content</b>"
"\n\n"
msgstr ""
"📊 <b>My content</b>\n"
"\n"
"Here you can see the list of your content."
#: app/bot/routers/content.py:21
#: app/bot/routers/content.py:21 app/bot/routers/content.py:17
msgid "webApp_uploadContent_button"
msgstr "📤 Upload content"
#: app/bot/routers/content.py:27
#: app/bot/routers/content.py:27 app/bot/routers/content.py:23
msgid "back_button"
msgstr "◀️ Back"
#: app/bot/routers/tonconnect.py:80
msgid "tonconnectInit_menu"
msgstr "🔌 <b>Connect wallet</b>"
"\n\n"
"Press the button below to connect your wallet."
msgstr ""
"🔌 <b>Connect wallet</b>\n"
"\n"
"Press the button below to connect your wallet"
#: app/bot/routers/tonconnect.py:101
#: app/bot/routers/tonconnect.py:101 app/bot/routers/tonconnect.py:105
msgid "p_successConnectWallet"
msgstr "✅ Wallet connected successfully"
#: app/api/routes/_blockchain.py:143
msgid "p_tonconnectTransactionRequested"
msgstr "⏳ <b>Transaction requested</b>\n\n👉 Please confirm the transaction in your wallet"
#: app/api/routes/_blockchain.py:146
msgid "gotoWallet_button"
msgstr "Open wallet"
#: app/api/routes/_blockchain.py:150 app/bot/routers/tonconnect.py:90
msgid "home_button"
msgstr "◀️ Back"
#: app/bot/routers/tonconnect.py:86
msgid "tonconnectOpenWallet_button"
msgstr "[Connect wallet]"