Skip to content

Commit

Permalink
Merge pull request #1474 from oasisprotocol/mz/consensusBlockProps
Browse files Browse the repository at this point in the history
Add missing props to Consensus block details
  • Loading branch information
buberdds authored Jul 11, 2024
2 parents 9a8a89c + d472142 commit 6f973e4
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 2 deletions.
1 change: 1 addition & 0 deletions .changelog/1474.trivial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add missing props to Consensus block details
57 changes: 56 additions & 1 deletion src/app/pages/ConsensusBlockDetailPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FC } from 'react'
import { useTranslation } from 'react-i18next'
import { useParams } from 'react-router-dom'
import Typography from '@mui/material/Typography'
import { AppErrors } from '../../../types/errors'
import { useScreenSize } from '../../hooks/useScreensize'
import { Block, Layer, useGetConsensusBlockByHeight } from '../../../oasis-nexus/api'
Expand All @@ -13,6 +14,7 @@ import { BlockLink, BlockHashLink } from '../../components/Blocks/BlockLink'
import { ConsensusNextBlockButton, ConsensusPrevBlockButton } from '../../components/BlockNavigationButtons'
import { PageLayout } from '../../components/PageLayout'
import { SubPageCard } from '../../components/SubPageCard'
import { AdaptiveTrimmer } from '../../components/AdaptiveTrimmer/AdaptiveTrimmer'
import { DashboardLink } from '../ParatimeDashboardPage/DashboardLink'

export type BlockDetailConsensusBlock = Block & {
Expand Down Expand Up @@ -48,7 +50,7 @@ export const ConsensusBlockDetailView: FC<{
enableBlockNavigation?: boolean
}> = ({ enableBlockNavigation, isLoading, block, showLayer, standalone = false }) => {
const { t } = useTranslation()
const { isMobile } = useScreenSize()
const { isMobile, isTablet } = useScreenSize()
const formattedTime = useFormattedTimestampStringWithDistance(block?.timestamp)

if (isLoading) return <TextSkeleton numberOfRows={7} />
Expand Down Expand Up @@ -93,6 +95,22 @@ export const ConsensusBlockDetailView: FC<{
<CopyToClipboard value={block.hash.toString()} />
</dd>

{block.state_root && (
<>
<dt>{t('common.stateRoot')}</dt>
<dd>
{isTablet ? (
<Typography variant="mono" sx={{ maxWidth: '100%', overflowX: 'hidden' }}>
<AdaptiveTrimmer text={block.state_root} strategy="middle" />
</Typography>
) : (
<Typography variant="mono">{block.state_root}</Typography>
)}
<CopyToClipboard value={block.state_root} />
</dd>
</>
)}

<dt>{t('common.timestamp')}</dt>
<dd>{formattedTime}</dd>

Expand All @@ -104,6 +122,43 @@ export const ConsensusBlockDetailView: FC<{
{transactionLabel}
{/*)}*/}
</dd>

{block.epoch && (
<>
<dt>{t('common.epoch')}</dt>
<dd>{block.epoch}</dd>
</>
)}

{block.gas_limit && (
<>
<dt>{t('common.gasLimit')}</dt>
<dd>
{t('common.valuePair', {
value: block.gas_limit,
})}
{block.gas_limit === '0' && ` ${t('block.unlimited')}`}
</dd>
</>
)}

{block.size_limit && (
<>
<dt>{t('common.blockSizeLimit')}</dt>
<dd>
{t('common.bytes', {
value: block.size_limit,
formatParams: {
value: {
style: 'unit',
unit: 'byte',
unitDisplay: 'long',
} satisfies Intl.NumberFormatOptions,
},
})}
</dd>
</>
)}
</StyledDescriptionList>
)
}
6 changes: 5 additions & 1 deletion src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"viewPrevious": "View previous block"
},
"block": {
"gasUsed": "{{value, number}} | {{percentage, number}}"
"gasUsed": "{{value, number}} | {{percentage, number}}",
"unlimited": "(unlimited)"
},
"banner": {
"buildStaging": "Please note this is an internal launch meant to gather your feedback.",
Expand All @@ -62,6 +63,7 @@
"age": "Age",
"balance": "Balance",
"block": "Block",
"blockSizeLimit": "Block size limit",
"bytes": "{{value, number}}",
"cancel": "Cancel",
"collection": "Collection",
Expand All @@ -70,6 +72,7 @@
"copy": "Copy",
"data": "Data",
"emerald": "Emerald",
"epoch": "Epoch",
"cipher": "Cipher",
"consensus": "Consensus",
"eth": "ETH",
Expand Down Expand Up @@ -114,6 +117,7 @@
"smartContract": "Smart Contract",
"smartContract_short": "Contract",
"staked": "Staked",
"stateRoot": "StateRoot",
"staking": "Staking",
"submitter": "Submitter",
"success": "Success",
Expand Down
12 changes: 12 additions & 0 deletions src/oasis-nexus/generated/api.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6f973e4

Please sign in to comment.