11import { useAtomValue } from "jotai" ;
2- import { identityKeyAtom , uptimeAtom } from "../../api/atoms" ;
2+ import {
3+ identityBalanceAtom ,
4+ uptimeAtom ,
5+ voteBalanceAtom ,
6+ } from "../../api/atoms" ;
37import { Text , Flex , Tooltip } from "@radix-ui/themes" ;
48import styles from "./identityKey.module.css" ;
5- import usePeer from "../../hooks/usePeer" ;
69import PeerIcon from "../../components/PeerIcon" ;
710import { myStakePctAtom , myStakeAmountAtom } from "../../atoms" ;
811import { PropsWithChildren , useEffect } from "react" ;
912import { Duration } from "luxon" ;
1013import { getFmtStake , getTimeTillText , slowDateTimeNow } from "../../utils" ;
1114import { formatNumber } from "../../numUtils" ;
1215import { useInterval , useMedia , useUpdate } from "react-use" ;
13- import Dropdown from "../../components/Dropdown" ;
1416import clsx from "clsx" ;
17+ import { useIdentityPeer } from "../../hooks/useIdentityPeer" ;
18+ import PopoverDropdown from "../../components/PopoverDropdown" ;
1519
1620export default function IdentityKey ( ) {
17- const identityKey = useAtomValue ( identityKeyAtom ) ;
18- const peer = usePeer ( identityKey ) ;
21+ const { peer, identityKey } = useIdentityPeer ( ) ;
1922
20- const isXXNarrowScreen = useMedia ( "(min-width: 500px )" ) ;
23+ const isXXNarrowScreen = useMedia ( "(min-width: 550px )" ) ;
2124 const isXNarrowScreen = useMedia ( "(min-width: 750px)" ) ;
2225 const isNarrowScreen = useMedia ( "(min-width: 900px)" ) ;
23- const isWideScreen = useMedia ( "(min-width: 1366px)" ) ;
2426
2527 useEffect ( ( ) => {
2628 let title = "Firedancer" ;
@@ -33,20 +35,17 @@ export default function IdentityKey() {
3335 document . title = title ;
3436 } , [ identityKey , peer ] ) ;
3537
36- const identityKeyLabel =
37- isWideScreen || ! identityKey
38- ? identityKey
39- : `${ identityKey . substring ( 0 , 8 ) } ...` ;
40-
4138 return (
42- < DropdownContainer showDropdown = { ! isNarrowScreen } >
43- < div className = { clsx ( styles . container , styles . horizontal ) } >
39+ < DropdownContainer showDropdown >
40+ < div
41+ className = { clsx ( styles . container , styles . horizontal , styles . pointer ) }
42+ >
4443 { isXXNarrowScreen && (
4544 < PeerIcon url = { peer ?. info ?. icon_url } size = { 24 } isYou />
4645 ) }
4746 < Label
4847 label = "Validator Name"
49- value = { identityKeyLabel }
48+ value = { ` ${ identityKey ?. substring ( 0 , 8 ) } ...` }
5049 tooltip = "The validators identity public key"
5150 />
5251 { isXNarrowScreen && (
@@ -59,6 +58,7 @@ export default function IdentityKey() {
5958 < >
6059 < Uptime />
6160 < Commission />
61+ < IdentityBalance />
6262 </ >
6363 ) }
6464 </ div >
@@ -79,15 +79,12 @@ function DropdownContainer({
7979 }
8080
8181 return (
82- < Dropdown dropdownMenu = { < DropdownMenu /> } noPadding >
83- { children }
84- </ Dropdown >
82+ < PopoverDropdown content = { < DropdownMenu /> } > { children } </ PopoverDropdown >
8583 ) ;
8684}
8785
8886function DropdownMenu ( ) {
89- const identityKey = useAtomValue ( identityKeyAtom ) ;
90- const peer = usePeer ( identityKey ) ;
87+ const { peer, identityKey } = useIdentityPeer ( ) ;
9188
9289 return (
9390 < div className = { styles . container } >
@@ -103,10 +100,51 @@ function DropdownMenu() {
103100 < StakePct />
104101 < Uptime />
105102 < Commission />
103+ < IdentityBalance />
104+ < VotePubkey />
105+ < VoteBalance />
106106 </ div >
107107 ) ;
108108}
109109
110+ function VotePubkey ( ) {
111+ const { peer } = useIdentityPeer ( ) ;
112+
113+ return (
114+ < Label
115+ label = "Vote Pubkey"
116+ value = { peer ?. vote [ 0 ] ?. vote_account }
117+ tooltip = "The public key of vote account, encoded in base58"
118+ />
119+ ) ;
120+ }
121+
122+ function VoteBalance ( ) {
123+ const voteBalance = useAtomValue ( voteBalanceAtom ) ;
124+
125+ return (
126+ < >
127+ < Label
128+ label = "Vote Balance"
129+ value = { getFmtStake ( voteBalance ) ?? "-" }
130+ tooltip = "Account balance of this validators vote account. The balance is on the highest slot of the currently active fork of the validator."
131+ />
132+ </ >
133+ ) ;
134+ }
135+
136+ function IdentityBalance ( ) {
137+ const identityBalance = useAtomValue ( identityBalanceAtom ) ;
138+
139+ return (
140+ < Label
141+ label = "Identity Balance"
142+ value = { getFmtStake ( identityBalance ) ?? "-" }
143+ tooltip = "Account balance of this validators identity account. The balance is on the highest slot of the currently active fork of the validator."
144+ />
145+ ) ;
146+ }
147+
110148function StakePct ( ) {
111149 const stakePct = useAtomValue ( myStakePctAtom ) ;
112150 let value = "-" ;
@@ -141,8 +179,7 @@ function StakeValue() {
141179}
142180
143181function Commission ( ) {
144- const identityKey = useAtomValue ( identityKeyAtom ) ;
145- const peer = usePeer ( identityKey ) ;
182+ const { peer } = useIdentityPeer ( ) ;
146183
147184 const maxCommission = peer ?. vote . reduce < {
148185 maxStake : number ;
@@ -198,15 +235,16 @@ interface LabelProps {
198235}
199236function Label ( { label, value, color, tooltip } : LabelProps ) {
200237 if ( ! value ) return null ;
238+ const textValue = (
239+ < Text className = { styles . value } style = { { color : color } } >
240+ { value }
241+ </ Text >
242+ ) ;
201243
202244 return (
203245 < Flex direction = "column" >
204246 < Text className = { styles . label } > { label } </ Text >
205- < Tooltip content = { tooltip } >
206- < Text className = { styles . value } style = { { color : color } } >
207- { value }
208- </ Text >
209- </ Tooltip >
247+ { tooltip ? < Tooltip content = { tooltip } > { textValue } </ Tooltip > : textValue }
210248 </ Flex >
211249 ) ;
212250}
0 commit comments