diff --git a/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx b/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx index 51413c2c82..82198f5c8f 100644 --- a/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx @@ -1,11 +1,12 @@ // eslint-disable-next-line no-use-before-define -import React, {useRef, useState} from 'react' +import React, {useRef, useState, useEffect} from 'react' import { RecorderProps } from '../types' import { OverlayTrigger, Tooltip } from 'react-bootstrap' // eslint-disable-line export function RecorderUI (props: RecorderProps) { const inputLive = useRef() const [toggleExpander, setToggleExpander] = useState(false) + const [enableRunButton, setEnableRunButton] = useState(true) const triggerRecordButton = () => { props.storeScenario(props.scenarioPrompt) } @@ -15,6 +16,11 @@ export function RecorderUI (props: RecorderProps) { props.runCurrentScenario(liveMode, props.gasEstimationPrompt, props.passphrasePrompt, props.mainnetPrompt) } + useEffect(() => { + if (props.currentFile.endsWith('.json')) setEnableRunButton(false) + else setEnableRunButton(true) + }, [props.currentFile]) + const toggleClass = () => { setToggleExpander(!toggleExpander) } @@ -60,7 +66,7 @@ export function RecorderUI (props: RecorderProps) { }> - + 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 f8715ac16e..128d315201 100644 --- a/libs/remix-ui/run-tab/src/lib/run-tab.tsx +++ b/libs/remix-ui/run-tab/src/lib/run-tab.tsx @@ -56,10 +56,11 @@ export function RunTabUI (props: RunTabProps) { storage: null, contract: null }) - runTabInitialState.selectExEnv = props.plugin.blockchain.getProvider() + runTabInitialState.selectExEnv = plugin.blockchain.getProvider() runTabInitialState.selectExEnv = runTabInitialState.selectExEnv === 'vm' ? 'vm-london' : runTabInitialState.selectExEnv const [runTab, dispatch] = useReducer(runTabReducer, runTabInitialState) const REACT_API = { runTab } + const currentfile = plugin.config.get('currentFile') useEffect(() => { initRunTab(plugin)(dispatch) @@ -249,6 +250,7 @@ export function RunTabUI (props: RunTabProps) { runCurrentScenario={runScenario} scenarioPrompt={scenarioPrompt} count={runTab.recorder.transactionCount} + currentFile={currentfile} /> - + ) } 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 dfb526d59d..d27eb1f580 100644 --- a/libs/remix-ui/run-tab/src/lib/types/index.ts +++ b/libs/remix-ui/run-tab/src/lib/types/index.ts @@ -173,6 +173,7 @@ export interface RecorderProps { passphrasePrompt: (msg: string) => JSX.Element, scenarioPrompt: (msg: string, defaultValue: string) => JSX.Element, count: number + currentFile: string } export interface InstanceContainerProps {