Skip to content

Commit 1ae7dbe

Browse files
committed
Remove custom config file for solidity compiler
1 parent 19198f4 commit 1ae7dbe

File tree

10 files changed

+82
-199
lines changed

10 files changed

+82
-199
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,7 @@ apps/remixdesktop/circom-download
7777
apps/remixdesktop/log_input_signals.txt
7878
apps/remixdesktop/log_input_signals_new.txt
7979
logs
80-
apps/remix-ide-e2e/src/extensions/chrome/metamask
80+
apps/remix-ide-e2e/src/extensions/chrome/metamask
81+
82+
# IDE - Cursor
83+
.cursor/

apps/remix-ide/src/app/plugins/script-runner-bridge.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,23 @@ export class ScriptRunnerBridgePlugin extends Plugin {
7474
dependencies: [],
7575
},
7676
}
77+
const oldConfigExists = await this.plugin.call('fileManager', 'exists', oldConfigFileName)
78+
const configExists = await this.plugin.call('fileManager', 'exists', configFileName)
79+
80+
if (oldConfigExists) {
81+
const oldConfigContent = await this.plugin.call('fileManager', 'readFile', oldConfigFileName)
82+
const oldConfig = JSON.parse(oldConfigContent)
83+
84+
if (configExists) {
85+
const configContent = await this.plugin.call('fileManager', 'readFile', configFileName)
86+
const config = JSON.parse(configContent)
87+
config['script-runner'] = oldConfig
88+
await this.plugin.call('fileManager', 'writeFile', configFileName, JSON.stringify(config, null, 2))
89+
} else {
90+
await this.plugin.call('fileManager', 'writeFile', configFileName, JSON.stringify({ 'script-runner': oldConfig }, null, 2))
91+
}
92+
await this.plugin.call('fileManager', 'remove', '.remix')
93+
}
7794
await this.loadCustomConfig()
7895
await this.loadConfigurations()
7996
this.renderComponent()

apps/remix-ide/src/app/tabs/compile-tab.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import * as packageJson from '../../../../../package.json'
1010
import { compilerConfigChangedToastMsg, compileToastMsg } from '@remix-ui/helper'
1111
import { isNative } from '../../remixAppManager'
1212
import { Registry } from '@remix-project/remix-lib'
13+
14+
const remixConfigPath = 'remix.config.json'
1315
const profile = {
1416
name: 'solidity',
1517
displayName: 'Solidity compiler',
@@ -139,12 +141,12 @@ export default class CompileTab extends CompilerApiMixin(ViewPlugin) { // implem
139141
group: 6
140142
})
141143
this.on('fileManager', 'fileSaved', async (file) => {
142-
if(await this.getAppParameter('configFilePath') === file) {
144+
if(file === remixConfigPath) {
143145
this.emit('configFileChanged', file)
144146
}
145147
})
146148
this.on('fileManager', 'fileAdded', async (file) => {
147-
if(await this.getAppParameter('configFilePath') === file) {
149+
if(file === remixConfigPath) {
148150
this.emit('configFileChanged', file)
149151
}
150152
})

apps/solidity-compiler/src/app/compiler.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const defaultCompilerParameters = {
1313
evmVersion: null, // compiler default
1414
language: 'Solidity',
1515
useFileConfiguration: false,
16-
configFilePath: "compiler_config.json"
1716
}
1817
export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements ICompilerApi {
1918
constructor () {
@@ -32,8 +31,7 @@ export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements
3231
version: localStorage.getItem('version') || defaultCompilerParameters.version,
3332
evmVersion: localStorage.getItem('evmVersion') || defaultCompilerParameters.evmVersion, // default
3433
language: localStorage.getItem('language') || defaultCompilerParameters.language,
35-
useFileConfiguration: localStorage.getItem('useFileConfiguration') === 'true',
36-
configFilePath: localStorage.getItem('configFilePath') || defaultCompilerParameters.configFilePath
34+
useFileConfiguration: localStorage.getItem('useFileConfiguration') === 'true'
3735
}
3836
return params
3937
}

libs/remix-solidity/src/compiler/compiler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class Compiler {
3737
compilationStartTime: null,
3838
target: null,
3939
useFileConfiguration: false,
40-
configFileContent: '',
40+
configFileContent: {},
4141
compilerRetriggerMode: CompilerRetriggerMode.none,
4242
lastCompilationResult: {
4343
data: null,
@@ -138,7 +138,7 @@ export class Compiler {
138138
const { optimize, runs, evmVersion, language, useFileConfiguration, configFileContent, remappings, viaIR } = this.state
139139

140140
if (useFileConfiguration) {
141-
input = compilerInputForConfigFile(source.sources, JSON.parse(configFileContent))
141+
input = compilerInputForConfigFile(source.sources, configFileContent)
142142
} else {
143143
input = compilerInput(source.sources, { optimize, runs, evmVersion, language, remappings, viaIR })
144144
}
@@ -216,7 +216,7 @@ export class Compiler {
216216
if (source && source.sources) {
217217
const { optimize, runs, evmVersion, language, remappings, useFileConfiguration, configFileContent, viaIR } = this.state
218218
if (useFileConfiguration) {
219-
input = compilerInputForConfigFile(source.sources, JSON.parse(configFileContent))
219+
input = compilerInputForConfigFile(source.sources, configFileContent)
220220
} else {
221221
input = compilerInput(source.sources, { optimize, runs, evmVersion, language, remappings, viaIR })
222222
}
@@ -337,7 +337,7 @@ export class Compiler {
337337

338338
try {
339339
if (useFileConfiguration) {
340-
const compilerInput = JSON.parse(configFileContent)
340+
const compilerInput = configFileContent
341341
if (compilerInput.settings.remappings?.length) compilerInput.settings.remappings.push(...remappings)
342342
else compilerInput.settings.remappings = remappings
343343
input = compilerInputForConfigFile(source.sources, compilerInput)

libs/remix-solidity/src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export interface CompilerState {
180180
compilationStartTime: number| null,
181181
target: string | null,
182182
useFileConfiguration: boolean,
183-
configFileContent: string,
183+
configFileContent: Record<string, any>,
184184
compilerRetriggerMode: CompilerRetriggerMode,
185185
lastCompilationResult: {
186186
data: CompilationResult | null,

0 commit comments

Comments
 (0)