diff --git a/ui/block/BlockDetails.tsx b/ui/block/BlockDetails.tsx index 05069648f8..de15d34871 100644 --- a/ui/block/BlockDetails.tsx +++ b/ui/block/BlockDetails.tsx @@ -1,4 +1,14 @@ -import { Grid, GridItem, Text, Link, Box, Tooltip, useColorModeValue, Skeleton, useColorMode } from '@chakra-ui/react'; +import { + Grid, + GridItem, + Text, + Link, + Box, + Tooltip, + useColorModeValue, + Skeleton, + useColorMode, +} from '@chakra-ui/react'; import BigNumber from 'bignumber.js'; import capitalize from 'lodash/capitalize'; import { useRouter } from 'next/router'; @@ -46,7 +56,8 @@ const rollupFeature = config.features.rollup; const BlockDetails = ({ query }: Props) => { const { colorMode } = useColorMode(); - const wvmIconPath = colorMode === 'light' ? 'networks/arweave-light' : 'networks/arweave-dark'; + const wvmIconPath = + colorMode === 'light' ? 'networks/arweave-dark' : 'networks/arweave-light'; const [ isExpanded, setIsExpanded ] = React.useState(false); const router = useRouter(); const heightOrHash = getQueryParamString(router.query.height_or_hash); @@ -55,16 +66,10 @@ const BlockDetails = ({ query }: Props) => { const { data, isPlaceholderData } = query; - const { data: arweaveId } = useArweaveId({ + const { data: arweaveId, isLoading } = useArweaveId({ block: data?.height, }); - const truncateArweaveId = (address: string) => { - const start = address.slice(0, 30); - const end = address.slice(-4); - return `${ start }...${ end }`; - }; - const handleCutClick = React.useCallback(() => { setIsExpanded((flag) => !flag); scroller.scrollTo('BlockDetails__cutLink', { @@ -73,16 +78,25 @@ const BlockDetails = ({ query }: Props) => { }); }, []); - const handlePrevNextClick = React.useCallback((direction: 'prev' | 'next') => { - if (!data) { - return; - } - - const increment = direction === 'next' ? +1 : -1; - const nextId = String(data.height + increment); + const handlePrevNextClick = React.useCallback( + (direction: 'prev' | 'next') => { + if (!data) { + return; + } - router.push({ pathname: '/block/[height_or_hash]', query: { height_or_hash: nextId } }, undefined); - }, [ data, router ]); + const increment = direction === 'next' ? +1 : -1; + const nextId = String(data.height + increment); + + router.push( + { + pathname: '/block/[height_or_hash]', + query: { height_or_hash: nextId }, + }, + undefined, + ); + }, + [ data, router ], + ); if (!data) { return null; @@ -93,7 +107,12 @@ const BlockDetails = ({ query }: Props) => { const validatorTitle = getNetworkValidatorTitle(); const rewardBreakDown = (() => { - if (rollupFeature.isEnabled || totalReward.isEqualTo(ZERO) || txFees.isEqualTo(ZERO) || burntFees.isEqualTo(ZERO)) { + if ( + rollupFeature.isEnabled || + totalReward.isEqualTo(ZERO) || + txFees.isEqualTo(ZERO) || + burntFees.isEqualTo(ZERO) + ) { return null; } @@ -131,24 +150,37 @@ const BlockDetails = ({ query }: Props) => { return 'Sequenced by'; } - return config.chain.verificationType === 'validation' ? 'Validated by' : 'Mined by'; + return config.chain.verificationType === 'validation' ? + 'Validated by' : + 'Mined by'; })(); const txsNum = (() => { const blockTxsNum = ( - + { data.tx_count } txn{ data.tx_count === 1 ? '' : 's' } ); - const blockBlobTxsNum = (config.features.dataAvailability.isEnabled && data.blob_tx_count) ? ( - <> - including - - { data.blob_tx_count } blob txn{ data.blob_tx_count === 1 ? '' : 's' } - - - ) : null; + const blockBlobTxsNum = + config.features.dataAvailability.isEnabled && data.blob_tx_count ? ( + <> + including + + { data.blob_tx_count } blob txn{ data.blob_tx_count === 1 ? '' : 's' } + + + ) : null; return ( <> @@ -174,7 +206,10 @@ const BlockDetails = ({ query }: Props) => { { { blockTypeLabel } height - - { data.height } - + { data.height } { data.height === 0 && - Genesis Block } { Timestamp - + { Transactions - - { txsNum } - + { txsNum } - { config.features.beaconChain.isEnabled && Boolean(data.withdrawals_count) && ( + { config.features.beaconChain.isEnabled && + Boolean(data.withdrawals_count) && ( <> - Withdrawals + Withdrawals - - { data.withdrawals_count } withdrawal{ data.withdrawals_count === 1 ? '' : 's' } + + { data.withdrawals_count } withdrawal + { data.withdrawals_count === 1 ? '' : 's' } ) } - { rollupFeature.isEnabled && rollupFeature.type === 'zkSync' && data.zksync && !config.UI.views.block.hiddenFields?.batch && ( + { rollupFeature.isEnabled && + rollupFeature.type === 'zkSync' && + data.zksync && + !config.UI.views.block.hiddenFields?.batch && ( <> - Batch + Batch - { data.zksync.batch_number ? - : - Pending } + { data.zksync.batch_number ? ( + + ) : ( + Pending + ) } ) } - { rollupFeature.isEnabled && rollupFeature.type === 'zkSync' && data.zksync && !config.UI.views.block.hiddenFields?.L1_status && ( + { rollupFeature.isEnabled && + rollupFeature.type === 'zkSync' && + data.zksync && + !config.UI.views.block.hiddenFields?.L1_status && ( <> - Status + Status - + ) } @@ -288,10 +344,7 @@ const BlockDetails = ({ query }: Props) => { { verificationTitle } - + ) } @@ -581,11 +634,15 @@ const BlockDetails = ({ query }: Props) => { ) } { data.rewards - ?.filter(({ type }) => type !== 'Validator Reward' && type !== 'Miner Reward') + ?.filter( + ({ type }) => type !== 'Validator Reward' && type !== 'Miner Reward', + ) .map(({ type, reward }) => ( { type } @@ -593,37 +650,45 @@ const BlockDetails = ({ query }: Props) => { { BigNumber(reward).dividedBy(WEI).toFixed() } { currencyUnits.ether } - )) - } + )) } { /* ARWEAVE TXID */ } - { arweaveId && ( - <> - - Block's permanent archive - - - - + { arweaveId && ( + <> + - - - - - - ) } + Block archive proof + + + + + + + + + + ) } + @@ -640,13 +705,18 @@ const BlockDetails = ({ query }: Props) => { { data.gas_target_percentage && ( <> - + ) } @@ -669,11 +739,12 @@ const BlockDetails = ({ query }: Props) => { hint="The minimum gas price a transaction should have in order to be included in this block" isLoading={ isPlaceholderData } > - Minimum gas price + Minimum gas price - { BigNumber(data.minimum_gas_price).dividedBy(GWEI).toFormat() } { currencyUnits.gwei } + { BigNumber(data.minimum_gas_price).dividedBy(GWEI).toFormat() }{ ' ' } + { currencyUnits.gwei } @@ -689,12 +760,24 @@ const BlockDetails = ({ query }: Props) => { { isPlaceholderData ? ( - + ) : ( <> - { BigNumber(data.base_fee_per_gas).dividedBy(WEI).toFixed() } { currencyUnits.ether } + + { BigNumber(data.base_fee_per_gas).dividedBy(WEI).toFixed() }{ ' ' } + { currencyUnits.ether }{ ' ' } + - { space }({ BigNumber(data.base_fee_per_gas).dividedBy(WEI_IN_GWEI).toFixed() } { currencyUnits.gwei }) + { space }( + { BigNumber(data.base_fee_per_gas) + .dividedBy(WEI_IN_GWEI) + .toFixed() }{ ' ' } + { currencyUnits.gwei }) ) } @@ -702,19 +785,25 @@ const BlockDetails = ({ query }: Props) => { ) } - { !config.UI.views.block.hiddenFields?.burnt_fees && !burntFees.isEqualTo(ZERO) && ( + { !config.UI.views.block.hiddenFields?.burnt_fees && + !burntFees.isEqualTo(ZERO) && ( <> - Burnt fees + Burnt fees - + { burntFees.dividedBy(WEI).toFixed() } { currencyUnits.ether } @@ -743,7 +832,8 @@ const BlockDetails = ({ query }: Props) => { - { BigNumber(data.priority_fee).dividedBy(WEI).toFixed() } { currencyUnits.ether } + { BigNumber(data.priority_fee).dividedBy(WEI).toFixed() }{ ' ' } + { currencyUnits.ether } @@ -768,26 +858,32 @@ const BlockDetails = ({ query }: Props) => { { /* ADDITIONAL INFO */ } { isExpanded && !isPlaceholderData && ( <> - - - { rollupFeature.isEnabled && rollupFeature.type === 'zkSync' && data.zksync && - } + + + { rollupFeature.isEnabled && + rollupFeature.type === 'zkSync' && + data.zksync && ( + + ) } { !isPlaceholderData && } { data.bitcoin_merged_mining_header && ( <> - + Bitcoin merged mining header - + - + @@ -796,9 +892,7 @@ const BlockDetails = ({ query }: Props) => { { data.bitcoin_merged_mining_coinbase_transaction && ( <> - + Bitcoin merged mining coinbase transaction @@ -814,9 +908,7 @@ const BlockDetails = ({ query }: Props) => { { data.bitcoin_merged_mining_merkle_proof && ( <> - + Bitcoin merged mining Merkle proof @@ -832,17 +924,14 @@ const BlockDetails = ({ query }: Props) => { { data.hash_for_merged_mining && ( <> - + Hash for merged mining - + - + @@ -855,31 +944,31 @@ const BlockDetails = ({ query }: Props) => { Difficulty - + { data.total_difficulty && ( <> - + Total difficulty - + ) } - + Hash - + @@ -887,20 +976,19 @@ const BlockDetails = ({ query }: Props) => { { data.height > 0 && ( <> - + Parent hash - + @@ -909,14 +997,10 @@ const BlockDetails = ({ query }: Props) => { { !config.UI.views.block.hiddenFields?.nonce && ( <> - + Nonce - - { data.nonce } - + { data.nonce } ) } diff --git a/ui/tx/details/TxInfo.tsx b/ui/tx/details/TxInfo.tsx index 6096f44f69..f6ae1dc475 100644 --- a/ui/tx/details/TxInfo.tsx +++ b/ui/tx/details/TxInfo.tsx @@ -78,12 +78,6 @@ const TxInfo = ({ data, isLoading, socketStatus }: Props) => { block: data?.block, }); - const truncateArweaveId = (address: string) => { - const start = address.slice(0, 30); - const end = address.slice(-4); - return `${ start }...${ end }`; - }; - const handleCutClick = React.useCallback(() => { setIsExpanded((flag) => !flag); scroller.scrollTo('TxInfo__cutLink', { @@ -418,25 +412,25 @@ const TxInfo = ({ data, isLoading, socketStatus }: Props) => { hint="The Arweave TXID of the WeaveVM block" isLoading={ isLoading } > - Arweave storage proof + Block archive proof