From 5c3f507c43a791162491c690867d35893822b531 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 5 Nov 2024 10:52:26 +0100 Subject: [PATCH] fix issues identified by @ryestew and @LianaHus --- .../src/lib/components/contractDropdownUI.tsx | 1 + .../src/lib/components/contractGUI.tsx | 151 +++++++----------- libs/remix-ui/run-tab/src/lib/run-tab.tsx | 3 +- libs/remix-ui/run-tab/src/lib/types/index.ts | 8 +- 4 files changed, 62 insertions(+), 101 deletions(-) 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 5945e0e126..212adea8ab 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx @@ -483,6 +483,7 @@ export function ContractDropdownUI(props: ContractDropdownProps) { setSolcVersion={props.setCompilerVersion} getVersion={props.getCompilerVersion} evmCheckComplete={props.evmCheckComplete} + setEvmCheckComplete={props.setEvmCheckComplete} plugin={props.plugin} runTabState={props.runTabState} /> 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 30ccf5ec25..71904b4850 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx @@ -172,114 +172,71 @@ export function ContractGUI(props: ContractGUIProps) { } } - const handleActionClick = async () => { - props.getVersion() - - if (props.runTabState.selectExEnv.toLowerCase().startsWith('vm-') || props.runTabState.selectExEnv.toLowerCase().includes('basic-http-provider')) { - 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']) + const handleDeploy = async () => { + 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 { - 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' - ) - } + 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) + } + } + + const handleActionClick = async () => { + props.getVersion() + + if (props.runTabState.selectExEnv.toLowerCase().startsWith('vm-') || props.runTabState.selectExEnv.toLowerCase().includes('basic-http-provider')) { + await handleDeploy() } else { const status = await props.getCompilerDetails() - console.log('exenv', props.runTabState.selectExEnv) 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 { - 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) + if (props.evmCheckComplete) { + await handleDeploy() } } } 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 fa6b96a855..9b1302e25a 100644 --- a/libs/remix-ui/run-tab/src/lib/run-tab.tsx +++ b/libs/remix-ui/run-tab/src/lib/run-tab.tsx @@ -124,6 +124,7 @@ export function RunTabUI(props: RunTabProps) { await plugin.call('solidity', 'setCompilerConfig', compilerParams) const currentFile = await plugin.call('fileManager', 'getCurrentFile') await plugin.call('solidity', 'compile', currentFile) + setEvmCheckComplete(true) } const checkEvmChainCompatibility = async () => { @@ -141,7 +142,6 @@ export function RunTabUI(props: RunTabProps) { plugin.call('terminal', 'log', { type: 'log', value: 'No compatible chain found for the selected EVM version.' }) return 'Failed' } else { - setEvmCheckComplete(true) if (!IsCompatible) { //show modal plugin.call('notification', 'modal', { @@ -400,6 +400,7 @@ export function RunTabUI(props: RunTabProps) { getCompilerVersion={getVersion} getCompilerDetails={getCompilerDetails} evmCheckComplete={evmCheckComplete} + setEvmCheckComplete={setEvmCheckComplete} plugin={plugin} runTabState={runTab} /> 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 103c918a12..f9ac19b6c9 100644 --- a/libs/remix-ui/run-tab/src/lib/types/index.ts +++ b/libs/remix-ui/run-tab/src/lib/types/index.ts @@ -1,4 +1,4 @@ -import { Ref } from 'react' +import { Dispatch, Ref } from 'react' import { CompilerAbstract } from '@remix-project/remix-solidity' import { ContractData, FuncABI, OverSizeLimit } from '@remix-project/core-plugin' import { RunTab } from './run-tab' @@ -234,7 +234,8 @@ export type MainnetPrompt = ( export interface ContractDropdownProps { getCompilerDetails: () => Promise - evmCheckComplete: boolean, + evmCheckComplete?: boolean, + setEvmCheckComplete?: Dispatch>, plugin: RunTab, runTabState: RunTabState selectedAccount: string, @@ -385,7 +386,8 @@ export interface DeployOptions { export interface ContractGUIProps { getCompilerDetails: () => Promise - evmCheckComplete: boolean, + evmCheckComplete?: boolean, + setEvmCheckComplete?: React.Dispatch>, plugin: RunTab, runTabState: RunTabState title?: string,