From a62fa1df56fad90bf6209349da659216fcf93458 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Sat, 3 Jul 2021 18:51:57 -0300 Subject: [PATCH] Add block/uncles rewards --- src/Block.tsx | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Block.tsx b/src/Block.tsx index 65f62e1..35951b0 100644 --- a/src/Block.tsx +++ b/src/Block.tsx @@ -9,12 +9,16 @@ import Timestamp from "./components/Timestamp"; import GasValue from "./components/GasValue"; import BlockLink from "./components/BlockLink"; import AddressLink from "./components/AddressLink"; +import TransactionValue from "./components/TransactionValue"; type BlockParams = { blockNumberOrHash: string; }; interface ExtendedBlock extends ethers.providers.Block { + blockReward: BigNumber; + unclesReward: BigNumber; + feeReward: BigNumber; size: number; sha3Uncles: string; stateRoot: string; @@ -27,21 +31,28 @@ const Block: React.FC = () => { const [block, setBlock] = useState(); useEffect(() => { const readBlock = async () => { - let _rawBlock: any; + let blockPromise: Promise; if (ethers.utils.isHexString(params.blockNumberOrHash, 32)) { - _rawBlock = await provider.send("eth_getBlockByHash", [ + blockPromise = provider.send("eth_getBlockByHash", [ params.blockNumberOrHash, false, ]); } else { - _rawBlock = await provider.send("eth_getBlockByNumber", [ + blockPromise = provider.send("eth_getBlockByNumber", [ params.blockNumberOrHash, false, ]); } + const [_rawBlock, _rawIssuance] = await Promise.all([ + blockPromise, + provider.send("erigon_issuance", [params.blockNumberOrHash]), + ]); const _block = provider.formatter.block(_rawBlock); const extBlock: ExtendedBlock = { + blockReward: provider.formatter.bigNumber(_rawIssuance.blockReward), + unclesReward: provider.formatter.bigNumber(_rawIssuance.uncleReward), + feeReward: provider.formatter.bigNumber("0"), size: provider.formatter.number(_rawBlock.size), sha3Uncles: _rawBlock.sha3Uncles, stateRoot: _rawBlock.stateRoot, @@ -101,8 +112,12 @@ const Block: React.FC = () => { - N/A - N/A + + + + + + {ethers.utils.commify(block.difficulty)}