1+ import { useState } from "react" ;
12import { useSorokit } from "@/context/useSorokit" ;
23import { AccountCard } from "@/components/AccountCard" ;
34import { Button } from "@/components/ui/Button" ;
45import { Badge } from "@/components/ui/Badge" ;
5- import { truncateAddress } from "@/lib/utils" ;
6+ import { cn , truncateAddress } from "@/lib/utils" ;
7+ import { HugeiconsIcon } from "@hugeicons/react" ;
8+ import { Copy01Icon , Tick01Icon } from "@hugeicons/core-free-icons" ;
69
710export function WalletScreen ( ) {
811 const { address, isConnected, disconnectWallet, network } = useSorokit ( ) ;
@@ -41,7 +44,7 @@ export function WalletScreen() {
4144 { network && (
4245 < div className = "grid grid-cols-1 sm:grid-cols-2 divide-y sm:divide-y-0 sm:divide-x divide-line" >
4346 < InfoCell label = "Network" value = { network . name } />
44- < InfoCell label = "RPC Endpoint" value = { network . rpcUrl } mono />
47+ < InfoCell label = "RPC Endpoint" value = { network . rpcUrl } mono copyable />
4548 </ div >
4649 ) }
4750 </ div >
@@ -55,21 +58,58 @@ function InfoCell({
5558 label,
5659 value,
5760 mono,
61+ copyable,
5862} : {
5963 label : string ;
6064 value : string ;
6165 mono ?: boolean ;
66+ copyable ?: boolean ;
6267} ) {
68+ const [ copied , setCopied ] = useState ( false ) ;
69+
70+ async function copy ( ) {
71+ try {
72+ await navigator . clipboard . writeText ( value ) ;
73+ setCopied ( true ) ;
74+ setTimeout ( ( ) => setCopied ( false ) , 2000 ) ;
75+ } catch {
76+ /* fallback */
77+ }
78+ }
79+
6380 return (
6481 < div className = "px-6 py-4 flex flex-col gap-1.5" >
6582 < span className = "text-[10px] font-semibold uppercase tracking-[0.1em] text-ink-4" >
6683 { label }
6784 </ span >
68- < span
69- className = { `text-[13px] text-ink-2 break-all ${ mono ? "font-mono text-[12px]" : "" } ` }
70- >
71- { value }
72- </ span >
85+ < div className = "flex items-center gap-2 group" >
86+ < span
87+ title = { value }
88+ className = { `text-[13px] text-ink-2 break-all ${ mono ? "font-mono text-[12px]" : "" } ` }
89+ >
90+ { value }
91+ </ span >
92+ { copyable && (
93+ < button
94+ onClick = { copy }
95+ aria-label = { copied ? "Copied" : "Copy value" }
96+ className = { cn (
97+ "shrink-0 p-1 rounded-md transition-all" ,
98+ copied
99+ ? "text-green bg-[rgba(34,197,94,0.1)]"
100+ : "text-ink-3 hover:text-ink-2 hover:bg-surface-2 opacity-50 hover:opacity-100" ,
101+ ) }
102+ title = { copied ? "Copied!" : "Copy value" }
103+ >
104+ < HugeiconsIcon
105+ icon = { copied ? Tick01Icon : Copy01Icon }
106+ size = { 12 }
107+ color = "currentColor"
108+ strokeWidth = { 2 }
109+ />
110+ </ button >
111+ ) }
112+ </ div >
73113 </ div >
74114 ) ;
75115}
0 commit comments