Skip to content

Commit

Permalink
Merge pull request #3401 from cardano-foundation/fix/add-block-producer
Browse files Browse the repository at this point in the history
Fix/add block producer
  • Loading branch information
Sotatek-TaiTruong committed May 3, 2024
2 parents df4cefb + e5b621e commit ae13f48
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/commons/resources/icons/king-icon.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/commons/resources/icons/tooltip-icon.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/commons/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ import OutputIcon from "./icons/outputIcon.svg?react";
import CubeIconComponent from "./icons/blockIcon.svg?react";
import TxConfirm from "./icons/txConfirm.svg?react";
import SlotIcon from "./icons/slot.svg?react";
import KingIcon from "./icons/king-icon.svg?react";
import TooltipIcon from "./icons/tooltip-icon.svg?react";
import TxInputIcon from "./icons/txInput.svg?react";
import TxOutputIcon from "./icons/txOutput.svg?react";
import VerifiedIcon from "./icons/verified.svg?react";
Expand Down Expand Up @@ -376,6 +378,8 @@ export {
PolygonDarkIcon,
PolygonDarkRedIcon,
CubeIconComponent,
KingIcon,
TooltipIcon,
SlotIcon,
TimeIconComponent,
TimelineIconComponent,
Expand Down
38 changes: 36 additions & 2 deletions src/components/BlockDetail/BlockOverview/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Box } from "@mui/material";
import { useSelector } from "react-redux";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";

import {
TimeIconComponent,
Expand All @@ -9,14 +10,18 @@ import {
ExchageAltIcon,
OutputIcon,
CubeIconComponent,
SlotIcon
SlotIcon,
KingIcon,
TooltipIcon
} from "src/commons/resources";
import { formatADAFull, formatDateTimeLocal, formatNameBlockNo } from "src/commons/utils/helper";
import { MAX_SLOT_EPOCH } from "src/commons/utils/constants";
import ADAicon from "src/components/commons/ADAIcon";
import DetailHeader from "src/components/commons/DetailHeader";
import CustomTooltip from "src/components/commons/CustomTooltip";
import DatetimeTypeTooltip from "src/components/commons/DatetimeTypeTooltip";
import DynamicEllipsisText from "src/components/DynamicEllipsisText";
import { details } from "src/commons/routers";

import { TitleCard, WrapConfirmation } from "./styles";

Expand All @@ -29,7 +34,7 @@ interface BlockOverviewProps {
const BlockOverview: React.FC<BlockOverviewProps> = ({ data, loading, lastUpdated }) => {
const { t } = useTranslation();
const { currentEpoch } = useSelector(({ system }: RootState) => system);

// eslint-disable-next-line no-console
const listOverview = [
{
icon: TimeIconComponent,
Expand Down Expand Up @@ -112,6 +117,35 @@ const BlockOverview: React.FC<BlockOverviewProps> = ({ data, loading, lastUpdate
</Box>
),
value: `${data?.epochSlotNo || ""} - ${data?.slotNo || ""}`
},
{
icon: KingIcon,
title: (
<Box display={"flex"} alignItems={"center"}>
<Box display={"flex"} alignItems="center">
<TitleCard mr={1}>{t("glossary.blockproducer")} </TitleCard>
</Box>
<CustomTooltip title="Block minted by">
<span>
<TooltipIcon />
</span>
</CustomTooltip>
</Box>
),
value: (
<Box
component={data?.poolView ? Link : Box}
color={({ palette }) => `${palette.primary.main}!important`}
to={details.delegation(data?.poolView)}
>
{data?.poolName ? (
data.poolName
) : (
<DynamicEllipsisText value={data?.poolView || ""} isTooltip={!!data?.poolView} />
)}{" "}
{data?.poolTicker && `- ${data.poolTicker}`}
</Box>
)
}
];
return (
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
"glossary.comfirmations": "Confirmations",
"glossary.comfirmation": "Confirmation",
"glossary.transactionfees": "Transaction Fees",
"glossary.blockproducer": "Block Producer",
"glossary.totalOutputInAda": "Total output in ADA",
"head.page.blockDetails": "Block details",
"glossary.outputInAda": "Output in ADA",
Expand Down
9 changes: 8 additions & 1 deletion src/pages/BlockDetail/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect } from "react";
import { Box, CircularProgress } from "@mui/material";
import { useLocation, useParams } from "react-router-dom";
import { useSelector } from "react-redux";

Expand Down Expand Up @@ -26,10 +27,16 @@ const BlockDetail = () => {
document.title = `Block ${blockId} | Cardano Blockchain Explorer`;
}, [blockId]);

if (loading) {
return (
<Box>
<CircularProgress />
</Box>
);
}
if (!initialized) {
return null;
}

if ((initialized && !data) || error) return <NoRecord />;

return (
Expand Down
3 changes: 3 additions & 0 deletions src/types/block.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ interface Block {
totalOutput: number;
txCount: number;
maxEpochSlot: number;
poolName: string;
poolTicker: string;
poolView: string;
}

type BlockDetail = Block & {
Expand Down

0 comments on commit ae13f48

Please sign in to comment.