@@ -35,6 +35,14 @@ import {
3535 TooltipTrigger ,
3636} from "@/components/ui/tooltip" ;
3737
38+ const LINEA_PARAMS = {
39+ chainId : '0xE705' , // 59141 in hex
40+ chainName : 'Linea Sepolia' ,
41+ rpcUrls : [ 'https://rpc.sepolia.linea.build' ] ,
42+ nativeCurrency : { name : 'Ethereum' , symbol : 'ETH' , decimals : 18 } ,
43+ blockExplorerUrls : [ 'https://sepolia.lineascan.build' ] ,
44+ } ;
45+
3846export function WalletDropdown ( ) {
3947 const { isConnected, address, chainId, connectWallet, disconnectWallet, balance, wttBalance, mintWTT } = useWallet ( ) ;
4048 const [ isDialogOpen , setIsDialogOpen ] = useState ( false ) ;
@@ -69,6 +77,21 @@ export function WalletDropdown() {
6977 return `Unknown (${ chainId } )` ;
7078 } ;
7179
80+ const addNetwork = async ( ) => {
81+ if ( ! window . ethereum ) {
82+ alert ( 'MetaMask is not installed.' ) ;
83+ return ;
84+ }
85+ try {
86+ await window . ethereum . request ( {
87+ method : 'wallet_addEthereumChain' ,
88+ params : [ LINEA_PARAMS ] ,
89+ } ) ;
90+ } catch {
91+ alert ( 'Failed to add Linea Sepolia network.' ) ;
92+ }
93+ } ;
94+
7295 if ( ! isConnected || ! address ) {
7396 return (
7497 < Button
@@ -141,7 +164,26 @@ export function WalletDropdown() {
141164 < Coins className = "h-3.5 w-3.5" />
142165 < span > ETH Balance</ span >
143166 </ div >
144- < span className = "text-primary font-medium" > { parseFloat ( balance || '0' ) . toFixed ( 4 ) } </ span >
167+ < div className = "flex items-center gap-1.5" >
168+ < span className = "text-primary font-medium" > { parseFloat ( balance || '0' ) . toFixed ( 4 ) } </ span >
169+ < TooltipProvider >
170+ < Tooltip >
171+ < TooltipTrigger asChild >
172+ < Button
173+ variant = "ghost"
174+ size = "icon"
175+ className = "h-5 w-5 p-0 text-muted-foreground hover:text-accent"
176+ onClick = { ( ) => window . open ( 'https://docs.metamask.io/developer-tools/faucet/' , '_blank' ) }
177+ >
178+ < PlusCircle className = "h-3.5 w-3.5" />
179+ </ Button >
180+ </ TooltipTrigger >
181+ < TooltipContent side = "left" >
182+ < p className = "font-mono text-xs" > Get Testnet ETH from Linea Faucet</ p >
183+ </ TooltipContent >
184+ </ Tooltip >
185+ </ TooltipProvider >
186+ </ div >
145187 </ div >
146188
147189 < div className = "flex items-center justify-between text-xs" >
@@ -196,6 +238,16 @@ export function WalletDropdown() {
196238 </ div >
197239 </ div >
198240 </ div >
241+ { chainId !== 59141 && (
242+ < Button
243+ onClick = { addNetwork }
244+ variant = "outline"
245+ size = "sm"
246+ className = "w-full flex items-center gap-2 mt-2"
247+ >
248+ 🦊 Add Linea Sepolia Network
249+ </ Button >
250+ ) }
199251 </ div >
200252
201253 < DropdownMenuSeparator className = "bg-terminal-border m-0" />
0 commit comments