11import styles from "./sankeyControls.module.css" ;
2- import { Text } from "@radix-ui/themes" ;
2+ import { Text , Tooltip } from "@radix-ui/themes" ;
33import * as ToggleGroup from "@radix-ui/react-toggle-group" ;
44import { useAtom , useAtomValue } from "jotai" ;
55import { DisplayType , sankeyDisplayTypeAtom , selectedSlotAtom } from "./atoms" ;
66import { useSlotQueryResponse } from "../../../hooks/useSlotQuery" ;
77import { fixValue } from "../../../utils" ;
88import { useMemo } from "react" ;
99import { lamportsPerSol } from "../../../consts" ;
10+ import { formatNumber } from "../../../numUtils" ;
1011
1112export default function SankeyControls ( ) {
1213 const [ value , setValue ] = useAtom ( sankeyDisplayTypeAtom ) ;
@@ -60,24 +61,45 @@ function SlotStats() {
6061 const totalTxns = fixValue ( query . response . publish . transactions ?? 0 ) ;
6162 const nonVoteTxns = totalTxns - voteTxns ;
6263
63- const transactionFeeFull =
64- query . response . publish . transaction_fee != null
65- ? (
66- Number ( query . response . publish . transaction_fee ) / lamportsPerSol
67- ) . toFixed ( 9 )
68- : "0" ;
64+ const transactionFee3Decimals = query . response . publish . transaction_fee
65+ ? formatNumber (
66+ Number ( query . response . publish . transaction_fee ) / lamportsPerSol ,
67+ {
68+ decimals : 3 ,
69+ } ,
70+ )
71+ : "0" ;
6972
70- const priorityFeeFull =
71- query . response . publish . priority_fee != null
72- ? (
73- Number ( query . response . publish . priority_fee ) / lamportsPerSol
74- ) . toFixed ( 9 )
75- : "0" ;
73+ const transactionFeeFull = query . response . publish . transaction_fee
74+ ? (
75+ Number ( query . response . publish . transaction_fee ) / lamportsPerSol
76+ ) . toFixed ( 9 )
77+ : "0" ;
7678
77- const tips =
78- query . response . publish . tips != null
79- ? ( Number ( query . response . publish . tips ) / lamportsPerSol ) . toFixed ( 9 )
80- : "0" ;
79+ const priorityFee3Decimals = query . response . publish . priority_fee
80+ ? formatNumber (
81+ Number ( query . response . publish . priority_fee ) / lamportsPerSol ,
82+ {
83+ decimals : 3 ,
84+ } ,
85+ )
86+ : "0" ;
87+
88+ const priorityFeeFull = query . response . publish . priority_fee
89+ ? ( Number ( query . response . publish . priority_fee ) / lamportsPerSol ) . toFixed (
90+ 9 ,
91+ )
92+ : "0" ;
93+
94+ const tips3Decimals = query . response . publish . tips
95+ ? formatNumber ( Number ( query . response . publish . tips ) / lamportsPerSol , {
96+ decimals : 3 ,
97+ } )
98+ : "0" ;
99+
100+ const tips = query . response . publish . tips
101+ ? ( Number ( query . response . publish . tips ) / lamportsPerSol ) . toFixed ( 9 )
102+ : "0" ;
81103
82104 const computeUnits = fixValue ( query . response . publish . compute_units ?? 0 ) ;
83105
@@ -86,8 +108,11 @@ function SlotStats() {
86108 voteTxns,
87109 nonVoteTxns,
88110 transactionFeeFull,
111+ transactionFee3Decimals,
89112 priorityFeeFull,
113+ priorityFee3Decimals,
90114 tips,
115+ tips3Decimals,
91116 } ;
92117 } , [ query . response ] ) ;
93118
@@ -96,15 +121,33 @@ function SlotStats() {
96121 return (
97122 < div className = { styles . stats } >
98123 < Text > Priority Fees</ Text >
99- < Text style = { { textAlign : "right" } } >
100- { values ?. priorityFeeFull ?? "-" }
101- </ Text >
124+ < Tooltip
125+ content = {
126+ values ?. priorityFeeFull ? `${ values ?. priorityFeeFull } SOL` : null
127+ }
128+ >
129+ < Text style = { { textAlign : "right" } } >
130+ { values ?. priorityFee3Decimals ?? "-" }
131+ </ Text >
132+ </ Tooltip >
102133 < Text > Transaction Fees</ Text >
103- < Text style = { { textAlign : "right" } } >
104- { values ?. transactionFeeFull ?? "-" }
105- </ Text >
134+ < Tooltip
135+ content = {
136+ values ?. transactionFeeFull
137+ ? `${ values ?. transactionFeeFull } SOL`
138+ : null
139+ }
140+ >
141+ < Text style = { { textAlign : "right" } } >
142+ { values ?. transactionFee3Decimals ?? "-" }
143+ </ Text >
144+ </ Tooltip >
106145 < Text > Tips</ Text >
107- < Text style = { { textAlign : "right" } } > { values ?. tips ?? "-" } </ Text >
146+ < Tooltip content = { values ?. tips ? `${ values ?. tips } SOL` : null } >
147+ < Text style = { { textAlign : "right" } } >
148+ { values ?. tips3Decimals ?? "-" }
149+ </ Text >
150+ </ Tooltip >
108151 < Text > Vote Transactions</ Text >
109152 < Text style = { { textAlign : "right" } } >
110153 { values ?. voteTxns ?. toLocaleString ( ) ?? "-" }
0 commit comments