@@ -6,8 +6,19 @@ import BN from 'bn.js';
66
77// Simple Copy Icon
88const CopyIcon = ( ) => (
9- < svg xmlns = "http://www.w3.org/2000/svg" className = "h-4 w-4 inline ml-1 text-gray-500 hover:text-gray-700 cursor-pointer" fill = "none" viewBox = "0 0 24 24" stroke = "currentColor" strokeWidth = { 2 } >
10- < path strokeLinecap = "round" strokeLinejoin = "round" d = "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
9+ < svg
10+ xmlns = "http://www.w3.org/2000/svg"
11+ className = "h-4 w-4 inline ml-1 text-gray-500 hover:text-gray-700 cursor-pointer"
12+ fill = "none"
13+ viewBox = "0 0 24 24"
14+ stroke = "currentColor"
15+ strokeWidth = { 2 }
16+ >
17+ < path
18+ strokeLinecap = "round"
19+ strokeLinejoin = "round"
20+ d = "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
21+ />
1122 </ svg >
1223) ;
1324
@@ -32,9 +43,9 @@ const formatLamports = (lamports: BN | undefined): string => {
3243
3344// Helper to format BN tokens (assuming JitoSOL has 9 decimals like SOL)
3445const formatPoolTokens = ( tokens : BN | undefined ) : string => {
35- if ( tokens === undefined ) return 'N/A' ;
36- // JitoSOL (pool token) also has 9 decimal places
37- return ( Number ( tokens . toString ( ) ) / 1_000_000_000 ) . toLocaleString ( undefined , { maximumFractionDigits : 4 } ) ;
46+ if ( tokens === undefined ) return 'N/A' ;
47+ // JitoSOL (pool token) also has 9 decimal places
48+ return ( Number ( tokens . toString ( ) ) / 1_000_000_000 ) . toLocaleString ( undefined , { maximumFractionDigits : 4 } ) ;
3849} ;
3950
4051// Helper to format fee percentage
@@ -45,9 +56,9 @@ const formatFee = (fee: number | null | undefined): string => {
4556
4657// Helper to format SOL/JitoSOL conversion rate
4758const formatConversion = ( rate : number | undefined ) : string => {
48- if ( rate === undefined ) return 'N/A' ;
49- // Display how many SOL you get for 1 JitoSOL
50- return `${ rate . toFixed ( 6 ) } SOL / JitoSOL` ;
59+ if ( rate === undefined ) return 'N/A' ;
60+ // Display how many SOL you get for 1 JitoSOL
61+ return `${ rate . toFixed ( 6 ) } SOL / JitoSOL` ;
5162} ;
5263
5364// Define type for details array items
@@ -64,12 +75,15 @@ const StakePoolDetails: React.FC<StakePoolDetailsProps> = ({ poolInfo, isLoading
6475
6576 const handleCopy = ( text : string | undefined , label : string ) => {
6677 if ( ! text ) return ;
67- navigator . clipboard . writeText ( text ) . then ( ( ) => {
68- setCopiedAddress ( label ) ; // Set the label of the copied item
69- setTimeout ( ( ) => setCopiedAddress ( null ) , 1500 ) ; // Reset after 1.5 seconds
70- } ) . catch ( err => {
71- console . error ( 'Failed to copy text: ' , err ) ;
72- } ) ;
78+ navigator . clipboard
79+ . writeText ( text )
80+ . then ( ( ) => {
81+ setCopiedAddress ( label ) ; // Set the label of the copied item
82+ setTimeout ( ( ) => setCopiedAddress ( null ) , 1500 ) ; // Reset after 1.5 seconds
83+ } )
84+ . catch ( ( err ) => {
85+ console . error ( 'Failed to copy text: ' , err ) ;
86+ } ) ;
7387 } ;
7488
7589 if ( isLoading ) {
@@ -85,15 +99,45 @@ const StakePoolDetails: React.FC<StakePoolDetailsProps> = ({ poolInfo, isLoading
8599 }
86100
87101 const allDetails : DetailItem [ ] = [
88- { label : 'Pool Address' , value : formatPublicKey ( poolInfo . pubkey ) , rawValue : poolInfo . pubkey . toBase58 ( ) , type : 'address' } ,
89- { label : 'Pool Mint' , value : formatPublicKey ( poolInfo . poolMint ) , rawValue : poolInfo . poolMint . toBase58 ( ) , type : 'address' } ,
102+ {
103+ label : 'Pool Address' ,
104+ value : formatPublicKey ( poolInfo . pubkey ) ,
105+ rawValue : poolInfo . pubkey . toBase58 ( ) ,
106+ type : 'address' ,
107+ } ,
108+ {
109+ label : 'Pool Mint' ,
110+ value : formatPublicKey ( poolInfo . poolMint ) ,
111+ rawValue : poolInfo . poolMint . toBase58 ( ) ,
112+ type : 'address' ,
113+ } ,
90114 { label : 'Total SOL Staked' , value : formatLamports ( poolInfo . totalLamports ) , type : 'number' } ,
91115 { label : 'Total JitoSOL Supply' , value : formatPoolTokens ( poolInfo . totalPoolTokens ) , type : 'number' } ,
92116 { label : 'SOL per JitoSOL' , value : formatConversion ( poolInfo . solJitoConversion ) , type : 'rate' } ,
93- { label : 'Reserve Stake Account' , value : formatPublicKey ( poolInfo . reserveStake ) , rawValue : poolInfo . reserveStake . toBase58 ( ) , type : 'address' } ,
94- { label : 'Manager' , value : formatPublicKey ( poolInfo . manager ) , rawValue : poolInfo . manager . toBase58 ( ) , type : 'address' } ,
95- { label : 'Manager Fee Account' , value : formatPublicKey ( poolInfo . managerFeeAccount ) , rawValue : poolInfo . managerFeeAccount . toBase58 ( ) , type : 'address' } ,
96- { label : 'Validator List' , value : formatPublicKey ( poolInfo . validatorList ) , rawValue : poolInfo . validatorList . toBase58 ( ) , type : 'address' } ,
117+ {
118+ label : 'Reserve Stake Account' ,
119+ value : formatPublicKey ( poolInfo . reserveStake ) ,
120+ rawValue : poolInfo . reserveStake . toBase58 ( ) ,
121+ type : 'address' ,
122+ } ,
123+ {
124+ label : 'Manager' ,
125+ value : formatPublicKey ( poolInfo . manager ) ,
126+ rawValue : poolInfo . manager . toBase58 ( ) ,
127+ type : 'address' ,
128+ } ,
129+ {
130+ label : 'Manager Fee Account' ,
131+ value : formatPublicKey ( poolInfo . managerFeeAccount ) ,
132+ rawValue : poolInfo . managerFeeAccount . toBase58 ( ) ,
133+ type : 'address' ,
134+ } ,
135+ {
136+ label : 'Validator List' ,
137+ value : formatPublicKey ( poolInfo . validatorList ) ,
138+ rawValue : poolInfo . validatorList . toBase58 ( ) ,
139+ type : 'address' ,
140+ } ,
97141 { label : 'SOL Deposit Fee' , value : formatFee ( poolInfo . solDepositFee ) , type : 'percentage' } ,
98142 { label : 'Stake Deposit Fee' , value : formatFee ( poolInfo . stakeDepositFee ) , type : 'percentage' } ,
99143 { label : 'SOL Withdrawal Fee' , value : formatFee ( poolInfo . solWithdrawalFee ) , type : 'percentage' } ,
@@ -133,8 +177,8 @@ const StakePoolDetails: React.FC<StakePoolDetailsProps> = ({ poolInfo, isLoading
133177 { isExpanded ? 'Show Less' : 'Show More' }
134178 </ button >
135179 </ div >
136- { /* Display raw data for debugging if needed */ }
137- { /* <pre className="mt-4 text-xs overflow-auto bg-gray-50 p-2 rounded">
180+ { /* Display raw data for debugging if needed */ }
181+ { /* <pre className="mt-4 text-xs overflow-auto bg-gray-50 p-2 rounded">
138182 {JSON.stringify(poolInfo, (key, value) =>
139183 typeof value === 'bigint' ? value.toString() : // Convert BigInt to string for JSON.stringify
140184 value instanceof PublicKey ? value.toBase58() : // Convert PublicKey to string
@@ -146,4 +190,4 @@ const StakePoolDetails: React.FC<StakePoolDetailsProps> = ({ poolInfo, isLoading
146190 ) ;
147191} ;
148192
149- export default StakePoolDetails ;
193+ export default StakePoolDetails ;
0 commit comments