Skip to content

Commit

Permalink
Merge pull request #335 from tonkeeper/feature/bring-to-front
Browse files Browse the repository at this point in the history
Handle bring to front link
  • Loading branch information
KuznetsovNikita authored Dec 16, 2024
2 parents 4394df7 + 30cf348 commit 8b93ac0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/core/src/service/deeplinkingService.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
11 changes: 10 additions & 1 deletion packages/uikit/src/components/connect/connectHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -29,6 +32,12 @@ export const useGetConnectInfo = () => {

return useMutation<null | TonConnectParams, Error, string>(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) {
Expand Down

0 comments on commit 8b93ac0

Please sign in to comment.