Commit 532d6a17 authored by tom's avatar tom

zero gas blocks

parent 7f4e9dea
...@@ -13,7 +13,7 @@ export interface Block { ...@@ -13,7 +13,7 @@ export interface Block {
parent_hash: string; parent_hash: string;
difficulty: string; difficulty: string;
total_difficulty: string; total_difficulty: string;
gas_used: string; gas_used: string | null;
gas_limit: string; gas_limit: string;
nonce: number; nonce: number;
base_fee_per_gas: number | null; base_fee_per_gas: number | null;
......
...@@ -55,8 +55,8 @@ const BlocksListItem = ({ data, isPending }: Props) => { ...@@ -55,8 +55,8 @@ const BlocksListItem = ({ data, isPending }: Props) => {
<Box> <Box>
<Text fontWeight={ 500 }>Gas used</Text> <Text fontWeight={ 500 }>Gas used</Text>
<Flex columnGap={ 4 }> <Flex columnGap={ 4 }>
<Text variant="secondary">{ BigNumber(data.gas_used).toFormat() }</Text> <Text variant="secondary">{ BigNumber(data.gas_used || 0).toFormat() }</Text>
<Utilization colorScheme="gray" value={ BigNumber(data.gas_used).div(BigNumber(data.gas_limit)).toNumber() }/> <Utilization colorScheme="gray" value={ BigNumber(data.gas_used || 0).div(BigNumber(data.gas_limit)).toNumber() }/>
<GasUsedToTargetRatio value={ data.gas_target_percentage || undefined }/> <GasUsedToTargetRatio value={ data.gas_target_percentage || undefined }/>
</Flex> </Flex>
</Box> </Box>
......
...@@ -46,9 +46,9 @@ const BlocksTableItem = ({ data, isPending }: Props) => { ...@@ -46,9 +46,9 @@ const BlocksTableItem = ({ data, isPending }: Props) => {
</Td> </Td>
<Td isNumeric fontSize="sm">{ data.tx_count }</Td> <Td isNumeric fontSize="sm">{ data.tx_count }</Td>
<Td fontSize="sm"> <Td fontSize="sm">
<Box>{ BigNumber(data.gas_used).toFormat() }</Box> <Box>{ BigNumber(data.gas_used || 0).toFormat() }</Box>
<Flex mt={ 2 }> <Flex mt={ 2 }>
<Utilization colorScheme="gray" value={ BigNumber(data.gas_used).dividedBy(BigNumber(data.gas_limit)).toNumber() }/> <Utilization colorScheme="gray" value={ BigNumber(data.gas_used || 0).dividedBy(BigNumber(data.gas_limit)).toNumber() }/>
<GasUsedToTargetRatio ml={ 2 } value={ data.gas_target_percentage || undefined }/> <GasUsedToTargetRatio ml={ 2 } value={ data.gas_target_percentage || undefined }/>
</Flex> </Flex>
</Td> </Td>
......
import { Box, Flex, Text, chakra, useColorModeValue } from '@chakra-ui/react'; import { Box, Flex, Text, chakra, useColorModeValue } from '@chakra-ui/react';
import clamp from 'lodash/clamp';
import React from 'react'; import React from 'react';
interface Props { interface Props {
...@@ -10,7 +11,7 @@ interface Props { ...@@ -10,7 +11,7 @@ interface Props {
const WIDTH = 50; const WIDTH = 50;
const Utilization = ({ className, value, colorScheme = 'green' }: Props) => { const Utilization = ({ className, value, colorScheme = 'green' }: Props) => {
const valueString = (value * 100).toLocaleString('en', { maximumFractionDigits: 2 }) + '%'; const valueString = (clamp(value * 100, 0, 100)).toLocaleString('en', { maximumFractionDigits: 2 }) + '%';
const colorGrayScheme = useColorModeValue('gray.500', 'gray.500'); const colorGrayScheme = useColorModeValue('gray.500', 'gray.500');
const color = colorScheme === 'gray' ? colorGrayScheme : 'green.500'; const color = colorScheme === 'gray' ? colorGrayScheme : 'green.500';
......
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