Skip to content

Commit ef158e9

Browse files
committed
add better minipool status management + display minipool address
1 parent c44a594 commit ef158e9

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
lines changed

build/ui/src/components/Setup/MinipoolCard.tsx

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import React from "react";
2-
import { Card, CardContent, Typography, Chip, Button } from "@mui/material";
3-
import { Minipool } from "../../types/MinipoolStatus";
4-
import { toEtherString } from "../../utils/Utils";
52
import OpenInNewIcon from "@mui/icons-material/OpenInNew";
6-
import "./minipool.css";
3+
import { Button, Card, CardContent, Chip, Tooltip, Typography } from "@mui/material";
4+
import CopyToClipboardButton from "../Buttons/CopyToClipboardButton";
5+
import { Minipool } from "../../types/MinipoolStatus";
6+
import { ethBalanceGreaterThanMinStake, shortenAddress, toEtherString } from "../../utils/Utils";
77
import ImportToSignerDialog from "./ImportToSignerDialog";
8+
import "./minipool.css";
9+
810

911
function MinipoolCard({
1012
data,
@@ -17,6 +19,7 @@ function MinipoolCard({
1719
}): JSX.Element {
1820
const [importToSignerDialogOpen, setImportToSignerDialogOpen] =
1921
React.useState<boolean>(false);
22+
const [showAddress, setShowAddress] = React.useState<boolean>(false);
2023

2124
const backgroundColor =
2225
data.status.status === "Staking"
@@ -25,6 +28,22 @@ function MinipoolCard({
2528
? "#E57373"
2629
: "#FFB74D";
2730

31+
const validatorStatus = data.finalised
32+
? "Exited"
33+
: (data.validator.active
34+
? "Active"
35+
: (data.status.status === "Staking" && ethBalanceGreaterThanMinStake(data.balances.eth)
36+
? "Ready to Close"
37+
: "Inactive"
38+
)
39+
);
40+
const validatorStatusColor =
41+
data.finalised || data.validator.active
42+
? "#81C784"
43+
: validatorStatus === "Ready to Close" || data.status.status === "Prelaunch"
44+
? "#FFC107"
45+
: "#E57373";
46+
2847
return (
2948
<Card
3049
sx={{
@@ -36,16 +55,28 @@ function MinipoolCard({
3655
>
3756
<CardContent>
3857
<div className="chip-container">
39-
<Chip label={`#${data.validator.index}`} />
58+
<div className="chip-with-clipboard-container">
59+
<Tooltip title={showAddress ? "Minipool Address" : "Validator Index"}>
60+
<Chip
61+
label={showAddress ? shortenAddress(data.address) : `#${data.validator.index}`}
62+
onClick={() => setShowAddress(!showAddress)}
63+
sx={{ cursor: 'pointer' }}
64+
/>
65+
</Tooltip>
66+
<CopyToClipboardButton
67+
value={showAddress ? data.address : data.validator.index.toString()}
68+
fontSize="small"
69+
/>
70+
</div>
4071
<Chip
4172
label={data.finalised ? "Finalised" : data.status.status}
4273
sx={{ backgroundColor: data.finalised ? "#FFC107" : backgroundColor }}
4374
/>
4475
</div>
4576
<div className="validator-status">
4677
<Chip
47-
label={data.finalised ? "Exited" : (data.validator.active ? "Active" : "Inactive")}
48-
sx={{ backgroundColor: data.finalised || data.validator.active ? "#81C784" : "#E57373" }}
78+
label={validatorStatus}
79+
sx={{ backgroundColor: validatorStatusColor }}
4980
/>
5081
</div>
5182

build/ui/src/components/Setup/minipool.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,17 @@
3939
margin-bottom: 0.5rem;
4040
}
4141

42+
.chip-with-clipboard-container {
43+
display: flex;
44+
align-items: center;
45+
}
46+
4247
.explorer-button-container {
4348
margin-top: 1rem;
4449
}
4550

4651
.minipool-ether {
52+
margin-top: 0.5rem !important;
4753
margin-bottom: 0.5rem !important;
4854
font-weight: bold !important;
4955
}

build/ui/src/utils/Utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,9 @@ export function enoughEthBalance(
4141
return is8EthPool ? ethBalance >= minimum8Eth : ethBalance >= minimum16Eth;
4242
}
4343

44+
export function ethBalanceGreaterThanMinStake(ethBalance: number): boolean {
45+
const minStake = BigInt(32 * 10 ** 18);
46+
return BigInt(ethBalance) > minStake;
47+
}
48+
4449
export const escapeNewLine = (text: string) => text.replace(/(\\n)/g, "\n");

0 commit comments

Comments
 (0)