|
|
|
@ -12,6 +12,7 @@ export class FoundryClient extends PluginClient { |
|
|
|
|
currentSharedFolder: string |
|
|
|
|
watcher: chokidar.FSWatcher |
|
|
|
|
warnlog: boolean |
|
|
|
|
buildPath: string |
|
|
|
|
|
|
|
|
|
constructor (private readOnly = false) { |
|
|
|
|
super() |
|
|
|
@ -28,6 +29,7 @@ export class FoundryClient extends PluginClient { |
|
|
|
|
|
|
|
|
|
sharedFolder (currentSharedFolder: string): void { |
|
|
|
|
this.currentSharedFolder = currentSharedFolder |
|
|
|
|
this.buildPath = utils.absolutePath('out', this.currentSharedFolder) |
|
|
|
|
this.listenOnFoundryCompilation() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -58,10 +60,8 @@ export class FoundryClient extends PluginClient { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
listenOnFoundryCompilation () { |
|
|
|
|
try { |
|
|
|
|
const buildPath = utils.absolutePath('out', this.currentSharedFolder) |
|
|
|
|
this.watcher = chokidar.watch(buildPath, { depth: 3, ignorePermissionErrors: true, ignoreInitial: true }) |
|
|
|
|
private async processArtifact () { |
|
|
|
|
const folderFiles = await fs.readdir(this.buildPath) |
|
|
|
|
const compilationResult = { |
|
|
|
|
input: {}, |
|
|
|
|
output: { |
|
|
|
@ -70,11 +70,9 @@ export class FoundryClient extends PluginClient { |
|
|
|
|
}, |
|
|
|
|
solcVersion: null |
|
|
|
|
} |
|
|
|
|
const processArtifact = async () => { |
|
|
|
|
const folderFiles = await fs.readdir(buildPath) |
|
|
|
|
// name of folders are file names
|
|
|
|
|
for (const file of folderFiles) { |
|
|
|
|
await this.readContract(join(buildPath, file), compilationResult) |
|
|
|
|
await this.readContract(join(this.buildPath, file), compilationResult) |
|
|
|
|
} |
|
|
|
|
if (!this.warnlog) { |
|
|
|
|
// @ts-ignore
|
|
|
|
@ -83,10 +81,16 @@ export class FoundryClient extends PluginClient { |
|
|
|
|
} |
|
|
|
|
this.emit('compilationFinished', '', { sources: compilationResult.input } , 'soljson', compilationResult.output, compilationResult.solcVersion) |
|
|
|
|
} |
|
|
|
|
this.watcher.on('change', async (f: string) => processArtifact()) |
|
|
|
|
this.watcher.on('add', async (f: string) => processArtifact()) |
|
|
|
|
|
|
|
|
|
listenOnFoundryCompilation () { |
|
|
|
|
try {
|
|
|
|
|
this.watcher = chokidar.watch(this.buildPath, { depth: 3, ignorePermissionErrors: true, ignoreInitial: true }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.watcher.on('change', async (f: string) => this.processArtifact()) |
|
|
|
|
this.watcher.on('add', async (f: string) => this.processArtifact()) |
|
|
|
|
// process the artifact on activation
|
|
|
|
|
processArtifact() |
|
|
|
|
this.processArtifact() |
|
|
|
|
} catch (e) { |
|
|
|
|
console.log(e) |
|
|
|
|
}
|
|
|
|
@ -137,4 +141,11 @@ export class FoundryClient extends PluginClient { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async sync () { |
|
|
|
|
console.log('syncing from foundry') |
|
|
|
|
this.processArtifact() |
|
|
|
|
// @ts-ignore
|
|
|
|
|
this.call('terminal', 'log', 'synced with foundry') |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|