diff --git a/libs/remix-ui/run-tab/src/lib/actions/evmmap.ts b/libs/remix-ui/run-tab/src/lib/actions/evmmap.ts index 672de51b5f..00d5242fe1 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/evmmap.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/evmmap.ts @@ -41,7 +41,7 @@ export const evmMap: Map chain.id === chainId) + // if (compatibleChain) { + // return { + // chain: compatibleChain, + // minCompilerVersion: forkData.minCompilerVersion, + // evmVersion: fork + // } + // } - const compatibleChain = forkData.chainId.find(chain => chain.id === chainId) - if (compatibleChain) { - return { - chain: compatibleChain, - minCompilerVersion: forkData.minCompilerVersion, - evmVersion: fork + for (const [forkKey, forkData] of evmMap) { + const compatibleChain = forkData.chainId.find(chain => chain.id === chainId) + if (compatibleChain) { + return { + chain: compatibleChain, + minCompilerVersion: forkData.minCompilerVersion, + evmVersion: forkKey + } } } diff --git a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx index a462ffe40c..3e00a401d4 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx @@ -482,6 +482,7 @@ export function ContractDropdownUI(props: ContractDropdownProps) { solcVersion={props.solCompilerVersion} setSolcVersion={props.setCompilerVersion} getVersion={props.getCompilerVersion} + evmCheckComplete={props.evmCheckComplete} />
{ props.getVersion() await props.getCompilerDetails() + if (props.evmCheckComplete === false) return if (deployState.deploy) { const proxyInitializeString = getMultiValsString(initializeFields.current) props.clickCallBack(props.initializerOptions.inputs.inputs, proxyInitializeString, ['Deploy with Proxy']) 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 5abaf34d8c..a0428c42a1 100644 --- a/libs/remix-ui/run-tab/src/lib/components/environment.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/environment.tsx @@ -67,7 +67,6 @@ export function EnvironmentUI(props: EnvironmentProps) { { - await props.checkSelectionCorrectness() handleChangeExEnv(name) }} data-id={`dropdown-item-${name}`} diff --git a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx index b4700a4b1c..321e4e29ae 100644 --- a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx @@ -327,6 +327,7 @@ export function UniversalDappUI(props: UdappProps) { { runTransaction(lookupOnly, funcABI, valArray, inputsValues, index) 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 2e87d1cbf6..1a687fa329 100644 --- a/libs/remix-ui/run-tab/src/lib/run-tab.tsx +++ b/libs/remix-ui/run-tab/src/lib/run-tab.tsx @@ -1,5 +1,5 @@ // eslint-disable-next-line no-use-before-define -import React, { Fragment, useEffect, useReducer, useState } from 'react' +import React, { Fragment, useCallback, useEffect, useReducer, useState } from 'react' import semver from 'semver' import { FormattedMessage } from 'react-intl' import { ModalDialog } from '@remix-ui/modal-dialog' @@ -86,6 +86,7 @@ export function RunTabUI(props: RunTabProps) { const REACT_API = { runTab } const currentfile = plugin.config.get('currentFile') const [solcVersion, setSolcVersion] = useState<{version: string, canReceive: boolean}>({ version: '', canReceive: true }) + const [evmCheckComplete, setEvmCheckComplete] = useState(false) const getVersion = () => { let version = '0.8.25' @@ -106,7 +107,9 @@ export function RunTabUI(props: RunTabProps) { const getCompilerDetails = async () => await checkEvmChainCompatibility() const returnCompatibleChain = async (evmVersion: HardFork, targetChainId: number) => { - return getCompatibleChain(evmVersion ?? 'paris', targetChainId) // using paris evm as a default fallback version + const result = getCompatibleChain(evmVersion ?? 'paris', targetChainId) // using paris evm as a default fallback version + console.log('result', result) + return result } const checkEvmChainCompatibilityOkFunction = async (fetchDetails: ChainCompatibleInfo) => { @@ -125,31 +128,41 @@ export function RunTabUI(props: RunTabProps) { const checkEvmChainCompatibility = async () => { const fetchDetails = await plugin.call('solidity', 'getCompilerQueryParameters') const compilerState = await plugin.call('solidity', 'getCompilerState') + // 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) { - const chain = await returnCompatibleChain(fetchDetails.evmVersion, targetChainId) - console.log('chain obtained', { chain, targetChainId, fetchDetails }) + if (compilerState.target !== null && !runTab.networkName.toLowerCase().includes('vm')) { + const targetChainId = runTab.chainId + const ideDefault = fetchDetails && fetchDetails.evmVersion !== null ? fetchDetails.evmVersion : 'cancun' + console.log(ideDefault) + const IsCompatible = isChainCompatible(ideDefault, targetChainId) + const chain = await returnCompatibleChain(ideDefault, targetChainId) + if (chain === undefined) { + //show modal + await plugin.call('notification', 'alert', { id: 'evm-chainId-error', message: 'No compatible chain found for the selected EVM version.', title: 'Error' }) + return + } else { + setEvmCheckComplete(true) + console.log('check the things', { chain, fetchDetails, compilerState, targetChainId, runTab }) + if (!IsCompatible) { //show modal - plugin.call('notification', 'modal', { - id: 'evm-chainId-incompatible', - title: 'Incompatible EVM - ChainId Detected', - message:
-

The selected chain is not compatible with the selected EVM version. Please select a one of the options below.

-
    -
  • Have Remix switch to a compatible EVM version for this chain and recompile the contract.
  • -
  • Cancel to keep the current EVM version.
  • -
-

To manually change the EVM version, go to the Advanced Configurations section of the Solidity compiler.

-
, - modalType: 'modal', - okLabel: 'Switch EVM and Recompile', - cancelLabel: 'Cancel', - okFn: () => checkEvmChainCompatibilityOkFunction(chain), - cancelFn: () => {} - }) + plugin.call('notification', 'modal', { + id: 'evm-chainId-incompatible', + title: 'Incompatible EVM - ChainId Detected', + message:
+

The selected chain is not compatible with the selected EVM version. Please select a one of the options below.

+
    +
  • Have Remix switch to a compatible EVM version for this chain and recompile the contract.
  • +
  • Cancel to keep the current EVM version.
  • +
+

To manually change the EVM version, go to the Advanced Configurations section of the Solidity compiler.

+
, + modalType: 'modal', + okLabel: 'Switch EVM and Recompile', + cancelLabel: 'Cancel', + okFn: () => checkEvmChainCompatibilityOkFunction(chain), + cancelFn: () => {} + }) + } } } } @@ -386,6 +399,7 @@ export function RunTabUI(props: RunTabProps) { setCompilerVersion={setSolcVersion} getCompilerVersion={getVersion} getCompilerDetails={getCompilerDetails} + evmCheckComplete={evmCheckComplete} /> Promise + evmCheckComplete: boolean, selectedAccount: string, exEnvironment: string, contracts: { @@ -380,6 +381,7 @@ export interface DeployOptions { export interface ContractGUIProps { getCompilerDetails: () => Promise + evmCheckComplete: boolean, title?: string, funcABI: FuncABI, inputs: string,