@@ -5,22 +5,28 @@ interface SponsoredFeed {
5
5
name : string ;
6
6
priceFeedId : string ;
7
7
updateParameters : string ;
8
+ accountAddress ?: string ; // Optional field for Solana
8
9
}
9
10
10
11
interface SponsoredFeedsTableProps {
11
12
feeds : SponsoredFeed [ ] ;
12
13
networkName : string ;
14
+ showAccountAddress ?: boolean ; // Optional prop to show account address column
13
15
}
14
16
15
17
export const SponsoredFeedsTable = ( {
16
18
feeds,
17
19
networkName,
20
+ showAccountAddress = false ,
18
21
} : SponsoredFeedsTableProps ) => {
19
22
const [ copiedId , setCopiedId ] = useState < string | null > ( null ) ;
20
23
21
- const copyToClipboard = ( text : string ) => {
24
+ const copyToClipboard = (
25
+ text : string ,
26
+ type : "priceFeedId" | "accountAddress" = "priceFeedId"
27
+ ) => {
22
28
navigator . clipboard . writeText ( text ) . then ( ( ) => {
23
- setCopiedId ( text ) ;
29
+ setCopiedId ( ` ${ type } - ${ text } ` ) ;
24
30
setTimeout ( ( ) => setCopiedId ( null ) , 2000 ) ;
25
31
} ) ;
26
32
} ;
@@ -41,11 +47,18 @@ export const SponsoredFeedsTable = ({
41
47
// Show 7 rows by default, then scroll - but maintain consistent minimum height
42
48
const maxVisibleRows = 7 ;
43
49
const shouldScroll = feeds . length > maxVisibleRows ;
44
- const rowHeight = 56 ; // Increased row height to account for actual content height
50
+ const rowHeight = showAccountAddress ? 78 : 62 ; // Match actualRowHeight for consistency
45
51
const headerHeight = 48 ; // Header height in pixels
46
52
const exactTableHeight = `${ headerHeight + maxVisibleRows * rowHeight } px` ; // Exact height for 7 rows
47
53
const tableHeight = shouldScroll ? exactTableHeight : "auto" ; // Use exact height for scrollable tables
48
54
55
+ // Calculate actual visible rows based on table height
56
+ // Different layouts have different row heights due to content wrapping
57
+ const actualRowHeight = showAccountAddress ? 78 : 62 ; // Solana (4 cols) vs EVM (3 cols)
58
+ const actualVisibleRows = shouldScroll
59
+ ? Math . floor ( ( parseInt ( exactTableHeight ) - headerHeight ) / actualRowHeight )
60
+ : Math . min ( feeds . length , maxVisibleRows ) ;
61
+
49
62
return (
50
63
< div className = "my-6" >
51
64
< p className = "mb-3" >
@@ -87,21 +100,38 @@ export const SponsoredFeedsTable = ({
87
100
</ div >
88
101
89
102
{ /* Table */ }
90
- < div className = "overflow-x-auto" >
103
+ < div >
91
104
< div
92
105
className = { `${ shouldScroll ? "overflow-y-auto" : "" } ` }
93
106
style = { { height : tableHeight } }
94
107
>
95
- < table className = "w-full text-sm min-w-full " >
108
+ < table className = "w-full text-sm table-fixed " >
96
109
< thead className = "sticky top-0 bg-gray-50 dark:bg-gray-800 z-30" >
97
110
< tr >
98
- < th className = "text-left px-3 py-2 font-semibold text-gray-900 dark:text-gray-100 border-b border-gray-200 dark:border-gray-600 min-w-[100px ]" >
111
+ < th className = "text-left px-3 py-2 font-semibold text-gray-900 dark:text-gray-100 border-b border-gray-200 dark:border-gray-600 w-[15%] min-w-[120px ]" >
99
112
Name
100
113
</ th >
101
- < th className = "text-left px-3 py-2 font-semibold text-gray-900 dark:text-gray-100 border-b border-gray-200 dark:border-gray-600 min-w-[400px]" >
114
+ { showAccountAddress && (
115
+ < th className = "text-left px-3 py-2 font-semibold text-gray-900 dark:text-gray-100 border-b border-gray-200 dark:border-gray-600 w-[30%] min-w-[280px]" >
116
+ Account Address
117
+ </ th >
118
+ ) }
119
+ < th
120
+ className = { `text-left px-3 py-2 font-semibold text-gray-900 dark:text-gray-100 border-b border-gray-200 dark:border-gray-600 ${
121
+ showAccountAddress
122
+ ? "w-[35%] min-w-[320px]"
123
+ : "w-[60%] min-w-[400px]"
124
+ } `}
125
+ >
102
126
Price Feed Id
103
127
</ th >
104
- < th className = "text-left px-3 py-2 font-semibold text-gray-900 dark:text-gray-100 border-b border-gray-200 dark:border-gray-600 min-w-[200px]" >
128
+ < th
129
+ className = { `text-left px-3 py-2 font-semibold text-gray-900 dark:text-gray-100 border-b border-gray-200 dark:border-gray-600 ${
130
+ showAccountAddress
131
+ ? "w-[20%] min-w-[180px]"
132
+ : "w-[25%] min-w-[200px]"
133
+ } `}
134
+ >
105
135
Update Parameters
106
136
</ th >
107
137
</ tr >
@@ -128,6 +158,36 @@ export const SponsoredFeedsTable = ({
128
158
{ feed . name }
129
159
</ span >
130
160
</ td >
161
+ { showAccountAddress && (
162
+ < td className = "px-3 py-2 align-top" >
163
+ < div className = "flex items-start gap-2" >
164
+ < code className = "text-xs font-mono text-gray-600 dark:text-gray-400 flex-1 break-all leading-relaxed" >
165
+ { feed . accountAddress || "N/A" }
166
+ </ code >
167
+ { feed . accountAddress && (
168
+ < button
169
+ onClick = { ( ) =>
170
+ copyToClipboard (
171
+ feed . accountAddress ! ,
172
+ "accountAddress"
173
+ )
174
+ }
175
+ className = "p-1 hover:bg-gray-200 dark:hover:bg-gray-600 rounded flex-shrink-0 mt-0.5"
176
+ title = "Copy Account Address"
177
+ >
178
+ { copiedId ===
179
+ `accountAddress-${ feed . accountAddress } ` ? (
180
+ < span className = "text-green-500 text-xs font-bold" >
181
+ ✓
182
+ </ span >
183
+ ) : (
184
+ < CopyIcon className = "w-3 h-3 text-gray-400" />
185
+ ) }
186
+ </ button >
187
+ ) }
188
+ </ div >
189
+ </ td >
190
+ ) }
131
191
< td className = "px-3 py-2 align-top" >
132
192
< div className = "flex items-start gap-2" >
133
193
< code className = "text-xs font-mono text-gray-600 dark:text-gray-400 flex-1 break-all leading-relaxed" >
@@ -138,7 +198,7 @@ export const SponsoredFeedsTable = ({
138
198
className = "p-1 hover:bg-gray-200 dark:hover:bg-gray-600 rounded flex-shrink-0 mt-0.5"
139
199
title = "Copy Price Feed ID"
140
200
>
141
- { copiedId === feed . priceFeedId ? (
201
+ { copiedId === `priceFeedId- ${ feed . priceFeedId } ` ? (
142
202
< span className = "text-green-500 text-xs font-bold" >
143
203
✓
144
204
</ span >
@@ -185,7 +245,7 @@ export const SponsoredFeedsTable = ({
185
245
{ /* Show count indicator when scrolling is needed */ }
186
246
{ shouldScroll && (
187
247
< div className = "px-3 py-1 bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-600 text-xs text-gray-500 text-center" >
188
- Showing { maxVisibleRows } of { feeds . length } feeds • Scroll to see
248
+ Showing { actualVisibleRows } of { feeds . length } feeds • Scroll to see
189
249
more
190
250
</ div >
191
251
) }
0 commit comments