Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to @blockscout/stats-types and @blockscout/visualizer-types #2063

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/api/resources.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type * as bens from '@blockscout/bens-types';
import type * as stats from '@blockscout/stats-types';
import type * as visualizer from '@blockscout/visualizer-types';
import { getFeaturePayload } from 'configs/app/features/types';
import type {
UserInfo,
Expand Down Expand Up @@ -71,7 +73,7 @@ import type {
import type { RawTracesResponse } from 'types/api/rawTrace';
import type { SearchRedirectResult, SearchResult, SearchResultFilters, SearchResultItem } from 'types/api/search';
import type { ShibariumWithdrawalsResponse, ShibariumDepositsResponse } from 'types/api/shibarium';
import type { Counters, StatsCharts, StatsChart, HomeStats } from 'types/api/stats';
import type { HomeStats } from 'types/api/stats';
import type {
TokenCounters,
TokenInfo,
Expand Down Expand Up @@ -99,7 +101,6 @@ import type { TxStateChanges } from 'types/api/txStateChanges';
import type { UserOpsResponse, UserOp, UserOpsFilters, UserOpsAccount } from 'types/api/userOps';
import type { ValidatorsCountersResponse, ValidatorsFilters, ValidatorsResponse, ValidatorsSorting } from 'types/api/validators';
import type { VerifiedContractsSorting } from 'types/api/verifiedContracts';
import type { VisualizedContract } from 'types/api/visualization';
import type { WithdrawalsResponse, WithdrawalsCounters } from 'types/api/withdrawals';
import type {
ZkEvmL2DepositsResponse,
Expand Down Expand Up @@ -931,9 +932,9 @@ Q extends 'homepage_zkevm_l2_batches' ? { items: Array<ZkEvmL2TxnBatchesItem> }
Q extends 'homepage_indexing_status' ? IndexingStatus :
Q extends 'homepage_zkevm_latest_batch' ? number :
Q extends 'homepage_zksync_latest_batch' ? number :
Q extends 'stats_counters' ? Counters :
Q extends 'stats_lines' ? StatsCharts :
Q extends 'stats_line' ? StatsChart :
Q extends 'stats_counters' ? stats.Counters :
Q extends 'stats_lines' ? stats.LineCharts :
Q extends 'stats_line' ? stats.LineChart :
Q extends 'blocks' ? BlocksResponse :
Q extends 'block' ? Block :
Q extends 'block_txs' ? BlockTransactionsResponse :
Expand Down Expand Up @@ -986,7 +987,7 @@ Q extends 'contract' ? SmartContract :
Q extends 'contract_solidityscan_report' ? SolidityscanReport :
Q extends 'verified_contracts' ? VerifiedContractsResponse :
Q extends 'verified_contracts_counters' ? VerifiedContractsCounters :
Q extends 'visualize_sol2uml' ? VisualizedContract :
Q extends 'visualize_sol2uml' ? visualizer.VisualizeResponse :
Q extends 'contract_verification_config' ? SmartContractVerificationConfig :
Q extends 'withdrawals' ? WithdrawalsResponse :
Q extends 'withdrawals_counters' ? WithdrawalsCounters :
Expand Down
35 changes: 34 additions & 1 deletion mocks/stats/line.ts
Original file line number Diff line number Diff line change
@@ -1,128 +1,161 @@
export const averageGasPrice = {
import type * as stats from '@blockscout/stats-types';

export const averageGasPrice: stats.LineChart = {
chart: [
{
date: '2023-12-22',
value: '37.7804422597599',
is_approximate: false,
},
{
date: '2023-12-23',
value: '25.84889883009387',
is_approximate: false,
},
{
date: '2023-12-24',
value: '25.818463227198574',
is_approximate: false,
},
{
date: '2023-12-25',
value: '26.045513050051298',
is_approximate: false,
},
{
date: '2023-12-26',
value: '21.42600692652399',
is_approximate: false,
},
{
date: '2023-12-27',
value: '31.066730409846656',
is_approximate: false,
},
{
date: '2023-12-28',
value: '33.63955781902089',
is_approximate: false,
},
{
date: '2023-12-29',
value: '28.064736756058384',
is_approximate: false,
},
{
date: '2023-12-30',
value: '23.074500869678175',
is_approximate: false,
},
{
date: '2023-12-31',
value: '17.651005734615133',
is_approximate: false,
},
{
date: '2024-01-01',
value: '14.906085174476441',
is_approximate: false,
},
{
date: '2024-01-02',
value: '22.28459059038656',
is_approximate: false,
},
{
date: '2024-01-03',
value: '39.8311646806592',
is_approximate: false,
},
{
date: '2024-01-04',
value: '26.09989322256083',
is_approximate: false,
},
{
date: '2024-01-05',
value: '22.821996688111998',
is_approximate: false,
},
{
date: '2024-01-06',
value: '20.32680041262083',
is_approximate: false,
},
{
date: '2024-01-07',
value: '32.535045831809704',
is_approximate: false,
},
{
date: '2024-01-08',
value: '27.443477102139482',
is_approximate: false,
},
{
date: '2024-01-09',
value: '20.7911332558055',
is_approximate: false,
},
{
date: '2024-01-10',
value: '42.10740192523919',
is_approximate: false,
},
{
date: '2024-01-11',
value: '35.75215680343582',
is_approximate: false,
},
{
date: '2024-01-12',
value: '27.430414798093253',
is_approximate: false,
},
{
date: '2024-01-13',
value: '20.170934096589875',
is_approximate: false,
},
{
date: '2024-01-14',
value: '38.79660984371034',
is_approximate: false,
},
{
date: '2024-01-15',
value: '26.140740484554204',
is_approximate: false,
},
{
date: '2024-01-16',
value: '36.708543184194156',
is_approximate: false,
},
{
date: '2024-01-17',
value: '40.325438794298876',
is_approximate: false,
},
{
date: '2024-01-18',
value: '37.55145309930694',
is_approximate: false,
},
{
date: '2024-01-19',
value: '33.271450114434664',
is_approximate: false,
},
{
date: '2024-01-20',
value: '19.303304377685638',
is_approximate: false,
},
{
date: '2024-01-21',
value: '14.375908594704976',
is_approximate: false,
},
],
};
28 changes: 15 additions & 13 deletions mocks/stats/lines.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const base = {
import type * as stats from '@blockscout/stats-types';

export const base: stats.LineCharts = {
sections: [
{
id: 'accounts',
Expand All @@ -8,19 +10,19 @@ export const base = {
id: 'accountsGrowth',
title: 'Accounts growth',
description: 'Cumulative accounts number per period',
units: null,
units: undefined,
},
{
id: 'activeAccounts',
title: 'Active accounts',
description: 'Active accounts number per period',
units: null,
units: undefined,
},
{
id: 'newAccounts',
title: 'New accounts',
description: 'New accounts number per day',
units: null,
units: undefined,
},
],
},
Expand All @@ -38,7 +40,7 @@ export const base = {
id: 'newTxns',
title: 'New transactions',
description: 'New transactions number',
units: null,
units: undefined,
},
{
id: 'txnsFee',
Expand All @@ -50,13 +52,13 @@ export const base = {
id: 'txnsGrowth',
title: 'Transactions growth',
description: 'Cumulative transactions number',
units: null,
units: undefined,
},
{
id: 'txnsSuccessRate',
title: 'Transactions success rate',
description: 'Successful transactions rate per day',
units: null,
units: undefined,
},
],
},
Expand All @@ -80,7 +82,7 @@ export const base = {
id: 'newBlocks',
title: 'New blocks',
description: 'New blocks number',
units: null,
units: undefined,
},
],
},
Expand All @@ -92,7 +94,7 @@ export const base = {
id: 'newNativeCoinTransfers',
title: 'New ETH transfers',
description: 'New token transfers number for the period',
units: null,
units: undefined,
},
],
},
Expand All @@ -104,7 +106,7 @@ export const base = {
id: 'averageGasLimit',
title: 'Average gas limit',
description: 'Average gas limit per block for the period',
units: null,
units: undefined,
},
{
id: 'averageGasPrice',
Expand All @@ -116,7 +118,7 @@ export const base = {
id: 'gasUsedGrowth',
title: 'Gas used growth',
description: 'Cumulative gas used for the period',
units: null,
units: undefined,
},
],
},
Expand All @@ -128,13 +130,13 @@ export const base = {
id: 'newVerifiedContracts',
title: 'New verified contracts',
description: 'New verified contracts number for the period',
units: null,
units: undefined,
},
{
id: 'verifiedContractsGrowth',
title: 'Verified contracts growth',
description: 'Cumulative number verified contracts for the period',
units: null,
units: undefined,
},
],
},
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"monitoring:grafana:local": "docker run -d -p 4000:3000 --name=blockscout_grafana --user $(id -u) --volume $(pwd)/grafana:/var/lib/grafana grafana/grafana-enterprise"
},
"dependencies": {
"@blockscout/bens-types": "v1.3.0-beta",
"@blockscout/bens-types": "1.3.4",
"@blockscout/stats-types": "1.6.0",
"@blockscout/visualizer-types": "0.2.0",
"@chakra-ui/react": "2.7.1",
"@chakra-ui/theme-tools": "^2.0.18",
"@emotion/react": "^11.10.4",
Expand Down
11 changes: 6 additions & 5 deletions stubs/stats.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Counter, HomeStats, StatsChartsSection } from 'types/api/stats';
import type * as stats from '@blockscout/stats-types';
import type { HomeStats } from 'types/api/stats';

export const HOMEPAGE_STATS: HomeStats = {
average_block_time: 14346,
Expand Down Expand Up @@ -41,7 +42,7 @@ export const HOMEPAGE_STATS: HomeStats = {
tvl: '1767425.102766552',
};

export const STATS_CHARTS_SECTION: StatsChartsSection = {
export const STATS_CHARTS_SECTION: stats.LineChartSection = {
id: 'placeholder',
title: 'Placeholder',
charts: [
Expand All @@ -61,13 +62,13 @@ export const STATS_CHARTS_SECTION: StatsChartsSection = {
id: 'chart_2',
title: 'New transactions',
description: 'New transactions number',
units: null,
units: undefined,
},
{
id: 'chart_3',
title: 'Transactions growth',
description: 'Cumulative transactions number',
units: null,
units: undefined,
},
],
};
Expand All @@ -76,7 +77,7 @@ export const STATS_CHARTS = {
sections: [ STATS_CHARTS_SECTION ],
};

export const STATS_COUNTER: Counter = {
export const STATS_COUNTER: stats.Counter = {
id: 'stub',
value: '9074405',
title: 'Placeholder Counter',
Expand Down
Loading
Loading