diff --git a/src/assets/Logo.svg b/src/assets/Logo.svg index 0534c55..2961583 100644 --- a/src/assets/Logo.svg +++ b/src/assets/Logo.svg @@ -1,4 +1,4 @@ - + diff --git a/src/components/appHeader/InfoButton.tsx b/src/components/appHeader/InfoButton.tsx index ecc2d3e..930cc86 100644 --- a/src/components/appHeader/InfoButton.tsx +++ b/src/components/appHeader/InfoButton.tsx @@ -1,10 +1,11 @@ -import React from "react"; +import React, { useState } from "react"; import { CaretDownFill } from "grommet-icons"; import { Box, DropButton, Anchor, Text } from "grommet"; import { useHistory } from "react-router-dom"; export function InfoButton() { const history = useHistory(); + const [isOpen, setIsOpen] = useState(false); return ( } + onClick={() => { + setIsOpen(true); + }} + open={isOpen} dropAlign={{ top: "bottom", right: "right" }} dropContent={ { - e.preventDefault(); + setIsOpen(false); history.push("/hrc20"); }} > @@ -37,9 +41,8 @@ export function InfoButton() { { - e.preventDefault(); + setIsOpen(false); history.push("/hrc721"); }} > @@ -47,9 +50,8 @@ export function InfoButton() { { - e.preventDefault(); + setIsOpen(false); history.push("/hrc1155"); }} > diff --git a/src/components/appHeader/index.tsx b/src/components/appHeader/index.tsx index 58805cd..d04f155 100644 --- a/src/components/appHeader/index.tsx +++ b/src/components/appHeader/index.tsx @@ -27,7 +27,10 @@ const HeaderLine = (props: any) => { }; const ProjectName = styled(Box)` - margin-left: 3px; + margin-top: 7px; + margin-left: 7px; + font-size: 1.2em; + line-height: 0.7em; `; export function AppHeader(props: { style: CSSProperties }) { @@ -50,17 +53,11 @@ export function AppHeader(props: { style: CSSProperties }) { > - - Harmony Block Explorer{" "} - - beta - + + Harmony + Block Explorer - diff --git a/src/components/metrics/index.tsx b/src/components/metrics/index.tsx index 8e9395c..6c8ff40 100644 --- a/src/components/metrics/index.tsx +++ b/src/components/metrics/index.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from "react"; -import { Box, Text, DataChart, Spinner } from "grommet"; -import { BasePage } from "src/components/ui"; +import { Box, Text, DataChart, Spinner, Tip } from "grommet"; +import { BasePage, TipContent } from "src/components/ui"; import { formatNumber } from "src/components/ui/utils"; import { LatencyIcon } from "src/components/ui/icons"; import dayjs from "dayjs"; @@ -13,7 +13,10 @@ import { getTransactionCountLast14Days } from "src/api/client"; import { getCount } from "src/api/client"; -export const Metrics = (params: { latency: number }) => { +export const Metrics = (params: { + latency: number; + latencyPerBlock: number[]; +}) => { const isLessLaptop = useMediaQuery({ maxDeviceWidth: "852px" }); const isLessTablet = useMediaQuery({ maxDeviceWidth: breakpoints.tablet }); const isLessMobileM = useMediaQuery({ maxDeviceWidth: "468px" }); @@ -58,7 +61,10 @@ export const Metrics = (params: { latency: number }) => { > {!isLessMobileM && } - + {isLessLaptop && ( - $ {(+lastPrice).toFixed(2)} + $ {(+lastPrice).toFixed(4)} (""); + const availableShards = (process.env.REACT_APP_AVAILABLE_SHARDS as string) + .split(",") + .map((t) => +t); + useEffect(() => { let tId = 0; const getRes = async () => { try { - let res = await getCount([0, "transactions"]); - setCount(res.count); + let res = await Promise.all( + availableShards.map((shardNumber) => + getCount([shardNumber, "transactions"]) + ) + ); + setCount( + res + .reduce((prev, cur) => { + prev = prev + +cur.count; + return prev; + }, 0) + .toString() + ); } catch (err) { console.log(err); } @@ -146,7 +167,7 @@ function TransactionsCount() { - {"TRANSACTIONS COUNT"} + {"TRANSACTIONS VOLUME"} {formatNumber(+count)} @@ -180,7 +201,7 @@ function ShardCount() { ); } -function BlockLatency(params: { latency: number }) { +function BlockLatency(params: { latency: number; latencyPerBlock: number[] }) { return ( {"BLOCK LATENCY"} - - {params.latency.toFixed(2)}s - + + {params.latencyPerBlock.map((item, index) => ( + + Shard {index} + {item.toFixed(2)}s + + ))} + + } + /> + } + plain + > + + {params.latency.toFixed(2)}s + + ); diff --git a/src/components/ui/Address.tsx b/src/components/ui/Address.tsx index c8ebda6..309f53c 100644 --- a/src/components/ui/Address.tsx +++ b/src/components/ui/Address.tsx @@ -24,6 +24,7 @@ interface IAddress { color?: string; displayHash?: boolean; noHistoryPush?: boolean; + hideCopyBtn?: boolean; } export const Address = (props: IAddress) => { @@ -34,6 +35,7 @@ export const Address = (props: IAddress) => { type = "address", color = "brand", displayHash, + hideCopyBtn = false, } = props; const history = useHistory(); const ERC20Map = useERC20Pool(); @@ -77,26 +79,28 @@ export const Address = (props: IAddress) => { return (
- { - e.preventDefault(); - e.stopPropagation(); - toaster.show({ - message: () => ( - - - Copied to clipboard - - ), - }); - }} - /> + {hideCopyBtn ? null : ( + { + e.preventDefault(); + e.stopPropagation(); + toaster.show({ + message: () => ( + + + Copied to clipboard + + ), + }); + }} + /> + )} { } const price = parseFloat(lastPrice).toLocaleString("en-US", { - minimumFractionDigits: 2, - maximumFractionDigits: 2, + minimumFractionDigits: 4, + maximumFractionDigits: 4, currency: "USD", }); const change = (+priceChangePercent).toFixed(2); diff --git a/src/components/ui/Tooltip.tsx b/src/components/ui/Tooltip.tsx index 3a7785b..65b2ddb 100644 --- a/src/components/ui/Tooltip.tsx +++ b/src/components/ui/Tooltip.tsx @@ -6,7 +6,7 @@ import { Trash } from 'grommet-icons' // @ts-ignore export const TipContent = ({ message }) => ( - +
{message}
diff --git a/src/pages/MainPage/LatestTransactionsTable.tsx b/src/pages/MainPage/LatestTransactionsTable.tsx index 8ea1fdc..30e5fe2 100644 --- a/src/pages/MainPage/LatestTransactionsTable.tsx +++ b/src/pages/MainPage/LatestTransactionsTable.tsx @@ -45,7 +45,7 @@ function getColumns(props: any) { }} color="brand" > -
+
), }, @@ -57,7 +57,7 @@ function getColumns(props: any) { ), render: (data: RPCTransactionHarmony) => ( -
+
), }, { @@ -68,7 +68,7 @@ function getColumns(props: any) { ), render: (data: RPCTransactionHarmony) => ( -
+
), }, { diff --git a/src/pages/MainPage/helpers.ts b/src/pages/MainPage/helpers.ts index 4eca882..57b9382 100644 --- a/src/pages/MainPage/helpers.ts +++ b/src/pages/MainPage/helpers.ts @@ -22,3 +22,9 @@ export const calculateSecondPerBlocks = ( all_blocks.length ); }; + +export const calculateSecondsPerBlock = ( + all_blocks: Array +): number[] => { + return all_blocks.map(getLatency); +}; diff --git a/src/pages/MainPage/index.tsx b/src/pages/MainPage/index.tsx index 2e250cc..9432b8e 100644 --- a/src/pages/MainPage/index.tsx +++ b/src/pages/MainPage/index.tsx @@ -10,7 +10,7 @@ import { LatestBlocksTable } from "./LatestBlocksTable"; import { LatestTransactionsTable } from "./LatestTransactionsTable"; import { Block } from "src/types"; import { getBlocks } from "src/api/client"; -import { calculateSecondPerBlocks } from "./helpers"; +import { calculateSecondPerBlocks, calculateSecondsPerBlock } from "./helpers"; const filter = { offset: 0, @@ -27,8 +27,11 @@ export function MainPage() { const [blocks, setBlocks] = useState([]); const [blockLatency, setBlockLatency] = useState(2.01); - const availableShards = (process.env - .REACT_APP_AVAILABLE_SHARDS as string).split(","); + + const [blockLatencyMap, setBlockLatencyMap] = useState([2.01]); + const availableShards = ( + process.env.REACT_APP_AVAILABLE_SHARDS as string + ).split(","); useEffect(() => { let tId = 0 as any; @@ -58,6 +61,7 @@ export function MainPage() { ); setBlockLatency(calculateSecondPerBlocks(blocks)); + setBlockLatencyMap(calculateSecondsPerBlock(blocks)) } catch (err) { console.log(err); } @@ -73,7 +77,7 @@ export function MainPage() { return ( - +