- {commify(formatEther(totalReward))} Ether
+ {commify(formatEther(totalReward))} {nativeSymbol}
- {commify(formatEther(block.gasUsed.mul(block.baseFeePerGas!)))} Ether
+ {commify(formatEther(block.gasUsed.mul(block.baseFeePerGas!)))}{" "}
+ {nativeSymbol}
diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx
index f8243f0..e845d5e 100644
--- a/src/transaction/Details.tsx
+++ b/src/transaction/Details.tsx
@@ -46,6 +46,7 @@ import { DevDoc, Metadata, useError, UserDoc } from "../sourcify/useSourcify";
import { RuntimeContext } from "../useRuntime";
import { useContractsMetadata } from "../hooks";
import { useTransactionError } from "../useErigonHooks";
+import { useChainInfo } from "../useChainInfo";
type DetailsProps = {
txData: TransactionData;
@@ -86,6 +87,7 @@ const Details: React.FC
= ({
const devMethod = txDesc ? devDoc?.methods[txDesc.signature] : undefined;
const { provider } = useContext(RuntimeContext);
+ const { nativeName, nativeSymbol } = useChainInfo();
const addresses = useMemo(() => {
const _addresses: ChecksummedAddress[] = [];
if (txData.to) {
@@ -313,7 +315,7 @@ const Details: React.FC = ({
)}
- Ether{" "}
+ {nativeSymbol}{" "}
{!txData.value.isZero() && ethUSDPrice && (
@@ -336,7 +338,8 @@ const Details: React.FC = ({
{txData.type === 2 && (
<>
- Ether (
+ {" "}
+ {nativeSymbol} (
= ({
Gwei)
- Ether (
+ {nativeSymbol} (
Gwei)
>
@@ -353,7 +356,7 @@ const Details: React.FC = ({
- Ether (
+ {nativeSymbol} (
Gwei)
{sendsEthToMiner && (
@@ -404,7 +407,8 @@ const Details: React.FC
= ({
- Ether{" "}
+ {" "}
+ {nativeSymbol}{" "}
{ethUSDPrice && (
= ({
{hasEIP1559 && }
-
+
>
diff --git a/src/transaction/RewardSplit.tsx b/src/transaction/RewardSplit.tsx
index 7d35a7e..d6e47b3 100644
--- a/src/transaction/RewardSplit.tsx
+++ b/src/transaction/RewardSplit.tsx
@@ -3,14 +3,16 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faBurn } from "@fortawesome/free-solid-svg-icons/faBurn";
import { faCoins } from "@fortawesome/free-solid-svg-icons/faCoins";
import FormattedBalance from "../components/FormattedBalance";
-import { TransactionData } from "../types";
import PercentageGauge from "../components/PercentageGauge";
+import { TransactionData } from "../types";
+import { useChainInfo } from "../useChainInfo";
type RewardSplitProps = {
txData: TransactionData;
};
const RewardSplit: React.FC = ({ txData }) => {
+ const { nativeSymbol } = useChainInfo();
const paidFees = txData.gasPrice.mul(txData.confirmedData!.gasUsed);
const burntFees = txData.confirmedData!.blockBaseFeePerGas!.mul(
txData.confirmedData!.gasUsed
@@ -39,7 +41,7 @@ const RewardSplit: React.FC = ({ txData }) => {
{" "}
- Ether
+ {nativeSymbol}
@@ -55,7 +57,7 @@ const RewardSplit: React.FC = ({ txData }) => {
- Ether
+ {nativeSymbol}
diff --git a/src/transaction/TraceInput.tsx b/src/transaction/TraceInput.tsx
index 7b917ff..2ae54e9 100644
--- a/src/transaction/TraceInput.tsx
+++ b/src/transaction/TraceInput.tsx
@@ -12,6 +12,7 @@ import {
use4Bytes,
useTransactionDescription,
} from "../use4Bytes";
+import { useChainInfo } from "../useChainInfo";
import { TransactionData } from "../types";
type TraceInputProps = {
@@ -20,6 +21,7 @@ type TraceInputProps = {
};
const TraceInput: React.FC = ({ t, txData }) => {
+ const { nativeSymbol } = useChainInfo();
const raw4Bytes = extract4Bytes(t.input);
const fourBytes = use4Bytes(raw4Bytes);
const sigText =
@@ -57,7 +59,9 @@ const TraceInput: React.FC = ({ t, txData }) => {
{t.value && !t.value.isZero() && (
- {"{"}value: ETH{"}"}
+ {"{"}value: {" "}
+ {nativeSymbol}
+ {"}"}
)}
diff --git a/src/useChainInfo.ts b/src/useChainInfo.ts
new file mode 100644
index 0000000..f1de917
--- /dev/null
+++ b/src/useChainInfo.ts
@@ -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(undefined);
+
+export const useChainInfo = (): ChainInfo => {
+ const chainInfo = useContext(ChainInfoContext);
+ if (chainInfo === undefined) {
+ throw new Error("no chain info");
+ }
+ return chainInfo;
+};