11import 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" ;
52import 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" ;
77import ImportToSignerDialog from "./ImportToSignerDialog" ;
8+ import "./minipool.css" ;
9+
810
911function 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,24 @@ function MinipoolCard({
2528 ? "#E57373"
2629 : "#FFB74D" ;
2730
31+ const validatorStatus = data . finalised
32+ ? "Exited"
33+ : ( ! data . validator . index && data . status . status === "Staking" )
34+ ? "Enqueued"
35+ : ( data . validator . active
36+ ? "Active"
37+ : ( data . status . status === "Staking" && ethBalanceGreaterThanMinStake ( data . balances . eth )
38+ ? "Ready to Close"
39+ : "Inactive"
40+ )
41+ ) ;
42+ const validatorStatusColor =
43+ data . finalised || data . validator . active
44+ ? "#81C784"
45+ : ( data . status . status === "Prelaunch" || [ "Enqueued" , "Ready to Close" ] . includes ( validatorStatus ) )
46+ ? "#FFC107"
47+ : "#E57373" ;
48+
2849 return (
2950 < Card
3051 sx = { {
@@ -36,16 +57,28 @@ function MinipoolCard({
3657 >
3758 < CardContent >
3859 < div className = "chip-container" >
39- < Chip label = { `#${ data . validator . index } ` } />
60+ < div className = "chip-with-clipboard-container" >
61+ < Tooltip title = { showAddress ? "Minipool Address" : "Validator Index" } >
62+ < Chip
63+ label = { showAddress ? shortenAddress ( data . address ) : `#${ data . validator . index } ` }
64+ onClick = { ( ) => setShowAddress ( ! showAddress ) }
65+ sx = { { cursor : 'pointer' } }
66+ />
67+ </ Tooltip >
68+ < CopyToClipboardButton
69+ value = { showAddress ? data . address : data . validator . index . toString ( ) }
70+ fontSize = "small"
71+ />
72+ </ div >
4073 < Chip
4174 label = { data . finalised ? "Finalised" : data . status . status }
4275 sx = { { backgroundColor : data . finalised ? "#FFC107" : backgroundColor } }
4376 />
4477 </ div >
4578 < div className = "validator-status" >
4679 < Chip
47- label = { data . finalised ? "Exited" : ( data . validator . active ? "Active" : "Inactive" ) }
48- sx = { { backgroundColor : data . finalised || data . validator . active ? "#81C784" : "#E57373" } }
80+ label = { validatorStatus }
81+ sx = { { backgroundColor : validatorStatusColor } }
4982 />
5083 </ div >
5184
0 commit comments