Skip to content

Commit dddab72

Browse files
ioedeveloperAniket-Engg
authored andcommitted
Create solidity config if it does not exist
1 parent 66d77d7 commit dddab72

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
197197

198198
useEffect(() => {
199199
compileTabLogic.setUseFileConfiguration(state.useFileConfiguration)
200-
if (state.useFileConfiguration && workspaceName) {
201-
// compileTabLogic.setConfigFilePath(configFilePath)
200+
if (state.useFileConfiguration) {
202201
createNewConfigFile()
203202
}
204203
}, [state.useFileConfiguration])
@@ -223,12 +222,14 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
223222
const remixConfig = await api.readFile(remixConfigPath)
224223
const remixConfigContent = JSON.parse(remixConfig)
225224

226-
let compilerConfig = remixConfigContent['solidity-compiler']
227-
if (!compilerConfig) compilerConfig = JSON.parse(configFileContent)
228-
if (isFoundryProject && !compilerConfig.settings.remappings) {
229-
compilerConfig.settings.remappings = ['ds-test/=lib/forge-std/lib/ds-test/src/', 'forge-std/=lib /forge-std/src/']
225+
if (!remixConfigContent['solidity-compiler']) {
226+
const compilerConfig = JSON.parse(configFileContent)
227+
228+
if (isFoundryProject && !compilerConfig.settings.remappings) {
229+
compilerConfig.settings.remappings = ['ds-test/=lib/forge-std/lib/ds-test/src/', 'forge-std/=lib /forge-std/src/']
230+
await api.writeFile(remixConfigPath, JSON.stringify({ ...remixConfigContent, 'solidity-compiler': compilerConfig }, null, 2))
231+
}
230232
}
231-
await api.writeFile(remixConfigPath, JSON.stringify({ ...remixConfigContent, 'solidity-compiler': compilerConfig }, null, 2))
232233
} else {
233234
const config = JSON.parse(configFileContent)
234235

@@ -433,18 +434,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
433434
const currentFile = api.currentFile
434435

435436
if (!isSolFileSelected()) return
436-
if (state.useFileConfiguration) {
437-
const exists = await api.fileExists(remixConfigPath)
438-
439-
if (exists) {
440-
const remixConfig = await api.readFile(remixConfigPath)
441-
const remixConfigContent = JSON.parse(remixConfig)
442-
443-
if (!remixConfigContent['solidity-compiler']) await createNewConfigFile()
444-
} else {
445-
await createNewConfigFile()
446-
}
447-
}
437+
if (state.useFileConfiguration) await createNewConfigFile()
448438
_setCompilerVersionFromPragma(currentFile)
449439
let externalCompType
450440
if (hhCompilation) externalCompType = 'hardhat'

0 commit comments

Comments
 (0)