From eb8acd263eef09efc80a0dded1520a69ca182139 Mon Sep 17 00:00:00 2001 From: Lu Jincheng Date: Fri, 28 Nov 2025 13:29:37 +0800 Subject: [PATCH] added logo --- .../Metamask/DiscoverWalletProviders.tsx | 150 +++++++++++++----- app/Components/Metamask/NewDiscover.tsx | 126 --------------- app/Components/ServerList.tsx | 13 +- app/routes/home.tsx | 4 +- app/routes/wallets.tsx | 4 +- public/favicon.ico | Bin 15086 -> 4286 bytes 6 files changed, 122 insertions(+), 175 deletions(-) delete mode 100644 app/Components/Metamask/NewDiscover.tsx diff --git a/app/Components/Metamask/DiscoverWalletProviders.tsx b/app/Components/Metamask/DiscoverWalletProviders.tsx index df776e6..b65052c 100644 --- a/app/Components/Metamask/DiscoverWalletProviders.tsx +++ b/app/Components/Metamask/DiscoverWalletProviders.tsx @@ -1,50 +1,126 @@ -import { useState, type SetStateAction } from 'react'; -import { useSyncProviders } from './useSyncProviders'; -import useAuth from '~/hooks/useAuth'; -// code from https://metamask.io/news/how-to-implement-eip-6963-support-in-your-web3-dapp +// ...existing code... +import React, { useState } from "react"; +import { useSyncProviders } from "./useSyncProviders"; +import useAuth from "~/hooks/useAuth"; +import type { EIP6963ProviderDetail } from "./EthereumProviderTypes"; +import { + Box, + Grid, + Card, + CardContent, + Avatar, + Typography, + Button, + Stack, + CircularProgress, + Alert, +} from "@mui/material"; -import type { - EIP6963ProviderDetail -} from "./EthereumProviderTypes"; +const shortAddress = (addr: string) => + addr.length > 12 ? `${addr.slice(0, 6)}...${addr.slice(-6)}` : addr; -export const DiscoverWalletProviders = () => { +export const DiscoverWalletProviders: React.FC = () => { const providers = useSyncProviders(); const { auth, setAuth } = useAuth(); + const [loadingUuid, setLoadingUuid] = useState(null); + const [error, setError] = useState(null); const handleConnect = async (providerWithInfo: EIP6963ProviderDetail) => { - const accounts = await providerWithInfo.provider.request({ method: 'eth_requestAccounts' }).catch(console.error); + setError(null); + setLoadingUuid(providerWithInfo.info.uuid); + try { + const accounts = await providerWithInfo.provider.request({ + method: "eth_requestAccounts", + }); - if (Array.isArray(accounts) && accounts.length > 0 && accounts[0]) { - setAuth({providerWithInfo: providerWithInfo, accounts: accounts}); + if (Array.isArray(accounts) && accounts.length > 0 && typeof accounts[0] === "string") { + setAuth({ providerWithInfo, accounts }); + } else { + setError("No accounts returned from wallet."); + } + } catch (err: any) { + console.error(err); + setError(err?.message ?? String(err)); + } finally { + setLoadingUuid(null); } }; return ( - <> -

Wallets Detected:

-
- {providers.length > 0 ? ( - providers.map((provider) => { - return ( - - ); - }) - ) : ( -
There are no announced providers.
- )} -
-
-

{auth.accounts.length > 0 ? 'Wallet Selected' : 'No Wallet Selected'}

- {auth.accounts.length > 0 && ( -
- {auth.providerWithInfo!.info.name} -
{auth.providerWithInfo!.info.name}
-
({auth.accounts[0]})
-
+ + + Wallets Detected + + + {error && ( + + {error} + )} - + + {providers.length === 0 ? ( + There are no announced providers. + ) : ( + + {providers.map((p) => ( + + + + + + + {p.info.name} + + + + + + + + + ))} + + )} + + + + {auth?.accounts?.length > 0 ? "Wallet Selected" : "No Wallet Selected"} + + + {auth?.accounts?.length > 0 && auth.providerWithInfo && ( + + + + + + {auth.providerWithInfo.info.name} + + {shortAddress(auth.accounts[0])} + + + + + + + )} + + ); -}; \ No newline at end of file +}; + +export default DiscoverWalletProviders; +// ...existing code... \ No newline at end of file diff --git a/app/Components/Metamask/NewDiscover.tsx b/app/Components/Metamask/NewDiscover.tsx deleted file mode 100644 index b65052c..0000000 --- a/app/Components/Metamask/NewDiscover.tsx +++ /dev/null @@ -1,126 +0,0 @@ -// ...existing code... -import React, { useState } from "react"; -import { useSyncProviders } from "./useSyncProviders"; -import useAuth from "~/hooks/useAuth"; -import type { EIP6963ProviderDetail } from "./EthereumProviderTypes"; -import { - Box, - Grid, - Card, - CardContent, - Avatar, - Typography, - Button, - Stack, - CircularProgress, - Alert, -} from "@mui/material"; - -const shortAddress = (addr: string) => - addr.length > 12 ? `${addr.slice(0, 6)}...${addr.slice(-6)}` : addr; - -export const DiscoverWalletProviders: React.FC = () => { - const providers = useSyncProviders(); - const { auth, setAuth } = useAuth(); - const [loadingUuid, setLoadingUuid] = useState(null); - const [error, setError] = useState(null); - - const handleConnect = async (providerWithInfo: EIP6963ProviderDetail) => { - setError(null); - setLoadingUuid(providerWithInfo.info.uuid); - try { - const accounts = await providerWithInfo.provider.request({ - method: "eth_requestAccounts", - }); - - if (Array.isArray(accounts) && accounts.length > 0 && typeof accounts[0] === "string") { - setAuth({ providerWithInfo, accounts }); - } else { - setError("No accounts returned from wallet."); - } - } catch (err: any) { - console.error(err); - setError(err?.message ?? String(err)); - } finally { - setLoadingUuid(null); - } - }; - - return ( - - - Wallets Detected - - - {error && ( - - {error} - - )} - - {providers.length === 0 ? ( - There are no announced providers. - ) : ( - - {providers.map((p) => ( - - - - - - - {p.info.name} - - - - - - - - - ))} - - )} - - - - {auth?.accounts?.length > 0 ? "Wallet Selected" : "No Wallet Selected"} - - - {auth?.accounts?.length > 0 && auth.providerWithInfo && ( - - - - - - {auth.providerWithInfo.info.name} - - {shortAddress(auth.accounts[0])} - - - - - - - )} - - - ); -}; - -export default DiscoverWalletProviders; -// ...existing code... \ No newline at end of file diff --git a/app/Components/ServerList.tsx b/app/Components/ServerList.tsx index b85241a..6b20ba6 100644 --- a/app/Components/ServerList.tsx +++ b/app/Components/ServerList.tsx @@ -36,7 +36,6 @@ function NodeItem({node}: {node: Node}) { } const disconnect = ({ip}: {ip: string}) => { - // TODO check code setRatingOpen(true); } @@ -51,12 +50,12 @@ function NodeItem({node}: {node: Node}) { } setSubmittingRating(true); try { - // await axios.post('http://' + node.ip + ":8080/rate", { - // rating: ratingValue, - // }, { - // headers: { "Content-Type": "application/json" } - // }); - // console.log('Rating submitted'); + await axios.post('http://' + node.ip + ":8080/rate", { + rating: ratingValue, + }, { + headers: { "Content-Type": "application/json" } + }); + console.log('Rating submitted'); } catch (err) { console.error('Failed to submit rating', err); } finally { diff --git a/app/routes/home.tsx b/app/routes/home.tsx index 53bcd66..cdc11b6 100644 --- a/app/routes/home.tsx +++ b/app/routes/home.tsx @@ -3,8 +3,8 @@ import type { Route } from "./+types/home"; export function meta({}: Route.MetaArgs) { return [ - { title: "New React Router App" }, - { name: "description", content: "Welcome to React Router!" }, + { title: "CLEARNET" }, + { name: "description", content: "Welcome to CLEARNET!" }, ]; } diff --git a/app/routes/wallets.tsx b/app/routes/wallets.tsx index 5a7ec66..d67ab79 100644 --- a/app/routes/wallets.tsx +++ b/app/routes/wallets.tsx @@ -1,10 +1,8 @@ import { DiscoverWalletProviders } from "~/Components/Metamask/DiscoverWalletProviders"; -import NewDiscover from "~/Components/Metamask/NewDiscover"; export default function Wallets() { return( - // - + ); } \ No newline at end of file diff --git a/public/favicon.ico b/public/favicon.ico index 5dbdfcddcb14182535f6d32d1c900681321b1aa3..2cff3457201aecc60af1d231153290b9341ae032 100644 GIT binary patch literal 4286 zcmeHLOK%%h6du-W5DV5__CK&eELZ^xD!~GYifuuv0MSJ^sHkk9Ev<@G11)V@l31iT zPH-SioR?j{;zt}m65A8M;`iI0iD&FM_Q#oV2Tel}u~i5{y`$rM=gzt3JM-Oh&K;Ry zo}=r;2}b&5bT2T>OAN!DB%vwh6%uJ)ZuIQM=La&FV3>Zt4@r)r9Vhm2yzev2{{aK4 zTo?4UZ(*e320bDtQVl0eGDhcnj5jWpHgIlN0V?%F6B~eC+t)QM0(Gk1o(Y~m* zYGij5ez;l&*=-w2gui3Ak+@*LI}OL!JYu$Ok`xMT194X!je;QKDQiaqA8^=im5{Vw zN5b_ZcKu5zL^siDHVMa#e1tF~Ny3hy)ew*kHW0Np;4n5}(h1<3-2wCn+tKeG$ZHG1 zNjS7G!=`-;>5v7DQW~Z!7vUJ6z|==qFm+Z7+Z{K4{oIObrVVzT!}Sk1TzsF$`chlA z@yOIrG$`EFi$VDHXAoJ@$oy~Uzk~VKRiuLm0=JQ%=N%3!T#B%Dzs*S8Q} zD}pNt*qF`2@I{7v?!vnwP);7evA8$DAJzq0)f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