From 6c9d229a5fef8d328f4ddbea556e62ef1856da00 Mon Sep 17 00:00:00 2001 From: Radu Mojic Date: Fri, 13 Dec 2024 14:21:57 +0200 Subject: [PATCH 1/7] update api entry for transfers from transfersCount to transfers --- src/hooks/useGetNativeTokenDetails.ts | 2 +- src/layouts/TokenLayout/TokenDetailsCard.tsx | 4 ++-- src/pages/Tokens/components/TokensTable/TokensTable.tsx | 2 +- src/types/token.types.ts | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/hooks/useGetNativeTokenDetails.ts b/src/hooks/useGetNativeTokenDetails.ts index e2642822..f1fb39bb 100644 --- a/src/hooks/useGetNativeTokenDetails.ts +++ b/src/hooks/useGetNativeTokenDetails.ts @@ -25,7 +25,7 @@ export interface NativeTokenType { marketCap?: number; valueUsd?: number; assets?: TokenAssetType; - transfersCount?: number; + transfers?: number; } export const useGetNativeTokenDetails = () => { diff --git a/src/layouts/TokenLayout/TokenDetailsCard.tsx b/src/layouts/TokenLayout/TokenDetailsCard.tsx index ab9db6d0..94ec6d06 100644 --- a/src/layouts/TokenLayout/TokenDetailsCard.tsx +++ b/src/layouts/TokenLayout/TokenDetailsCard.tsx @@ -27,7 +27,7 @@ export const TokenDetailsCard = () => { circulatingSupply, accounts, transactions, - transfersCount, + transfers, price, marketCap, isLowLiquidity @@ -104,7 +104,7 @@ export const TokenDetailsCard = () => { { title: 'Holders', value: new BigNumber(accounts).toFormat() }, { title: 'Transactions', - value: new BigNumber(transfersCount || transactions || 0).toFormat() + value: new BigNumber(transfers || transactions || 0).toFormat() } ]; diff --git a/src/pages/Tokens/components/TokensTable/TokensTable.tsx b/src/pages/Tokens/components/TokensTable/TokensTable.tsx index 174e0ecb..d5ec9528 100644 --- a/src/pages/Tokens/components/TokensTable/TokensTable.tsx +++ b/src/pages/Tokens/components/TokensTable/TokensTable.tsx @@ -157,7 +157,7 @@ export const TokensTable = ({ {new BigNumber( - token.transfersCount || token.transactions || 0 + token.transfers || token.transactions || 0 ).toFormat()} diff --git a/src/types/token.types.ts b/src/types/token.types.ts index 6caf22c1..8c2b695f 100644 --- a/src/types/token.types.ts +++ b/src/types/token.types.ts @@ -1,7 +1,8 @@ -import { RolesType, SliceType, AccountAssetType } from 'types'; +import { RolesType, SliceType, AccountAssetType, NftSubtypeEnum } from 'types'; export interface TokenType { type: TokenTypeEnum; + subType?: NftSubtypeEnum; identifier: string; ticker?: string; name: string; @@ -22,6 +23,7 @@ export interface TokenType { isPaused?: boolean; transactions: number; accounts: number; + transfers?: number; price?: number; marketCap?: number; valueUsd?: number; @@ -29,7 +31,6 @@ export interface TokenType { totalLiquidity?: number; isLowLiquidity?: boolean; lowLiquidityThresholdPercent?: number; - transfersCount?: number; roles?: TokenRolesType[]; } From 0b71ef4b1f3746ddbceb000467324384640c86d5 Mon Sep 17 00:00:00 2001 From: Radu Mojic Date: Fri, 13 Dec 2024 14:41:31 +0200 Subject: [PATCH 2/7] exclude the EGLD-000000 token as it will be replaced by the native token row --- .../components/TokensTable/TokensTable.tsx | 172 +++++++++--------- 1 file changed, 90 insertions(+), 82 deletions(-) diff --git a/src/pages/Tokens/components/TokensTable/TokensTable.tsx b/src/pages/Tokens/components/TokensTable/TokensTable.tsx index d5ec9528..e18c107a 100644 --- a/src/pages/Tokens/components/TokensTable/TokensTable.tsx +++ b/src/pages/Tokens/components/TokensTable/TokensTable.tsx @@ -2,7 +2,7 @@ import { Fragment } from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import BigNumber from 'bignumber.js'; -import { ELLIPSIS } from 'appConstants'; +import { ELLIPSIS, NATIVE_TOKEN_IDENTIFIER } from 'appConstants'; import { NetworkLink, FormatAmount, @@ -74,93 +74,101 @@ export const TokensTable = ({ totalTokens={totalTokens} /> )} - - -
-
- - {token.assets && token.assets.svgUrl ? ( - {token.name} - ) : ( -
- -
- )} -
-
-
- + {token.identifier !== NATIVE_TOKEN_IDENTIFIER && ( + + +
+
- {token.ticker} + {token.assets && token.assets.svgUrl ? ( + {token.name} + ) : ( +
+ +
+ )}
- - - {token.assets && token.assets.description && ( -
- {token.assets.description} -
- )} +
+
+ + + {token.ticker} + + + + {token.assets && token.assets.description && ( +
+ {token.assets.description} +
+ )} +
-
- - {token.name} - - {token.price && ( - - )} - - - {token.circulatingSupply && ( - - )} - - - {token.price && token.marketCap && !token.isLowLiquidity && ( - - )} - - - {token.accounts - ? new BigNumber(token.accounts).toFormat() - : 0} - - - {new BigNumber( - token.transfers || token.transactions || 0 - ).toFormat()} - - + + {token.name} + + {token.price && ( + + )} + + + {token.circulatingSupply && ( + + )} + + + {token.price && + token.marketCap && + !token.isLowLiquidity && ( + + )} + + + {token.accounts + ? new BigNumber(token.accounts).toFormat() + : 0} + + + {new BigNumber( + token.transfers || token.transactions || 0 + ).toFormat()} + + + )} {typeof totalTokens === 'number' && order === SortOrderEnum.asc && i !== 0 && ( From a46ab4ae86f9a3221dd3717e6385d18d08d56ed3 Mon Sep 17 00:00:00 2001 From: Radu Mojic Date: Fri, 13 Dec 2024 14:42:01 +0200 Subject: [PATCH 3/7] show the growthTotalTokens value if available --- src/pages/Tokens/Tokens.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/Tokens/Tokens.tsx b/src/pages/Tokens/Tokens.tsx index 53f4fc43..3f9e7c56 100644 --- a/src/pages/Tokens/Tokens.tsx +++ b/src/pages/Tokens/Tokens.tsx @@ -41,12 +41,14 @@ export const Tokens = () => { const [dataReady, setDataReady] = useState(); const [totalTokens, setTotalTokens] = useState(); - const displayTotalTokens = new BigNumber(totalTokens ?? 0).plus(1).toFormat(); + const { totalTokens: growthTotalTokens } = pageHeadersTokens; + const displayTotalTokens = + growthTotalTokens ?? new BigNumber(totalTokens || 1).toFormat(); const fetchTokens = () => { Promise.all([ - getTokens({ search, page, size, sort, order }), - getTokensCount({ search }) + getTokens({ search, page, size, sort, order, includeMetaESDT: false }), + getTokensCount({ search, includeMetaESDT: false }) ]).then(([tokensData, count]) => { if (ref.current !== null) { if (tokensData.success) { From 14c3508598b4304a336be5728db8cbd4292a4eed Mon Sep 17 00:00:00 2001 From: Radu Mojic Date: Fri, 13 Dec 2024 14:45:48 +0200 Subject: [PATCH 4/7] show NATIVE_TOKEN_IDENTIFIER on search --- src/hooks/useIsNativeTokenSearched.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hooks/useIsNativeTokenSearched.ts b/src/hooks/useIsNativeTokenSearched.ts index 96704fed..783537bd 100644 --- a/src/hooks/useIsNativeTokenSearched.ts +++ b/src/hooks/useIsNativeTokenSearched.ts @@ -1,6 +1,6 @@ import { useSelector } from 'react-redux'; -import { BRAND_NAME } from 'appConstants'; +import { BRAND_NAME, NATIVE_TOKEN_IDENTIFIER } from 'appConstants'; import { useGetSearch } from 'hooks'; import { activeNetworkSelector } from 'redux/selectors'; @@ -15,7 +15,8 @@ export const useIsNativeTokenSearched = () => { 'elrond', 'multiversx', BRAND_NAME.toLowerCase(), - (egldLabel ?? '').toLowerCase() + (egldLabel ?? '').toLowerCase(), + NATIVE_TOKEN_IDENTIFIER.toLowerCase() ].includes(search.toLowerCase().trim()) ); From 1f229948c8c1ceace3614c25746c23d7a9f2355a Mon Sep 17 00:00:00 2001 From: Radu Mojic Date: Fri, 13 Dec 2024 15:21:19 +0200 Subject: [PATCH 5/7] added shard filter on blocks --- src/components/BlocksTable/BlocksTable.tsx | 7 +++++-- src/hooks/urlFilters/useGetBlockFilters.ts | 2 +- src/pages/Blocks/Blocks.tsx | 12 ++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/BlocksTable/BlocksTable.tsx b/src/components/BlocksTable/BlocksTable.tsx index 5d2af483..f3bebd78 100644 --- a/src/components/BlocksTable/BlocksTable.tsx +++ b/src/components/BlocksTable/BlocksTable.tsx @@ -4,7 +4,8 @@ import { Trim, BlockGasUsed, IdentityBlock, - ShardLink + ShardLink, + ShardFilter } from 'components'; import { formatSize } from 'helpers'; import { useIsSovereign } from 'hooks'; @@ -27,7 +28,9 @@ export const BlocksTable = ({ Block Age Txns - {isSovereign ? 'Chain' : 'Shard'} + + + Size Gas Used diff --git a/src/hooks/urlFilters/useGetBlockFilters.ts b/src/hooks/urlFilters/useGetBlockFilters.ts index bd915cce..0ed1cc86 100644 --- a/src/hooks/urlFilters/useGetBlockFilters.ts +++ b/src/hooks/urlFilters/useGetBlockFilters.ts @@ -8,6 +8,6 @@ export const useGetBlockFilters = () => { const getParam = getUrlParam(searchParams); return { - shard: getParam(BlockFiltersEnum.shard) + shard: getParam(BlockFiltersEnum.shard, true) }; }; diff --git a/src/pages/Blocks/Blocks.tsx b/src/pages/Blocks/Blocks.tsx index 35a1b5fb..5e6d2e19 100644 --- a/src/pages/Blocks/Blocks.tsx +++ b/src/pages/Blocks/Blocks.tsx @@ -26,20 +26,20 @@ interface StateType { export const Blocks = () => { const ref = useRef(null); const [searchParams] = useSearchParams(); + + const networkRoute = useNetworkRoute(); const hasGrowthWidgets = useHasGrowthWidgets(); - const { shard } = useGetBlockFilters(); + const { shard: filterShard } = useGetBlockFilters(); const { page, size, firstPageRefreshTrigger } = useGetPage(); + const { getBlocks, getBlocksCount } = useAdapter(); + const { id: activeNetworkId } = useSelector(activeNetworkSelector); const pageHeadersBlocks = useSelector(pageHeadersBlocksStatsSelector); - const networkRoute = useNetworkRoute(); - const [state, setState] = useState(); const [dataReady, setDataReady] = useState(); const [totalBlocks, setTotalBlocks] = useState('...'); - const { id: activeNetworkId } = useSelector(activeNetworkSelector); - - const { getBlocks, getBlocksCount } = useAdapter(); + const shard = filterShard !== undefined ? Number(filterShard) : undefined; useEffect(() => { if (shard !== undefined) { From b0d21b65246ee66352ec3299a030c9d4c72b01f4 Mon Sep 17 00:00:00 2001 From: Radu Mojic Date: Fri, 13 Dec 2024 15:22:10 +0200 Subject: [PATCH 6/7] use growth data as backup(if available) in case api fails --- .../BlockHeightStatsCard.tsx | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/widgets/BlockHeightStatsCard/BlockHeightStatsCard.tsx b/src/widgets/BlockHeightStatsCard/BlockHeightStatsCard.tsx index 4c7a75a7..bd19051a 100644 --- a/src/widgets/BlockHeightStatsCard/BlockHeightStatsCard.tsx +++ b/src/widgets/BlockHeightStatsCard/BlockHeightStatsCard.tsx @@ -1,12 +1,30 @@ +import BigNumber from 'bignumber.js'; import { useSelector } from 'react-redux'; +import { ELLIPSIS } from 'appConstants'; import { statsSelector } from 'redux/selectors'; +import { pageHeadersBlocksStatsSelector } from 'redux/selectors/pageHeadersBlocksStats'; import { StatsCard } from 'widgets'; export const BlockHeightStatsCard = () => { - const { blocks } = useSelector(statsSelector); + const { unprocessed } = useSelector(statsSelector); + const { blockHeight } = useSelector(pageHeadersBlocksStatsSelector); + const bNBlocks = new BigNumber(unprocessed?.blocks); + + const displayStatsHeight = + bNBlocks.isInteger() && bNBlocks.isGreaterThan(0) + ? bNBlocks.toFormat(0) + : undefined; + const displayGrowthHeight = + blockHeight && !isNaN(Number(blockHeight)) ? blockHeight : undefined; + + const displayValue = displayStatsHeight || displayGrowthHeight || ELLIPSIS; return ( - + ); }; From f52214beab4af61e1ef11a68549625128ba8ebb4 Mon Sep 17 00:00:00 2001 From: Radu Mojic Date: Fri, 13 Dec 2024 15:27:01 +0200 Subject: [PATCH 7/7] use growth data as backup(if available) in case api fails --- src/widgets/BlockHeightStatsCard/BlockHeightStatsCard.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/widgets/BlockHeightStatsCard/BlockHeightStatsCard.tsx b/src/widgets/BlockHeightStatsCard/BlockHeightStatsCard.tsx index bd19051a..c1156e7b 100644 --- a/src/widgets/BlockHeightStatsCard/BlockHeightStatsCard.tsx +++ b/src/widgets/BlockHeightStatsCard/BlockHeightStatsCard.tsx @@ -16,7 +16,9 @@ export const BlockHeightStatsCard = () => { ? bNBlocks.toFormat(0) : undefined; const displayGrowthHeight = - blockHeight && !isNaN(Number(blockHeight)) ? blockHeight : undefined; + blockHeight && !isNaN(Number(blockHeight)) && Number(blockHeight) > 0 + ? blockHeight + : undefined; const displayValue = displayStatsHeight || displayGrowthHeight || ELLIPSIS;