|
|
|
@ -1,5 +1,8 @@ |
|
|
|
|
import * as WS from 'ws' // eslint-disable-line
|
|
|
|
|
import { PluginClient } from '@remixproject/plugin' |
|
|
|
|
import * as chokidar from 'chokidar' |
|
|
|
|
import * as utils from '../utils' |
|
|
|
|
import * as fs from 'fs-extra' |
|
|
|
|
const { spawn } = require('child_process') // eslint-disable-line
|
|
|
|
|
|
|
|
|
|
export class HardhatClient extends PluginClient { |
|
|
|
@ -18,6 +21,7 @@ export class HardhatClient extends PluginClient { |
|
|
|
|
|
|
|
|
|
sharedFolder (currentSharedFolder: string): void { |
|
|
|
|
this.currentSharedFolder = currentSharedFolder |
|
|
|
|
this.listenOnHardhatCompilation() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
compile (configPath: string) { |
|
|
|
@ -46,4 +50,19 @@ export class HardhatClient extends PluginClient { |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
listenOnHardhatCompilation () { |
|
|
|
|
try { |
|
|
|
|
const buildPath = utils.absolutePath('artifacts/build-info', this.currentSharedFolder) |
|
|
|
|
const watcher = chokidar.watch(buildPath, { depth: 0, ignorePermissionErrors: true }) |
|
|
|
|
watcher.on('change', async (f: string) => { |
|
|
|
|
const content = await fs.readFile(f, { encoding: 'utf-8' }) |
|
|
|
|
const compilationResult = JSON.parse(content) |
|
|
|
|
this.call('terminal', 'log', {type: 'info', value: 'received compilation result from hardhat'}) |
|
|
|
|
this.emit('compilationFinished', '', compilationResult.input, 'soljson', compilationResult.output, compilationResult.solcVersion) |
|
|
|
|
}) |
|
|
|
|
} catch (e) { |
|
|
|
|
console.log(e) |
|
|
|
|
}
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|