11import React from 'react' ;
2-
32import Image from 'next/image' ;
43import Link from 'next/link' ;
54import { usePathname , useSearchParams } from 'next/navigation' ;
@@ -18,24 +17,44 @@ interface INetworkSelector {
1817 dropdownSelectedChain : number ;
1918 nopool ?: boolean ;
2019 enabledChains ?: number [ ] ;
21- upcomingChains ?: string [ ] ;
20+ showUpcomingChains ?: boolean ;
2221}
2322
23+ const ALL_NETWORKS = [
24+ 'MetalL2' ,
25+ 'Ozean' ,
26+ 'Soneium' ,
27+ 'Camp' ,
28+ 'FX' ,
29+ 'Ink' ,
30+ 'Kroma' ,
31+ 'Unichain' ,
32+ 'Mode' ,
33+ 'Base' ,
34+ 'Optimism' ,
35+ 'Fraxtal' ,
36+ 'Lisk' ,
37+ 'BoB' ,
38+ 'Worldchain' ,
39+ 'Superseed'
40+ ] ;
41+
2442const ACTIVE_NETWORKS = [
2543 'Mode' ,
2644 'Base' ,
2745 'Optimism' ,
2846 'Fraxtal' ,
2947 'Lisk' ,
3048 'BoB' ,
31- 'Worldchain'
49+ 'Worldchain' ,
50+ 'Superseed'
3251] ;
3352
3453function NetworkSelector ( {
3554 dropdownSelectedChain,
3655 nopool = false ,
3756 enabledChains,
38- upcomingChains
57+ showUpcomingChains = false
3958} : INetworkSelector ) {
4059 const pathname = usePathname ( ) ;
4160 const searchParams = useSearchParams ( ) ;
@@ -49,6 +68,10 @@ function NetworkSelector({
4968 ( ! enabledChains || enabledChains . includes ( + entry [ 0 ] ) )
5069 ) ;
5170
71+ const upcomingNetworks = showUpcomingChains
72+ ? ALL_NETWORKS . filter ( ( network ) => ! ACTIVE_NETWORKS . includes ( network ) )
73+ : [ ] ;
74+
5275 const getUrlWithParams = ( chainId : string ) => {
5376 const params = new URLSearchParams ( searchParams . toString ( ) ) ;
5477 // Always reset pool to 0 when changing chains unless nopool is true
@@ -72,7 +95,7 @@ function NetworkSelector({
7295 < Button
7396 variant = { isSelected ? 'secondary' : 'ghost' }
7497 asChild
75- className = { `h-9 rounded-md ${ isSelected ? 'min-w-[80px] p-2' : 'min-w-[32px] p-1 ' } ` }
98+ className = { `h-9 rounded-md ${ isSelected ? 'min-w-[80px] p-2' : 'min-w-[32px] p-1' } ` }
7699 >
77100 < Link
78101 href = { getUrlWithParams ( chainId ) }
@@ -109,41 +132,42 @@ function NetworkSelector({
109132 ) ;
110133 } ) }
111134
112- { upcomingChains ?. map ( ( upcomingChain , idx ) => (
113- < TooltipProvider key = { idx } >
114- < Tooltip delayDuration = { 100 } >
115- < TooltipTrigger asChild >
116- < div >
117- < Button
118- variant = "ghost"
119- size = "sm"
120- className = "p-1 h-8 min-w-[32px] opacity-75 cursor-not-allowed hover:opacity-75"
121- disabled
122- >
123- < Image
124- alt = { upcomingChain }
125- className = "w-6 h-6 grayscale-[30%]"
126- src = { `/img/logo/${ upcomingChain . toUpperCase ( ) } .png` }
127- width = { 24 }
128- height = { 24 }
129- />
130- </ Button >
131- </ div >
132- </ TooltipTrigger >
133- < TooltipContent className = "flex items-center gap-2 bg-background" >
134- < Image
135- alt = { upcomingChain }
136- className = "w-4 h-4 grayscale-[30%]"
137- src = { `/img/logo/${ upcomingChain . toUpperCase ( ) } .png` }
138- width = { 16 }
139- height = { 16 }
140- />
141- < p > { upcomingChain } </ p >
142- < span className = "text-yellow-400 text-xs" > Coming Soon</ span >
143- </ TooltipContent >
144- </ Tooltip >
145- </ TooltipProvider >
146- ) ) }
135+ { showUpcomingChains &&
136+ upcomingNetworks . map ( ( upcomingChain , idx ) => (
137+ < TooltipProvider key = { `upcoming-${ idx } ` } >
138+ < Tooltip delayDuration = { 100 } >
139+ < TooltipTrigger asChild >
140+ < div >
141+ < Button
142+ variant = "ghost"
143+ size = "sm"
144+ className = "p-1 h-8 min-w-[32px] opacity-75 cursor-not-allowed hover:opacity-75"
145+ disabled
146+ >
147+ < Image
148+ alt = { upcomingChain }
149+ className = "w-6 h-6 grayscale-[30%]"
150+ src = { `/img/logo/${ upcomingChain . toUpperCase ( ) } .png` }
151+ width = { 24 }
152+ height = { 24 }
153+ />
154+ </ Button >
155+ </ div >
156+ </ TooltipTrigger >
157+ < TooltipContent className = "flex items-center gap-2 bg-background" >
158+ < Image
159+ alt = { upcomingChain }
160+ className = "w-4 h-4 grayscale-[30%]"
161+ src = { `/img/logo/${ upcomingChain . toUpperCase ( ) } .png` }
162+ width = { 16 }
163+ height = { 16 }
164+ />
165+ < p > { upcomingChain } </ p >
166+ < span className = "text-yellow-400 text-xs" > Coming Soon</ span >
167+ </ TooltipContent >
168+ </ Tooltip >
169+ </ TooltipProvider >
170+ ) ) }
147171 </ div >
148172 ) ;
149173}
0 commit comments