File tree Expand file tree Collapse file tree 4 files changed +4500
-3382
lines changed Expand file tree Collapse file tree 4 files changed +4500
-3382
lines changed Original file line number Diff line number Diff line change 1
1
import type { ReactElement } from 'react'
2
2
import { CHAIN_CONSTANTS , LEGACY_CONTRACT_NAMES } from '@/utils/constants'
3
3
4
- interface TableAddresses {
4
+ export interface TableAddresses {
5
5
[ contract : string ] : string
6
6
}
7
7
@@ -37,7 +37,7 @@ export function AddressTable({
37
37
Object . entries ( filtered )
38
38
. map ( ( [ contract , address ] ) => {
39
39
return (
40
- < tr key = { `${ chain } .${ address } ` } className = "nx-m-0 nx-border-t nx-border-gray-300 nx-p-0 dark:nx-border-gray-600 even:nx-bg-gray-100 even:dark:nx-bg-gray-600/20" >
40
+ < tr key = { `${ chain } .${ contract } . ${ address } ` } className = "nx-m-0 nx-border-t nx-border-gray-300 nx-p-0 dark:nx-border-gray-600 even:nx-bg-gray-100 even:dark:nx-bg-gray-600/20" >
41
41
< td className = "nx-m-0 nx-border nx-border-gray-300 nx-px-4 nx-py-2 dark:nx-border-gray-600" >
42
42
< code className = "nx-border-black nx-border-opacity-[0.04] nx-bg-opacity-[0.03] nx-bg-black nx-break-words nx-rounded-md nx-border nx-py-0.5 nx-px-[.25em] nx-text-[.9em] dark:nx-border-white/10 dark:nx-bg-white/10" >
43
43
{ contract }
Original file line number Diff line number Diff line change 1
1
import type { ReactElement } from 'react'
2
- import * as addresses from 'superchain-registry/superchain/extra/addresses/addresses.json'
3
- import { AddressTable } from '@/components/AddressTable'
2
+ import { useEffect , useState } from 'react'
3
+ import { AddressTable , TableAddresses } from '@/components/AddressTable'
4
+
5
+ const ADDRESSES_URL = 'https://raw.githubusercontent.com/ethereum-optimism/superchain-registry/main/superchain/extra/addresses/addresses.json' ;
4
6
5
7
export function L1ContractTable ( {
6
8
chain,
@@ -11,16 +13,47 @@ export function L1ContractTable({
11
13
explorer : string ,
12
14
legacy : boolean
13
15
} ) : ReactElement {
16
+ const [ addresses , setAddresses ] = useState < Record < string , any > | null > ( null )
17
+ const [ loading , setLoading ] = useState ( true )
18
+ const [ error , setError ] = useState < string | null > ( null )
19
+
20
+ useEffect ( ( ) => {
21
+ async function fetchAddresses ( ) {
22
+ try {
23
+ const response = await fetch ( ADDRESSES_URL )
24
+ if ( ! response . ok ) {
25
+ throw new Error ( 'Failed to fetch addresses' )
26
+ }
27
+ const data = await response . json ( )
28
+ setAddresses ( data )
29
+ } catch ( err ) {
30
+ setError ( err . message )
31
+ } finally {
32
+ setLoading ( false )
33
+ }
34
+ }
35
+
36
+ fetchAddresses ( )
37
+ } , [ ] )
38
+
39
+ if ( loading ) {
40
+ return < div > Loading...</ div >
41
+ }
42
+
43
+ if ( error ) {
44
+ return < div > Error: { error } </ div >
45
+ }
46
+
14
47
return (
15
48
< AddressTable
16
49
chain = { chain }
17
50
explorer = { explorer }
18
51
legacy = { legacy }
19
52
addresses = {
20
- Object . entries ( addresses )
53
+ addresses && Object . entries ( addresses )
21
54
. find ( ( [ chainid , ] ) => {
22
55
return chainid === chain
23
- } ) [ 1 ]
56
+ } ) ?. [ 1 ] as TableAddresses
24
57
}
25
58
/>
26
59
)
Original file line number Diff line number Diff line change 22
22
"nextra" : " 2.13.2" ,
23
23
"nextra-theme-docs" : " 2.13.2" ,
24
24
"react" : " ^18.2.0" ,
25
- "react-dom" : " ^18.2.0" ,
26
- "superchain-registry" : " github:ethereum-optimism/superchain-registry#main"
25
+ "react-dom" : " ^18.2.0"
27
26
},
28
27
"devDependencies" : {
29
28
"@double-great/remark-lint-alt-text" : " ^1.0.0" ,
You can’t perform that action at this time.
0 commit comments