Skip to content

Commit

Permalink
Merge branch 'main' of ssh://github.com/blockscout/frontend into sync…
Browse files Browse the repository at this point in the history
…-02-07
  • Loading branch information
pustovalov committed Jul 4, 2024
2 parents 403162b + ca3d530 commit 1d5f744
Show file tree
Hide file tree
Showing 27 changed files with 217 additions and 168 deletions.
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
1 change: 1 addition & 0 deletions lib/hooks/useToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const defaultOptions: UseToastOptions & { toastComponent?: React.FC<ToastProps>
containerStyle: {
margin: 8,
},
variant: 'subtle',
};

export default function useToastModified() {
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
6 changes: 4 additions & 2 deletions 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 Expand Up @@ -67,7 +69,7 @@
"chakra-react-select": "^4.4.3",
"crypto-js": "^4.2.0",
"d3": "^7.6.1",
"dappscout-iframe": "0.2.1",
"dappscout-iframe": "0.2.2",
"dayjs": "^1.11.5",
"dom-to-image": "^2.6.0",
"focus-visible": "^5.2.0",
Expand Down
52 changes: 52 additions & 0 deletions playwright/fixtures/mockRpcResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import type { TestFixture, Page } from '@playwright/test';
import _isEqual from 'lodash/isEqual';
import type { PublicRpcSchema } from 'viem';

import { getEnvValue } from 'configs/app/utils';

type Params = PublicRpcSchema[number];

export type MockRpcResponseFixture = (params: Params) => Promise<void>;

// WIP
const fixture: TestFixture<MockRpcResponseFixture, { page: Page }> = async({ page }, use) => {
await use(async({ Method, ReturnType }) => {
const rpcUrl = getEnvValue('NEXT_PUBLIC_NETWORK_RPC_URL');

if (!rpcUrl) {
return;
}

await page.route(rpcUrl, (route) => {
const method = route.request().method();

if (method !== 'POST') {
route.continue();
return;
}

const json = route.request().postDataJSON();
const id = json?.id;

const payload = {
id,
jsonrpc: '2.0',
method: Method,
// TODO: add params to match actual payload
};

if (_isEqual(json, payload) && id !== undefined) {
return route.fulfill({
status: 200,
body: JSON.stringify({
id,
jsonrpc: '2.0',
result: ReturnType,
}),
});
}
});
});
};

export default fixture;
Loading

0 comments on commit 1d5f744

Please sign in to comment.