From 2ae3429d51e9585dd327cb545ffef5c05bdd852f Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 26 Jul 2021 19:59:07 -0300 Subject: [PATCH 01/18] Extract custom hook --- src/Block.tsx | 70 +++-------------------------------------- src/useErigonHooks.ts | 73 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 67 deletions(-) diff --git a/src/Block.tsx b/src/Block.tsx index 3064c99..00ca0dc 100644 --- a/src/Block.tsx +++ b/src/Block.tsx @@ -1,6 +1,6 @@ -import React, { useEffect, useState, useMemo, useContext } from "react"; +import React, { useEffect, useMemo, useContext } from "react"; import { useParams, NavLink } from "react-router-dom"; -import { ethers, BigNumber } from "ethers"; +import { ethers } from "ethers"; import StandardFrame from "./StandardFrame"; import StandardSubtitle from "./StandardSubtitle"; import NavBlock from "./block/NavBlock"; @@ -14,79 +14,17 @@ import HexValue from "./components/HexValue"; import { RuntimeContext } from "./useRuntime"; import { useLatestBlockNumber } from "./useLatestBlock"; import { blockTxsURL } from "./url"; +import { useBlockData } from "./useErigonHooks"; type BlockParams = { blockNumberOrHash: string; }; -interface ExtendedBlock extends ethers.providers.Block { - blockReward: BigNumber; - unclesReward: BigNumber; - feeReward: BigNumber; - size: number; - sha3Uncles: string; - stateRoot: string; - totalDifficulty: BigNumber; -} - const Block: React.FC = () => { const { provider } = useContext(RuntimeContext); const params = useParams(); - const [block, setBlock] = useState(); - useEffect(() => { - if (!provider) { - return; - } - - const readBlock = async () => { - let blockPromise: Promise; - if (ethers.utils.isHexString(params.blockNumberOrHash, 32)) { - blockPromise = provider.send("eth_getBlockByHash", [ - params.blockNumberOrHash, - false, - ]); - } else { - blockPromise = provider.send("eth_getBlockByNumber", [ - params.blockNumberOrHash, - false, - ]); - } - const [_rawBlock, _rawIssuance, _rawReceipts] = await Promise.all([ - blockPromise, - provider.send("erigon_issuance", [params.blockNumberOrHash]), - provider.send("eth_getBlockReceipts", [params.blockNumberOrHash]), - ]); - const receipts = (_rawReceipts as any[]).map((r) => - provider.formatter.receipt(r) - ); - const fees = receipts.reduce( - (acc, r) => acc.add(r.effectiveGasPrice.mul(r.gasUsed)), - BigNumber.from(0) - ); - - const _block = provider.formatter.block(_rawBlock); - const extBlock: ExtendedBlock = { - blockReward: provider.formatter.bigNumber( - _rawIssuance.blockReward ?? 0 - ), - unclesReward: provider.formatter.bigNumber( - _rawIssuance.uncleReward ?? 0 - ), - feeReward: fees, - size: provider.formatter.number(_rawBlock.size), - sha3Uncles: _rawBlock.sha3Uncles, - stateRoot: _rawBlock.stateRoot, - totalDifficulty: provider.formatter.bigNumber( - _rawBlock.totalDifficulty - ), - ..._block, - }; - setBlock(extBlock); - }; - readBlock(); - }, [provider, params.blockNumberOrHash]); - + const block = useBlockData(provider, params.blockNumberOrHash); useEffect(() => { if (block) { document.title = `Block #${block.number} | Otterscan`; diff --git a/src/useErigonHooks.ts b/src/useErigonHooks.ts index 50d4bf3..ecbda33 100644 --- a/src/useErigonHooks.ts +++ b/src/useErigonHooks.ts @@ -1,8 +1,79 @@ -import { ethers } from "ethers"; +import { ethers, BigNumber } from "ethers"; import { useState, useEffect } from "react"; import { getInternalOperations } from "./nodeFunctions"; import { TransactionData, InternalOperation } from "./types"; +export interface ExtendedBlock extends ethers.providers.Block { + blockReward: BigNumber; + unclesReward: BigNumber; + feeReward: BigNumber; + size: number; + sha3Uncles: string; + stateRoot: string; + totalDifficulty: BigNumber; +} + +export const useBlockData = ( + provider: ethers.providers.JsonRpcProvider | undefined, + blockNumberOrHash: string +) => { + const [block, setBlock] = useState(); + useEffect(() => { + if (!provider) { + return; + } + + const readBlock = async () => { + let blockPromise: Promise; + if (ethers.utils.isHexString(blockNumberOrHash, 32)) { + blockPromise = provider.send("eth_getBlockByHash", [ + blockNumberOrHash, + false, + ]); + } else { + blockPromise = provider.send("eth_getBlockByNumber", [ + blockNumberOrHash, + false, + ]); + } + const [_rawBlock, _rawIssuance, _rawReceipts] = await Promise.all([ + blockPromise, + provider.send("erigon_issuance", [blockNumberOrHash]), + provider.send("eth_getBlockReceipts", [blockNumberOrHash]), + ]); + const receipts = (_rawReceipts as any[]).map((r) => + provider.formatter.receipt(r) + ); + const fees = receipts.reduce( + (acc, r) => acc.add(r.effectiveGasPrice.mul(r.gasUsed)), + BigNumber.from(0) + ); + + const _block = provider.formatter.block(_rawBlock); + const extBlock: ExtendedBlock = { + blockReward: provider.formatter.bigNumber( + _rawIssuance.blockReward ?? 0 + ), + unclesReward: provider.formatter.bigNumber( + _rawIssuance.uncleReward ?? 0 + ), + feeReward: fees, + size: provider.formatter.number(_rawBlock.size), + sha3Uncles: _rawBlock.sha3Uncles, + stateRoot: _rawBlock.stateRoot, + totalDifficulty: provider.formatter.bigNumber( + _rawBlock.totalDifficulty + ), + ..._block, + }; + setBlock(extBlock); + }; + readBlock(); + }, [provider, blockNumberOrHash]); + + return block; +}; + export const useInternalOperations = ( provider: ethers.providers.JsonRpcProvider | undefined, txData: TransactionData | undefined From bc8bf0cf9352523743d10134f45328595a435f92 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 26 Jul 2021 20:46:11 -0300 Subject: [PATCH 02/18] Add burned fees info; subtract from fees received by miner --- src/Block.tsx | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/Block.tsx b/src/Block.tsx index 00ca0dc..9e061e7 100644 --- a/src/Block.tsx +++ b/src/Block.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useMemo, useContext } from "react"; import { useParams, NavLink } from "react-router-dom"; -import { ethers } from "ethers"; +import { BigNumber, ethers } from "ethers"; import StandardFrame from "./StandardFrame"; import StandardSubtitle from "./StandardSubtitle"; import NavBlock from "./block/NavBlock"; @@ -10,6 +10,7 @@ import GasValue from "./components/GasValue"; import BlockLink from "./components/BlockLink"; import DecoratedAddressLink from "./components/DecoratedAddressLink"; import TransactionValue from "./components/TransactionValue"; +import FormattedBalance from "./components/FormattedBalance"; import HexValue from "./components/HexValue"; import { RuntimeContext } from "./useRuntime"; import { useLatestBlockNumber } from "./useLatestBlock"; @@ -39,6 +40,9 @@ const Block: React.FC = () => { console.error(err); } }, [block]); + const burnedFees = + block?.baseFeePerGas && block.baseFeePerGas.mul(block.gasUsed); + const netFeeReward = block && block.feeReward.sub(burnedFees ?? 0); const latestBlockNumber = useLatestBlockNumber(provider); @@ -81,12 +85,18 @@ const Block: React.FC = () => { - + {!block.feeReward.isZero() && ( <> {" "} ( +{" "} - ) + + ) )} @@ -102,6 +112,24 @@ const Block: React.FC = () => { {ethers.utils.commify(block.size)} bytes + {block.baseFeePerGas && ( + + + {" "} + Gwei ( + {" "} + wei) + + + )} + {burnedFees && ( + + Ether + + )} From e967abf61e67def44d54e79cbccf845783d3119e Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 26 Jul 2021 20:47:25 -0300 Subject: [PATCH 03/18] Add max fee per gas/max priority fee per gas --- src/Transaction.tsx | 3 +++ src/components/TransactionType.tsx | 30 ++++++++++++++++++++++++++++++ src/transaction/Details.tsx | 24 ++++++++++++++++++++++++ src/types.ts | 3 +++ 4 files changed, 60 insertions(+) create mode 100644 src/components/TransactionType.tsx diff --git a/src/Transaction.tsx b/src/Transaction.tsx index 55de7ac..5e8bb3f 100644 --- a/src/Transaction.tsx +++ b/src/Transaction.tsx @@ -92,7 +92,10 @@ const Transaction: React.FC = () => { value: _response.value, tokenTransfers, tokenMetas, + type: _response.type ?? 0, fee: _response.gasPrice!.mul(_receipt.gasUsed), + maxFeePerGas: _response.maxFeePerGas, + maxPriorityFeePerGas: _response.maxPriorityFeePerGas, gasPrice: _response.gasPrice!, gasLimit: _response.gasLimit, gasUsed: _receipt.gasUsed, diff --git a/src/components/TransactionType.tsx b/src/components/TransactionType.tsx new file mode 100644 index 0000000..ab4c58a --- /dev/null +++ b/src/components/TransactionType.tsx @@ -0,0 +1,30 @@ +import React from "react"; + +type TransactionTypeProps = { + type: number; +}; + +const TransactionType: React.FC = ({ type }) => { + let description: string; + switch (type) { + case 0: + description = "legacy"; + break; + case 1: + description = "EIP-2930"; + break; + case 2: + description = "EIP-1559"; + break; + default: + description = "unknown"; + } + + return ( + + {type} ({description}) + + ); +}; + +export default React.memo(TransactionType); diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 30bcbbd..0b2277f 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -15,6 +15,7 @@ import Copy from "../components/Copy"; import Timestamp from "../components/Timestamp"; import InternalTransactionOperation from "../components/InternalTransactionOperation"; import MethodName from "../components/MethodName"; +import TransactionType from "../components/TransactionType"; import GasValue from "../components/GasValue"; import FormattedBalance from "../components/FormattedBalance"; import TokenTransferItem from "../TokenTransferItem"; @@ -130,6 +131,29 @@ const Details: React.FC = ({ {ethers.utils.formatEther(txData.value)} Ether + + + + {txData.type === 2 && ( + <> + + + Ether ( + Gwei) + + + + + Ether ( + {" "} + Gwei) + + + + )} Ether diff --git a/src/types.ts b/src/types.ts index ac53edd..144b9c3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -49,6 +49,9 @@ export type TransactionData = { value: BigNumber; tokenTransfers: TokenTransfer[]; tokenMetas: TokenMetas; + type: number; + maxFeePerGas?: BigNumber | undefined; + maxPriorityFeePerGas?: BigNumber | undefined; fee: BigNumber; gasPrice: BigNumber; gasLimit: BigNumber; From 91dd933aa2bf9518e3454843a9d51058439f872c Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 28 Jul 2021 04:24:48 -0300 Subject: [PATCH 04/18] Squash block gas used/limit info; add percentage bar --- src/Block.tsx | 37 +++++++++++++++++++++---------------- src/components/InfoRow.tsx | 2 +- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/Block.tsx b/src/Block.tsx index 9e061e7..91951ec 100644 --- a/src/Block.tsx +++ b/src/Block.tsx @@ -5,6 +5,7 @@ import StandardFrame from "./StandardFrame"; import StandardSubtitle from "./StandardSubtitle"; import NavBlock from "./block/NavBlock"; import ContentFrame from "./ContentFrame"; +import InfoRow from "./components/InfoRow"; import Timestamp from "./components/Timestamp"; import GasValue from "./components/GasValue"; import BlockLink from "./components/BlockLink"; @@ -43,6 +44,8 @@ const Block: React.FC = () => { const burnedFees = block?.baseFeePerGas && block.baseFeePerGas.mul(block.gasUsed); const netFeeReward = block && block.feeReward.sub(burnedFees ?? 0); + const gasUsedPerc = + block && block.gasUsed.mul(10000).div(block.gasLimit).toNumber() / 100; const latestBlockNumber = useLatestBlockNumber(provider); @@ -130,11 +133,24 @@ const Block: React.FC = () => { Ether )} - - - - - + +
+
+ /{" "} + +
+
+
+
+
+ {gasUsedPerc}% +
+
+
+
{extraStr} (Hex:{" "} @@ -162,15 +178,4 @@ const Block: React.FC = () => { ); }; -type InfoRowProps = { - title: string; -}; - -const InfoRow: React.FC = ({ title, children }) => ( -
-
{title}:
-
{children}
-
-); - export default React.memo(Block); diff --git a/src/components/InfoRow.tsx b/src/components/InfoRow.tsx index d3758b3..eb40eb6 100644 --- a/src/components/InfoRow.tsx +++ b/src/components/InfoRow.tsx @@ -5,7 +5,7 @@ type InfoRowProps = React.PropsWithChildren<{ }>; const InfoRow: React.FC = ({ title, children }) => ( -
+
{title}:
{children}
From d893eb8545583d84258c6bff4ae8104de17fb1cb Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 28 Jul 2021 04:27:08 -0300 Subject: [PATCH 05/18] Reorder difficult/total difficult fields --- src/Block.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Block.tsx b/src/Block.tsx index 91951ec..afa68f4 100644 --- a/src/Block.tsx +++ b/src/Block.tsx @@ -106,12 +106,6 @@ const Block: React.FC = () => { - - {ethers.utils.commify(block.difficulty)} - - - {ethers.utils.commify(block.totalDifficulty.toString())} - {ethers.utils.commify(block.size)} bytes @@ -157,6 +151,12 @@ const Block: React.FC = () => { {block.extraData}) N/A + + {ethers.utils.commify(block.difficulty)} + + + {ethers.utils.commify(block.totalDifficulty.toString())} + From e354973a6382bfa4aa4268e7164c85f9a47d9a2c Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 28 Jul 2021 04:29:36 -0300 Subject: [PATCH 06/18] Squash tx gas used/limit info --- src/transaction/Details.tsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 0b2277f..71cef91 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -170,14 +170,11 @@ const Details: React.FC = ({ )}
+ + / {" "} + ({(txData.gasUsedPerc * 100).toFixed(2)}%) + N/A - - - - - ( - {(txData.gasUsedPerc * 100).toFixed(2)}%) - {txData.nonce} From e214117f47fab35b8e58e0ac6ea2755df6efea5f Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 28 Jul 2021 04:40:38 -0300 Subject: [PATCH 07/18] Extract PercentageBar component; apply percentage bar to tx gas usage --- src/Block.tsx | 13 ++----------- src/components/PercentageBar.tsx | 21 +++++++++++++++++++++ src/transaction/Details.tsx | 10 ++++++++-- 3 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 src/components/PercentageBar.tsx diff --git a/src/Block.tsx b/src/Block.tsx index afa68f4..83ab187 100644 --- a/src/Block.tsx +++ b/src/Block.tsx @@ -8,6 +8,7 @@ import ContentFrame from "./ContentFrame"; import InfoRow from "./components/InfoRow"; import Timestamp from "./components/Timestamp"; import GasValue from "./components/GasValue"; +import PercentageBar from "./components/PercentageBar"; import BlockLink from "./components/BlockLink"; import DecoratedAddressLink from "./components/DecoratedAddressLink"; import TransactionValue from "./components/TransactionValue"; @@ -133,17 +134,7 @@ const Block: React.FC = () => { /{" "} -
-
-
-
- {gasUsedPerc}% -
-
-
+
diff --git a/src/components/PercentageBar.tsx b/src/components/PercentageBar.tsx new file mode 100644 index 0000000..a868784 --- /dev/null +++ b/src/components/PercentageBar.tsx @@ -0,0 +1,21 @@ +import React from "react"; + +type PercentageBarProps = { + perc: number; +}; + +const PercentageBar: React.FC = ({ perc }) => ( +
+
+
+
+ {perc}% +
+
+
+); + +export default React.memo(PercentageBar); diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 71cef91..2619204 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -20,6 +20,7 @@ import GasValue from "../components/GasValue"; import FormattedBalance from "../components/FormattedBalance"; import TokenTransferItem from "../TokenTransferItem"; import { TransactionData, InternalOperation } from "../types"; +import PercentageBar from "../components/PercentageBar"; type DetailsProps = { txData: TransactionData; @@ -171,8 +172,13 @@ const Details: React.FC = ({
- / {" "} - ({(txData.gasUsedPerc * 100).toFixed(2)}%) +
+
+ /{" "} + +
+ +
N/A {txData.nonce} From 31287796f0b55ee1212ad678d055e826777aa467 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 28 Jul 2021 04:53:55 -0300 Subject: [PATCH 08/18] Remove unnecessary field --- src/Transaction.tsx | 4 +--- src/transaction/Details.tsx | 8 +++++++- src/types.ts | 3 +-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Transaction.tsx b/src/Transaction.tsx index 5e8bb3f..ae4fb54 100644 --- a/src/Transaction.tsx +++ b/src/Transaction.tsx @@ -97,10 +97,8 @@ const Transaction: React.FC = () => { maxFeePerGas: _response.maxFeePerGas, maxPriorityFeePerGas: _response.maxPriorityFeePerGas, gasPrice: _response.gasPrice!, - gasLimit: _response.gasLimit, gasUsed: _receipt.gasUsed, - gasUsedPerc: - _receipt.gasUsed.toNumber() / _response.gasLimit.toNumber(), + gasLimit: _response.gasLimit, nonce: _response.nonce, data: _response.data, logs: _receipt.logs, diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 2619204..65a4592 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -177,7 +177,13 @@ const Details: React.FC = ({ /{" "} - +
N/A diff --git a/src/types.ts b/src/types.ts index 144b9c3..64fba94 100644 --- a/src/types.ts +++ b/src/types.ts @@ -54,9 +54,8 @@ export type TransactionData = { maxPriorityFeePerGas?: BigNumber | undefined; fee: BigNumber; gasPrice: BigNumber; - gasLimit: BigNumber; gasUsed: BigNumber; - gasUsedPerc: number; + gasLimit: BigNumber; nonce: number; data: string; logs: ethers.providers.Log[]; From 9484ed59e2eb916e5301e19e53c15d0600838fe2 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 28 Jul 2021 14:49:40 -0300 Subject: [PATCH 09/18] Add block base fee info to tx details page --- src/Transaction.tsx | 1 + src/transaction/Details.tsx | 13 +++++++++++++ src/types.ts | 1 + 3 files changed, 15 insertions(+) diff --git a/src/Transaction.tsx b/src/Transaction.tsx index ae4fb54..ad940fe 100644 --- a/src/Transaction.tsx +++ b/src/Transaction.tsx @@ -94,6 +94,7 @@ const Transaction: React.FC = () => { tokenMetas, type: _response.type ?? 0, fee: _response.gasPrice!.mul(_receipt.gasUsed), + blockBaseFeePerGas: _block.baseFeePerGas, maxFeePerGas: _response.maxFeePerGas, maxPriorityFeePerGas: _response.maxPriorityFeePerGas, gasPrice: _response.gasPrice!, diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 65a4592..27d1197 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -135,6 +135,19 @@ const Details: React.FC = ({ + {txData.blockBaseFeePerGas && ( + + + {" "} + Gwei ( + {" "} + wei) + + + )} {txData.type === 2 && ( <> diff --git a/src/types.ts b/src/types.ts index 64fba94..482828e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -53,6 +53,7 @@ export type TransactionData = { maxFeePerGas?: BigNumber | undefined; maxPriorityFeePerGas?: BigNumber | undefined; fee: BigNumber; + blockBaseFeePerGas?: BigNumber | undefined | null; gasPrice: BigNumber; gasUsed: BigNumber; gasLimit: BigNumber; From eaa018e207bb68603095f29e3acf80b0acf1fdcb Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 28 Jul 2021 16:09:40 -0300 Subject: [PATCH 10/18] Reorder fields --- src/transaction/Details.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 27d1197..e8e1159 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -150,12 +150,6 @@ const Details: React.FC = ({ )} {txData.type === 2 && ( <> - - - Ether ( - Gwei) - - Ether ( @@ -166,6 +160,12 @@ const Details: React.FC = ({ Gwei) + + + Ether ( + Gwei) + + )} From 873541ec647dab211f6e5fec0f3d330183c4212d Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 28 Jul 2021 16:27:06 -0300 Subject: [PATCH 11/18] Add hyperlinks to EIP tx types --- src/components/ExternalLink.tsx | 23 +++++++++++++++++++++++ src/components/TransactionType.tsx | 15 ++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 src/components/ExternalLink.tsx diff --git a/src/components/ExternalLink.tsx b/src/components/ExternalLink.tsx new file mode 100644 index 0000000..5232a9d --- /dev/null +++ b/src/components/ExternalLink.tsx @@ -0,0 +1,23 @@ +import React from "react"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons"; + +type ExternalLinkProps = { + href: string; +}; + +const ExternalLink: React.FC = ({ href, children }) => ( + + + {children} + + + +); + +export default ExternalLink; diff --git a/src/components/TransactionType.tsx b/src/components/TransactionType.tsx index ab4c58a..e7faa6c 100644 --- a/src/components/TransactionType.tsx +++ b/src/components/TransactionType.tsx @@ -1,20 +1,29 @@ import React from "react"; +import ExternalLink from "./ExternalLink"; type TransactionTypeProps = { type: number; }; const TransactionType: React.FC = ({ type }) => { - let description: string; + let description: React.ReactNode; switch (type) { case 0: description = "legacy"; break; case 1: - description = "EIP-2930"; + description = ( + + EIP-2930 + + ); break; case 2: - description = "EIP-1559"; + description = ( + + EIP-1559 + + ); break; default: description = "unknown"; From 8cacd01f4260d58cae09ca6991c1feb40a7597a1 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 28 Jul 2021 16:36:34 -0300 Subject: [PATCH 12/18] Enable rich info on InfoRow component title; add EIP hyperlink to tx type --- src/components/ExternalLink.tsx | 4 ++-- src/components/InfoRow.tsx | 2 +- src/transaction/Details.tsx | 13 ++++++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/ExternalLink.tsx b/src/components/ExternalLink.tsx index 5232a9d..51769a8 100644 --- a/src/components/ExternalLink.tsx +++ b/src/components/ExternalLink.tsx @@ -13,9 +13,9 @@ const ExternalLink: React.FC = ({ href, children }) => ( target="_blank" rel="noopener noreferrer" > - + {children} - + ); diff --git a/src/components/InfoRow.tsx b/src/components/InfoRow.tsx index eb40eb6..947eec7 100644 --- a/src/components/InfoRow.tsx +++ b/src/components/InfoRow.tsx @@ -1,7 +1,7 @@ import React from "react"; type InfoRowProps = React.PropsWithChildren<{ - title: string; + title: React.ReactNode; }>; const InfoRow: React.FC = ({ title, children }) => ( diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index e8e1159..86b0c0e 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -21,6 +21,7 @@ import FormattedBalance from "../components/FormattedBalance"; import TokenTransferItem from "../TokenTransferItem"; import { TransactionData, InternalOperation } from "../types"; import PercentageBar from "../components/PercentageBar"; +import ExternalLink from "../components/ExternalLink"; type DetailsProps = { txData: TransactionData; @@ -132,7 +133,17 @@ const Details: React.FC = ({ {ethers.utils.formatEther(txData.value)} Ether - + + Type ( + + EIP-2718 + + ) + + } + > {txData.blockBaseFeePerGas && ( From f0e96990efea88be5dd390afbf7c0ad8903e9698 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 28 Jul 2021 18:44:50 -0300 Subject: [PATCH 13/18] Add burnt/miner fee split info --- src/transaction/Details.tsx | 388 +++++++++++++++++--------------- src/transaction/RewardSplit.tsx | 54 +++++ 2 files changed, 256 insertions(+), 186 deletions(-) create mode 100644 src/transaction/RewardSplit.tsx diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 86b0c0e..1a1cd64 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -16,6 +16,7 @@ import Timestamp from "../components/Timestamp"; import InternalTransactionOperation from "../components/InternalTransactionOperation"; import MethodName from "../components/MethodName"; import TransactionType from "../components/TransactionType"; +import RewardSplit from "./RewardSplit"; import GasValue from "../components/GasValue"; import FormattedBalance from "../components/FormattedBalance"; import TokenTransferItem from "../TokenTransferItem"; @@ -33,198 +34,213 @@ const Details: React.FC = ({ txData, internalOps, sendsEthToMiner, -}) => ( - - -
- {txData.transactionHash} - -
-
- - {txData.status ? ( - - - Success - - ) : ( - - - Fail - - )} - - -
- - -
-
- - - - -
- - - - -
-
- - {txData.to ? ( -
- - - - -
- ) : ( -
- - - - -
- )} - {internalOps && ( -
- {internalOps.map((op, i) => ( - - ))} -
- )} -
- - - - {txData.tokenTransfers.length > 0 && ( - -
- {txData.tokenTransfers.map((t, i) => ( - - ))} +}) => { + const hasEIP1559 = + txData.blockBaseFeePerGas !== undefined && + txData.blockBaseFeePerGas !== null; + + return ( + + +
+ {txData.transactionHash} +
- )} - - - {ethers.utils.formatEther(txData.value)} Ether - - - - Type ( - - EIP-2718 - - ) - - } - > - - - {txData.blockBaseFeePerGas && ( - - - {" "} - Gwei ( - {" "} - wei) - - - )} - {txData.type === 2 && ( - <> - - - Ether ( - {" "} - Gwei) + + {txData.status ? ( + + + Success - - - - Ether ( - Gwei) - - - - )} - - Ether - - -
- - Ether ( - Gwei) - - {sendsEthToMiner && ( - - Flashbots + ) : ( + + + Fail )} -
-
- -
-
- /{" "} - + + +
+ +
- + + + + +
+ + + + +
+
+ + {txData.to ? ( +
+ + + + +
+ ) : ( +
+ + + + +
+ )} + {internalOps && ( +
+ {internalOps.map((op, i) => ( + + ))} +
+ )} +
+ + + + {txData.tokenTransfers.length > 0 && ( + +
+ {txData.tokenTransfers.map((t, i) => ( + + ))} +
+
+ )} + + + {ethers.utils.formatEther(txData.value)} Ether + + + + Type ( + + EIP-2718 + + ) + + } + > + + + {hasEIP1559 && ( + + + {" "} + Gwei ( + {" "} + wei) + + + )} + {txData.type === 2 && ( + <> + + + Ether ( + {" "} + Gwei) + + + + + Ether ( + {" "} + Gwei) + + + + )} + +
+
+ Ether +
+ {hasEIP1559 && } +
+
+ +
+ + Ether ( + Gwei) + + {sendsEthToMiner && ( + + Flashbots + + )} +
+
+ +
+
+ /{" "} + +
+ +
+
+ N/A + {txData.nonce} + + + {txData.transactionIndex} + + + +