Skip to content
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
4 changes: 3 additions & 1 deletion configs/app/features/beaconChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { getEnvValue } from '../utils';

const title = 'Beacon chain';

const config: Feature<{ currency: { symbol: string } }> = (() => {
const config: Feature<{ currency: { symbol: string }; validatorUrlTemplate: string | undefined }> = (() => {
if (getEnvValue('NEXT_PUBLIC_HAS_BEACON_CHAIN') === 'true') {
const validatorUrlTemplate = getEnvValue('NEXT_PUBLIC_BEACON_CHAIN_VALIDATOR_URL_TEMPLATE');
return Object.freeze({
title,
isEnabled: true,
Expand All @@ -15,6 +16,7 @@ const config: Feature<{ currency: { symbol: string } }> = (() => {
getEnvValue('NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL') ||
'', // maybe we need some other default value here
},
validatorUrlTemplate,
});
}

Expand Down
1 change: 1 addition & 0 deletions configs/envs/.env.eth_sepolia
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ NEXT_PUBLIC_FOOTER_LINKS=https://raw.githubusercontent.com/blockscout/frontend-c
NEXT_PUBLIC_GAME_BADGE_CLAIM_LINK=https://badges.blockscout.com/mint/sherblockHolmesBadge
NEXT_PUBLIC_GRAPHIQL_TRANSACTION=0xbf69c7abc4fee283b59a9633dadfdaedde5c5ee0fba3e80a08b5b8a3acbd4363
NEXT_PUBLIC_HAS_BEACON_CHAIN=true
NEXT_PUBLIC_BEACON_CHAIN_VALIDATOR_URL_TEMPLATE=https://light-sepolia.beaconcha.in/validator/{pk}
NEXT_PUBLIC_HAS_USER_OPS=true
NEXT_PUBLIC_HOMEPAGE_CHARTS=['daily_txs']
NEXT_PUBLIC_HOMEPAGE_HERO_BANNER_CONFIG={'background':['rgba(51, 53, 67, 1)'],'text_color':['rgba(165, 252, 122, 1)']}
Expand Down
7 changes: 7 additions & 0 deletions deploy/tools/envs-validator/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ const beaconChainSchema = yup
'NEXT_PUBLIC_BEACON_CHAIN_CURRENCY_SYMBOL cannot not be used if NEXT_PUBLIC_HAS_BEACON_CHAIN is not set to "true"',
),
}),
NEXT_PUBLIC_BEACON_CHAIN_VALIDATOR_URL_TEMPLATE: yup
.string()
.when('NEXT_PUBLIC_HAS_BEACON_CHAIN', {
is: (value: boolean) => value,
then: (schema) => schema,
otherwise: (schema) => schema.max(-1, 'NEXT_PUBLIC_BEACON_CHAIN_VALIDATOR_URL_TEMPLATE cannot not be used if NEXT_PUBLIC_HAS_BEACON_CHAIN is not set to "true"'),
}),
});

const tacSchema = yup
Expand Down
1 change: 1 addition & 0 deletions docs/ENVS.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ Ads are enabled by default on all self-hosted instances. If you would like to di
| --- | --- | --- | --- | --- | --- | --- |
| NEXT_PUBLIC_HAS_BEACON_CHAIN | `boolean` | Set to true for networks with the beacon chain | Required | - | `true` | v1.0.x+ |
| NEXT_PUBLIC_BEACON_CHAIN_CURRENCY_SYMBOL | `string` | Beacon network currency symbol | - | `NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL` | `ETH` | v1.0.x+ |
| NEXT_PUBLIC_BEACON_CHAIN_VALIDATOR_URL_TEMPLATE | `string` | Url template to build a link to validator. Should contain `{pk}` string that will be replaced with the validator's public key | - | - | `https://example.com/beacon/{pk}/validator` | v2.3.0+ |

&nbsp;

Expand Down
8 changes: 8 additions & 0 deletions lib/api/services/general/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
AddressNFTTokensFilter,
} from 'types/api/address';
import type { AddressesMetadataSearchFilters, AddressesMetadataSearchResult, AddressesResponse } from 'types/api/addresses';
import type { DepositsResponse } from 'types/api/deposits';
import type { LogsResponseAddress } from 'types/api/log';
import type { TransactionsSorting } from 'types/api/transaction';

Expand Down Expand Up @@ -109,6 +110,12 @@ export const GENERAL_API_ADDRESS_RESOURCES = {
filterFields: [ 'type' as const ],
paginated: true,
},
address_deposits: {
path: '/api/v2/addresses/:hash/beacon/deposits',
pathParams: [ 'hash' as const ],
filterFields: [],
paginated: true,
},
address_withdrawals: {
path: '/api/v2/addresses/:hash/withdrawals',
pathParams: [ 'hash' as const ],
Expand Down Expand Up @@ -174,6 +181,7 @@ R extends 'general:address_tokens' ? AddressTokensResponse :
R extends 'general:address_nfts' ? AddressNFTsResponse :
R extends 'general:address_collections' ? AddressCollectionsResponse :
R extends 'general:address_withdrawals' ? AddressWithdrawalsResponse :
R extends 'general:address_deposits' ? DepositsResponse :
R extends 'general:address_epoch_rewards' ? AddressEpochRewardsResponse :
R extends 'general:address_xstar_score' ? AddressXStarResponse :
R extends 'general:address_3rd_party_info' ? unknown :
Expand Down
8 changes: 8 additions & 0 deletions lib/api/services/general/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
BlockCountdownResponse,
BlockInternalTransactionsResponse,
} from 'types/api/block';
import type { DepositsResponse } from 'types/api/deposits';
import type { TTxsWithBlobsFilters } from 'types/api/txsFilters';

export const GENERAL_API_BLOCK_RESOURCES = {
Expand All @@ -31,6 +32,12 @@ export const GENERAL_API_BLOCK_RESOURCES = {
pathParams: [ 'height_or_hash' as const ],
paginated: true,
},
block_deposits: {
path: '/api/v2/blocks/:height_or_hash/beacon/deposits',
pathParams: [ 'height_or_hash' as const ],
filterFields: [],
paginated: true,
},
block_withdrawals: {
path: '/api/v2/blocks/:height_or_hash/withdrawals',
pathParams: [ 'height_or_hash' as const ],
Expand All @@ -49,6 +56,7 @@ R extends 'general:block_countdown' ? BlockCountdownResponse :
R extends 'general:block_txs' ? BlockTransactionsResponse :
R extends 'general:block_internal_txs' ? BlockInternalTransactionsResponse :
R extends 'general:block_withdrawals' ? BlockWithdrawalsResponse :
R extends 'general:block_deposits' ? DepositsResponse :
never;
/* eslint-enable @stylistic/indent */

Expand Down
13 changes: 13 additions & 0 deletions lib/api/services/general/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { Blob } from 'types/api/blobs';
import type { Block } from 'types/api/block';
import type { ChartMarketResponse, ChartSecondaryCoinPriceResponse, ChartTransactionResponse } from 'types/api/charts';
import type { BackendVersionConfig, CeloConfig, CsvExportConfig } from 'types/api/configs';
import type { DepositsResponse, DepositsCounters } from 'types/api/deposits';
import type { CeloEpochDetails, CeloEpochElectionRewardDetailsResponse, CeloEpochListResponse } from 'types/api/epochs';
import type { IndexingStatus } from 'types/api/indexingStatus';
import type { NovesAccountHistoryResponse, NovesDescribeTxsResponse, NovesResponseData } from 'types/api/noves';
Expand Down Expand Up @@ -48,6 +49,16 @@ export const GENERAL_API_MISC_RESOURCES = {
path: '/api/v2/withdrawals/counters',
},

// DEPOSITS
deposits: {
path: '/api/v2/beacon/deposits',
filterFields: [],
paginated: true,
},
deposits_counters: {
path: '/api/v2/beacon/deposits/count',
},

// APP STATS
stats: {
path: '/api/v2/stats',
Expand Down Expand Up @@ -296,6 +307,8 @@ R extends 'general:noves_address_history' ? NovesAccountHistoryResponse :
R extends 'general:noves_describe_txs' ? NovesDescribeTxsResponse :
R extends 'general:withdrawals' ? WithdrawalsResponse :
R extends 'general:withdrawals_counters' ? WithdrawalsCounters :
R extends 'general:deposits' ? DepositsResponse :
R extends 'general:deposits_counters' ? DepositsCounters :
R extends 'general:advanced_filter' ? AdvancedFilterResponse :
R extends 'general:advanced_filter_methods' ? AdvancedFilterMethodsResponse :
never;
Expand Down
6 changes: 6 additions & 0 deletions lib/hooks/useNavItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ export default function useNavItems(): ReturnType {
validators,
verifiedContracts,
ensLookup,
config.features.beaconChain.isEnabled && {
text: 'Deposits',
nextRoute: { pathname: '/deposits' as const },
icon: 'arrows/south-east',
isActive: pathname === '/deposits',
},
config.features.beaconChain.isEnabled && {
text: 'Withdrawals',
nextRoute: { pathname: '/withdrawals' as const },
Expand Down
2 changes: 1 addition & 1 deletion lib/metadata/templates/title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const TEMPLATE_MAP: Record<Route['pathname'], string> = {
'/txn-withdrawals': '%network_name% L2 to L1 message relayer',
'/visualize/sol2uml': '%network_name% Solidity UML diagram',
'/csv-export': '%network_name% export data to CSV',
'/deposits': '%network_name% deposits (L1 > L2)',
'/deposits': '%network_name% deposits - track on %network_name% explorer',
'/output-roots': '%network_name% output roots',
'/dispute-games': '%network_name% dispute games',
'/batches': '%network_name% txn batches',
Expand Down
2 changes: 1 addition & 1 deletion lib/mixpanel/getPageType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const PAGE_TYPE_DICT: Record<Route['pathname'], string> = {
'/txn-withdrawals': 'Txn withdrawals',
'/visualize/sol2uml': 'Solidity UML diagram',
'/csv-export': 'Export data to CSV file',
'/deposits': 'Deposits (L1 > L2)',
'/deposits': 'Deposits',
'/output-roots': 'Output roots',
'/dispute-games': 'Dispute games',
'/batches': 'Txn batches',
Expand Down
1 change: 1 addition & 0 deletions mocks/address/tabCounters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export const base: AddressTabsCounters = {
transactions_count: 51,
validations_count: 42,
withdrawals_count: 11,
beacon_deposits_count: 10,
};
86 changes: 86 additions & 0 deletions mocks/deposits/deposits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import type { AddressParam } from 'types/api/addressParams';
import type { DepositsResponse } from 'types/api/deposits';

export const data: DepositsResponse = {
items: [
{
amount: '192175000000000',
block_number: 43242,
index: 11688,
pubkey: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
signature: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
status: 'completed',
from_address: {
hash: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
implementations: null,
is_contract: false,
is_verified: null,
name: null,
} as AddressParam,
block_hash: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
block_timestamp: '2022-06-07T18:12:24.000000Z',
transaction_hash: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
withdrawal_address: {
hash: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
implementations: null,
is_contract: false,
is_verified: null,
name: null,
} as AddressParam,
},
{
amount: '192175000000000',
block_number: 43242,
index: 11687,
pubkey: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
signature: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
status: 'pending',
from_address: {
hash: '0xf97e987c050e5Ab072211Ad2C213Eb5AEE4DF134',
implementations: null,
is_contract: false,
is_verified: null,
name: null,
} as AddressParam,
block_hash: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
block_timestamp: '2022-05-07T18:12:24.000000Z',
transaction_hash: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
withdrawal_address: {
hash: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
implementations: null,
is_contract: false,
is_verified: null,
name: null,
} as AddressParam,
},
{
amount: '182773000000000',
block_number: 43242,
index: 11686,
pubkey: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
signature: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
status: 'invalid',
from_address: {
hash: '0xf97e123c050e5Ab072211Ad2C213Eb5AEE4DF134',
implementations: null,
is_contract: false,
is_verified: null,
name: null,
} as AddressParam,
block_hash: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
block_timestamp: '2022-04-07T18:12:24.000000Z',
transaction_hash: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
withdrawal_address: {
hash: '0xf97e180c050e5Ab072211Ad2C213Eb5AEE4DF134',
implementations: null,
is_contract: false,
is_verified: null,
name: null,
} as AddressParam,
},
],
next_page_params: {
index: 11639,
items_count: 50,
},
};
4 changes: 3 additions & 1 deletion nextjs/getServerSideProps/guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ export const rollup: Guard = (chainConfig: typeof config) => async() => {
const DEPOSITS_ROLLUP_TYPES: Array<RollupType> = [ 'optimistic', 'shibarium', 'zkEvm', 'arbitrum', 'scroll' ];
export const deposits: Guard = (chainConfig: typeof config) => async() => {
const rollupFeature = chainConfig.features.rollup;
if (!(rollupFeature.isEnabled && DEPOSITS_ROLLUP_TYPES.includes(rollupFeature.type))) {
if (
!chainConfig.features.beaconChain.isEnabled &&
!(rollupFeature.isEnabled && DEPOSITS_ROLLUP_TYPES.includes(rollupFeature.type))) {
return {
notFound: true,
};
Expand Down
5 changes: 5 additions & 0 deletions pages/deposits/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PageNextJs from 'nextjs/PageNextJs';

import config from 'configs/app';
const rollupFeature = config.features.rollup;
const beaconChainFeature = config.features.beaconChain;

const Deposits = dynamic(() => {
if (rollupFeature.isEnabled && rollupFeature.type === 'optimistic') {
Expand All @@ -28,6 +29,10 @@ const Deposits = dynamic(() => {
return import('ui/pages/ScrollL2Deposits');
}

if (beaconChainFeature.isEnabled) {
return import('ui/pages/BeaconChainDeposits');
}

throw new Error('Deposits feature is not enabled.');
}, { ssr: false });

Expand Down
1 change: 1 addition & 0 deletions playwright/fixtures/mockEnvs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const ENVS_MAP: Record<string, Array<[string, string]>> = {
],
beaconChain: [
[ 'NEXT_PUBLIC_HAS_BEACON_CHAIN', 'true' ],
[ 'NEXT_PUBLIC_BEACON_CHAIN_VALIDATOR_URL_TEMPLATE', 'https://beaconcha.in/validator/{pk}' ],
],
txInterpretation: [
[ 'NEXT_PUBLIC_TRANSACTION_INTERPRETATION_PROVIDER', 'blockscout' ],
Expand Down
1 change: 1 addition & 0 deletions stubs/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const ADDRESS_TABS_COUNTERS: AddressTabsCounters = {
transactions_count: 10,
validations_count: 10,
withdrawals_count: 10,
beacon_deposits_count: 10,
};

export const TOP_ADDRESS: AddressesItem = {
Expand Down
18 changes: 18 additions & 0 deletions stubs/deposits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { DepositsItem } from 'types/api/deposits';

import { ADDRESS_PARAMS } from './addressParams';
import { TX_HASH } from './tx';

export const DEPOSIT: DepositsItem = {
amount: '12565723',
index: 1,
block_number: 1231111111,
block_hash: '0x1234567890',
block_timestamp: '2023-05-12T19:29:12.000000Z',
pubkey: '0x1234567890123456789012345678901234567890',
status: 'pending',
from_address: ADDRESS_PARAMS,
transaction_hash: TX_HASH,
withdrawal_address: ADDRESS_PARAMS,
signature: '0x1234567890123456789012345678901234567890',
};
1 change: 1 addition & 0 deletions types/api/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export type AddressTabsCounters = {
transactions_count: number | null;
validations_count: number | null;
withdrawals_count: number | null;
beacon_deposits_count: number | null;
celo_election_rewards_count?: number | null;
};

Expand Down
1 change: 1 addition & 0 deletions types/api/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface Block {
transaction_fees: string | null;
uncles_hashes: Array<string>;
withdrawals_count?: number;
beacon_deposits_count?: number;
// ROOTSTOCK FIELDS
bitcoin_merged_mining_coinbase_transaction?: string | null;
bitcoin_merged_mining_header?: string | null;
Expand Down
29 changes: 29 additions & 0 deletions types/api/deposits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { AddressParam } from './addressParams';

export type DepositStatus = 'pending' | 'invalid' | 'completed';

export type DepositsResponse = {
items: Array<DepositsItem>;
next_page_params: {
index: number;
items_count: number;
} | null;
};

export type DepositsItem = {
amount: string;
block_number: number;
block_hash: string;
block_timestamp: string;
index: number;
pubkey: string;
signature: string;
status: DepositStatus;
from_address: AddressParam;
transaction_hash: string;
withdrawal_address: AddressParam;
};

export type DepositsCounters = {
deposits_count: string;
};
Loading
Loading