From 9610e193bc03384940e9b08cfdaa22d59c110b94 Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Mon, 29 Jan 2024 12:42:35 +0100 Subject: [PATCH] DomainRenew --- packages/core/src/utils/common.ts | 6 ++- .../activity/ton/ActivityActionDetails.tsx | 28 +++++++++++- .../activity/ton/ActivityNotification.tsx | 5 ++- .../activity/ton/TonActivityAction.tsx | 36 ++++++++++++++- .../activity/ton/TonActivityEvents.tsx | 4 +- .../uikit/src/pages/activity/Activity.tsx | 45 +++++++++---------- 6 files changed, 95 insertions(+), 29 deletions(-) diff --git a/packages/core/src/utils/common.ts b/packages/core/src/utils/common.ts index 6726d9a1d..bdd708cd1 100644 --- a/packages/core/src/utils/common.ts +++ b/packages/core/src/utils/common.ts @@ -54,7 +54,11 @@ export const areEqAddresses = (address1: string, address2: string) => { }; export const toShortValue = (value: string, length = 4): string => { - return value.slice(0, length) + '...' + value.slice(-length); + if (value.length > length * 2) { + return value.slice(0, length) + '...' + value.slice(-length); + } else { + return value; + } }; export const formatAddress = (value: string, network?: Network, bounceable = false) => { diff --git a/packages/uikit/src/components/activity/ton/ActivityActionDetails.tsx b/packages/uikit/src/components/activity/ton/ActivityActionDetails.tsx index 6483c1c25..606b6f82d 100644 --- a/packages/uikit/src/components/activity/ton/ActivityActionDetails.tsx +++ b/packages/uikit/src/components/activity/ton/ActivityActionDetails.tsx @@ -1,7 +1,7 @@ import { CryptoCurrency } from '@tonkeeper/core/dist/entries/crypto'; import { AccountEvent, ActionStatusEnum, TonTransferAction } from '@tonkeeper/core/dist/tonApiV2'; import { formatDecimals } from '@tonkeeper/core/dist/utils/balance'; -import React, { FC } from 'react'; +import { FC } from 'react'; import { useWalletContext } from '../../../hooks/appContext'; import { useFormatCoinValue } from '../../../hooks/balance'; import { useTranslation } from '../../../hooks/translation'; @@ -115,6 +115,32 @@ export const AuctionBidActionDetails: FC = ({ action, timestamp, eve ); }; +export const DomainRenewActionDetails: FC = ({ action, timestamp, event }) => { + const { t } = useTranslation(); + const { domainRenew, simplePreview } = action; + + if (!domainRenew) { + return ; + } + + return ( + +
+ + {simplePreview.name} {domainRenew.domain} + + + +
+ + + + + +
+ ); +}; + export const SmartContractExecActionDetails: FC = ({ action, timestamp, event }) => { const { smartContractExec } = action; const format = useFormatCoinValue(); diff --git a/packages/uikit/src/components/activity/ton/ActivityNotification.tsx b/packages/uikit/src/components/activity/ton/ActivityNotification.tsx index c4ec97806..09dbac738 100644 --- a/packages/uikit/src/components/activity/ton/ActivityNotification.tsx +++ b/packages/uikit/src/components/activity/ton/ActivityNotification.tsx @@ -1,9 +1,10 @@ import { AccountEvent, Action } from '@tonkeeper/core/dist/tonApiV2'; -import React, { FC, useCallback } from 'react'; +import { FC, useCallback } from 'react'; import { Notification } from '../../Notification'; import { ErrorActivityNotification } from '../NotificationCommon'; import { AuctionBidActionDetails, + DomainRenewActionDetails, SmartContractExecActionDetails, TonTransferActionNotification } from './ActivityActionDetails'; @@ -43,6 +44,8 @@ const ActivityContent: FC = props => { return ; case 'AuctionBid': return ; + case 'DomainRenew': + return ; case 'SmartContractExec': return ; case 'JettonTransfer': diff --git a/packages/uikit/src/components/activity/ton/TonActivityAction.tsx b/packages/uikit/src/components/activity/ton/TonActivityAction.tsx index db6edaff9..ad2f32bac 100644 --- a/packages/uikit/src/components/activity/ton/TonActivityAction.tsx +++ b/packages/uikit/src/components/activity/ton/TonActivityAction.tsx @@ -1,7 +1,7 @@ import { CryptoCurrency } from '@tonkeeper/core/dist/entries/crypto'; import { Action } from '@tonkeeper/core/dist/tonApiV2'; import { formatAddress, seeIfAddressEqual, toShortValue } from '@tonkeeper/core/dist/utils/common'; -import React, { FC } from 'react'; +import { FC } from 'react'; import { ListItemPayload } from '../../../components/List'; import { ActivityIcon, @@ -177,6 +177,38 @@ const AuctionBidAction: FC<{ ); }; +const DomainRenewAction: FC<{ + action: Action; + date: string; +}> = ({ action, date }) => { + const { t } = useTranslation(); + const { domainRenew, simplePreview } = action; + const wallet = useWalletContext(); + const format = useFormatCoinValue(); + + if (!domainRenew) { + return ; + } + + return ( + + + + + + + {simplePreview.name} + + + {domainRenew.domain} + {date} + + + + + ); +}; + export const ActivityAction: FC<{ action: Action; date: string; @@ -215,6 +247,8 @@ export const ActivityAction: FC<{ return ; case 'WithdrawStakeRequest': return ; + case 'DomainRenew': + return ; case 'Unknown': return {t('txActions_signRaw_types_unknownTransaction')}; default: { diff --git a/packages/uikit/src/components/activity/ton/TonActivityEvents.tsx b/packages/uikit/src/components/activity/ton/TonActivityEvents.tsx index 56659333a..c1d48b54a 100644 --- a/packages/uikit/src/components/activity/ton/TonActivityEvents.tsx +++ b/packages/uikit/src/components/activity/ton/TonActivityEvents.tsx @@ -1,5 +1,5 @@ -import { AccountEvent, NftItem } from '@tonkeeper/core/dist/tonApiV2'; -import React, { FC } from 'react'; +import { AccountEvent } from '@tonkeeper/core/dist/tonApiV2'; +import { FC } from 'react'; import { ListItem } from '../../List'; import { ProgressIcon } from '../ActivityLayout'; import { ActionData } from './ActivityNotification'; diff --git a/packages/uikit/src/pages/activity/Activity.tsx b/packages/uikit/src/pages/activity/Activity.tsx index 65cadab25..8e2eac2de 100644 --- a/packages/uikit/src/pages/activity/Activity.tsx +++ b/packages/uikit/src/pages/activity/Activity.tsx @@ -1,6 +1,5 @@ import { useInfiniteQuery } from '@tanstack/react-query'; import { AccountsApi } from '@tonkeeper/core/dist/tonApiV2'; -import { TronApi } from '@tonkeeper/core/dist/tronApi'; import React, { FC, Suspense, useMemo, useRef } from 'react'; import { InnerBody } from '../../components/Body'; import { ActivityHeader } from '../../components/Header'; @@ -38,34 +37,34 @@ const Activity: FC = () => { getNextPageParam: lastPage => (lastPage.nextFrom > 0 ? lastPage.nextFrom : undefined) }); - const { - isFetched: isTronFetched, - data: tronEvents, - isFetchingNextPage: isTronFetchingNextPage, - hasNextPage: hasTronNextPage, - fetchNextPage: fetchTronNextPage - } = useInfiniteQuery({ - queryKey: [wallet.tron?.ownerWalletAddress, wallet.network, QueryKey.tron], - queryFn: ({ pageParam = undefined }) => - new TronApi(api.tronApi).getTransactions({ - ownerAddress: wallet.tron!.ownerWalletAddress, - fingerprint: pageParam, - limit: 100 - }), - getNextPageParam: lastPage => lastPage.fingerprint, - enabled: wallet.tron !== undefined - }); + // const { + // isFetched: isTronFetched, + // data: tronEvents, + // isFetchingNextPage: isTronFetchingNextPage, + // hasNextPage: hasTronNextPage, + // fetchNextPage: fetchTronNextPage + // } = useInfiniteQuery({ + // queryKey: [wallet.tron?.ownerWalletAddress, wallet.network, QueryKey.tron], + // queryFn: ({ pageParam = undefined }) => + // new TronApi(api.tronApi).getTransactions({ + // ownerAddress: wallet.tron!.ownerWalletAddress, + // fingerprint: pageParam, + // limit: 100 + // }), + // getNextPageParam: lastPage => lastPage.fingerprint, + // enabled: wallet.tron !== undefined + // }); - const isFetchingNextPage = isTonFetchingNextPage || isTronFetchingNextPage; + const isFetchingNextPage = isTonFetchingNextPage; useFetchNext(hasTonNextPage, isFetchingNextPage, fetchTonNextPage, standalone, ref); - useFetchNext(hasTronNextPage, isFetchingNextPage, fetchTronNextPage, standalone, ref); + // useFetchNext(hasTronNextPage, isFetchingNextPage, fetchTronNextPage, standalone, ref); const activity = useMemo(() => { - return getMixedActivity(tonEvents, tronEvents); - }, [tonEvents, tronEvents]); + return getMixedActivity(tonEvents, undefined); + }, [tonEvents]); - if (!isTonFetched || (wallet.tron !== undefined && !isTronFetched)) { + if (!isTonFetched) { return ; }