Skip to content

Commit

Permalink
DomainRenew
Browse files Browse the repository at this point in the history
  • Loading branch information
KuznetsovNikita committed Jan 29, 2024
1 parent e88b92e commit 9610e19
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 29 deletions.
6 changes: 5 additions & 1 deletion packages/core/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -115,6 +115,32 @@ export const AuctionBidActionDetails: FC<ActionData> = ({ action, timestamp, eve
);
};

export const DomainRenewActionDetails: FC<ActionData> = ({ action, timestamp, event }) => {
const { t } = useTranslation();
const { domainRenew, simplePreview } = action;

if (!domainRenew) {
return <ErrorActivityNotification event={event} />;
}

return (
<ActionDetailsBlock event={event}>
<div>
<Title>
{simplePreview.name} {domainRenew.domain}
</Title>
<ActionDate kind="send" timestamp={timestamp} />
<FailedDetail status={action.status} />
</div>
<ListBlock margin={false} fullWidth>
<ActionRecipientDetails recipient={domainRenew.renewer} bounced />
<ActionTransactionDetails eventId={event.eventId} />
<ActionExtraDetails extra={event.extra} />
</ListBlock>
</ActionDetailsBlock>
);
};

export const SmartContractExecActionDetails: FC<ActionData> = ({ action, timestamp, event }) => {
const { smartContractExec } = action;
const format = useFormatCoinValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -43,6 +44,8 @@ const ActivityContent: FC<ActionData> = props => {
return <SubscribeActionDetails {...props} />;
case 'AuctionBid':
return <AuctionBidActionDetails {...props} />;
case 'DomainRenew':
return <DomainRenewActionDetails {...props} />;
case 'SmartContractExec':
return <SmartContractExecActionDetails {...props} />;
case 'JettonTransfer':
Expand Down
36 changes: 35 additions & 1 deletion packages/uikit/src/components/activity/ton/TonActivityAction.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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 <ErrorAction />;
}

return (
<ListItemGrid>
<ActivityIcon status={action.status}>
<SentIcon />
</ActivityIcon>
<Description>
<FirstLine>
<FirstLabel>{simplePreview.name}</FirstLabel>
</FirstLine>
<SecondLine>
<SecondaryText>{domainRenew.domain}</SecondaryText>
<SecondaryText>{date}</SecondaryText>
</SecondLine>
</Description>
<FailedNote status={action.status} />
</ListItemGrid>
);
};

export const ActivityAction: FC<{
action: Action;
date: string;
Expand Down Expand Up @@ -215,6 +247,8 @@ export const ActivityAction: FC<{
return <WithdrawStakeAction action={action} date={date} />;
case 'WithdrawStakeRequest':
return <WithdrawRequestStakeAction action={action} date={date} />;
case 'DomainRenew':
return <DomainRenewAction action={action} date={date} />;
case 'Unknown':
return <ErrorAction>{t('txActions_signRaw_types_unknownTransaction')}</ErrorAction>;
default: {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
45 changes: 22 additions & 23 deletions packages/uikit/src/pages/activity/Activity.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 <ActivitySkeletonPage />;
}

Expand Down

0 comments on commit 9610e19

Please sign in to comment.