diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx index 746f110d6d..8fada2cb3a 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -39,10 +39,14 @@ export const CompilerContainer = (props: CompilerContainerProps) => { language: 'Solidity', evmVersion: '' }) - const [toggleExpander, setToggleExpander] = useState(true) + const [manualConfig, setManualConfig] = useState(true) + const [configFilePath, setConfigFilePath] = useState("/compiler_config.json") + const [showFilePathInput, setShowFilePathInput] = useState(false) + const [disableCompileButton, setDisableCompileButton] = useState(false) const compileIcon = useRef(null) const promptMessageInput = useRef(null) + const configFilePathInput = useRef(null) const [hhCompilation, sethhCompilation] = useState(false) const [truffleCompilation, setTruffleCompilation] = useState(false) const [compilerContainer, dispatch] = useReducer(compilerReducer, compilerInitialState) @@ -147,8 +151,27 @@ export const CompilerContainer = (props: CompilerContainerProps) => { } }, [configurationSettings]) - const toggleClass = () => { - setToggleExpander(!toggleExpander) + const toggleConfigType = () => { + setManualConfig(!manualConfig) + } + + const createNewConfigFile = async () => { + await api.writeFile(configFilePathInput.current.value, "") + setConfigFilePath(configFilePathInput.current.value) + } + const handleConfigPathChange = async () => { + if (await api.fileExists(configFilePathInput.current.value)) + setConfigFilePath(configFilePathInput.current.value) + else { + modal( + 'New configuration file', 'The file you entered does not exist. Do you want to create a new one?', + 'Create', + async () => await createNewConfigFile, + 'Cancel', + () => {} + ) + } + setShowFilePathInput(false) } const _retrieveVersion = (version?) => { @@ -546,74 +569,107 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
-
- - -
-
- - -
-
- - -
-
- - +
+ +
-
-
- - - - +
+
+ +
-
-
- - -
-
-
- { handleOptimizeChange(e.target.checked) }} className="custom-control-input" id="optimize" type="checkbox" checked={state.optimize} /> - - onChangeRuns(e.target.value)} - disabled={!state.optimize} - /> +
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+ { handleOptimizeChange(e.target.checked) }} className="custom-control-input" id="optimize" type="checkbox" checked={state.optimize} /> + + onChangeRuns(e.target.value)} + disabled={!state.optimize} + /> +
+
+
+ +
-
-
- -
+ { + isHardhatProject && + + } +
+
+ + +
+
+ { !showFilePathInput && {configFilePath} } + { showFilePathInput && { + if (event.key === 'Enter') { + handleConfigPathChange() + } + }} + /> } + { !showFilePathInput && }
{ isHardhatProject &&