dev@locazia: add "confirm tx" message

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

No files matched your search

+17 -1
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')
+37
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()
+2 -1
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
+7
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: