Skip to content

Commit 719b426

Browse files
authored
reorg block fix (#2936)
1 parent 2dd32a4 commit 719b426

File tree

5 files changed

+43
-33
lines changed

5 files changed

+43
-33
lines changed

types/api/block.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ export interface Block {
2323
transactions_count: number;
2424
internal_transactions_count: number;
2525
miner: AddressParam;
26-
size: number;
26+
size?: number;
2727
hash: string;
2828
parent_hash: string;
29-
difficulty: string;
30-
total_difficulty: string | null;
29+
difficulty?: string;
30+
total_difficulty?: string | null;
3131
gas_used: string | null;
3232
gas_limit: string;
3333
nonce: string;
34-
base_fee_per_gas: string | null;
34+
base_fee_per_gas?: string | null;
3535
burnt_fees: string | null;
3636
priority_fee: string | null;
3737
extra_data: string | null;

ui/block/BlockDetails.tsx

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,21 @@ const BlockDetails = ({ query }: Props) => {
224224
</>
225225
) }
226226

227-
<DetailedInfo.ItemLabel
228-
hint="Size of the block in bytes"
229-
isLoading={ isPlaceholderData }
230-
>
231-
Size
232-
</DetailedInfo.ItemLabel>
233-
<DetailedInfo.ItemValue>
234-
<Skeleton loading={ isPlaceholderData }>
235-
{ data.size.toLocaleString() }
236-
</Skeleton>
237-
</DetailedInfo.ItemValue>
227+
{ data.size && (
228+
<>
229+
<DetailedInfo.ItemLabel
230+
hint="Size of the block in bytes"
231+
isLoading={ isPlaceholderData }
232+
>
233+
Size
234+
</DetailedInfo.ItemLabel>
235+
<DetailedInfo.ItemValue>
236+
<Skeleton loading={ isPlaceholderData }>
237+
{ data.size.toLocaleString() }
238+
</Skeleton>
239+
</DetailedInfo.ItemValue>
240+
</>
241+
) }
238242

239243
<DetailedInfo.ItemLabel
240244
hint="Date & time at which block was produced."
@@ -623,14 +627,18 @@ const BlockDetails = ({ query }: Props) => {
623627
</>
624628
) }
625629

626-
<DetailedInfo.ItemLabel
627-
hint={ `Block difficulty for ${ validatorTitle }, used to calibrate block generation time` }
628-
>
629-
Difficulty
630-
</DetailedInfo.ItemLabel>
631-
<DetailedInfo.ItemValue overflow="hidden">
632-
<HashStringShortenDynamic hash={ BigNumber(data.difficulty).toFormat() }/>
633-
</DetailedInfo.ItemValue>
630+
{ data.difficulty && (
631+
<>
632+
<DetailedInfo.ItemLabel
633+
hint={ `Block difficulty for ${ validatorTitle }, used to calibrate block generation time` }
634+
>
635+
Difficulty
636+
</DetailedInfo.ItemLabel>
637+
<DetailedInfo.ItemValue overflow="hidden">
638+
<HashStringShortenDynamic hash={ BigNumber(data.difficulty).toFormat() }/>
639+
</DetailedInfo.ItemValue>
640+
</>
641+
) }
634642

635643
{ data.total_difficulty && (
636644
<>

ui/block/useBlockQuery.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default function useBlockQuery({ heightOrHash }: Params): BlockQuery {
7171
size: Number(block.size),
7272
hash: block.hash,
7373
parent_hash: block.parentHash,
74-
difficulty: block.difficulty.toString(),
74+
difficulty: block.difficulty?.toString() ?? null,
7575
total_difficulty: block.totalDifficulty?.toString() ?? null,
7676
gas_used: block.gasUsed.toString(),
7777
gas_limit: block.gasLimit.toString(),

ui/blocks/BlocksListItem.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const BlocksListItem = ({ data, isLoading, enableTimeIncrement, animation }: Pro
3838
const totalReward = getBlockTotalReward(data);
3939
const burntFees = BigNumber(data.burnt_fees || 0);
4040
const txFees = BigNumber(data.transaction_fees || 0);
41-
const baseFeeValue = getBaseFeeValue(data.base_fee_per_gas);
41+
const baseFeeValue = getBaseFeeValue(data.base_fee_per_gas || null);
4242

4343
return (
4444
<ListItemMobile rowGap={ 3 } key={ String(data.height) } animation={ animation }>
@@ -66,12 +66,14 @@ const BlocksListItem = ({ data, isLoading, enableTimeIncrement, animation }: Pro
6666
display="inline-block"
6767
/>
6868
</Flex>
69-
<Flex columnGap={ 2 }>
70-
<Text fontWeight={ 500 }>Size</Text>
71-
<Skeleton loading={ isLoading } display="inline-block" color="text.secondary">
72-
<span>{ data.size.toLocaleString() } bytes</span>
73-
</Skeleton>
74-
</Flex>
69+
{ data.size && (
70+
<Flex columnGap={ 2 }>
71+
<Text fontWeight={ 500 }>Size</Text>
72+
<Skeleton loading={ isLoading } display="inline-block" color="text.secondary">
73+
<span>{ data.size?.toLocaleString() } bytes</span>
74+
</Skeleton>
75+
</Flex>
76+
) }
7577
{ !config.UI.views.block.hiddenFields?.miner && (
7678
<Flex columnGap={ 2 } w="100%">
7779
<Text fontWeight={ 500 }>{ capitalize(getNetworkValidatorTitle()) }</Text>

ui/blocks/BlocksTableItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const BlocksTableItem = ({ data, isLoading, enableTimeIncrement, animation }: Pr
3535
const totalReward = getBlockTotalReward(data);
3636
const burntFees = BigNumber(data.burnt_fees || 0);
3737
const txFees = BigNumber(data.transaction_fees || 0);
38-
const baseFeeValue = getBaseFeeValue(data.base_fee_per_gas);
38+
const baseFeeValue = getBaseFeeValue(data.base_fee_per_gas || null);
3939

4040
return (
4141
<TableRow animation={ animation }>
@@ -69,7 +69,7 @@ const BlocksTableItem = ({ data, isLoading, enableTimeIncrement, animation }: Pr
6969
</TableCell>
7070
<TableCell >
7171
<Skeleton loading={ isLoading } display="inline-block">
72-
{ data.size.toLocaleString() }
72+
{ data.size?.toLocaleString() || 'N/A' }
7373
</Skeleton>
7474
</TableCell>
7575
{ !config.UI.views.block.hiddenFields?.miner && (

0 commit comments

Comments
 (0)