@@ -143,8 +143,45 @@ function renderTable(rows: ReadonlyArray<readonly [Chain, Address]>): string {
143143 return content ;
144144}
145145
146- export function AdminsTable ( ) {
147- const content = useMemo ( ( ) => renderTable ( CURRENT_CHAIN_ADMINS ) , [ ] ) ;
146+ const CURRENT_ADMIN_BY_CHAIN_ID : ReadonlyMap < number , Address > = new Map (
147+ CURRENT_CHAIN_ADMINS . map ( ( [ chain , admin ] ) => [ chain . id , admin ] )
148+ ) ;
149+
150+ function renderComptrollerAdminsTable ( ) : string {
151+ // Iterating the comptroller catalog (rather than CURRENT_CHAIN_ADMINS) keeps
152+ // the table in sync with deployments automatically; the admin lookup throws
153+ // at module load if the hand-maintained map falls out of step.
154+ const rows = sablier . comptroller
155+ . getAll ( )
156+ . flatMap ( ( comptroller ) => {
157+ const chain = sablier . chains . get ( comptroller . chainId ) ;
158+ if ( ! chain || chain . isTestnet || ! chain . isSupportedByUI ) {
159+ return [ ] ;
160+ }
161+ const admin = CURRENT_ADMIN_BY_CHAIN_ID . get ( chain . id ) ;
162+ if ( ! admin ) {
163+ throw new Error (
164+ `AdminsTable: missing current admin for chain ${ chain . name } (${ chain . id } ). ` +
165+ "Add it to CURRENT_CHAIN_ADMINS in src/components/organisms/AdminsTable.tsx."
166+ ) ;
167+ }
168+ return [ { admin, chain, comptroller : comptroller . address } ] ;
169+ } )
170+ . sort ( ( a , b ) => a . chain . name . localeCompare ( b . chain . name ) ) ;
171+
172+ let content = "| Chain | Comptroller | Comptroller Admin |\n" ;
173+ content += "| :---- | :---------- | :---- |\n" ;
174+ for ( const { admin, chain, comptroller } of rows ) {
175+ const explorerBaseUrl = chain . blockExplorers . default . url ;
176+ const comptrollerLink = `[${ comptroller } ](${ explorerBaseUrl } /address/${ comptroller } )` ;
177+ const adminLink = `[${ admin } ](${ explorerBaseUrl } /address/${ admin } )` ;
178+ content += `| ${ chain . name } | ${ comptrollerLink } | ${ adminLink } |\n` ;
179+ }
180+ return content ;
181+ }
182+
183+ export function ComptrollerAdminsTable ( ) {
184+ const content = useMemo ( ( ) => renderComptrollerAdminsTable ( ) , [ ] ) ;
148185 return < GFMContent content = { content } /> ;
149186}
150187
@@ -153,4 +190,4 @@ export function OldAdminsTable() {
153190 return < GFMContent content = { content } /> ;
154191}
155192
156- export default AdminsTable ;
193+ export default ComptrollerAdminsTable ;
0 commit comments