Commit 29b4eb7e authored by aniket-engg's avatar aniket-engg Committed by Aniket

compiler configuration from remix IDE

parent 25edaefe
...@@ -57,9 +57,10 @@ class FileManager extends Plugin { ...@@ -57,9 +57,10 @@ class FileManager extends Plugin {
this.mode = mode this.mode = mode
} }
async compileWithHardhat (cmd) { async compileWithHardhat (fileContent) {
console.log('Inside compileWithHardhat, calling hardhat compile using appManager') const configFilePath = 'remixCompiler.config.js'
return await this.appManager.call('hardhat', 'compile', cmd) this.setFileContent(configFilePath, fileContent)
return await this.appManager.call('hardhat', 'compile', configFilePath)
} }
limitPluginScope (path) { limitPluginScope (path) {
......
...@@ -83,7 +83,18 @@ class CompileTab { ...@@ -83,7 +83,18 @@ class CompileTab {
console.log('mode is - ', this.fileManager.mode) console.log('mode is - ', this.fileManager.mode)
if (this.fileManager.mode === 'localhost') { if (this.fileManager.mode === 'localhost') {
console.log('calling compilehardhat') console.log('calling compilehardhat')
this.fileManager.compileWithHardhat('npx hardhat compile').then(console.log) const { currentVersion, optimize, runs } = this.compiler.state
const fileContent = `module.exports = {
solidity: '${currentVersion.substring(0, currentVersion.indexOf('+commit'))}',
settings: {
optimizer: {
enabled: ${optimize},
runs: ${runs}
}
}
}
`
this.fileManager.compileWithHardhat(fileContent).then(console.log)
} }
this.fileManager.saveCurrentFile() this.fileManager.saveCurrentFile()
this.miscApi.clearAnnotations() this.miscApi.clearAnnotations()
......
...@@ -21,7 +21,8 @@ export class HardhatClient extends PluginClient { ...@@ -21,7 +21,8 @@ export class HardhatClient extends PluginClient {
this.currentSharedFolder = currentSharedFolder this.currentSharedFolder = currentSharedFolder
} }
compile (cmd: string) { compile (configPath: string) {
const cmd = `npx hardhat compile --config ${configPath}`
const options = { cwd: this.currentSharedFolder, shell: true } const options = { cwd: this.currentSharedFolder, shell: true }
const child = spawn(cmd, options) const child = spawn(cmd, options)
let result = '' let result = ''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment