Skip to content

Commit 146a783

Browse files
committed
feat: add rpc endpoint copy to clipboard functionality
1 parent cb9bff7 commit 146a783

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/components/RPCEndpoints.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { useState, useMemo, useEffect } from "react";
22
import { useStore } from "../store";
3+
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
34
import * as log from "@tauri-apps/plugin-log";
45
import {
56
defaultWalletshieldListenAddress,
67
NetworkServices,
78
readNetworkAssetFile,
89
} from "../utils";
10+
import { IconClipboard } from "./icons";
911

1012
export function RPCEndpoints() {
1113
const [includeTestnets, setIncludeTestnets] = useState(true);
1214
const [search, setSearch] = useState("");
1315
const [services, setServices] = useState<NetworkServices | null>();
16+
const [copied, setCopied] = useState("");
1417

1518
const networkConnected = useStore((s) => s.networkConnected);
1619
const setMessage = useStore((s) => s.setMessage);
@@ -40,6 +43,11 @@ export function RPCEndpoints() {
4043
}
4144
}, []);
4245

46+
const handleCopy = async (rpcPath: string) => {
47+
await writeText(`${BASE_URL}${rpcPath}`);
48+
setCopied(rpcPath);
49+
};
50+
4351
const filtered = useMemo(() => {
4452
if (!services) return [];
4553
const endpoints = services.RPCEndpoints;
@@ -106,7 +114,16 @@ export function RPCEndpoints() {
106114
<td>{n.chain}</td>
107115
<td>{n.network}</td>
108116
<td>{n.chainId ?? ""}</td>
109-
<td>{`${BASE_URL}${n.rpcPath}`}</td>
117+
<td
118+
className="flex items-center gap-x-1 hover:cursor-pointer"
119+
onClick={() => handleCopy(n.rpcPath)}
120+
>
121+
<IconClipboard
122+
className="size-5"
123+
withCheck={copied === n.rpcPath}
124+
/>
125+
{`${BASE_URL}${n.rpcPath}`}
126+
</td>
110127
</tr>
111128
))}
112129
</tbody>

0 commit comments

Comments
 (0)