diff --git a/docs/ENVS.md b/docs/ENVS.md index 8d1f8c7565..aa07436be7 100644 --- a/docs/ENVS.md +++ b/docs/ENVS.md @@ -219,6 +219,7 @@ Settings for meta tags, OG tags and SEO ##### Block fields list | Id | Description | | --- | --- | +| `base_fee` | Base fee | | `burnt_fees` | Burnt fees | | `total_reward` | Total block reward | | `nonce` | Block nonce | diff --git a/types/views/block.ts b/types/views/block.ts index 838dc523b7..c0324e508a 100644 --- a/types/views/block.ts +++ b/types/views/block.ts @@ -1,6 +1,7 @@ import type { ArrayElement } from 'types/utils'; export const BLOCK_FIELDS_IDS = [ + 'base_fee', 'burnt_fees', 'total_reward', 'nonce', diff --git a/ui/blocks/BlocksListItem.tsx b/ui/blocks/BlocksListItem.tsx index 6bf4d34bbf..d93b3f3ce1 100644 --- a/ui/blocks/BlocksListItem.tsx +++ b/ui/blocks/BlocksListItem.tsx @@ -21,6 +21,8 @@ import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile'; import TimeAgoWithTooltip from 'ui/shared/TimeAgoWithTooltip'; import Utilization from 'ui/shared/Utilization/Utilization'; +import { getBaseFeeValue } from './utils'; + interface Props { data: Block; isLoading?: boolean; @@ -33,6 +35,7 @@ const BlocksListItem = ({ data, isLoading, enableTimeIncrement }: Props) => { const totalReward = getBlockTotalReward(data); const burntFees = BigNumber(data.burnt_fees || 0); const txFees = BigNumber(data.tx_fees || 0); + const baseFeeValue = getBaseFeeValue(data.base_fee_per_gas); return ( @@ -124,6 +127,14 @@ const BlocksListItem = ({ data, isLoading, enableTimeIncrement }: Props) => { ) } + { !isRollup && !config.UI.views.block.hiddenFields?.base_fee && baseFeeValue && ( + + Base fee + + { baseFeeValue } + + + ) } ); }; diff --git a/ui/blocks/BlocksTable.tsx b/ui/blocks/BlocksTable.tsx index 657635fca8..45a1fd0cbd 100644 --- a/ui/blocks/BlocksTable.tsx +++ b/ui/blocks/BlocksTable.tsx @@ -53,6 +53,8 @@ const BlocksTable = ({ data, isLoading, top, page, showSocketInfo, socketInfoNum Reward { currencyUnits.ether } } { !isRollup && !config.UI.views.block.hiddenFields?.burnt_fees && Burnt fees { currencyUnits.ether } } + { !isRollup && !config.UI.views.block.hiddenFields?.base_fee && + Base fee } diff --git a/ui/blocks/BlocksTableItem.tsx b/ui/blocks/BlocksTableItem.tsx index 80af501a61..f0c0080d41 100644 --- a/ui/blocks/BlocksTableItem.tsx +++ b/ui/blocks/BlocksTableItem.tsx @@ -18,6 +18,8 @@ import LinkInternal from 'ui/shared/links/LinkInternal'; import TimeAgoWithTooltip from 'ui/shared/TimeAgoWithTooltip'; import Utilization from 'ui/shared/Utilization/Utilization'; +import { getBaseFeeValue } from './utils'; + interface Props { data: Block; isLoading?: boolean; @@ -33,6 +35,8 @@ const BlocksTableItem = ({ data, isLoading, enableTimeIncrement }: Props) => { const burntFeesIconColor = useColorModeValue('gray.500', 'inherit'); + const baseFeeValue = getBaseFeeValue(data.base_fee_per_gas); + return ( { ) } + { !isRollup && !config.UI.views.block.hiddenFields?.base_fee && Boolean(baseFeeValue) && ( + + + { baseFeeValue } + + + ) } ); }; diff --git a/ui/blocks/utils.ts b/ui/blocks/utils.ts new file mode 100644 index 0000000000..ab47657c13 --- /dev/null +++ b/ui/blocks/utils.ts @@ -0,0 +1,13 @@ +import getValueWithUnit from 'lib/getValueWithUnit'; +import { currencyUnits } from 'lib/units'; + +export const getBaseFeeValue = (baseFee: string | null) => { + if (!baseFee) { + return null; + } + const valGwei = getValueWithUnit(baseFee, 'gwei'); + if (valGwei.isGreaterThanOrEqualTo(0.0001)) { + return `${ valGwei.toFormat(4) } ${ currencyUnits.gwei }`; + } + return `${ getValueWithUnit(baseFee, 'wei').toFormat() } ${ currencyUnits.wei }`; +}; diff --git a/ui/pages/__screenshots__/Blocks.pw.tsx_dark-color-mode_base-view-dark-mode-1.png b/ui/pages/__screenshots__/Blocks.pw.tsx_dark-color-mode_base-view-dark-mode-1.png index a48327b7ee..5b61b217b1 100644 Binary files a/ui/pages/__screenshots__/Blocks.pw.tsx_dark-color-mode_base-view-dark-mode-1.png and b/ui/pages/__screenshots__/Blocks.pw.tsx_dark-color-mode_base-view-dark-mode-1.png differ diff --git a/ui/pages/__screenshots__/Blocks.pw.tsx_default_base-view-dark-mode-1.png b/ui/pages/__screenshots__/Blocks.pw.tsx_default_base-view-dark-mode-1.png index 1d0a457621..b6871847ef 100644 Binary files a/ui/pages/__screenshots__/Blocks.pw.tsx_default_base-view-dark-mode-1.png and b/ui/pages/__screenshots__/Blocks.pw.tsx_default_base-view-dark-mode-1.png differ diff --git a/ui/pages/__screenshots__/Blocks.pw.tsx_default_hidden-fields-1.png b/ui/pages/__screenshots__/Blocks.pw.tsx_default_hidden-fields-1.png index 4bc3aa29c3..3f74c05125 100644 Binary files a/ui/pages/__screenshots__/Blocks.pw.tsx_default_hidden-fields-1.png and b/ui/pages/__screenshots__/Blocks.pw.tsx_default_hidden-fields-1.png differ diff --git a/ui/pages/__screenshots__/Blocks.pw.tsx_default_mobile-base-view-1.png b/ui/pages/__screenshots__/Blocks.pw.tsx_default_mobile-base-view-1.png index 995fb75993..5af072f741 100644 Binary files a/ui/pages/__screenshots__/Blocks.pw.tsx_default_mobile-base-view-1.png and b/ui/pages/__screenshots__/Blocks.pw.tsx_default_mobile-base-view-1.png differ diff --git a/ui/pages/__screenshots__/Blocks.pw.tsx_default_mobile-hidden-fields-1.png b/ui/pages/__screenshots__/Blocks.pw.tsx_default_mobile-hidden-fields-1.png index f376b907d4..d7032c6094 100644 Binary files a/ui/pages/__screenshots__/Blocks.pw.tsx_default_mobile-hidden-fields-1.png and b/ui/pages/__screenshots__/Blocks.pw.tsx_default_mobile-hidden-fields-1.png differ diff --git a/ui/pages/__screenshots__/Blocks.pw.tsx_default_new-item-from-socket-1.png b/ui/pages/__screenshots__/Blocks.pw.tsx_default_new-item-from-socket-1.png index e3d6b8c4c9..ec0ac04f7f 100644 Binary files a/ui/pages/__screenshots__/Blocks.pw.tsx_default_new-item-from-socket-1.png and b/ui/pages/__screenshots__/Blocks.pw.tsx_default_new-item-from-socket-1.png differ diff --git a/ui/pages/__screenshots__/Blocks.pw.tsx_default_socket-error-1.png b/ui/pages/__screenshots__/Blocks.pw.tsx_default_socket-error-1.png index b9d7affd43..a5d2bee80a 100644 Binary files a/ui/pages/__screenshots__/Blocks.pw.tsx_default_socket-error-1.png and b/ui/pages/__screenshots__/Blocks.pw.tsx_default_socket-error-1.png differ