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 00d5242fe1..2551ac12c3 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 - // } - // } for (const [forkKey, forkData] of evmMap) { const compatibleChain = forkData.chainId.find(chain => chain.id === chainId) diff --git a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx index 8e2e0330a9..da49a73978 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx @@ -174,56 +174,112 @@ export function ContractGUI(props: ContractGUIProps) { const handleActionClick = async () => { props.getVersion() - await props.getCompilerDetails() - if (props.evmCheckComplete === false && !props.runTabState.selectExEnv.toLowerCase().includes('vm-')) return - if (deployState.deploy) { - const proxyInitializeString = getMultiValsString(initializeFields.current) - props.clickCallBack(props.initializerOptions.inputs.inputs, proxyInitializeString, ['Deploy with Proxy']) - } else if (deployState.upgrade) { - if (proxyAddress === '') { - setProxyAddressError(intl.formatMessage({ id: 'udapp.proxyAddressError1' })) - } else { - const isValidProxyAddress = await props.isValidProxyAddress(proxyAddress) - if (isValidProxyAddress) { - setProxyAddressError('') - const upgradeReport: any = await props.isValidProxyUpgrade(proxyAddress) - if (upgradeReport.ok) { - !proxyAddressError && props.clickCallBack(props.funcABI.inputs, proxyAddress, ['Upgrade with Proxy']) - } else { - if (upgradeReport.warning) { - props.modal( - 'Proxy Upgrade Warning', - unavailableProxyLayoutMsg(), - 'Proceed', - () => { - !proxyAddressError && props.clickCallBack(props.funcABI.inputs, proxyAddress, ['Upgrade with Proxy']) - }, - 'Cancel', - () => {}, - 'btn-warning', - 'btn-secondary' - ) + + if (!props.runTabState.selectExEnv.toLowerCase().includes('vm-') || !props.runTabState.selectExEnv.toLowerCase().includes('basic-http-provider')) { + const status = await props.getCompilerDetails() + if (status === 'Failed') { + props.plugin.call('terminal', 'log', { type: 'log', value: 'Consider opening an issue to update our internal store with your desired chainId.' }) + return + } + if (deployState.deploy) { + const proxyInitializeString = getMultiValsString(initializeFields.current) + props.clickCallBack(props.initializerOptions.inputs.inputs, proxyInitializeString, ['Deploy with Proxy']) + } else if (deployState.upgrade) { + if (proxyAddress === '') { + setProxyAddressError(intl.formatMessage({ id: 'udapp.proxyAddressError1' })) + } else { + const isValidProxyAddress = await props.isValidProxyAddress(proxyAddress) + if (isValidProxyAddress) { + setProxyAddressError('') + const upgradeReport: any = await props.isValidProxyUpgrade(proxyAddress) + if (upgradeReport.ok) { + !proxyAddressError && props.clickCallBack(props.funcABI.inputs, proxyAddress, ['Upgrade with Proxy']) } else { - props.modal( - 'Proxy Upgrade Error', - upgradeReportMsg(upgradeReport), - 'Continue anyway ', - () => { - !proxyAddressError && props.clickCallBack(props.funcABI.inputs, proxyAddress, ['Upgrade with Proxy']) - }, - 'Cancel', - () => {}, - 'btn-warning', - 'btn-secondary' - ) + if (upgradeReport.warning) { + props.modal( + 'Proxy Upgrade Warning', + unavailableProxyLayoutMsg(), + 'Proceed', + () => { + !proxyAddressError && props.clickCallBack(props.funcABI.inputs, proxyAddress, ['Upgrade with Proxy']) + }, + 'Cancel', + () => {}, + 'btn-warning', + 'btn-secondary' + ) + } else { + props.modal( + 'Proxy Upgrade Error', + upgradeReportMsg(upgradeReport), + 'Continue anyway ', + () => { + !proxyAddressError && props.clickCallBack(props.funcABI.inputs, proxyAddress, ['Upgrade with Proxy']) + }, + 'Cancel', + () => {}, + 'btn-warning', + 'btn-secondary' + ) + } } + } else { + setProxyAddressError(intl.formatMessage({ id: 'udapp.proxyAddressError2' })) } - } else { - setProxyAddressError(intl.formatMessage({ id: 'udapp.proxyAddressError2' })) } + } else { + props.clickCallBack(props.funcABI.inputs, basicInput) } } else { - props.clickCallBack(props.funcABI.inputs, basicInput) + if (deployState.deploy) { + const proxyInitializeString = getMultiValsString(initializeFields.current) + props.clickCallBack(props.initializerOptions.inputs.inputs, proxyInitializeString, ['Deploy with Proxy']) + } else if (deployState.upgrade) { + if (proxyAddress === '') { + setProxyAddressError(intl.formatMessage({ id: 'udapp.proxyAddressError1' })) + } else { + const isValidProxyAddress = await props.isValidProxyAddress(proxyAddress) + if (isValidProxyAddress) { + setProxyAddressError('') + const upgradeReport: any = await props.isValidProxyUpgrade(proxyAddress) + if (upgradeReport.ok) { + !proxyAddressError && props.clickCallBack(props.funcABI.inputs, proxyAddress, ['Upgrade with Proxy']) + } else { + if (upgradeReport.warning) { + props.modal( + 'Proxy Upgrade Warning', + unavailableProxyLayoutMsg(), + 'Proceed', + () => { + !proxyAddressError && props.clickCallBack(props.funcABI.inputs, proxyAddress, ['Upgrade with Proxy']) + }, + 'Cancel', + () => {}, + 'btn-warning', + 'btn-secondary' + ) + } else { + props.modal( + 'Proxy Upgrade Error', + upgradeReportMsg(upgradeReport), + 'Continue anyway ', + () => { + !proxyAddressError && props.clickCallBack(props.funcABI.inputs, proxyAddress, ['Upgrade with Proxy']) + }, + 'Cancel', + () => {}, + 'btn-warning', + 'btn-secondary' + ) + } + } + } else { + setProxyAddressError(intl.formatMessage({ id: 'udapp.proxyAddressError2' })) + } + } + } else { + props.clickCallBack(props.funcABI.inputs, basicInput) + } } } 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 a210aa7dbb..835bf7aafd 100644 --- a/libs/remix-ui/run-tab/src/lib/run-tab.tsx +++ b/libs/remix-ui/run-tab/src/lib/run-tab.tsx @@ -58,6 +58,8 @@ import { ScenarioPrompt } from './components/scenario' import { setIpfsCheckedState, setRemixDActivated } from './actions/payload' import { ChainCompatibleInfo, getCompatibleChain, getCompatibleChains, HardFork, isChainCompatible, isChainCompatibleWithAnyFork } from './actions/evmmap' +export type CheckStatus = 'Passed' | 'Failed' + export function RunTabUI(props: RunTabProps) { const { plugin } = props const [focusModal, setFocusModal] = useState({ @@ -129,7 +131,7 @@ export function RunTabUI(props: RunTabProps) { const compilerState = await plugin.call('solidity', 'getCompilerState') // if no contract file is open, don't do anything - if (compilerState.target !== null && !runTab.networkName.toLowerCase().includes('vm')) { + if (compilerState.target !== null) { const targetChainId = runTab.chainId const ideDefault = fetchDetails && fetchDetails.evmVersion !== null ? fetchDetails.evmVersion : 'cancun' const IsCompatible = isChainCompatible(ideDefault, targetChainId) @@ -137,7 +139,7 @@ export function RunTabUI(props: RunTabProps) { if (chain === undefined) { //show modal plugin.call('terminal', 'log', { type: 'log', value: 'No compatible chain found for the selected EVM version.' }) - return + return 'Failed' } else { setEvmCheckComplete(true) if (!IsCompatible) { @@ -161,6 +163,7 @@ export function RunTabUI(props: RunTabProps) { }) } } + return 'Passed' } } diff --git a/libs/remix-ui/run-tab/src/lib/types/index.ts b/libs/remix-ui/run-tab/src/lib/types/index.ts index 2be96aed4a..103c918a12 100644 --- a/libs/remix-ui/run-tab/src/lib/types/index.ts +++ b/libs/remix-ui/run-tab/src/lib/types/index.ts @@ -4,6 +4,7 @@ import { ContractData, FuncABI, OverSizeLimit } from '@remix-project/core-plugin import { RunTab } from './run-tab' import { SolcInput, SolcOutput } from '@openzeppelin/upgrades-core' import { LayoutCompatibilityReport } from '@openzeppelin/upgrades-core/dist/storage/report' +import { CheckStatus } from '../run-tab' export interface RunTabProps { plugin: RunTab, initialState?: RunTabState @@ -232,7 +233,7 @@ export type MainnetPrompt = ( ) => JSX.Element export interface ContractDropdownProps { - getCompilerDetails: () => Promise + getCompilerDetails: () => Promise evmCheckComplete: boolean, plugin: RunTab, runTabState: RunTabState @@ -300,7 +301,7 @@ export interface RecorderProps { } export interface InstanceContainerProps { - getCompilerDetails: () => Promise + getCompilerDetails: () => Promise runTabState: RunTabState instances: { instanceList: { @@ -383,7 +384,7 @@ export interface DeployOptions { } export interface ContractGUIProps { - getCompilerDetails: () => Promise + getCompilerDetails: () => Promise evmCheckComplete: boolean, plugin: RunTab, runTabState: RunTabState @@ -426,7 +427,7 @@ export interface MainnetProps { } export interface UdappProps { - getCompilerDetails: () => Promise + getCompilerDetails: () => Promise runTabState: RunTabState instance: { contractData?: ContractData,