Skip to content

Commit

Permalink
fix: correct account hasn't been activated on ton connect tx request …
Browse files Browse the repository at this point in the history
…received
  • Loading branch information
siandreev committed Dec 20, 2024
1 parent 1fa1450 commit ec145f4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
16 changes: 14 additions & 2 deletions apps/desktop/src/app/components/TonConnectSubscription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,30 @@ import {
} from '@tonkeeper/uikit/dist/state/tonConnect';
import { sendBackground } from '../../libs/backgroudService';
import { SendTransactionAppRequest } from '@tonkeeper/core/dist/entries/tonConnect';
import { QueryKey } from '@tonkeeper/uikit/dist/libs/queryKey';
import { useQueryClient } from '@tanstack/react-query';

export const TonConnectSubscription = () => {
const [request, setRequest] = useState<SendTransactionAppRequest | undefined>(undefined);

const { mutateAsync: responseSendAsync } = useResponseSendMutation();
const { mutate: disconnect } = useDisconnectTonConnectApp({ skipEmit: true });

const queryClient = useQueryClient();

const onTransaction = useCallback(
async (request: SendTransactionAppRequest) => {
await queryClient.invalidateQueries([QueryKey.account]);
setRequest(request);
},
[setRequest]
);

useSendNotificationAnalytics(request?.connection?.manifest);

useEffect(() => {
window.backgroundApi.onTonConnectTransaction(setRequest);
}, [setRequest]);
window.backgroundApi.onTonConnectTransaction(onTransaction);
}, [onTransaction]);

useEffect(() => {
window.backgroundApi.onTonConnectDisconnect(disconnect);
Expand Down
10 changes: 9 additions & 1 deletion apps/tablet/src/app/components/TonConnectSubscription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
tonConnectSSE
} from "../../libs/tonConnect";
import { useActiveWallet } from "@tonkeeper/uikit/dist/state/wallet";
import { useQueryClient } from "@tanstack/react-query";
import { QueryKey } from "@tonkeeper/uikit/dist/libs/queryKey";

export const TonConnectSubscription = () => {
const [request, setRequest] = useState<SendTransactionAppRequest | undefined>(undefined);
Expand All @@ -22,10 +24,16 @@ export const TonConnectSubscription = () => {
const { data: appConnections } = useAppTonConnectConnections();
const wallet = useActiveWallet();
const activeWalletConnections = useMemo(() => appConnections?.find(c => c.wallet.id === wallet.id)?.connections, [appConnections, wallet.id]);
const queryClient = useQueryClient();

useSendNotificationAnalytics(request?.connection?.manifest);

useEffect(() => subscribeToTonConnectSendTransaction(setRequest), [setRequest]);
const onTransaction = useCallback(async (request: SendTransactionAppRequest) => {
await queryClient.invalidateQueries([QueryKey.account]);
setRequest(request);
}, [setRequest]);

useEffect(() => subscribeToTonConnectSendTransaction(onTransaction), [onTransaction]);

useEffect(() => subscribeToTonConnectDisconnect(disconnect), [disconnect]);

Expand Down

0 comments on commit ec145f4

Please sign in to comment.