Skip to content

Commit

Permalink
feat: usdt trc20 for mobile layout
Browse files Browse the repository at this point in the history
  • Loading branch information
siandreev committed Dec 27, 2024
1 parent 7100880 commit 0ab64aa
Show file tree
Hide file tree
Showing 22 changed files with 488 additions and 615 deletions.
12 changes: 6 additions & 6 deletions packages/core/src/tonkeeperApi/tonendpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ export interface TonendpointConfig {
*/
tablet_enable_additional_security?: boolean;

'2fa_public_key'?: string;
'2fa_api_url'?: string;
'2fa_tg_confirm_send_message_ttl_seconds'?: number;
'2fa_tg_linked_ttl_seconds'?: number;
'2fa_bot_url'?: string;
'2fa_public_key'?: string;
'2fa_api_url'?: string;
'2fa_tg_confirm_send_message_ttl_seconds'?: number;
'2fa_tg_linked_ttl_seconds'?: number;
'2fa_bot_url'?: string;

tron_api_url?: string;
tron_api_url?: string;
}

const defaultTonendpoint = 'https://api.tonkeeper.com'; // 'http://localhost:1339';
Expand Down
82 changes: 0 additions & 82 deletions packages/uikit/src/components/activity/ActivityGroup.tsx

This file was deleted.

73 changes: 73 additions & 0 deletions packages/uikit/src/components/activity/MobileActivityList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React, { FC, useMemo, useState } from 'react';
import {
formatActivityDate,
getActivityTitle,
ActivityItem,
groupActivityItems
} from '../../state/activity';
import { Group, List, Title } from './ActivityLayout';
import { ActivityNotification, ActivityNotificationData } from './ton/ActivityNotification';
import { TonActivityEvents } from './ton/TonActivityEvents';
import { useTranslation } from '../../hooks/translation';
import { TronActivityEvents } from './tron/TronActivityEvents';

export const MobileActivityList: FC<{
items: ActivityItem[];
}> = ({ items }) => {
const [activityNotificationData, setActivityNotificationData] = useState<
ActivityNotificationData | undefined
>(undefined);
const { i18n } = useTranslation();

const groups = useMemo(() => groupActivityItems(items), [items]);

return (
<>
{groups.map(([groupKey, groupEvents]) => {
return (
<Group key={groupKey}>
<Title>
{getActivityTitle(i18n.language, groupKey, groupEvents[0].timestamp)}
</Title>
{groupEvents.map(({ timestamp, event, type, key }) => {
const date = formatActivityDate(i18n.language, groupKey, timestamp);
return (
<List key={key}>
{type === 'tron' ? (
<TronActivityEvents
event={event}
formattedDate={date}
onClick={() =>
setActivityNotificationData({
type: 'tron',
event,
timestamp: event.timestamp
})
}
/>
) : type === 'ton' ? (
<TonActivityEvents
event={event}
date={date}
timestamp={timestamp}
setActivity={ad =>
setActivityNotificationData({
type: 'ton',
...ad
})
}
/>
) : null}
</List>
);
})}
</Group>
);
})}
<ActivityNotification
value={activityNotificationData}
handleClose={() => setActivityNotificationData(undefined)}
/>
</>
);
};
55 changes: 55 additions & 0 deletions packages/uikit/src/components/activity/tron/TronActivityEvents.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { FC } from 'react';
import { ListItem } from '../../List';
import { TronHistoryItem, TronHistoryItemTransferAsset } from '@tonkeeper/core/dist/tronApi';
import { ReceiveActivityAction, SendActivityAction } from '../ActivityActionLayout';
import { useActiveTronWallet } from '../../../state/tron/tron';
import { ErrorAction } from '../CommonAction';
import { ActionStatusEnum } from '@tonkeeper/core/dist/tonApiV2';

export const TronActivityEvents: FC<{
event: TronHistoryItem;
formattedDate: string;
onClick: () => void;
}> = ({ event, onClick, formattedDate }) => {
return (
<>
<ListItem onClick={onClick}>
<TronTransferAction event={event} formattedDate={formattedDate} />
</ListItem>
</>
);
};

const TronTransferAction: FC<{
event: TronHistoryItemTransferAsset;
formattedDate: string;
}> = ({ event, formattedDate }) => {
const wallet = useActiveTronWallet();

if (!wallet) {
return <ErrorAction />;
}

if (event.to === wallet?.address) {
return (
<ReceiveActivityAction
amount={event.assetAmount.stringRelativeAmount}
sender={event.from}
symbol={event.assetAmount.asset.symbol}
date={formattedDate}
isScam={event.isScam}
status={event.isFailed ? ActionStatusEnum.Failed : ActionStatusEnum.Ok}
/>
);
}
return (
<SendActivityAction
amount={event.assetAmount.stringRelativeAmount}
symbol={event.assetAmount.asset.symbol}
recipient={event.to}
date={formattedDate}
isScam={event.isScam}
status={event.isFailed ? ActionStatusEnum.Failed : ActionStatusEnum.Ok}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const TRCBadge = styled(Badge)`

export const AssetHistoryFilter = () => {
const { t } = useTranslation();
const assets = useAllChainsAssets();
const { assets } = useAllChainsAssets();
const { asset: selectedAsset, setAsset } = useHistoryFilters();
if (!assets) {
return null;
Expand Down
4 changes: 1 addition & 3 deletions packages/uikit/src/components/home/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import { useAppContext } from '../../hooks/appContext';
import { useAppSdk } from '../../hooks/appSdk';
import { formatFiatCurrency } from '../../hooks/balance';
import { QueryKey } from '../../libs/queryKey';
import { useActiveAccount, useActiveTonNetwork, useActiveWallet } from '../../state/wallet';
import { useActiveAccount, useActiveWallet } from '../../state/wallet';
import { Body3, Label2, Num2 } from '../Text';
import { SkeletonText } from '../shared/Skeleton';
import { AssetData } from './Jettons';
import { useWalletTotalBalance } from '../../state/asset';
import { useTranslation } from '../../hooks/translation';
import { AccountAndWalletBadgesGroup, NetworkBadge } from '../account/AccountBadge';
Expand Down Expand Up @@ -88,7 +87,6 @@ export const BalanceSkeleton = () => {
export const Balance: FC<{
error?: Error | null;
isFetching: boolean;
assets: AssetData;
}> = ({ error, isFetching }) => {
const { t } = useTranslation();
const account = useActiveAccount();
Expand Down
5 changes: 3 additions & 2 deletions packages/uikit/src/components/home/CompactView.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { NFT } from '@tonkeeper/core/dist/entries/nft';
import React, { FC } from 'react';
import { NftsList } from '../nft/Nfts';
import { AssetData, JettonList } from './Jettons';
import { JettonList } from './Jettons';
import { AssetAmount } from '@tonkeeper/core/dist/entries/crypto/asset/asset-amount';

export const CompactView: FC<{
assets: AssetData;
assets: AssetAmount[];
nfts: NFT[];
}> = ({ assets, nfts }) => {
return (
Expand Down
Loading

0 comments on commit 0ab64aa

Please sign in to comment.