mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
Remake counters API integration.
This commit is contained in:
@@ -22,7 +22,7 @@ import type { InternalTransactionsResponse } from 'types/api/internalTransaction
|
||||
import type { LogsResponseTx, LogsResponseAddress } from 'types/api/log';
|
||||
import type { RawTracesResponse } from 'types/api/rawTrace';
|
||||
import type { SearchResult, SearchResultFilters } from 'types/api/search';
|
||||
import type { Stats, Charts, HomeStats } from 'types/api/stats';
|
||||
import type { Counters, Charts, HomeStats } from 'types/api/stats';
|
||||
import type { TokenCounters, TokenInfo, TokenHolders } from 'types/api/tokenInfo';
|
||||
import type { TokenTransferResponse, TokenTransferFilters } from 'types/api/tokenTransfer';
|
||||
import type { TransactionsResponseValidated, TransactionsResponsePending, Transaction } from 'types/api/transaction';
|
||||
@@ -292,7 +292,7 @@ Q extends 'homepage_chart_market' ? ChartMarketResponse :
|
||||
Q extends 'homepage_blocks' ? Array<Block> :
|
||||
Q extends 'homepage_txs' ? Array<Transaction> :
|
||||
Q extends 'homepage_indexing_status' ? IndexingStatus :
|
||||
Q extends 'stats_counters' ? Stats :
|
||||
Q extends 'stats_counters' ? Counters :
|
||||
Q extends 'stats_charts' ? Charts :
|
||||
Q extends 'blocks' ? BlocksResponse :
|
||||
Q extends 'block' ? Block :
|
||||
|
||||
+8
-14
@@ -19,21 +19,15 @@ export type GasPrices = {
|
||||
slow: number;
|
||||
}
|
||||
|
||||
export type Stats = {
|
||||
counters: {
|
||||
totalBlocks: string;
|
||||
averageBlockTime: string;
|
||||
export type Counters = {
|
||||
counters: Array<Counter>;
|
||||
}
|
||||
|
||||
totalTransactions: string;
|
||||
completedTransactions: string;
|
||||
|
||||
totalAccounts: string;
|
||||
|
||||
totalTokens: string;
|
||||
|
||||
totalNativeCoinHolders: string;
|
||||
totalNativeCoinTransfers: string;
|
||||
};
|
||||
type Counter = {
|
||||
id: string;
|
||||
value: string;
|
||||
title: string;
|
||||
units: string;
|
||||
}
|
||||
|
||||
export type Charts = {
|
||||
|
||||
@@ -4,7 +4,6 @@ import React from 'react';
|
||||
import useApiQuery from 'lib/api/useApiQuery';
|
||||
import formatNumberToMetricPrefix from 'lib/formatNumberToMetricPrefix';
|
||||
|
||||
import { numberWidgetsScheme } from './constants/number-widgets-scheme';
|
||||
import NumberWidget from './NumberWidget';
|
||||
import NumberWidgetSkeleton from './NumberWidgetSkeleton';
|
||||
|
||||
@@ -22,20 +21,13 @@ const NumberWidgetsList = () => {
|
||||
gridGap={ 4 }
|
||||
>
|
||||
{ isLoading ? skeletonElement :
|
||||
numberWidgetsScheme.map(({ id, title, formatFn }) => {
|
||||
if (!data?.counters[id]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const value = formatNumberToMetricPrefix(Number(data.counters[id]));
|
||||
data?.counters?.map(({ id, title, value, units }) => {
|
||||
|
||||
return (
|
||||
<NumberWidget
|
||||
key={ id }
|
||||
label={ title }
|
||||
value={ formatFn ?
|
||||
formatFn(value) :
|
||||
value }
|
||||
value={ `${ formatNumberToMetricPrefix(Number(value)) } ${ units }` }
|
||||
/>
|
||||
);
|
||||
}) }
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
import type { Stats } from 'types/api/stats';
|
||||
|
||||
type Key = keyof Stats['counters'];
|
||||
|
||||
export const numberWidgetsScheme: Array<{id: Key; title: string; formatFn?: (n: string) => string}> = [
|
||||
{
|
||||
id: 'totalBlocks',
|
||||
title: 'Total blocks',
|
||||
},
|
||||
{
|
||||
id: 'averageBlockTime',
|
||||
title: 'Average block time',
|
||||
formatFn: (n) => `${ n } s`,
|
||||
},
|
||||
{
|
||||
id: 'totalTransactions',
|
||||
title: 'Total transactions',
|
||||
},
|
||||
{
|
||||
id: 'completedTransactions',
|
||||
title: 'Completed transactions',
|
||||
},
|
||||
{
|
||||
id: 'totalAccounts',
|
||||
title: 'Total accounts',
|
||||
},
|
||||
{
|
||||
id: 'totalTokens',
|
||||
title: 'Total tokens',
|
||||
},
|
||||
{
|
||||
id: 'totalNativeCoinHolders',
|
||||
title: 'Total native coin holders',
|
||||
},
|
||||
{
|
||||
id: 'totalNativeCoinTransfers',
|
||||
title: 'Total native coin transfers',
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user