|
|
@ -123,14 +123,18 @@ export class CircomPluginClient extends PluginClient { |
|
|
|
|
|
|
|
|
|
|
|
async compile(path: string, compilationConfig?: CompilationConfig): Promise<void> { |
|
|
|
async compile(path: string, compilationConfig?: CompilationConfig): Promise<void> { |
|
|
|
this.internalEvents.emit('circuit_compiling_start') |
|
|
|
this.internalEvents.emit('circuit_compiling_start') |
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
|
|
this.call('terminal', 'log', { type: 'log', value: 'Compiling ' + path }) |
|
|
|
const [parseErrors, filePathToId] = await this.parse(path) |
|
|
|
const [parseErrors, filePathToId] = await this.parse(path) |
|
|
|
|
|
|
|
|
|
|
|
if (parseErrors && (parseErrors.length > 0)) { |
|
|
|
if (parseErrors && (parseErrors.length > 0)) { |
|
|
|
if (parseErrors[0].type === 'Error') { |
|
|
|
if (parseErrors[0].type === 'Error') { |
|
|
|
this.internalEvents.emit('circuit_parsing_errored', parseErrors, filePathToId) |
|
|
|
this.internalEvents.emit('circuit_parsing_errored', parseErrors, filePathToId) |
|
|
|
|
|
|
|
this.logCompilerReport(parseErrors) |
|
|
|
return |
|
|
|
return |
|
|
|
} else if (parseErrors[0].type === 'Warning') { |
|
|
|
} else if (parseErrors[0].type === 'Warning') { |
|
|
|
this.internalEvents.emit('circuit_parsing_warning', parseErrors, filePathToId) |
|
|
|
this.internalEvents.emit('circuit_parsing_warning', parseErrors, filePathToId) |
|
|
|
|
|
|
|
this.logCompilerReport(parseErrors) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.internalEvents.emit('circuit_parsing_done', parseErrors, filePathToId) |
|
|
|
this.internalEvents.emit('circuit_parsing_done', parseErrors, filePathToId) |
|
|
@ -147,6 +151,7 @@ export class CircomPluginClient extends PluginClient { |
|
|
|
if (circuitProgram.length < 1) { |
|
|
|
if (circuitProgram.length < 1) { |
|
|
|
const circuitErrors = circuitApi.report() |
|
|
|
const circuitErrors = circuitApi.report() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.logCompilerReport(circuitErrors) |
|
|
|
throw new Error(circuitErrors) |
|
|
|
throw new Error(circuitErrors) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.lastCompiledFile = path |
|
|
|
this.lastCompiledFile = path |
|
|
@ -166,19 +171,28 @@ export class CircomPluginClient extends PluginClient { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.internalEvents.emit('circuit_compiling_done', []) |
|
|
|
this.internalEvents.emit('circuit_compiling_done', []) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
circuitApi.log().map(log => { |
|
|
|
|
|
|
|
log && this.call('terminal', 'log', { type: 'log', value: log })
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
|
|
this.call('terminal', 'log', { type: 'typewritersuccess', value: 'Everything went okay, circom safe' }) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async generateR1cs (path: string, compilationConfig?: CompilationConfig): Promise<void> { |
|
|
|
async generateR1cs (path: string, compilationConfig?: CompilationConfig): Promise<void> { |
|
|
|
this.internalEvents.emit('circuit_generating_r1cs_start') |
|
|
|
this.internalEvents.emit('circuit_generating_r1cs_start') |
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
|
|
this.call('terminal', 'log', { type: 'log', value: 'Generating R1CS for ' + path }) |
|
|
|
const [parseErrors, filePathToId] = await this.parse(path) |
|
|
|
const [parseErrors, filePathToId] = await this.parse(path) |
|
|
|
|
|
|
|
|
|
|
|
if (parseErrors && (parseErrors.length > 0)) { |
|
|
|
if (parseErrors && (parseErrors.length > 0)) { |
|
|
|
if (parseErrors[0].type === 'Error') { |
|
|
|
if (parseErrors[0].type === 'Error') { |
|
|
|
this.internalEvents.emit('circuit_parsing_errored', parseErrors) |
|
|
|
this.internalEvents.emit('circuit_parsing_errored', parseErrors) |
|
|
|
|
|
|
|
this.logCompilerReport(parseErrors) |
|
|
|
return |
|
|
|
return |
|
|
|
} else if (parseErrors[0].type === 'Warning') { |
|
|
|
} else if (parseErrors[0].type === 'Warning') { |
|
|
|
this.internalEvents.emit('circuit_parsing_warning', parseErrors) |
|
|
|
this.internalEvents.emit('circuit_parsing_warning', parseErrors) |
|
|
|
|
|
|
|
this.logCompilerReport(parseErrors) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.internalEvents.emit('circuit_parsing_done', parseErrors, filePathToId) |
|
|
|
this.internalEvents.emit('circuit_parsing_done', parseErrors, filePathToId) |
|
|
@ -195,6 +209,7 @@ export class CircomPluginClient extends PluginClient { |
|
|
|
if (r1csProgram.length < 1) { |
|
|
|
if (r1csProgram.length < 1) { |
|
|
|
const r1csErrors = r1csApi.report() |
|
|
|
const r1csErrors = r1csApi.report() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.logCompilerReport(r1csErrors) |
|
|
|
throw new Error(r1csErrors) |
|
|
|
throw new Error(r1csErrors) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.internalEvents.emit('circuit_generating_r1cs_done') |
|
|
|
this.internalEvents.emit('circuit_generating_r1cs_done') |
|
|
@ -203,6 +218,11 @@ export class CircomPluginClient extends PluginClient { |
|
|
|
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
await this.call('fileManager', 'writeFile', writePath, r1csProgram, true) |
|
|
|
await this.call('fileManager', 'writeFile', writePath, r1csProgram, true) |
|
|
|
|
|
|
|
r1csApi.log().map(log => { |
|
|
|
|
|
|
|
log && this.call('terminal', 'log', { type: 'log', value: log })
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
|
|
this.call('terminal', 'log', { type: 'typewritersuccess', value: 'Everything went okay, circom safe' }) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -373,4 +393,10 @@ export class CircomPluginClient extends PluginClient { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async logCompilerReport (report: CompilerReport[]): Promise<void> { |
|
|
|
|
|
|
|
this.call('terminal', 'log', { type: 'log', value: JSON.stringify(report, null, 2) }) |
|
|
|
|
|
|
|
if (report[0].type === 'Error') this.call('terminal', 'log', { type: 'error', value: 'previous errors were found' }) |
|
|
|
|
|
|
|
if (report[0].type === 'Warning') this.call('terminal', 'log', { type: 'log', value: 'previous warnings were found' }) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|