From cc8e5b94e59a43ff5a2c2de8b1a82ea8847fceb8 Mon Sep 17 00:00:00 2001 From: Jovells <35954298+Jovells@users.noreply.github.com> Date: Sun, 24 Dec 2023 22:44:45 +0000 Subject: [PATCH] Attempt_2 (#56) * Jovells workflow auto sync after pr merge (#4) * Update main.yml * Update main.yml * Fix_Attempt_2 --- frontend/nextjs/emt.config.ts | 3 ++- frontend/nextjs/src/lib/hooks/useContracts.tsx | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/nextjs/emt.config.ts b/frontend/nextjs/emt.config.ts index bbcd451..c448231 100644 --- a/frontend/nextjs/emt.config.ts +++ b/frontend/nextjs/emt.config.ts @@ -29,9 +29,10 @@ import { HOME_PAGE } from "@/app/(with wallet)/_components/page-links"; const oldMobileGetUri = old.mobile!.getUri; old.mobile!.getUri = async () => { if(window?.ethereum){ + alert('eth') return oldMobileGetUri as any } - return 'metamask.app.link/dapp/'+location.host+HOME_PAGE + return 'https://metamask.app.link/dapp/'+location.origin+HOME_PAGE } return old } diff --git a/frontend/nextjs/src/lib/hooks/useContracts.tsx b/frontend/nextjs/src/lib/hooks/useContracts.tsx index b2acd4d..bbeed66 100644 --- a/frontend/nextjs/src/lib/hooks/useContracts.tsx +++ b/frontend/nextjs/src/lib/hooks/useContracts.tsx @@ -147,18 +147,18 @@ export function ContractProvider({ children }: { children: React.ReactNode }) { }, [ethereum, chain.id, account.address, network?.chain?.id]); useEffect(() => { - if (network?.chain?.id !== chain.id) { + if (network.chain && network.chain.id !== chain.id) { toast({ title: "Wrong Network", - description: "Please change to the topos network", + description: "Please change to the Topos network", variant: "destructive", }) setWrongNetwork(true); } else { - if (wrongNetwork) { + if (network.chain && wrongNetwork) { toast({ title: "Network Changed", - description: "You have successfully changed to the topos network", + description: "You have successfully changed to the Topos network", variant: "success", }) setWrongNetwork(false);