Parameterize components by chain native name/token symbol/decimals
This commit is contained in:
parent
f14e8590d1
commit
4b85cc8cd5
52
src/App.tsx
52
src/App.tsx
|
@ -7,6 +7,7 @@ import ConnectionErrorPanel from "./ConnectionErrorPanel";
|
||||||
import Footer from "./Footer";
|
import Footer from "./Footer";
|
||||||
import { ConnectionStatus } from "./types";
|
import { ConnectionStatus } from "./types";
|
||||||
import { RuntimeContext, useRuntime } from "./useRuntime";
|
import { RuntimeContext, useRuntime } from "./useRuntime";
|
||||||
|
import { ChainInfoContext, defaultChainInfo } from "./useChainInfo";
|
||||||
|
|
||||||
const Block = React.lazy(
|
const Block = React.lazy(
|
||||||
() => import(/* webpackChunkName: "block", webpackPrefetch: true */ "./Block")
|
() => import(/* webpackChunkName: "block", webpackPrefetch: true */ "./Block")
|
||||||
|
@ -50,29 +51,34 @@ const App = () => {
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<RuntimeContext.Provider value={runtime}>
|
<RuntimeContext.Provider value={runtime}>
|
||||||
<div className="h-screen flex flex-col">
|
<ChainInfoContext.Provider value={defaultChainInfo}>
|
||||||
<WarningHeader />
|
<div className="h-screen flex flex-col">
|
||||||
<Router>
|
<WarningHeader />
|
||||||
<Routes>
|
<Router>
|
||||||
<Route index element={<Home />} />
|
<Routes>
|
||||||
<Route path="/special/london" element={<London />} />
|
<Route index element={<Home />} />
|
||||||
<Route path="*" element={<Main />}>
|
<Route path="/special/london" element={<London />} />
|
||||||
<Route path="block/:blockNumberOrHash" element={<Block />} />
|
<Route path="*" element={<Main />}>
|
||||||
<Route
|
<Route
|
||||||
path="block/:blockNumber/txs"
|
path="block/:blockNumberOrHash"
|
||||||
element={<BlockTransactions />}
|
element={<Block />}
|
||||||
/>
|
/>
|
||||||
<Route path="tx/:txhash/*" element={<Transaction />} />
|
<Route
|
||||||
<Route
|
path="block/:blockNumber/txs"
|
||||||
path="address/:addressOrName/*"
|
element={<BlockTransactions />}
|
||||||
element={<Address />}
|
/>
|
||||||
/>
|
<Route path="tx/:txhash/*" element={<Transaction />} />
|
||||||
<Route path="*" element={<PageNotFound />} />
|
<Route
|
||||||
</Route>
|
path="address/:addressOrName/*"
|
||||||
</Routes>
|
element={<Address />}
|
||||||
</Router>
|
/>
|
||||||
<Footer />
|
<Route path="*" element={<PageNotFound />} />
|
||||||
</div>
|
</Route>
|
||||||
|
</Routes>
|
||||||
|
</Router>
|
||||||
|
<Footer />
|
||||||
|
</div>
|
||||||
|
</ChainInfoContext.Provider>
|
||||||
</RuntimeContext.Provider>
|
</RuntimeContext.Provider>
|
||||||
)}
|
)}
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|
|
@ -9,6 +9,7 @@ import StandardFrame from "./StandardFrame";
|
||||||
import StandardSubtitle from "./StandardSubtitle";
|
import StandardSubtitle from "./StandardSubtitle";
|
||||||
import NavBlock from "./block/NavBlock";
|
import NavBlock from "./block/NavBlock";
|
||||||
import ContentFrame from "./ContentFrame";
|
import ContentFrame from "./ContentFrame";
|
||||||
|
import BlockNotFound from "./components/BlockNotFound";
|
||||||
import InfoRow from "./components/InfoRow";
|
import InfoRow from "./components/InfoRow";
|
||||||
import Timestamp from "./components/Timestamp";
|
import Timestamp from "./components/Timestamp";
|
||||||
import GasValue from "./components/GasValue";
|
import GasValue from "./components/GasValue";
|
||||||
|
@ -25,7 +26,7 @@ import { useLatestBlockNumber } from "./useLatestBlock";
|
||||||
import { blockTxsURL } from "./url";
|
import { blockTxsURL } from "./url";
|
||||||
import { useBlockData } from "./useErigonHooks";
|
import { useBlockData } from "./useErigonHooks";
|
||||||
import { useETHUSDOracle } from "./usePriceOracle";
|
import { useETHUSDOracle } from "./usePriceOracle";
|
||||||
import BlockNotFound from "./components/BlockNotFound";
|
import { useChainInfo } from "./useChainInfo";
|
||||||
|
|
||||||
const Block: React.FC = () => {
|
const Block: React.FC = () => {
|
||||||
const { provider } = useContext(RuntimeContext);
|
const { provider } = useContext(RuntimeContext);
|
||||||
|
@ -33,6 +34,7 @@ const Block: React.FC = () => {
|
||||||
if (blockNumberOrHash === undefined) {
|
if (blockNumberOrHash === undefined) {
|
||||||
throw new Error("blockNumberOrHash couldn't be undefined here");
|
throw new Error("blockNumberOrHash couldn't be undefined here");
|
||||||
}
|
}
|
||||||
|
const { nativeName, nativeSymbol } = useChainInfo();
|
||||||
|
|
||||||
const block = useBlockData(provider, blockNumberOrHash);
|
const block = useBlockData(provider, blockNumberOrHash);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -144,7 +146,7 @@ const Block: React.FC = () => {
|
||||||
<span className="line-through">
|
<span className="line-through">
|
||||||
<FormattedBalance value={burntFees} />
|
<FormattedBalance value={burntFees} />
|
||||||
</span>{" "}
|
</span>{" "}
|
||||||
Ether
|
{nativeSymbol}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -163,7 +165,7 @@ const Block: React.FC = () => {
|
||||||
{extraStr} (Hex:{" "}
|
{extraStr} (Hex:{" "}
|
||||||
<span className="font-data break-all">{block.extraData}</span>)
|
<span className="font-data break-all">{block.extraData}</span>)
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow title="Ether Price">
|
<InfoRow title={`${nativeName} Price`}>
|
||||||
<USDValue value={blockETHUSDPrice} />
|
<USDValue value={blockETHUSDPrice} />
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow title="Difficult">
|
<InfoRow title="Difficult">
|
||||||
|
|
|
@ -7,12 +7,14 @@ import AggregatorV3Interface from "@chainlink/contracts/abi/v0.8/AggregatorV3Int
|
||||||
import { RuntimeContext } from "./useRuntime";
|
import { RuntimeContext } from "./useRuntime";
|
||||||
import { formatValue } from "./components/formatter";
|
import { formatValue } from "./components/formatter";
|
||||||
import { useLatestBlock } from "./useLatestBlock";
|
import { useLatestBlock } from "./useLatestBlock";
|
||||||
|
import { useChainInfo } from "./useChainInfo";
|
||||||
|
|
||||||
const ETH_FEED_DECIMALS = 8;
|
const ETH_FEED_DECIMALS = 8;
|
||||||
|
|
||||||
// TODO: reduce duplication with useETHUSDOracle
|
// TODO: reduce duplication with useETHUSDOracle
|
||||||
const PriceBox: React.FC = () => {
|
const PriceBox: React.FC = () => {
|
||||||
const { provider } = useContext(RuntimeContext);
|
const { provider } = useContext(RuntimeContext);
|
||||||
|
const { nativeSymbol } = useChainInfo();
|
||||||
const latestBlock = useLatestBlock(provider);
|
const latestBlock = useLatestBlock(provider);
|
||||||
|
|
||||||
const maybeOutdated: boolean =
|
const maybeOutdated: boolean =
|
||||||
|
@ -80,9 +82,9 @@ const PriceBox: React.FC = () => {
|
||||||
} font-sans text-xs text-gray-800`}
|
} font-sans text-xs text-gray-800`}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
title={`ETH/USD last updated at: ${latestPriceTimestamp?.toString()}`}
|
title={`${nativeSymbol}/USD last updated at: ${latestPriceTimestamp?.toString()}`}
|
||||||
>
|
>
|
||||||
Eth: $<span className="font-balance">{latestPrice}</span>
|
{nativeSymbol}: $<span className="font-balance">{latestPrice}</span>
|
||||||
</span>
|
</span>
|
||||||
{latestGasData && (
|
{latestGasData && (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -4,8 +4,9 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { faAngleRight } from "@fortawesome/free-solid-svg-icons/faAngleRight";
|
import { faAngleRight } from "@fortawesome/free-solid-svg-icons/faAngleRight";
|
||||||
import AddressHighlighter from "./AddressHighlighter";
|
import AddressHighlighter from "./AddressHighlighter";
|
||||||
import DecoratedAddressLink from "./DecoratedAddressLink";
|
import DecoratedAddressLink from "./DecoratedAddressLink";
|
||||||
import { TransactionData, InternalOperation } from "../types";
|
|
||||||
import TransactionAddress from "./TransactionAddress";
|
import TransactionAddress from "./TransactionAddress";
|
||||||
|
import { useChainInfo } from "../useChainInfo";
|
||||||
|
import { TransactionData, InternalOperation } from "../types";
|
||||||
|
|
||||||
type InternalSelfDestructProps = {
|
type InternalSelfDestructProps = {
|
||||||
txData: TransactionData;
|
txData: TransactionData;
|
||||||
|
@ -16,6 +17,7 @@ const InternalSelfDestruct: React.FC<InternalSelfDestructProps> = ({
|
||||||
txData,
|
txData,
|
||||||
internalOp,
|
internalOp,
|
||||||
}) => {
|
}) => {
|
||||||
|
const { nativeSymbol } = useChainInfo();
|
||||||
const toMiner =
|
const toMiner =
|
||||||
txData.confirmedData?.miner !== undefined &&
|
txData.confirmedData?.miner !== undefined &&
|
||||||
internalOp.to === txData.confirmedData.miner;
|
internalOp.to === txData.confirmedData.miner;
|
||||||
|
@ -43,7 +45,9 @@ const InternalSelfDestruct: React.FC<InternalSelfDestructProps> = ({
|
||||||
<span className="text-gray-500">
|
<span className="text-gray-500">
|
||||||
<FontAwesomeIcon icon={faAngleRight} size="1x" /> TRANSFER
|
<FontAwesomeIcon icon={faAngleRight} size="1x" /> TRANSFER
|
||||||
</span>
|
</span>
|
||||||
<span>{formatEther(internalOp.value)} Ether</span>
|
<span>
|
||||||
|
{formatEther(internalOp.value)} {nativeSymbol}
|
||||||
|
</span>
|
||||||
<div className="flex items-baseline">
|
<div className="flex items-baseline">
|
||||||
<span className="text-gray-500">To</span>
|
<span className="text-gray-500">To</span>
|
||||||
<AddressHighlighter address={internalOp.to}>
|
<AddressHighlighter address={internalOp.to}>
|
||||||
|
|
|
@ -6,6 +6,7 @@ import AddressHighlighter from "./AddressHighlighter";
|
||||||
import DecoratedAddressLink from "./DecoratedAddressLink";
|
import DecoratedAddressLink from "./DecoratedAddressLink";
|
||||||
import { RuntimeContext } from "../useRuntime";
|
import { RuntimeContext } from "../useRuntime";
|
||||||
import { useHasCode } from "../useErigonHooks";
|
import { useHasCode } from "../useErigonHooks";
|
||||||
|
import { useChainInfo } from "../useChainInfo";
|
||||||
import { TransactionData, InternalOperation } from "../types";
|
import { TransactionData, InternalOperation } from "../types";
|
||||||
|
|
||||||
type InternalTransferProps = {
|
type InternalTransferProps = {
|
||||||
|
@ -17,6 +18,7 @@ const InternalTransfer: React.FC<InternalTransferProps> = ({
|
||||||
txData,
|
txData,
|
||||||
internalOp,
|
internalOp,
|
||||||
}) => {
|
}) => {
|
||||||
|
const { nativeSymbol } = useChainInfo();
|
||||||
const fromMiner =
|
const fromMiner =
|
||||||
txData.confirmedData?.miner !== undefined &&
|
txData.confirmedData?.miner !== undefined &&
|
||||||
internalOp.from === txData.confirmedData.miner;
|
internalOp.from === txData.confirmedData.miner;
|
||||||
|
@ -41,7 +43,9 @@ const InternalTransfer: React.FC<InternalTransferProps> = ({
|
||||||
<span className="text-gray-500">
|
<span className="text-gray-500">
|
||||||
<FontAwesomeIcon icon={faAngleRight} size="1x" /> TRANSFER
|
<FontAwesomeIcon icon={faAngleRight} size="1x" /> TRANSFER
|
||||||
</span>
|
</span>
|
||||||
<span>{formatEther(internalOp.value)} Ether</span>
|
<span>
|
||||||
|
{formatEther(internalOp.value)} {nativeSymbol}
|
||||||
|
</span>
|
||||||
<div className="flex items-baseline">
|
<div className="flex items-baseline">
|
||||||
<span className="text-gray-500">From</span>
|
<span className="text-gray-500">From</span>
|
||||||
<AddressHighlighter address={internalOp.from}>
|
<AddressHighlighter address={internalOp.from}>
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { BigNumber } from "@ethersproject/bignumber";
|
import { BigNumber } from "@ethersproject/bignumber";
|
||||||
|
import { useChainInfo } from "../useChainInfo";
|
||||||
import { formatValue } from "./formatter";
|
import { formatValue } from "./formatter";
|
||||||
|
|
||||||
type TransactionValueProps = {
|
type TransactionValueProps = {
|
||||||
value: BigNumber;
|
value: BigNumber;
|
||||||
decimals?: number;
|
|
||||||
hideUnit?: boolean;
|
hideUnit?: boolean;
|
||||||
unitName?: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,19 +20,18 @@ type TransactionValueProps = {
|
||||||
*/
|
*/
|
||||||
const TransactionValue: React.FC<TransactionValueProps> = ({
|
const TransactionValue: React.FC<TransactionValueProps> = ({
|
||||||
value,
|
value,
|
||||||
decimals = 18,
|
|
||||||
hideUnit,
|
hideUnit,
|
||||||
unitName = "ETH",
|
|
||||||
}) => {
|
}) => {
|
||||||
const formattedValue = formatValue(value, decimals);
|
const { nativeSymbol, nativeDecimals } = useChainInfo();
|
||||||
|
const formattedValue = formatValue(value, nativeDecimals);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={`text-sm ${value.isZero() ? "text-gray-400" : ""}`}
|
className={`text-sm ${value.isZero() ? "text-gray-400" : ""}`}
|
||||||
title={`${formattedValue} ${unitName}`}
|
title={`${formattedValue} ${nativeSymbol}`}
|
||||||
>
|
>
|
||||||
<span className={`font-balance`}>{formattedValue}</span>
|
<span className={`font-balance`}>{formattedValue}</span>
|
||||||
{!hideUnit && ` ${unitName}`}
|
{!hideUnit && ` ${nativeSymbol}`}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { BigNumber, FixedNumber } from "@ethersproject/bignumber";
|
import { BigNumber, FixedNumber } from "@ethersproject/bignumber";
|
||||||
import { commify } from "@ethersproject/units";
|
import { commify } from "@ethersproject/units";
|
||||||
|
import { useChainInfo } from "../useChainInfo";
|
||||||
|
|
||||||
const ETH_FEED_DECIMALS = 8;
|
const ETH_FEED_DECIMALS = 8;
|
||||||
|
|
||||||
|
@ -8,22 +9,28 @@ type USDValueProps = {
|
||||||
value: BigNumber | undefined;
|
value: BigNumber | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const USDValue: React.FC<USDValueProps> = ({ value }) => (
|
const USDValue: React.FC<USDValueProps> = ({ value }) => {
|
||||||
<span className="text-sm">
|
const { nativeSymbol } = useChainInfo();
|
||||||
{value ? (
|
|
||||||
<>
|
return (
|
||||||
$
|
<span className="text-sm">
|
||||||
<span className="font-balance">
|
{value ? (
|
||||||
{commify(
|
<>
|
||||||
FixedNumber.fromValue(value, ETH_FEED_DECIMALS).round(2).toString()
|
$
|
||||||
)}
|
<span className="font-balance">
|
||||||
</span>{" "}
|
{commify(
|
||||||
<span className="text-xs text-gray-500">/ ETH</span>
|
FixedNumber.fromValue(value, ETH_FEED_DECIMALS)
|
||||||
</>
|
.round(2)
|
||||||
) : (
|
.toString()
|
||||||
"N/A"
|
)}
|
||||||
)}
|
</span>{" "}
|
||||||
</span>
|
<span className="text-xs text-gray-500">/ {nativeSymbol}</span>
|
||||||
);
|
</>
|
||||||
|
) : (
|
||||||
|
"N/A"
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default React.memo(USDValue);
|
export default React.memo(USDValue);
|
||||||
|
|
|
@ -3,8 +3,9 @@ import { FixedNumber } from "@ethersproject/bignumber";
|
||||||
import { commify, formatEther } from "@ethersproject/units";
|
import { commify, formatEther } from "@ethersproject/units";
|
||||||
import BlockLink from "../../components/BlockLink";
|
import BlockLink from "../../components/BlockLink";
|
||||||
import TimestampAge from "../../components/TimestampAge";
|
import TimestampAge from "../../components/TimestampAge";
|
||||||
import { ExtendedBlock } from "../../useErigonHooks";
|
|
||||||
import Blip from "./Blip";
|
import Blip from "./Blip";
|
||||||
|
import { ExtendedBlock } from "../../useErigonHooks";
|
||||||
|
import { useChainInfo } from "../../useChainInfo";
|
||||||
|
|
||||||
const ELASTICITY_MULTIPLIER = 2;
|
const ELASTICITY_MULTIPLIER = 2;
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ type BlockRowProps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const BlockRow: React.FC<BlockRowProps> = ({ now, block, baseFeeDelta }) => {
|
const BlockRow: React.FC<BlockRowProps> = ({ now, block, baseFeeDelta }) => {
|
||||||
|
const { nativeSymbol } = useChainInfo();
|
||||||
const gasTarget = block.gasLimit.div(ELASTICITY_MULTIPLIER);
|
const gasTarget = block.gasLimit.div(ELASTICITY_MULTIPLIER);
|
||||||
const burntFees =
|
const burntFees =
|
||||||
block?.baseFeePerGas && block.baseFeePerGas.mul(block.gasUsed);
|
block?.baseFeePerGas && block.baseFeePerGas.mul(block.gasUsed);
|
||||||
|
@ -53,10 +55,11 @@ const BlockRow: React.FC<BlockRowProps> = ({ now, block, baseFeeDelta }) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-right col-span-2">
|
<div className="text-right col-span-2">
|
||||||
{commify(formatEther(totalReward))} Ether
|
{commify(formatEther(totalReward))} {nativeSymbol}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-right col-span-2 line-through text-orange-500">
|
<div className="text-right col-span-2 line-through text-orange-500">
|
||||||
{commify(formatEther(block.gasUsed.mul(block.baseFeePerGas!)))} Ether
|
{commify(formatEther(block.gasUsed.mul(block.baseFeePerGas!)))}{" "}
|
||||||
|
{nativeSymbol}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-right text-gray-400">
|
<div className="text-right text-gray-400">
|
||||||
<TimestampAge now={now / 1000} timestamp={block.timestamp} />
|
<TimestampAge now={now / 1000} timestamp={block.timestamp} />
|
||||||
|
|
|
@ -46,6 +46,7 @@ import { DevDoc, Metadata, useError, UserDoc } from "../sourcify/useSourcify";
|
||||||
import { RuntimeContext } from "../useRuntime";
|
import { RuntimeContext } from "../useRuntime";
|
||||||
import { useContractsMetadata } from "../hooks";
|
import { useContractsMetadata } from "../hooks";
|
||||||
import { useTransactionError } from "../useErigonHooks";
|
import { useTransactionError } from "../useErigonHooks";
|
||||||
|
import { useChainInfo } from "../useChainInfo";
|
||||||
|
|
||||||
type DetailsProps = {
|
type DetailsProps = {
|
||||||
txData: TransactionData;
|
txData: TransactionData;
|
||||||
|
@ -86,6 +87,7 @@ const Details: React.FC<DetailsProps> = ({
|
||||||
const devMethod = txDesc ? devDoc?.methods[txDesc.signature] : undefined;
|
const devMethod = txDesc ? devDoc?.methods[txDesc.signature] : undefined;
|
||||||
|
|
||||||
const { provider } = useContext(RuntimeContext);
|
const { provider } = useContext(RuntimeContext);
|
||||||
|
const { nativeName, nativeSymbol } = useChainInfo();
|
||||||
const addresses = useMemo(() => {
|
const addresses = useMemo(() => {
|
||||||
const _addresses: ChecksummedAddress[] = [];
|
const _addresses: ChecksummedAddress[] = [];
|
||||||
if (txData.to) {
|
if (txData.to) {
|
||||||
|
@ -313,7 +315,7 @@ const Details: React.FC<DetailsProps> = ({
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
)}
|
)}
|
||||||
<InfoRow title="Value">
|
<InfoRow title="Value">
|
||||||
<FormattedBalance value={txData.value} /> Ether{" "}
|
<FormattedBalance value={txData.value} /> {nativeSymbol}{" "}
|
||||||
{!txData.value.isZero() && ethUSDPrice && (
|
{!txData.value.isZero() && ethUSDPrice && (
|
||||||
<span className="px-2 border-skin-from border rounded-lg bg-skin-from text-skin-from">
|
<span className="px-2 border-skin-from border rounded-lg bg-skin-from text-skin-from">
|
||||||
<ETH2USDValue ethAmount={txData.value} eth2USDValue={ethUSDPrice} />
|
<ETH2USDValue ethAmount={txData.value} eth2USDValue={ethUSDPrice} />
|
||||||
|
@ -336,7 +338,8 @@ const Details: React.FC<DetailsProps> = ({
|
||||||
{txData.type === 2 && (
|
{txData.type === 2 && (
|
||||||
<>
|
<>
|
||||||
<InfoRow title="Max Priority Fee Per Gas">
|
<InfoRow title="Max Priority Fee Per Gas">
|
||||||
<FormattedBalance value={txData.maxPriorityFeePerGas!} /> Ether (
|
<FormattedBalance value={txData.maxPriorityFeePerGas!} />{" "}
|
||||||
|
{nativeSymbol} (
|
||||||
<FormattedBalance
|
<FormattedBalance
|
||||||
value={txData.maxPriorityFeePerGas!}
|
value={txData.maxPriorityFeePerGas!}
|
||||||
decimals={9}
|
decimals={9}
|
||||||
|
@ -344,7 +347,7 @@ const Details: React.FC<DetailsProps> = ({
|
||||||
Gwei)
|
Gwei)
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow title="Max Fee Per Gas">
|
<InfoRow title="Max Fee Per Gas">
|
||||||
<FormattedBalance value={txData.maxFeePerGas!} /> Ether (
|
<FormattedBalance value={txData.maxFeePerGas!} /> {nativeSymbol} (
|
||||||
<FormattedBalance value={txData.maxFeePerGas!} decimals={9} /> Gwei)
|
<FormattedBalance value={txData.maxFeePerGas!} decimals={9} /> Gwei)
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
</>
|
</>
|
||||||
|
@ -353,7 +356,7 @@ const Details: React.FC<DetailsProps> = ({
|
||||||
<InfoRow title="Gas Price">
|
<InfoRow title="Gas Price">
|
||||||
<div className="flex items-baseline space-x-1">
|
<div className="flex items-baseline space-x-1">
|
||||||
<span>
|
<span>
|
||||||
<FormattedBalance value={txData.gasPrice} /> Ether (
|
<FormattedBalance value={txData.gasPrice} /> {nativeSymbol} (
|
||||||
<FormattedBalance value={txData.gasPrice} decimals={9} /> Gwei)
|
<FormattedBalance value={txData.gasPrice} decimals={9} /> Gwei)
|
||||||
</span>
|
</span>
|
||||||
{sendsEthToMiner && (
|
{sendsEthToMiner && (
|
||||||
|
@ -404,7 +407,8 @@ const Details: React.FC<DetailsProps> = ({
|
||||||
<InfoRow title="Transaction Fee">
|
<InfoRow title="Transaction Fee">
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<div>
|
<div>
|
||||||
<FormattedBalance value={txData.confirmedData.fee} /> Ether{" "}
|
<FormattedBalance value={txData.confirmedData.fee} />{" "}
|
||||||
|
{nativeSymbol}{" "}
|
||||||
{ethUSDPrice && (
|
{ethUSDPrice && (
|
||||||
<span className="px-2 border-skin-from border rounded-lg bg-skin-from text-skin-from">
|
<span className="px-2 border-skin-from border rounded-lg bg-skin-from text-skin-from">
|
||||||
<ETH2USDValue
|
<ETH2USDValue
|
||||||
|
@ -417,7 +421,7 @@ const Details: React.FC<DetailsProps> = ({
|
||||||
{hasEIP1559 && <RewardSplit txData={txData} />}
|
{hasEIP1559 && <RewardSplit txData={txData} />}
|
||||||
</div>
|
</div>
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow title="Ether Price">
|
<InfoRow title={`${nativeName} Price`}>
|
||||||
<USDValue value={ethUSDPrice} />
|
<USDValue value={ethUSDPrice} />
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -3,14 +3,16 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { faBurn } from "@fortawesome/free-solid-svg-icons/faBurn";
|
import { faBurn } from "@fortawesome/free-solid-svg-icons/faBurn";
|
||||||
import { faCoins } from "@fortawesome/free-solid-svg-icons/faCoins";
|
import { faCoins } from "@fortawesome/free-solid-svg-icons/faCoins";
|
||||||
import FormattedBalance from "../components/FormattedBalance";
|
import FormattedBalance from "../components/FormattedBalance";
|
||||||
import { TransactionData } from "../types";
|
|
||||||
import PercentageGauge from "../components/PercentageGauge";
|
import PercentageGauge from "../components/PercentageGauge";
|
||||||
|
import { TransactionData } from "../types";
|
||||||
|
import { useChainInfo } from "../useChainInfo";
|
||||||
|
|
||||||
type RewardSplitProps = {
|
type RewardSplitProps = {
|
||||||
txData: TransactionData;
|
txData: TransactionData;
|
||||||
};
|
};
|
||||||
|
|
||||||
const RewardSplit: React.FC<RewardSplitProps> = ({ txData }) => {
|
const RewardSplit: React.FC<RewardSplitProps> = ({ txData }) => {
|
||||||
|
const { nativeSymbol } = useChainInfo();
|
||||||
const paidFees = txData.gasPrice.mul(txData.confirmedData!.gasUsed);
|
const paidFees = txData.gasPrice.mul(txData.confirmedData!.gasUsed);
|
||||||
const burntFees = txData.confirmedData!.blockBaseFeePerGas!.mul(
|
const burntFees = txData.confirmedData!.blockBaseFeePerGas!.mul(
|
||||||
txData.confirmedData!.gasUsed
|
txData.confirmedData!.gasUsed
|
||||||
|
@ -39,7 +41,7 @@ const RewardSplit: React.FC<RewardSplitProps> = ({ txData }) => {
|
||||||
<span className="line-through">
|
<span className="line-through">
|
||||||
<FormattedBalance value={burntFees} />
|
<FormattedBalance value={burntFees} />
|
||||||
</span>{" "}
|
</span>{" "}
|
||||||
Ether
|
{nativeSymbol}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -55,7 +57,7 @@ const RewardSplit: React.FC<RewardSplitProps> = ({ txData }) => {
|
||||||
<FontAwesomeIcon icon={faCoins} size="1x" />
|
<FontAwesomeIcon icon={faCoins} size="1x" />
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<FormattedBalance value={minerReward} /> Ether
|
<FormattedBalance value={minerReward} /> {nativeSymbol}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {
|
||||||
use4Bytes,
|
use4Bytes,
|
||||||
useTransactionDescription,
|
useTransactionDescription,
|
||||||
} from "../use4Bytes";
|
} from "../use4Bytes";
|
||||||
|
import { useChainInfo } from "../useChainInfo";
|
||||||
import { TransactionData } from "../types";
|
import { TransactionData } from "../types";
|
||||||
|
|
||||||
type TraceInputProps = {
|
type TraceInputProps = {
|
||||||
|
@ -20,6 +21,7 @@ type TraceInputProps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const TraceInput: React.FC<TraceInputProps> = ({ t, txData }) => {
|
const TraceInput: React.FC<TraceInputProps> = ({ t, txData }) => {
|
||||||
|
const { nativeSymbol } = useChainInfo();
|
||||||
const raw4Bytes = extract4Bytes(t.input);
|
const raw4Bytes = extract4Bytes(t.input);
|
||||||
const fourBytes = use4Bytes(raw4Bytes);
|
const fourBytes = use4Bytes(raw4Bytes);
|
||||||
const sigText =
|
const sigText =
|
||||||
|
@ -57,7 +59,9 @@ const TraceInput: React.FC<TraceInputProps> = ({ t, txData }) => {
|
||||||
<FunctionSignature callType={t.type} sig={sigText} />
|
<FunctionSignature callType={t.type} sig={sigText} />
|
||||||
{t.value && !t.value.isZero() && (
|
{t.value && !t.value.isZero() && (
|
||||||
<span className="text-red-700 whitespace-nowrap">
|
<span className="text-red-700 whitespace-nowrap">
|
||||||
{"{"}value: <FormattedBalance value={t.value} /> ETH{"}"}
|
{"{"}value: <FormattedBalance value={t.value} />{" "}
|
||||||
|
{nativeSymbol}
|
||||||
|
{"}"}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
<span className="whitespace-nowrap">
|
<span className="whitespace-nowrap">
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { createContext, useContext } from "react";
|
||||||
|
|
||||||
|
export type ChainInfo = {
|
||||||
|
nativeName: string;
|
||||||
|
nativeSymbol: string;
|
||||||
|
nativeDecimals: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const defaultChainInfo: ChainInfo = {
|
||||||
|
nativeName: "Ether",
|
||||||
|
nativeSymbol: "ETH",
|
||||||
|
nativeDecimals: 18,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ChainInfoContext = createContext<ChainInfo | undefined>(undefined);
|
||||||
|
|
||||||
|
export const useChainInfo = (): ChainInfo => {
|
||||||
|
const chainInfo = useContext(ChainInfoContext);
|
||||||
|
if (chainInfo === undefined) {
|
||||||
|
throw new Error("no chain info");
|
||||||
|
}
|
||||||
|
return chainInfo;
|
||||||
|
};
|
Loading…
Reference in New Issue