|
1 | 1 | import { useState, useMemo, useEffect } from "react";
|
2 | 2 | import { useStore } from "../store";
|
| 3 | +import { writeText } from "@tauri-apps/plugin-clipboard-manager"; |
3 | 4 | import * as log from "@tauri-apps/plugin-log";
|
4 | 5 | import {
|
5 | 6 | defaultWalletshieldListenAddress,
|
6 | 7 | NetworkServices,
|
7 | 8 | readNetworkAssetFile,
|
8 | 9 | } from "../utils";
|
| 10 | +import { IconClipboard } from "./icons"; |
9 | 11 |
|
10 | 12 | export function RPCEndpoints() {
|
11 | 13 | const [includeTestnets, setIncludeTestnets] = useState(true);
|
12 | 14 | const [search, setSearch] = useState("");
|
13 | 15 | const [services, setServices] = useState<NetworkServices | null>();
|
| 16 | + const [copied, setCopied] = useState(""); |
14 | 17 |
|
15 | 18 | const networkConnected = useStore((s) => s.networkConnected);
|
16 | 19 | const setMessage = useStore((s) => s.setMessage);
|
@@ -40,6 +43,11 @@ export function RPCEndpoints() {
|
40 | 43 | }
|
41 | 44 | }, []);
|
42 | 45 |
|
| 46 | + const handleCopy = async (rpcPath: string) => { |
| 47 | + await writeText(`${BASE_URL}${rpcPath}`); |
| 48 | + setCopied(rpcPath); |
| 49 | + }; |
| 50 | + |
43 | 51 | const filtered = useMemo(() => {
|
44 | 52 | if (!services) return [];
|
45 | 53 | const endpoints = services.RPCEndpoints;
|
@@ -106,7 +114,16 @@ export function RPCEndpoints() {
|
106 | 114 | <td>{n.chain}</td>
|
107 | 115 | <td>{n.network}</td>
|
108 | 116 | <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> |
110 | 127 | </tr>
|
111 | 128 | ))}
|
112 | 129 | </tbody>
|
|
0 commit comments