Commit db52d2cf authored by isstuev's avatar isstuev

block hash or height

parent ddc68cf9
...@@ -164,18 +164,18 @@ export const RESOURCES = { ...@@ -164,18 +164,18 @@ export const RESOURCES = {
filterFields: [ 'type' as const ], filterFields: [ 'type' as const ],
}, },
block: { block: {
path: '/api/v2/blocks/:height', path: '/api/v2/blocks/:height_or_hash',
pathParams: [ 'height' as const ], pathParams: [ 'height_or_hash' as const ],
}, },
block_txs: { block_txs: {
path: '/api/v2/blocks/:height/transactions', path: '/api/v2/blocks/:height_or_hash/transactions',
pathParams: [ 'height' as const ], pathParams: [ 'height_or_hash' as const ],
paginationFields: [ 'block_number' as const, 'items_count' as const, 'index' as const ], paginationFields: [ 'block_number' as const, 'items_count' as const, 'index' as const ],
filterFields: [], filterFields: [],
}, },
block_withdrawals: { block_withdrawals: {
path: '/api/v2/blocks/:height/withdrawals', path: '/api/v2/blocks/:height_or_hash/withdrawals',
pathParams: [ 'height' as const ], pathParams: [ 'height_or_hash' as const ],
paginationFields: [ 'items_count' as const, 'index' as const ], paginationFields: [ 'items_count' as const, 'index' as const ],
filterFields: [], filterFields: [],
}, },
......
...@@ -62,7 +62,7 @@ export default function useNavItems(): ReturnType { ...@@ -62,7 +62,7 @@ export default function useNavItems(): ReturnType {
text: 'Blocks', text: 'Blocks',
nextRoute: { pathname: '/blocks' as const }, nextRoute: { pathname: '/blocks' as const },
icon: blocksIcon, icon: blocksIcon,
isActive: pathname === '/blocks' || pathname === '/block/[height]', isActive: pathname === '/blocks' || pathname === '/block/[height_or_hash]',
}; };
const txs = { const txs = {
text: 'Transactions', text: 'Transactions',
......
...@@ -5,7 +5,7 @@ const PAGE_TYPE_DICT: Record<Route['pathname'], string> = { ...@@ -5,7 +5,7 @@ const PAGE_TYPE_DICT: Record<Route['pathname'], string> = {
'/txs': 'Transactions', '/txs': 'Transactions',
'/tx/[hash]': 'Transaction details', '/tx/[hash]': 'Transaction details',
'/blocks': 'Blocks', '/blocks': 'Blocks',
'/block/[height]': 'Block details', '/block/[height_or_hash]': 'Block details',
'/accounts': 'Top accounts', '/accounts': 'Top accounts',
'/address/[hash]': 'Address details', '/address/[hash]': 'Address details',
'/verified-contracts': 'Verified contracts', '/verified-contracts': 'Verified contracts',
......
...@@ -2,11 +2,14 @@ import type { RoutedQuery } from 'nextjs-routes'; ...@@ -2,11 +2,14 @@ import type { RoutedQuery } from 'nextjs-routes';
import getNetworkTitle from 'lib/networks/getNetworkTitle'; import getNetworkTitle from 'lib/networks/getNetworkTitle';
export default function getSeo(params?: RoutedQuery<'/block/[height]'>) { export default function getSeo(params?: RoutedQuery<'/block/[height_or_hash]'>) {
const networkTitle = getNetworkTitle(); const networkTitle = getNetworkTitle();
const isHash = params ? params.height_or_hash.startsWith('0x') : false;
return { return {
title: params ? `Block ${ params.height } - ${ networkTitle }` : '', title: params ? `Block ${ params.height_or_hash } - ${ networkTitle }` : '',
description: params ? `View the transactions, token transfers, and uncles for block number ${ params.height }` : '', description: params ?
`View the transactions, token transfers, and uncles for block ${ isHash ? '' : 'number ' }${ params.height_or_hash }` : '',
}; };
} }
...@@ -14,8 +14,8 @@ export const getServerSideProps: GetServerSideProps<Props> = async({ req, query ...@@ -14,8 +14,8 @@ export const getServerSideProps: GetServerSideProps<Props> = async({ req, query
cookies: req.headers.cookie || '', cookies: req.headers.cookie || '',
referrer: req.headers.referer || '', referrer: req.headers.referer || '',
id: query.id?.toString() || '', id: query.id?.toString() || '',
height: query.height?.toString() || '',
hash: query.hash?.toString() || '', hash: query.hash?.toString() || '',
height_or_hash: query.height_or_hash?.toString() || '',
}, },
}; };
}; };
...@@ -9,8 +9,8 @@ import Page from 'ui/shared/Page/Page'; ...@@ -9,8 +9,8 @@ import Page from 'ui/shared/Page/Page';
const Block = dynamic(() => import('ui/pages/Block'), { ssr: false }); const Block = dynamic(() => import('ui/pages/Block'), { ssr: false });
const BlockPage: NextPage<RoutedQuery<'/block/[height]'>> = ({ height }: RoutedQuery<'/block/[height]'>) => { const BlockPage: NextPage<RoutedQuery<'/block/[height_or_hash]'>> = (params: RoutedQuery<'/block/[height_or_hash]'>) => {
const { title, description } = getSeo({ height }); const { title, description } = getSeo({ height_or_hash: params.height_or_hash });
return ( return (
<> <>
<Head> <Head>
......
...@@ -23,7 +23,7 @@ declare module "nextjs-routes" { ...@@ -23,7 +23,7 @@ declare module "nextjs-routes" {
| StaticRoute<"/apps"> | StaticRoute<"/apps">
| StaticRoute<"/auth/auth0"> | StaticRoute<"/auth/auth0">
| StaticRoute<"/auth/profile"> | StaticRoute<"/auth/profile">
| DynamicRoute<"/block/[height]", { "height": string }> | DynamicRoute<"/block/[height_or_hash]", { "height_or_hash": string }>
| StaticRoute<"/blocks"> | StaticRoute<"/blocks">
| StaticRoute<"/csv-export"> | StaticRoute<"/csv-export">
| StaticRoute<"/graphiql"> | StaticRoute<"/graphiql">
......
...@@ -210,7 +210,7 @@ const AddressDetails = ({ addressQuery, scrollRef }: Props) => { ...@@ -210,7 +210,7 @@ const AddressDetails = ({ addressQuery, scrollRef }: Props) => {
isLoading={ addressQuery.isPlaceholderData } isLoading={ addressQuery.isPlaceholderData }
> >
<LinkInternal <LinkInternal
href={ route({ pathname: '/block/[height]', query: { height: String(data.block_number_balance_updated_at) } }) } href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: String(data.block_number_balance_updated_at) } }) }
display="flex" display="flex"
alignItems="center" alignItems="center"
> >
......
...@@ -18,7 +18,7 @@ type Props = Block & { ...@@ -18,7 +18,7 @@ type Props = Block & {
}; };
const AddressBlocksValidatedListItem = (props: Props) => { const AddressBlocksValidatedListItem = (props: Props) => {
const blockUrl = route({ pathname: '/block/[height]', query: { height: props.height.toString() } }); const blockUrl = route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: props.height.toString() } });
const timeAgo = useTimeAgoIncrement(props.timestamp, props.page === 1); const timeAgo = useTimeAgoIncrement(props.timestamp, props.page === 1);
const totalReward = getBlockTotalReward(props); const totalReward = getBlockTotalReward(props);
......
...@@ -16,7 +16,7 @@ type Props = Block & { ...@@ -16,7 +16,7 @@ type Props = Block & {
}; };
const AddressBlocksValidatedTableItem = (props: Props) => { const AddressBlocksValidatedTableItem = (props: Props) => {
const blockUrl = route({ pathname: '/block/[height]', query: { height: String(props.height) } }); const blockUrl = route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: String(props.height) } });
const timeAgo = useTimeAgoIncrement(props.timestamp, props.page === 1); const timeAgo = useTimeAgoIncrement(props.timestamp, props.page === 1);
const totalReward = getBlockTotalReward(props); const totalReward = getBlockTotalReward(props);
......
...@@ -19,7 +19,7 @@ type Props = AddressCoinBalanceHistoryItem & { ...@@ -19,7 +19,7 @@ type Props = AddressCoinBalanceHistoryItem & {
}; };
const AddressCoinBalanceListItem = (props: Props) => { const AddressCoinBalanceListItem = (props: Props) => {
const blockUrl = route({ pathname: '/block/[height]', query: { height: String(props.block_number) } }); const blockUrl = route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: String(props.block_number) } });
const deltaBn = BigNumber(props.delta).div(WEI); const deltaBn = BigNumber(props.delta).div(WEI);
const isPositiveDelta = deltaBn.gte(ZERO); const isPositiveDelta = deltaBn.gte(ZERO);
const timeAgo = useTimeAgoIncrement(props.block_timestamp, props.page === 1); const timeAgo = useTimeAgoIncrement(props.block_timestamp, props.page === 1);
......
...@@ -17,7 +17,7 @@ type Props = AddressCoinBalanceHistoryItem & { ...@@ -17,7 +17,7 @@ type Props = AddressCoinBalanceHistoryItem & {
}; };
const AddressCoinBalanceTableItem = (props: Props) => { const AddressCoinBalanceTableItem = (props: Props) => {
const blockUrl = route({ pathname: '/block/[height]', query: { height: String(props.block_number) } }); const blockUrl = route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: String(props.block_number) } });
const deltaBn = BigNumber(props.delta).div(WEI); const deltaBn = BigNumber(props.delta).div(WEI);
const isPositiveDelta = deltaBn.gte(ZERO); const isPositiveDelta = deltaBn.gte(ZERO);
const timeAgo = useTimeAgoIncrement(props.block_timestamp, props.page === 1); const timeAgo = useTimeAgoIncrement(props.block_timestamp, props.page === 1);
......
...@@ -57,7 +57,7 @@ const TxInternalsListItem = ({ ...@@ -57,7 +57,7 @@ const TxInternalsListItem = ({
<HStack spacing={ 1 }> <HStack spacing={ 1 }>
<Skeleton isLoaded={ !isLoading } fontSize="sm" fontWeight={ 500 }>Block</Skeleton> <Skeleton isLoaded={ !isLoading } fontSize="sm" fontWeight={ 500 }>Block</Skeleton>
<Skeleton isLoaded={ !isLoading }> <Skeleton isLoaded={ !isLoading }>
<LinkInternal href={ route({ pathname: '/block/[height]', query: { height: block.toString() } }) }>{ block }</LinkInternal> <LinkInternal href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: block.toString() } }) }>{ block }</LinkInternal>
</Skeleton> </Skeleton>
</HStack> </HStack>
<Box w="100%" display="flex" columnGap={ 3 }> <Box w="100%" display="flex" columnGap={ 3 }>
......
...@@ -67,7 +67,7 @@ const AddressIntTxsTableItem = ({ ...@@ -67,7 +67,7 @@ const AddressIntTxsTableItem = ({
</Td> </Td>
<Td verticalAlign="middle"> <Td verticalAlign="middle">
<Skeleton isLoaded={ !isLoading } display="inline-block"> <Skeleton isLoaded={ !isLoading } display="inline-block">
<LinkInternal href={ route({ pathname: '/block/[height]', query: { height: block.toString() } }) }> <LinkInternal href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: block.toString() } }) }>
{ block } { block }
</LinkInternal> </LinkInternal>
</Skeleton> </Skeleton>
......
...@@ -38,7 +38,7 @@ interface Props { ...@@ -38,7 +38,7 @@ interface Props {
const BlockDetails = ({ query }: Props) => { const BlockDetails = ({ query }: Props) => {
const [ isExpanded, setIsExpanded ] = React.useState(false); const [ isExpanded, setIsExpanded ] = React.useState(false);
const router = useRouter(); const router = useRouter();
const heightOrHash = getQueryParamString(router.query.height); const heightOrHash = getQueryParamString(router.query.height_or_hash);
const separatorColor = useColorModeValue('gray.200', 'gray.700'); const separatorColor = useColorModeValue('gray.200', 'gray.700');
...@@ -60,7 +60,7 @@ const BlockDetails = ({ query }: Props) => { ...@@ -60,7 +60,7 @@ const BlockDetails = ({ query }: Props) => {
const increment = direction === 'next' ? +1 : -1; const increment = direction === 'next' ? +1 : -1;
const nextId = String(data.height + increment); const nextId = String(data.height + increment);
router.push({ pathname: '/block/[height]', query: { height: nextId } }, undefined); router.push({ pathname: '/block/[height_or_hash]', query: { height_or_hash: nextId } }, undefined);
}, [ data, router ]); }, [ data, router ]);
if (isError) { if (isError) {
...@@ -175,7 +175,7 @@ const BlockDetails = ({ query }: Props) => { ...@@ -175,7 +175,7 @@ const BlockDetails = ({ query }: Props) => {
isLoading={ isPlaceholderData } isLoading={ isPlaceholderData }
> >
<Skeleton isLoaded={ !isPlaceholderData }> <Skeleton isLoaded={ !isPlaceholderData }>
<LinkInternal href={ route({ pathname: '/block/[height]', query: { height: heightOrHash, tab: 'txs' } }) }> <LinkInternal href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: heightOrHash, tab: 'txs' } }) }>
{ data.tx_count } transaction{ data.tx_count === 1 ? '' : 's' } { data.tx_count } transaction{ data.tx_count === 1 ? '' : 's' }
</LinkInternal> </LinkInternal>
</Skeleton> </Skeleton>
......
...@@ -40,7 +40,10 @@ const BlocksListItem = ({ data, isLoading, enableTimeIncrement }: Props) => { ...@@ -40,7 +40,10 @@ const BlocksListItem = ({ data, isLoading, enableTimeIncrement }: Props) => {
<Skeleton isLoaded={ !isLoading } display="inline-block"> <Skeleton isLoaded={ !isLoading } display="inline-block">
<LinkInternal <LinkInternal
fontWeight={ 600 } fontWeight={ 600 }
href={ route({ pathname: '/block/[height]', query: { height: data.type === 'reorg' ? String(data.hash) : String(data.height) } }) } href={ route({
pathname: '/block/[height_or_hash]',
query: { height_or_hash: data.type === 'reorg' ? String(data.hash) : String(data.height) },
}) }
> >
{ data.height } { data.height }
</LinkInternal> </LinkInternal>
...@@ -62,7 +65,7 @@ const BlocksListItem = ({ data, isLoading, enableTimeIncrement }: Props) => { ...@@ -62,7 +65,7 @@ const BlocksListItem = ({ data, isLoading, enableTimeIncrement }: Props) => {
<Text fontWeight={ 500 }>Txn</Text> <Text fontWeight={ 500 }>Txn</Text>
{ data.tx_count > 0 ? ( { data.tx_count > 0 ? (
<Skeleton isLoaded={ !isLoading } display="inline-block"> <Skeleton isLoaded={ !isLoading } display="inline-block">
<LinkInternal href={ route({ pathname: '/block/[height]', query: { height: String(data.height), tab: 'txs' } }) }> <LinkInternal href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: String(data.height), tab: 'txs' } }) }>
{ data.tx_count } { data.tx_count }
</LinkInternal> </LinkInternal>
</Skeleton> </Skeleton>
......
...@@ -47,7 +47,10 @@ const BlocksTableItem = ({ data, isLoading, enableTimeIncrement }: Props) => { ...@@ -47,7 +47,10 @@ const BlocksTableItem = ({ data, isLoading, enableTimeIncrement }: Props) => {
<Skeleton isLoaded={ !isLoading } display="inline-block"> <Skeleton isLoaded={ !isLoading } display="inline-block">
<LinkInternal <LinkInternal
fontWeight={ 600 } fontWeight={ 600 }
href={ route({ pathname: '/block/[height]', query: { height: data.type === 'reorg' ? String(data.hash) : String(data.height) } }) } href={ route({
pathname: '/block/[height_or_hash]',
query: { height_or_hash: data.type === 'reorg' ? String(data.hash) : String(data.height) },
}) }
> >
{ data.height } { data.height }
</LinkInternal> </LinkInternal>
...@@ -75,7 +78,10 @@ const BlocksTableItem = ({ data, isLoading, enableTimeIncrement }: Props) => { ...@@ -75,7 +78,10 @@ const BlocksTableItem = ({ data, isLoading, enableTimeIncrement }: Props) => {
<Td isNumeric fontSize="sm"> <Td isNumeric fontSize="sm">
{ data.tx_count > 0 ? ( { data.tx_count > 0 ? (
<Skeleton isLoaded={ !isLoading } display="inline-block"> <Skeleton isLoaded={ !isLoading } display="inline-block">
<LinkInternal href={ route({ pathname: '/block/[height]', query: { height: String(data.height), tab: 'txs' } }) }> <LinkInternal href={ route({
pathname: '/block/[height_or_hash]',
query: { height_or_hash: String(data.height), tab: 'txs' },
}) }>
{ data.tx_count } { data.tx_count }
</LinkInternal> </LinkInternal>
</Skeleton> </Skeleton>
......
...@@ -45,7 +45,7 @@ const LatestBlocksItem = ({ block, h }: Props) => { ...@@ -45,7 +45,7 @@ const LatestBlocksItem = ({ block, h }: Props) => {
<HStack spacing={ 2 }> <HStack spacing={ 2 }>
<Icon as={ blockIcon } boxSize="30px" color="link"/> <Icon as={ blockIcon } boxSize="30px" color="link"/>
<LinkInternal <LinkInternal
href={ route({ pathname: '/block/[height]', query: { height: String(block.height) } }) } href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: String(block.height) } }) }
fontSize="xl" fontSize="xl"
fontWeight="500" fontWeight="500"
> >
......
...@@ -29,7 +29,9 @@ const LatestTxsItem = ({ item }: Props) => { ...@@ -29,7 +29,9 @@ const LatestTxsItem = ({ item }: Props) => {
const l1BlockLink = ( const l1BlockLink = (
<LinkExternal <LinkExternal
href={ appConfig.L2.L1BaseUrl + route({ pathname: '/block/[height]', query: { height: item.l1_block_number.toString() } }) } href={ appConfig.L2.L1BaseUrl +
route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: item.l1_block_number.toString() } })
}
fontWeight={ 700 } fontWeight={ 700 }
display="inline-flex" display="inline-flex"
mr={ 2 } mr={ 2 }
......
...@@ -26,7 +26,7 @@ const DepositsListItem = ({ item }: Props) => { ...@@ -26,7 +26,7 @@ const DepositsListItem = ({ item }: Props) => {
<ListItemMobileGrid.Label>L1 block No</ListItemMobileGrid.Label> <ListItemMobileGrid.Label>L1 block No</ListItemMobileGrid.Label>
<ListItemMobileGrid.Value> <ListItemMobileGrid.Value>
<LinkExternal <LinkExternal
href={ appConfig.L2.L1BaseUrl + route({ pathname: '/block/[height]', query: { height: item.l1_block_number.toString() } }) } href={ appConfig.L2.L1BaseUrl + route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: item.l1_block_number.toString() } }) }
fontWeight={ 600 } fontWeight={ 600 }
display="inline-flex" display="inline-flex"
> >
......
...@@ -23,7 +23,7 @@ const WithdrawalsTableItem = ({ item }: Props) => { ...@@ -23,7 +23,7 @@ const WithdrawalsTableItem = ({ item }: Props) => {
<Tr> <Tr>
<Td verticalAlign="middle" fontWeight={ 600 }> <Td verticalAlign="middle" fontWeight={ 600 }>
<LinkExternal <LinkExternal
href={ appConfig.L2.L1BaseUrl + route({ pathname: '/block/[height]', query: { height: item.l1_block_number.toString() } }) } href={ appConfig.L2.L1BaseUrl + route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: item.l1_block_number.toString() } }) }
fontWeight={ 600 } fontWeight={ 600 }
display="inline-flex" display="inline-flex"
> >
......
...@@ -35,7 +35,7 @@ const OutputRootsListItem = ({ item }: Props) => { ...@@ -35,7 +35,7 @@ const OutputRootsListItem = ({ item }: Props) => {
display="flex" display="flex"
width="fit-content" width="fit-content"
alignItems="center" alignItems="center"
href={ route({ pathname: '/block/[height]', query: { height: item.l2_block_number.toString() } }) } href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: item.l2_block_number.toString() } }) }
> >
{ item.l2_block_number } { item.l2_block_number }
</LinkInternal> </LinkInternal>
......
...@@ -32,7 +32,7 @@ const OutputRootsTableItem = ({ item }: Props) => { ...@@ -32,7 +32,7 @@ const OutputRootsTableItem = ({ item }: Props) => {
display="flex" display="flex"
width="fit-content" width="fit-content"
alignItems="center" alignItems="center"
href={ route({ pathname: '/block/[height]', query: { height: item.l2_block_number.toString() } }) } href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: item.l2_block_number.toString() } }) }
> >
<Icon as={ txBatchIcon } boxSize={ 6 } mr={ 1 }/> <Icon as={ txBatchIcon } boxSize={ 6 } mr={ 1 }/>
{ item.l2_block_number } { item.l2_block_number }
......
...@@ -28,7 +28,7 @@ const TxnBatchesListItem = ({ item }: Props) => { ...@@ -28,7 +28,7 @@ const TxnBatchesListItem = ({ item }: Props) => {
display="flex" display="flex"
width="fit-content" width="fit-content"
alignItems="center" alignItems="center"
href={ route({ pathname: '/block/[height]', query: { height: item.l2_block_number.toString() } }) } href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: item.l2_block_number.toString() } }) }
> >
<Icon as={ txBatchIcon } boxSize={ 6 } mr={ 1 }/> <Icon as={ txBatchIcon } boxSize={ 6 } mr={ 1 }/>
{ item.l2_block_number } { item.l2_block_number }
...@@ -37,7 +37,7 @@ const TxnBatchesListItem = ({ item }: Props) => { ...@@ -37,7 +37,7 @@ const TxnBatchesListItem = ({ item }: Props) => {
<ListItemMobileGrid.Label>L2 block txn count</ListItemMobileGrid.Label> <ListItemMobileGrid.Label>L2 block txn count</ListItemMobileGrid.Label>
<ListItemMobileGrid.Value> <ListItemMobileGrid.Value>
<LinkInternal href={ route({ pathname: '/block/[height]', query: { height: item.l2_block_number.toString(), tab: 'txs' } }) }> <LinkInternal href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: item.l2_block_number.toString(), tab: 'txs' } }) }>
{ item.tx_count } { item.tx_count }
</LinkInternal> </LinkInternal>
</ListItemMobileGrid.Value> </ListItemMobileGrid.Value>
...@@ -47,7 +47,7 @@ const TxnBatchesListItem = ({ item }: Props) => { ...@@ -47,7 +47,7 @@ const TxnBatchesListItem = ({ item }: Props) => {
<LinkExternal <LinkExternal
fontWeight={ 600 } fontWeight={ 600 }
display="inline-flex" display="inline-flex"
href={ appConfig.L2.L1BaseUrl + route({ pathname: '/block/[height]', query: { height: item.epoch_number.toString() } }) } href={ appConfig.L2.L1BaseUrl + route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: item.epoch_number.toString() } }) }
> >
{ item.epoch_number } { item.epoch_number }
</LinkExternal> </LinkExternal>
......
...@@ -25,7 +25,7 @@ const TxnBatchesTableItem = ({ item }: Props) => { ...@@ -25,7 +25,7 @@ const TxnBatchesTableItem = ({ item }: Props) => {
display="flex" display="flex"
width="fit-content" width="fit-content"
alignItems="center" alignItems="center"
href={ route({ pathname: '/block/[height]', query: { height: item.l2_block_number.toString() } }) } href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: item.l2_block_number.toString() } }) }
> >
<Icon as={ txBatchIcon } boxSize={ 6 } mr={ 1 }/> <Icon as={ txBatchIcon } boxSize={ 6 } mr={ 1 }/>
{ item.l2_block_number } { item.l2_block_number }
...@@ -33,7 +33,7 @@ const TxnBatchesTableItem = ({ item }: Props) => { ...@@ -33,7 +33,7 @@ const TxnBatchesTableItem = ({ item }: Props) => {
</Td> </Td>
<Td> <Td>
<LinkInternal <LinkInternal
href={ route({ pathname: '/block/[height]', query: { height: item.l2_block_number.toString(), tab: 'txs' } }) } href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: item.l2_block_number.toString(), tab: 'txs' } }) }
lineHeight="24px" lineHeight="24px"
> >
{ item.tx_count } { item.tx_count }
...@@ -41,7 +41,7 @@ const TxnBatchesTableItem = ({ item }: Props) => { ...@@ -41,7 +41,7 @@ const TxnBatchesTableItem = ({ item }: Props) => {
</Td> </Td>
<Td> <Td>
<LinkExternal <LinkExternal
href={ appConfig.L2.L1BaseUrl + route({ pathname: '/block/[height]', query: { height: item.epoch_number.toString() } }) } href={ appConfig.L2.L1BaseUrl + route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: item.epoch_number.toString() } }) }
fontWeight={ 600 } fontWeight={ 600 }
lineHeight="24px" lineHeight="24px"
display="inline-flex" display="inline-flex"
......
...@@ -34,20 +34,20 @@ const BlockPageContent = () => { ...@@ -34,20 +34,20 @@ const BlockPageContent = () => {
const router = useRouter(); const router = useRouter();
const isMobile = useIsMobile(); const isMobile = useIsMobile();
const appProps = useAppContext(); const appProps = useAppContext();
const height = getQueryParamString(router.query.height); const heightOrHash = getQueryParamString(router.query.height_or_hash);
const tab = getQueryParamString(router.query.tab); const tab = getQueryParamString(router.query.tab);
const blockQuery = useApiQuery('block', { const blockQuery = useApiQuery('block', {
pathParams: { height }, pathParams: { height_or_hash: heightOrHash },
queryOptions: { queryOptions: {
enabled: Boolean(height), enabled: Boolean(heightOrHash),
placeholderData: BLOCK, placeholderData: BLOCK,
}, },
}); });
const blockTxsQuery = useQueryWithPages({ const blockTxsQuery = useQueryWithPages({
resourceName: 'block_txs', resourceName: 'block_txs',
pathParams: { height }, pathParams: { height_or_hash: heightOrHash },
options: { options: {
enabled: Boolean(!blockQuery.isPlaceholderData && blockQuery.data?.height && tab === 'txs'), enabled: Boolean(!blockQuery.isPlaceholderData && blockQuery.data?.height && tab === 'txs'),
placeholderData: generateListStub<'block_txs'>(TX, 50, { next_page_params: { placeholderData: generateListStub<'block_txs'>(TX, 50, { next_page_params: {
...@@ -60,7 +60,7 @@ const BlockPageContent = () => { ...@@ -60,7 +60,7 @@ const BlockPageContent = () => {
const blockWithdrawalsQuery = useQueryWithPages({ const blockWithdrawalsQuery = useQueryWithPages({
resourceName: 'block_withdrawals', resourceName: 'block_withdrawals',
pathParams: { height }, pathParams: { height_or_hash: heightOrHash },
options: { options: {
enabled: Boolean(!blockQuery.isPlaceholderData && blockQuery.data?.height && appConfig.beaconChain.hasBeaconChain && tab === 'withdrawals'), enabled: Boolean(!blockQuery.isPlaceholderData && blockQuery.data?.height && appConfig.beaconChain.hasBeaconChain && tab === 'withdrawals'),
placeholderData: generateListStub<'block_withdrawals'>(WITHDRAWAL, 50, { next_page_params: { placeholderData: generateListStub<'block_withdrawals'>(WITHDRAWAL, 50, { next_page_params: {
...@@ -70,7 +70,7 @@ const BlockPageContent = () => { ...@@ -70,7 +70,7 @@ const BlockPageContent = () => {
}, },
}); });
if (!height) { if (!heightOrHash) {
throw new Error('Block not found', { cause: { status: 404 } }); throw new Error('Block not found', { cause: { status: 404 } });
} }
...@@ -117,7 +117,7 @@ const BlockPageContent = () => { ...@@ -117,7 +117,7 @@ const BlockPageContent = () => {
<PageTitle <PageTitle
title={ `Block #${ blockQuery.data?.height }` } title={ `Block #${ blockQuery.data?.height }` }
backLink={ backLink } backLink={ backLink }
contentAfter={ <NetworkExplorers type="block" pathParam={ height } ml={{ base: 'initial', lg: 'auto' }}/> } contentAfter={ <NetworkExplorers type="block" pathParam={ heightOrHash } ml={{ base: 'initial', lg: 'auto' }}/> }
isLoading={ blockQuery.isPlaceholderData } isLoading={ blockQuery.isPlaceholderData }
/> />
{ blockQuery.isPlaceholderData ? <SkeletonTabs tabs={ tabs }/> : ( { blockQuery.isPlaceholderData ? <SkeletonTabs tabs={ tabs }/> : (
......
...@@ -26,7 +26,7 @@ const SearchResultsPageContent = () => { ...@@ -26,7 +26,7 @@ const SearchResultsPageContent = () => {
if (redirectCheckQuery.data?.redirect && redirectCheckQuery.data.parameter) { if (redirectCheckQuery.data?.redirect && redirectCheckQuery.data.parameter) {
switch (redirectCheckQuery.data.type) { switch (redirectCheckQuery.data.type) {
case 'block': { case 'block': {
router.push({ pathname: '/block/[height]', query: { height: redirectCheckQuery.data.parameter } }); router.push({ pathname: '/block/[height_or_hash]', query: { height_or_hash: redirectCheckQuery.data.parameter } });
return; return;
} }
case 'address': { case 'address': {
......
...@@ -56,7 +56,7 @@ const SearchResultListItem = ({ data, searchTerm }: Props) => { ...@@ -56,7 +56,7 @@ const SearchResultListItem = ({ data, searchTerm }: Props) => {
return ( return (
<Flex alignItems="center"> <Flex alignItems="center">
<Icon as={ blockIcon } boxSize={ 6 } mr={ 2 } color="gray.500"/> <Icon as={ blockIcon } boxSize={ 6 } mr={ 2 } color="gray.500"/>
<LinkInternal fontWeight={ 700 } href={ route({ pathname: '/block/[height]', query: { height: String(data.block_number) } }) }> <LinkInternal fontWeight={ 700 } href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: String(data.block_hash) } }) }>
<Box as={ shouldHighlightHash ? 'span' : 'mark' }>{ data.block_number }</Box> <Box as={ shouldHighlightHash ? 'span' : 'mark' }>{ data.block_number }</Box>
</LinkInternal> </LinkInternal>
</Flex> </Flex>
......
...@@ -93,7 +93,7 @@ const SearchResultTableItem = ({ data, searchTerm }: Props) => { ...@@ -93,7 +93,7 @@ const SearchResultTableItem = ({ data, searchTerm }: Props) => {
<Td fontSize="sm"> <Td fontSize="sm">
<Flex alignItems="center"> <Flex alignItems="center">
<Icon as={ blockIcon } boxSize={ 6 } mr={ 2 } color="gray.500"/> <Icon as={ blockIcon } boxSize={ 6 } mr={ 2 } color="gray.500"/>
<LinkInternal fontWeight={ 700 } href={ route({ pathname: '/block/[height]', query: { height: String(data.block_number) } }) }> <LinkInternal fontWeight={ 700 } href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: String(data.block_hash) } }) }>
<Box as={ shouldHighlightHash ? 'span' : 'mark' }>{ data.block_number }</Box> <Box as={ shouldHighlightHash ? 'span' : 'mark' }>{ data.block_number }</Box>
</LinkInternal> </LinkInternal>
</Flex> </Flex>
......
...@@ -19,7 +19,7 @@ const AppErrorBlockConsensus = ({ hash, className }: Props) => { ...@@ -19,7 +19,7 @@ const AppErrorBlockConsensus = ({ hash, className }: Props) => {
size="lg" size="lg"
variant="outline" variant="outline"
as="a" as="a"
href={ hash ? route({ pathname: '/block/[height]', query: { height: hash } }) : route({ pathname: '/' }) } href={ hash ? route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: hash } }) : route({ pathname: '/' }) }
> >
{ hash ? 'View reorg' : 'Back to home' } { hash ? 'View reorg' : 'Back to home' }
</Button> </Button>
......
...@@ -49,7 +49,7 @@ const AddressLink = (props: Props) => { ...@@ -49,7 +49,7 @@ const AddressLink = (props: Props) => {
} else if (type === 'token') { } else if (type === 'token') {
url = route({ pathname: '/token/[hash]', query: { hash } }); url = route({ pathname: '/token/[hash]', query: { hash } });
} else if (type === 'block') { } else if (type === 'block') {
url = route({ pathname: '/block/[height]', query: { height: props.blockHeight } }); url = route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: props.blockHeight } });
} else if (type === 'address_token') { } else if (type === 'address_token') {
url = route({ pathname: '/address/[hash]', query: { hash, tab: 'token_transfers', token: props.tokenHash, scroll_to_tabs: 'true' } }); url = route({ pathname: '/address/[hash]', query: { hash, tab: 'token_transfers', token: props.tokenHash, scroll_to_tabs: 'true' } });
} else { } else {
......
...@@ -35,7 +35,7 @@ const SearchBarSuggestItem = ({ data, isMobile, searchTerm, onClick }: Props) => ...@@ -35,7 +35,7 @@ const SearchBarSuggestItem = ({ data, isMobile, searchTerm, onClick }: Props) =>
return route({ pathname: '/tx/[hash]', query: { hash: data.tx_hash } }); return route({ pathname: '/tx/[hash]', query: { hash: data.tx_hash } });
} }
case 'block': { case 'block': {
return route({ pathname: '/block/[height]', query: { height: String(data.block_number) } }); return route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: String(data.block_hash) } });
} }
} }
})(); })();
......
...@@ -163,7 +163,7 @@ const TxDetails = () => { ...@@ -163,7 +163,7 @@ const TxDetails = () => {
{ data.block === null ? { data.block === null ?
<Text>Pending</Text> : ( <Text>Pending</Text> : (
<Skeleton isLoaded={ !isPlaceholderData }> <Skeleton isLoaded={ !isPlaceholderData }>
<LinkInternal href={ route({ pathname: '/block/[height]', query: { height: String(data.block) } }) }> <LinkInternal href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: String(data.block) } }) }>
{ data.block } { data.block }
</LinkInternal> </LinkInternal>
</Skeleton> </Skeleton>
......
...@@ -96,7 +96,7 @@ const TxsListItem = ({ tx, isLoading, showBlockInfo, currentAddress, enableTimeI ...@@ -96,7 +96,7 @@ const TxsListItem = ({ tx, isLoading, showBlockInfo, currentAddress, enableTimeI
<Box mt={ 2 }> <Box mt={ 2 }>
<Skeleton isLoaded={ !isLoading } display="inline-block" whiteSpace="pre">Block </Skeleton> <Skeleton isLoaded={ !isLoading } display="inline-block" whiteSpace="pre">Block </Skeleton>
<Skeleton isLoaded={ !isLoading } display="inline-block"> <Skeleton isLoaded={ !isLoading } display="inline-block">
<LinkInternal href={ route({ pathname: '/block/[height]', query: { height: tx.block.toString() } }) }>{ tx.block }</LinkInternal> <LinkInternal href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: tx.block.toString() } }) }>{ tx.block }</LinkInternal>
</Skeleton> </Skeleton>
</Box> </Box>
) } ) }
......
...@@ -120,7 +120,7 @@ const TxsTableItem = ({ tx, showBlockInfo, currentAddress, enableTimeIncrement, ...@@ -120,7 +120,7 @@ const TxsTableItem = ({ tx, showBlockInfo, currentAddress, enableTimeIncrement,
<Td> <Td>
{ tx.block && ( { tx.block && (
<Skeleton isLoaded={ !isLoading } display="inline-block"> <Skeleton isLoaded={ !isLoading } display="inline-block">
<LinkInternal href={ route({ pathname: '/block/[height]', query: { height: tx.block.toString() } }) }> <LinkInternal href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: tx.block.toString() } }) }>
{ tx.block } { tx.block }
</LinkInternal> </LinkInternal>
</Skeleton> </Skeleton>
......
...@@ -52,7 +52,7 @@ const WithdrawalsListItem = ({ item, isLoading, view }: Props) => { ...@@ -52,7 +52,7 @@ const WithdrawalsListItem = ({ item, isLoading, view }: Props) => {
</Flex> </Flex>
) : ( ) : (
<LinkInternal <LinkInternal
href={ route({ pathname: '/block/[height]', query: { height: item.block_number.toString() } }) } href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: item.block_number.toString() } }) }
display="flex" display="flex"
width="fit-content" width="fit-content"
alignItems="center" alignItems="center"
......
...@@ -43,7 +43,7 @@ const WithdrawalsTableItem = ({ item, view, isLoading }: Props) => { ...@@ -43,7 +43,7 @@ const WithdrawalsTableItem = ({ item, view, isLoading }: Props) => {
</Flex> </Flex>
) : ( ) : (
<LinkInternal <LinkInternal
href={ route({ pathname: '/block/[height]', query: { height: item.block_number.toString() } }) } href={ route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: item.block_number.toString() } }) }
display="flex" display="flex"
width="fit-content" width="fit-content"
alignItems="center" alignItems="center"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment