diff --git a/tools/walletextension/frontend/src/components/layouts/footer.tsx b/tools/walletextension/frontend/src/components/layouts/footer.tsx index 8cc2f0de75..9f8caca5c5 100644 --- a/tools/walletextension/frontend/src/components/layouts/footer.tsx +++ b/tools/walletextension/frontend/src/components/layouts/footer.tsx @@ -5,8 +5,11 @@ import { TwitterLogoIcon, DiscordLogoIcon, } from "@radix-ui/react-icons"; +import { useWalletConnection } from "../providers/wallet-provider"; export default function Footer() { + const { version } = useWalletConnection(); + return (
@@ -33,6 +36,11 @@ export default function Footer() {
+
+

+ Version: {version || "Unknown"} +

+
{ - const { accounts, connectAccount, version, revokeAccounts } = - useWalletConnection(); + const { accounts, connectAccount, revokeAccounts } = useWalletConnection(); return ( <> @@ -84,12 +83,6 @@ const Connected = () => { )} - -
-

- Version: {version || "Unknown"} -

-
); }; diff --git a/tools/walletextension/frontend/src/components/providers/wallet-provider.tsx b/tools/walletextension/frontend/src/components/providers/wallet-provider.tsx index c7a507c374..2210b49183 100644 --- a/tools/walletextension/frontend/src/components/providers/wallet-provider.tsx +++ b/tools/walletextension/frontend/src/components/providers/wallet-provider.tsx @@ -43,40 +43,22 @@ export const WalletConnectionProvider = ({ const [accounts, setAccounts] = useState(null); const [provider, setProvider] = useState({} as ethers.providers.Web3Provider); - useEffect(() => { - initialize(); - ethereum.on("accountsChanged", handleAccountsChanged); - - return () => { - ethereum.removeListener("accountsChanged", handleAccountsChanged); - }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - const handleAccountsChanged = async () => { - if (!ethereum) { - return; - } - const status = await ethService.isUserConnectedToTenChain(token); - await fetchUserAccounts(); - setWalletConnected(status); - }; - const initialize = async () => { - if (!ethereum) { - showToast( - ToastType.DESTRUCTIVE, - "Please install Metamask to connect your wallet." - ); - return; - } try { + if (!ethereum) { + showToast( + ToastType.DESTRUCTIVE, + "Please install Metamask to connect your wallet." + ); + return; + } const providerInstance = new ethers.providers.Web3Provider(ethereum); setProvider(providerInstance); await ethService.checkIfMetamaskIsLoaded(providerInstance); const fetchedToken = await getToken(providerInstance); setToken(fetchedToken); + const status = await ethService.isUserConnectedToTenChain(fetchedToken); setWalletConnected(status); @@ -179,6 +161,11 @@ export const WalletConnectionProvider = ({ } }; + useEffect(() => { + initialize(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + const walletConnectionContextValue: WalletConnectionContextType = { walletConnected, accounts, diff --git a/tools/walletextension/frontend/src/lib/constants.ts b/tools/walletextension/frontend/src/lib/constants.ts index e6079b5fa4..a7d646130c 100644 --- a/tools/walletextension/frontend/src/lib/constants.ts +++ b/tools/walletextension/frontend/src/lib/constants.ts @@ -3,10 +3,10 @@ export const tenGatewayAddress = process.env.NEXT_PUBLIC_API_GATEWAY_URL || "htt export const tenscanLink = "https://testnet.tenscan.com"; export const socialLinks = { - github: "https://github.com/obscuronet", - discord: "https://discord.gg/2JQ2Z3r", - twitter: "https://twitter.com/obscuronet", - twitterHandle: "@obscuronet", + github: "https://github.com/ten-protocol", + discord: "https://discord.gg/fVXstswaJY", + twitter: "https://twitter.com/tenprotocol", + twitterHandle: "@tenprotocol", }; export const GOOGLE_ANALYTICS_ID = process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID;