From 6b79df94c4cc23319583ad64230d4f378b7d1b65 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Fri, 1 Nov 2024 11:59:49 +0100 Subject: [PATCH] fix function --- .../run-tab/src/lib/components/environment.tsx | 16 ++-------------- libs/remix-ui/run-tab/src/lib/run-tab.tsx | 6 ++---- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/components/environment.tsx b/libs/remix-ui/run-tab/src/lib/components/environment.tsx index f5d3530f63..5abaf34d8c 100644 --- a/libs/remix-ui/run-tab/src/lib/components/environment.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/environment.tsx @@ -11,16 +11,6 @@ export function EnvironmentUI(props: EnvironmentProps) { Object.entries(props.providers.providerList.filter((provider) => { return provider.isInjected })) Object.entries(props.providers.providerList.filter((provider) => { return !(provider.isVM || provider.isInjected) })) - const EvaluateSelectionForCorrectness = async () => { - // if the evmVersion is not provided in the url, we use the default value - // and the default would be the latest evmFork, which is now cancun. - // checking both url and compiler details - const url = window.location.href - const regVersion = url.match(/evmVersion=([a-zA-Z]+)/)?.[1] - const fetched = await props.checkSelectionCorrectness() - return { regVersion, fetched } - } - const handleChangeExEnv = (env: string) => { const provider = props.providers.providerList.find((exEnv) => exEnv.name === env) const context = provider.name @@ -76,12 +66,10 @@ export function EnvironmentUI(props: EnvironmentProps) { { (props.providers.providerList.filter((provider) => { return provider.isInjected })).map(({ name, displayName }) => ( { + onClick={async () => { + await props.checkSelectionCorrectness() handleChangeExEnv(name) }} - onSelect={() => { - EvaluateSelectionForCorrectness() - }} data-id={`dropdown-item-${name}`} > 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 d23cc3367b..f8d5d122bf 100644 --- a/libs/remix-ui/run-tab/src/lib/run-tab.tsx +++ b/libs/remix-ui/run-tab/src/lib/run-tab.tsx @@ -124,12 +124,10 @@ export function RunTabUI(props: RunTabProps) { } const checkEvmChainCompatibility = async () => { - const isVm = await plugin.call('blockchain', 'getProvider') const fetchDetails = await plugin.call('solidity', 'getCompilerQueryParameters') const compilerState = await plugin.call('solidity', 'getCompilerState') - console.log('compilerState', compilerState) - console.log('runTab', runTab) - if (!isVm.startsWith('vm') && compilerState.target !== null) { //vms are exempt from this treatment & if no contract file is open, don't do anything + // if no contract file is open, don't do anything + if (compilerState.target !== null) { const targetChainId = runTab.chainId ? parseInt(runTab.chainId) : runTab.chainId const IsCompatible = isChainCompatible(fetchDetails.evmVersion ?? 'cancun', targetChainId) if (!IsCompatible) {