import React, { useContext } from "react"; import { BigNumber } from "@ethersproject/bignumber"; import TransactionValue from "./components/TransactionValue"; import FiatValue from "./components/FiatValue"; import { RuntimeContext } from "./useRuntime"; import { ExtendedBlock } from "./useErigonHooks"; import { useETHUSDOracle } from "./usePriceOracle"; type BlockRewardProps = { block: ExtendedBlock; }; const BlockReward: React.FC = ({ block }) => { const { provider } = useContext(RuntimeContext); const eth2USDValue = useETHUSDOracle(provider, block.number); const netFeeReward = block?.feeReward ?? BigNumber.from(0); const value = eth2USDValue ? block.blockReward .add(netFeeReward) .mul(eth2USDValue) .div(10 ** 8) : undefined; return ( <> {!netFeeReward.isZero() && ( <> {" "} ( +{" "} ) )} {value && ( <> {" "} )} ); }; export default BlockReward;