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,9 +4,10 @@ import { getEnvValue } from '../utils';

const title = 'Beacon chain';

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

Expand Down
11 changes: 11 additions & 0 deletions deploy/tools/envs-validator/schemas/features/beaconChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ export const beaconChainSchema = yup
.object()
.shape({
NEXT_PUBLIC_HAS_BEACON_CHAIN: yup.boolean(),
NEXT_PUBLIC_BEACON_CHAIN_WITHDRAWALS_ONLY: yup
.boolean()
.when('NEXT_PUBLIC_HAS_BEACON_CHAIN', {
is: (value: boolean) => value,
then: (schema) => schema,
otherwise: (schema) => schema.test(
'not-exist',
'NEXT_PUBLIC_BEACON_CHAIN_WITHDRAWALS_ONLY can only be used if NEXT_PUBLIC_HAS_BEACON_CHAIN is set to "true"',
value => value === undefined,
),
}),
NEXT_PUBLIC_BEACON_CHAIN_CURRENCY_SYMBOL: yup
.string()
.when('NEXT_PUBLIC_HAS_BEACON_CHAIN', {
Expand Down
2 changes: 1 addition & 1 deletion deploy/tools/sitemap-generator/next-sitemap.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module.exports = {
break;
case '/batches':
case '/deposits':
if (!process.env.NEXT_PUBLIC_ROLLUP_TYPE) {
if (!process.env.NEXT_PUBLIC_ROLLUP_TYPE && (process.env.NEXT_PUBLIC_HAS_BEACON_CHAIN !== 'true' || process.env.NEXT_PUBLIC_BEACON_CHAIN_WITHDRAWALS_ONLY === 'true')) {
return null;
}
break;
Expand Down
1 change: 1 addition & 0 deletions docs/ENVS.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ Ads are enabled by default on all self-hosted instances. If you would like to di
| Variable | Type| Description | Compulsoriness | Default value | Example value | Version |
| --- | --- | --- | --- | --- | --- | --- |
| NEXT_PUBLIC_HAS_BEACON_CHAIN | `boolean` | Set to true for networks with the beacon chain | Required | - | `true` | v1.0.x+ |
| NEXT_PUBLIC_BEACON_CHAIN_WITHDRAWALS_ONLY | `boolean` | Set to true for networks that have only withdrawals (no deposits) | - | - | `true` | v2.6.0+ |
| 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+ |

Expand Down
3 changes: 2 additions & 1 deletion lib/hooks/useNavItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import config from 'configs/app';
import { rightLineArrow } from 'toolkit/utils/htmlEntities';

const marketplaceFeature = config.features.marketplace;
const beaconChainFeature = config.features.beaconChain;

interface ReturnType {
mainNavItems: Array<NavItem | NavGroupItem>;
Expand Down Expand Up @@ -224,7 +225,7 @@ export default function useNavItems(): ReturnType {
validators,
verifiedContracts,
nameLookup,
config.features.beaconChain.isEnabled && {
beaconChainFeature.isEnabled && !beaconChainFeature.withdrawalsOnly && {
text: 'Deposits',
nextRoute: { pathname: '/deposits' as const },
icon: 'navigation/deposits',
Expand Down
3 changes: 2 additions & 1 deletion nextjs/getServerSideProps/guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,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;
const beaconChainFeature = chainConfig.features.beaconChain;
if (
!chainConfig.features.beaconChain.isEnabled &&
(!beaconChainFeature.isEnabled || beaconChainFeature.withdrawalsOnly) &&
!(rollupFeature.isEnabled && DEPOSITS_ROLLUP_TYPES.includes(rollupFeature.type))) {
return {
notFound: true,
Expand Down
2 changes: 1 addition & 1 deletion pages/deposits/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const Deposits = dynamic(() => {
return import('ui/pages/ScrollL2Deposits');
}

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

Expand Down
4 changes: 3 additions & 1 deletion ui/block/useBlockDepositsQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ interface Params {
tab: string;
}

const beaconChainFeature = config.features.beaconChain;

// No deposits data in RPC, so we use API only
export default function useBlockDepositsQuery({ heightOrHash, blockQuery, tab }: Params): BlockDepositsQuery {
const apiQuery = useQueryWithPages({
Expand All @@ -24,7 +26,7 @@ export default function useBlockDepositsQuery({ heightOrHash, blockQuery, tab }:
options: {
enabled:
tab === 'deposits' &&
config.features.beaconChain.isEnabled &&
beaconChainFeature.isEnabled && !beaconChainFeature.withdrawalsOnly &&
!blockQuery.isPlaceholderData && !blockQuery.isDegradedData,
placeholderData: generateListStub<'general:block_deposits'>(DEPOSIT, 50, { next_page_params: {
index: 5,
Expand Down
2 changes: 1 addition & 1 deletion ui/deposits/beaconChain/BeaconChainDepositsListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Props = {
};

const BeaconChainDepositsListItem = ({ item, isLoading, view }: Props) => {
if (!feature.isEnabled) {
if (!feature.isEnabled || feature.withdrawalsOnly) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion ui/deposits/beaconChain/BeaconChainDepositsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Props = {
const BeaconChainDepositsTable = ({ items, isLoading, top, view }: Props) => {
const { cutRef, renderedItemsNum } = useLazyRenderedList(items, !isLoading);

if (!feature.isEnabled) {
if (!feature.isEnabled || feature.withdrawalsOnly) {
return null;
}

Expand Down
3 changes: 2 additions & 1 deletion ui/pages/Address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const txInterpretation = config.features.txInterpretation;
const addressProfileAPIFeature = config.features.addressProfileAPI;
const xScoreFeature = config.features.xStarScore;
const nameServicesFeature = config.features.nameServices;
const beaconChainFeature = config.features.beaconChain;

const AddressPageContent = () => {
const router = useRouter();
Expand Down Expand Up @@ -231,7 +232,7 @@ const AddressPageContent = () => {
component: <AddressUserOps shouldRender={ !isTabsLoading } isQueryEnabled={ areQueriesEnabled }/>,
} :
undefined,
config.features.beaconChain.isEnabled && addressTabsCountersQuery.data?.beacon_deposits_count ?
beaconChainFeature.isEnabled && !beaconChainFeature.withdrawalsOnly && addressTabsCountersQuery.data?.beacon_deposits_count ?
{
id: 'deposits',
title: 'Deposits',
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/BeaconChainDeposits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const BeaconChainDeposits = () => {
) : null;

const text = (() => {
if (countersQuery.isError || !feature.isEnabled) {
if (countersQuery.isError || !feature.isEnabled || feature.withdrawalsOnly) {
return null;
}

Expand Down
4 changes: 3 additions & 1 deletion ui/pages/Block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const TAB_LIST_PROPS = {
};
const TABS_HEIGHT = 88;

const beaconChainFeature = config.features.beaconChain;

const BlockPageContent = () => {
const router = useRouter();
const isMobile = useIsMobile();
Expand Down Expand Up @@ -109,7 +111,7 @@ const BlockPageContent = () => {
<TxsWithFrontendSorting query={ blockBlobTxsQuery } showBlockInfo={ false }/>
),
} : null,
config.features.beaconChain.isEnabled && Boolean(blockQuery.data?.beacon_deposits_count) ?
beaconChainFeature.isEnabled && !beaconChainFeature.withdrawalsOnly && Boolean(blockQuery.data?.beacon_deposits_count) ?
{
id: 'deposits',
title: 'Deposits',
Expand Down
Loading