Merge branch 'feature/chain-params' into develop
This commit is contained in:
commit
c9debd585b
@ -7,3 +7,5 @@ trustwallet
|
|||||||
!trustwallet/blockchains/ethereum/assets
|
!trustwallet/blockchains/ethereum/assets
|
||||||
!trustwallet/blockchains/polygon/assets
|
!trustwallet/blockchains/polygon/assets
|
||||||
!trustwallet/blockchains/smartchain/assets
|
!trustwallet/blockchains/smartchain/assets
|
||||||
|
chains
|
||||||
|
!chains/_data/chains
|
||||||
|
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -10,3 +10,7 @@
|
|||||||
path = topic0
|
path = topic0
|
||||||
url = https://github.com/wmitsuda/topic0.git
|
url = https://github.com/wmitsuda/topic0.git
|
||||||
ignore = dirty
|
ignore = dirty
|
||||||
|
[submodule "chains"]
|
||||||
|
path = chains
|
||||||
|
url = https://github.com/ethereum-lists/chains.git
|
||||||
|
ignore = dirty
|
||||||
|
@ -24,6 +24,10 @@ FROM alpine:3.15.0 AS topic0builder
|
|||||||
WORKDIR /topic0
|
WORKDIR /topic0
|
||||||
COPY topic0/with_parameter_names /topic0/
|
COPY topic0/with_parameter_names /topic0/
|
||||||
|
|
||||||
|
FROM alpine:3.15.0 AS chainsbuilder
|
||||||
|
WORKDIR /chains
|
||||||
|
COPY chains/_data/chains /chains/
|
||||||
|
|
||||||
# Add brotli module to official nginx image
|
# Add brotli module to official nginx image
|
||||||
# Based on: https://github.com/nginxinc/docker-nginx/tree/master/modules
|
# Based on: https://github.com/nginxinc/docker-nginx/tree/master/modules
|
||||||
FROM nginx:1.21.3-alpine as nginxbuilder
|
FROM nginx:1.21.3-alpine as nginxbuilder
|
||||||
@ -87,6 +91,7 @@ RUN set -ex \
|
|||||||
done \
|
done \
|
||||||
&& rm -rf /tmp/packages
|
&& rm -rf /tmp/packages
|
||||||
RUN apk update && apk add jq
|
RUN apk update && apk add jq
|
||||||
|
COPY --from=chainsbuilder /chains /usr/share/nginx/html/chains/
|
||||||
COPY --from=topic0builder /topic0 /usr/share/nginx/html/topic0/
|
COPY --from=topic0builder /topic0 /usr/share/nginx/html/topic0/
|
||||||
COPY --from=fourbytesbuilder /signatures /usr/share/nginx/html/signatures/
|
COPY --from=fourbytesbuilder /signatures /usr/share/nginx/html/signatures/
|
||||||
COPY --from=logobuilder /assets /usr/share/nginx/html/assets/
|
COPY --from=logobuilder /assets /usr/share/nginx/html/assets/
|
||||||
|
1
chains
Submodule
1
chains
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit af79eb7387b2a4f747bf31cb318d4f1db43c4d84
|
@ -113,6 +113,40 @@ server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /chains {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
expires 30d;
|
||||||
|
|
||||||
|
# Base on: https://michielkalkman.com/snippets/nginx-cors-open-configuration/
|
||||||
|
if ($request_method = 'OPTIONS') {
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
|
#
|
||||||
|
# Om nom nom cookies
|
||||||
|
#
|
||||||
|
add_header 'Access-Control-Allow-Credentials' 'true';
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
|
||||||
|
|
||||||
|
#
|
||||||
|
# Custom headers and headers various browsers *should* be OK with but aren't
|
||||||
|
#
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
|
||||||
|
|
||||||
|
#
|
||||||
|
# Tell client that this pre-flight info is valid for 20 days
|
||||||
|
#
|
||||||
|
add_header 'Access-Control-Max-Age' 1728000;
|
||||||
|
add_header 'Content-Type' 'text/plain charset=UTF-8';
|
||||||
|
add_header 'Content-Length' 0;
|
||||||
|
return 204;
|
||||||
|
}
|
||||||
|
if ($request_method = 'GET') {
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||||
|
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html;
|
index index.html;
|
||||||
|
@ -52,8 +52,8 @@
|
|||||||
"test": "craco test",
|
"test": "craco test",
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject",
|
||||||
"source-map-explorer": "source-map-explorer build/static/js/*.js",
|
"source-map-explorer": "source-map-explorer build/static/js/*.js",
|
||||||
"assets-start": "docker run --rm -p 3001:80 --name otterscan-assets -d -v$(pwd)/4bytes/signatures:/usr/share/nginx/html/signatures/ -v$(pwd)/trustwallet/blockchains/ethereum/assets:/usr/share/nginx/html/assets/1 -v$(pwd)/topic0/with_parameter_names:/usr/share/nginx/html/topic0/ -v$(pwd)/nginx/nginx.conf:/etc/nginx/nginx.conf -v$(pwd)/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf nginx:1.21.1-alpine",
|
"assets-start": "docker run --rm -p 3001:80 --name otterscan-assets -d -v$(pwd)/4bytes/signatures:/usr/share/nginx/html/signatures/ -v$(pwd)/trustwallet/blockchains/ethereum/assets:/usr/share/nginx/html/assets/1 -v$(pwd)/topic0/with_parameter_names:/usr/share/nginx/html/topic0/ -v$(pwd)/chains/_data/chains:/usr/share/nginx/html/chains/ -v$(pwd)/nginx/nginx.conf:/etc/nginx/nginx.conf -v$(pwd)/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf nginx:1.21.1-alpine",
|
||||||
"assets-start-with-param-names": "docker run --rm -p 3001:80 --name otterscan-assets -d -v$(pwd)/4bytes/with_parameter_names:/usr/share/nginx/html/signatures/ -v$(pwd)/trustwallet/blockchains/ethereum/assets:/usr/share/nginx/html/assets/1 -v$(pwd)/topic0/with_parameter_names:/usr/share/nginx/html/topic0/ -v$(pwd)/nginx/nginx.conf:/etc/nginx/nginx.conf -v$(pwd)/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf nginx:1.21.1-alpine",
|
"assets-start-with-param-names": "docker run --rm -p 3001:80 --name otterscan-assets -d -v$(pwd)/4bytes/with_parameter_names:/usr/share/nginx/html/signatures/ -v$(pwd)/trustwallet/blockchains/ethereum/assets:/usr/share/nginx/html/assets/1 -v$(pwd)/topic0/with_parameter_names:/usr/share/nginx/html/topic0/ -v$(pwd)/chains/_data/chains:/usr/share/nginx/html/chains/ -v$(pwd)/nginx/nginx.conf:/etc/nginx/nginx.conf -v$(pwd)/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf nginx:1.21.1-alpine",
|
||||||
"assets-stop": "docker stop otterscan-assets",
|
"assets-stop": "docker stop otterscan-assets",
|
||||||
"docker-build": "DOCKER_BUILDKIT=1 docker build -t otterscan -f Dockerfile .",
|
"docker-build": "DOCKER_BUILDKIT=1 docker build -t otterscan -f Dockerfile .",
|
||||||
"docker-start": "docker run --rm -p 5000:80 --name otterscan -d otterscan",
|
"docker-start": "docker run --rm -p 5000:80 --name otterscan -d otterscan",
|
||||||
|
56
src/App.tsx
56
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, useChainInfoFromMetadataFile } from "./useChainInfo";
|
||||||
|
|
||||||
const Block = React.lazy(
|
const Block = React.lazy(
|
||||||
() => import(/* webpackChunkName: "block", webpackPrefetch: true */ "./Block")
|
() => import(/* webpackChunkName: "block", webpackPrefetch: true */ "./Block")
|
||||||
@ -40,39 +41,46 @@ const PageNotFound = React.lazy(
|
|||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const runtime = useRuntime();
|
const runtime = useRuntime();
|
||||||
|
const chainInfo = useChainInfoFromMetadataFile(runtime);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={null}>
|
<Suspense fallback={null}>
|
||||||
{runtime.connStatus !== ConnectionStatus.CONNECTED ? (
|
{runtime.connStatus !== ConnectionStatus.CONNECTED ||
|
||||||
|
chainInfo === undefined ? (
|
||||||
<ConnectionErrorPanel
|
<ConnectionErrorPanel
|
||||||
connStatus={runtime.connStatus}
|
connStatus={runtime.connStatus}
|
||||||
config={runtime.config}
|
config={runtime.config}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<RuntimeContext.Provider value={runtime}>
|
<RuntimeContext.Provider value={runtime}>
|
||||||
<div className="h-screen flex flex-col">
|
<ChainInfoContext.Provider value={chainInfo}>
|
||||||
<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>
|
||||||
|
@ -24,12 +24,7 @@ const Trace: React.FC<TraceProps> = ({ txData }) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="ml-5 space-y-3 self-stretch">
|
<div className="ml-5 space-y-3 self-stretch">
|
||||||
{traces.map((t, i, a) => (
|
{traces.map((t, i, a) => (
|
||||||
<TraceItem
|
<TraceItem key={i} t={t} last={i === a.length - 1} />
|
||||||
key={i}
|
|
||||||
t={t}
|
|
||||||
last={i === a.length - 1}
|
|
||||||
txData={txData}
|
|
||||||
/>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
@ -12,14 +12,14 @@ import {
|
|||||||
use4Bytes,
|
use4Bytes,
|
||||||
useTransactionDescription,
|
useTransactionDescription,
|
||||||
} from "../use4Bytes";
|
} from "../use4Bytes";
|
||||||
import { TransactionData } from "../types";
|
import { useChainInfo } from "../useChainInfo";
|
||||||
|
|
||||||
type TraceInputProps = {
|
type TraceInputProps = {
|
||||||
t: TraceEntry;
|
t: TraceEntry;
|
||||||
txData: TransactionData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const TraceInput: React.FC<TraceInputProps> = ({ t, txData }) => {
|
const TraceInput: React.FC<TraceInputProps> = ({ t }) => {
|
||||||
|
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 +57,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">
|
||||||
|
@ -5,15 +5,13 @@ import { faMinusSquare } from "@fortawesome/free-regular-svg-icons/faMinusSquare
|
|||||||
import { Switch } from "@headlessui/react";
|
import { Switch } from "@headlessui/react";
|
||||||
import { TraceGroup } from "../useErigonHooks";
|
import { TraceGroup } from "../useErigonHooks";
|
||||||
import TraceInput from "./TraceInput";
|
import TraceInput from "./TraceInput";
|
||||||
import { TransactionData } from "../types";
|
|
||||||
|
|
||||||
type TraceItemProps = {
|
type TraceItemProps = {
|
||||||
t: TraceGroup;
|
t: TraceGroup;
|
||||||
last: boolean;
|
last: boolean;
|
||||||
txData: TransactionData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const TraceItem: React.FC<TraceItemProps> = ({ t, last, txData }) => {
|
const TraceItem: React.FC<TraceItemProps> = ({ t, last }) => {
|
||||||
const [expanded, setExpanded] = useState<boolean>(true);
|
const [expanded, setExpanded] = useState<boolean>(true);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -35,7 +33,7 @@ const TraceItem: React.FC<TraceItemProps> = ({ t, last, txData }) => {
|
|||||||
/>
|
/>
|
||||||
</Switch>
|
</Switch>
|
||||||
)}
|
)}
|
||||||
<TraceInput t={t} txData={txData} />
|
<TraceInput t={t} />
|
||||||
</div>
|
</div>
|
||||||
{t.children && (
|
{t.children && (
|
||||||
<div
|
<div
|
||||||
@ -43,7 +41,7 @@ const TraceItem: React.FC<TraceItemProps> = ({ t, last, txData }) => {
|
|||||||
expanded ? "" : "hidden"
|
expanded ? "" : "hidden"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<TraceChildren c={t.children} txData={txData} />
|
<TraceChildren c={t.children} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
@ -52,19 +50,16 @@ const TraceItem: React.FC<TraceItemProps> = ({ t, last, txData }) => {
|
|||||||
|
|
||||||
type TraceChildrenProps = {
|
type TraceChildrenProps = {
|
||||||
c: TraceGroup[];
|
c: TraceGroup[];
|
||||||
txData: TransactionData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const TraceChildren: React.FC<TraceChildrenProps> = React.memo(
|
const TraceChildren: React.FC<TraceChildrenProps> = React.memo(({ c }) => {
|
||||||
({ c, txData }) => {
|
return (
|
||||||
return (
|
<>
|
||||||
<>
|
{c.map((tc, i, a) => (
|
||||||
{c.map((tc, i, a) => (
|
<TraceItem key={i} t={tc} last={i === a.length - 1} />
|
||||||
<TraceItem key={i} t={tc} last={i === a.length - 1} txData={txData} />
|
))}
|
||||||
))}
|
</>
|
||||||
</>
|
);
|
||||||
);
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
export default TraceItem;
|
export default TraceItem;
|
||||||
|
@ -15,6 +15,11 @@ export const tokenLogoURL = (
|
|||||||
address: string
|
address: string
|
||||||
): string => `${assetsURLPrefix}/assets/${chainId}/${address}/logo.png`;
|
): string => `${assetsURLPrefix}/assets/${chainId}/${address}/logo.png`;
|
||||||
|
|
||||||
|
export const chainInfoURL = (
|
||||||
|
assetsURLPrefix: string,
|
||||||
|
chainId: number
|
||||||
|
): string => `${assetsURLPrefix}/chains/eip155-${chainId}.json`;
|
||||||
|
|
||||||
export const blockURL = (blockNum: BlockTag) => `/block/${blockNum}`;
|
export const blockURL = (blockNum: BlockTag) => `/block/${blockNum}`;
|
||||||
|
|
||||||
export const blockTxsURL = (blockNum: BlockTag) => `/block/${blockNum}/txs`;
|
export const blockTxsURL = (blockNum: BlockTag) => `/block/${blockNum}/txs`;
|
||||||
|
59
src/useChainInfo.ts
Normal file
59
src/useChainInfo.ts
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import { createContext, useContext, useEffect, useState } from "react";
|
||||||
|
import { chainInfoURL } from "./url";
|
||||||
|
import { OtterscanRuntime } from "./useRuntime";
|
||||||
|
|
||||||
|
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 useChainInfoFromMetadataFile = (
|
||||||
|
runtime: OtterscanRuntime | undefined
|
||||||
|
): ChainInfo | undefined => {
|
||||||
|
const assetsURLPrefix = runtime?.config?.assetsURLPrefix;
|
||||||
|
const chainId = runtime?.provider?.network.chainId;
|
||||||
|
|
||||||
|
const [chainInfo, setChainInfo] = useState<ChainInfo | undefined>(undefined);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (chainId === undefined) {
|
||||||
|
setChainInfo(undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const readChainInfo = async () => {
|
||||||
|
const res = await fetch(chainInfoURL(assetsURLPrefix!, chainId));
|
||||||
|
if (!res.ok) {
|
||||||
|
setChainInfo(defaultChainInfo);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const info = await res.json();
|
||||||
|
|
||||||
|
setChainInfo({
|
||||||
|
nativeName: info.nativeCurrency.name,
|
||||||
|
nativeDecimals: info.nativeCurrency.decimals,
|
||||||
|
nativeSymbol: info.nativeCurrency.symbol,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
readChainInfo();
|
||||||
|
}, [assetsURLPrefix, chainId]);
|
||||||
|
|
||||||
|
return chainInfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useChainInfo = (): ChainInfo => {
|
||||||
|
const chainInfo = useContext(ChainInfoContext);
|
||||||
|
if (chainInfo === undefined) {
|
||||||
|
throw new Error("no chain info");
|
||||||
|
}
|
||||||
|
return chainInfo;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user