From 63779ad248c0467e603223f721bcc5606495ae59 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Fri, 10 Jan 2025 13:32:47 +0100 Subject: [PATCH] add useEffect to handle disconnection condition --- libs/remix-ui/run-tab/src/lib/run-tab.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libs/remix-ui/run-tab/src/lib/run-tab.tsx b/libs/remix-ui/run-tab/src/lib/run-tab.tsx index c6eb716af6..d352347eb9 100644 --- a/libs/remix-ui/run-tab/src/lib/run-tab.tsx +++ b/libs/remix-ui/run-tab/src/lib/run-tab.tsx @@ -235,6 +235,16 @@ export function RunTabUI(props: RunTabProps) { } }, [runTab.popup]) + useEffect(() => { + if (runTab.selectExEnv.includes('injected') && + Object.entries(runTab.accounts.loadedAccounts).length === 0 && + runTab.accounts.selectedAccount.length > 0) { + // switch to vm-cancum because no account is loaded from injected provider + const context = plugin.blockchain.defaultPinnedProviders[0] // vm-cancun + setExecutionEnvironment({ context, fork: '' }) + } + }, [runTab.accounts.loadedAccounts]) + const setCheckIpfs = (value: boolean) => { dispatch(setIpfsCheckedState(value)) }