From 30cf34809977b77032f717a2b440dd3fa6e22a09 Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Mon, 16 Dec 2024 12:37:18 +0100 Subject: [PATCH] Handle bring to front link --- packages/core/src/service/deeplinkingService.ts | 10 ++++++++++ packages/uikit/src/components/connect/connectHook.ts | 11 ++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/core/src/service/deeplinkingService.ts b/packages/core/src/service/deeplinkingService.ts index 6f6850332..030e8071a 100644 --- a/packages/core/src/service/deeplinkingService.ts +++ b/packages/core/src/service/deeplinkingService.ts @@ -1,6 +1,16 @@ import queryString from 'query-string'; import { seeIfValidTonAddress } from '../utils/common'; +export function seeIfBringToFrontLink(options: { url: string }) { + const { query } = queryString.parseUrl(options.url); + + if (typeof query.ret === 'string' && query.v == null) { + return { ret: query.ret }; + } else { + return null; + } +} + export interface TonTransferParams { address?: string; amount?: string; diff --git a/packages/uikit/src/components/connect/connectHook.ts b/packages/uikit/src/components/connect/connectHook.ts index 055806497..dd9e87ade 100644 --- a/packages/uikit/src/components/connect/connectHook.ts +++ b/packages/uikit/src/components/connect/connectHook.ts @@ -4,7 +4,10 @@ import { DAppManifest, SendTransactionAppRequest } from '@tonkeeper/core/dist/entries/tonConnect'; -import { parseTonTransferWithAddress } from '@tonkeeper/core/dist/service/deeplinkingService'; +import { + parseTonTransferWithAddress, + seeIfBringToFrontLink +} from '@tonkeeper/core/dist/service/deeplinkingService'; import { connectRejectResponse, parseTonConnect, @@ -28,6 +31,12 @@ export const useGetConnectInfo = () => { return useMutation(async url => { try { + const bring = seeIfBringToFrontLink({ url }); + if (bring != null) { + // TODO: save ret parameter and user after confirm transaction + return null; + } + const transfer = parseTonTransferWithAddress({ url }); if (transfer) {